home *** CD-ROM | disk | FTP | other *** search
- {TITLE: CGA SNOW BANISHED}
- (***********************************************************************)
- (* Don Milne, MicroPack Ltd. 1986 (BIX-id mpack) *)
- (* *)
- (* Copy between offscreen and the IBM PC Graphics video ram in either *)
- (* direction. source and dest are the source and destination pointers *)
- (* for the copy, pixels is the number of screen positions which should *)
- (* be copied. The procedure expects a global constant called NumChars, *)
- (* which is the maximum number of pixels which can be moved during one *)
- (* vertical retrace period. The best way to find this constant for your*)
- (* own hardware is to write test code, trying numbers between 50 and *)
- (* 2000 until you find a number that doesn't cause snow (a binary chop *)
- (* is the fastest way to find it). *)
- (* *)
- (* The code was actually written for my Modula-2 compiler, but is *)
- (* simple inline code and should be easy enough to convert to Turbo or *)
- (* whatever. *)
- (***********************************************************************)
-
-
- PROCEDURE CopyVideo(source,dest:ADDRESS; pixels:CARDINAL);
-
- VAR maxchars:CARDINAL;
-
- BEGIN
- maxchars := NumChars;
- SETREG(SI,source.OFFSET);
- SETREG(DS,source.SEGMENT);
- SETREG(DI,dest.OFFSET);
- SETREG(ES,dest.SEGMENT);
- SETREG(BX,maxchars);
- SETREG(CX,pixels);
- CODE(0BAH,0DAH,003H, (* MOV DX,3DAH *)
- 051H, (* $1 PUSH CX *)
- 03BH,0D9H, (* CMP BX,CX *)
- 077H,005H, (* JA $2 *)
- 08BH,0CBH, (* MOV CX,BX *)
- 0E9H,002H,000H, (* JMP $3 *)
- 08BH,0D9H, (* $2 MOV BX,CX *)
- 0ECH, (* $3 IN AL,DX *)
- 0A8H,008H, (* TEST AL,8 *)
- 075H,0FBH, (* JNZ $3 *)
- 0ECH, (* $4 IN AL,DX *)
- 0A8H,008H, (* TEST AL,8 *)
- 074H,0FBH, (* JZ $4 *)
- 0FCH, (* CLD *)
- 0F3H,0A5H, (* REP MOVSW *)
- 059H, (* POP CX *)
- 02BH,0CBH, (* SUB CX,BX *)
- 00BH,0C9H, (* OR CX,CX *)
- 075H,0E0H); (* JNZ $1 *)
- END CopyVideo;
-