home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / bix / cgasnow.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-08-04  |  2.6 KB  |  53 lines

  1. {TITLE: CGA SNOW BANISHED}
  2. (***********************************************************************)
  3. (* Don Milne, MicroPack Ltd. 1986 (BIX-id mpack)                       *)
  4. (*                                                                     *)
  5. (* Copy between offscreen and the IBM PC Graphics video ram in either  *)
  6. (* direction. source and dest are the source and destination pointers  *)
  7. (* for the copy, pixels is the number of screen positions which should *)
  8. (* be copied. The procedure expects a global constant called NumChars, *)
  9. (* which is the maximum number of pixels which can be moved during one *)
  10. (* vertical retrace period. The best way to find this constant for your*)
  11. (* own hardware is to write test code, trying numbers between 50 and   *)
  12. (* 2000 until you find a number that doesn't cause snow (a binary chop *)
  13. (* is the fastest way to find it).                                     *)
  14. (*                                                                     *)
  15. (* The code was actually written for my Modula-2 compiler, but is      *)
  16. (* simple inline code and should be easy enough to convert to Turbo or *)
  17. (* whatever.                                                           *)
  18. (***********************************************************************)
  19.  
  20.  
  21. PROCEDURE CopyVideo(source,dest:ADDRESS; pixels:CARDINAL);
  22.  
  23. VAR maxchars:CARDINAL;
  24.  
  25. BEGIN
  26.      maxchars := NumChars;
  27.      SETREG(SI,source.OFFSET);
  28.      SETREG(DS,source.SEGMENT);
  29.      SETREG(DI,dest.OFFSET);
  30.      SETREG(ES,dest.SEGMENT);
  31.      SETREG(BX,maxchars);
  32.      SETREG(CX,pixels);
  33.      CODE(0BAH,0DAH,003H,      (*    MOV  DX,3DAH   *)
  34.           051H,                (* $1 PUSH CX        *)
  35.           03BH,0D9H,           (*    CMP  BX,CX     *)
  36.           077H,005H,           (*    JA   $2        *)
  37.           08BH,0CBH,           (*    MOV  CX,BX     *)
  38.           0E9H,002H,000H,      (*    JMP  $3        *)
  39.           08BH,0D9H,           (* $2 MOV  BX,CX     *)
  40.           0ECH,                (* $3 IN   AL,DX     *)
  41.           0A8H,008H,           (*    TEST AL,8      *)
  42.           075H,0FBH,           (*    JNZ  $3        *)
  43.           0ECH,                (* $4 IN   AL,DX     *)
  44.           0A8H,008H,           (*    TEST AL,8      *)
  45.           074H,0FBH,           (*    JZ   $4        *)
  46.           0FCH,                (*    CLD            *)
  47.           0F3H,0A5H,           (*    REP  MOVSW     *)
  48.           059H,                (*    POP  CX        *)
  49.           02BH,0CBH,           (*    SUB  CX,BX     *)
  50.           00BH,0C9H,           (*    OR   CX,CX     *)
  51.           075H,0E0H);          (*    JNZ  $1        *)
  52. END CopyVideo;
  53.