home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / FASTWR1.ZIP / FASTWR.PAS
Encoding:
Pascal/Delphi Source File  |  1989-03-20  |  2.8 KB  |  75 lines

  1.  
  2. {
  3. ITE routine and example.
  4.                 Code by Marshall Brain.
  5.     This program contains a routine called FASTWRITE, that can
  6. be used on the IBM PC, XT, and compatibles to update the screen
  7. much faster than can be done with write statements. It handles
  8. graphics and monochrome screens.
  9.     As can be seen, four variables are passed to Fastwrite. They
  10. are: the cursor's column location to begin printing (0..79), the
  11. cursor's row location (0..24), the screen attribute (contols
  12. color, underlining, and intensity), and the string to be printed.
  13. A typical call to fastwrite would be as follows:
  14.  
  15.      tempstring:='Fastwrite is fast as lightning';
  16.      fastwrite(15,10,$07,tempstring);
  17.  
  18. This would print tempstring at location (15,10), with characters
  19. that are white on black (if you are not familiar with attribute
  20. bytes, look them up in the Technical Reference manual, or get a
  21. book such as "Inside the IBM PC" by Peter Norton).
  22.     These four parameters are crucial to Fastwrite's speed. In
  23. order to write to the screen as quickly as it does, Fastwrite
  24. ignores all of the normal channels used for screen updating such
  25. as DOS and BIOS calls. Instead, it dumps the string to be
  26. displayed directly into the display's memory buffer. The
  27. advantage of speed is gained, but in the process you lose the
  28. use of the gotoxy statement, the color statements, and
  29. windowing. If you like, you can mix Fastwrite and regular write
  30. statements and continue to make use of some of these features. Or
  31. you can, as I have, create new routines to handle windows,
  32. gotoxy, etc.
  33.     An article on this routine was submitted to the TUG
  34. newsletter in October - it contains code listings, etc, but
  35. it has not been printed and I have not been told when it will
  36. be printed. If there is any demand, I can upload the source code
  37. for FASTWRITE.
  38.      Good luck using this routine.  MB.   }
  39.  
  40.  
  41. program fasttest;
  42. type
  43.   string80 = string[80];
  44. var
  45.   x:string[80];
  46.   y : byte;
  47.   I: integer;
  48.  
  49. procedure fastwrite(col,row,attrib:byte;str:string80);
  50. begin
  51.   inline
  52.     ($1E/$1E/$8A/$86/row/$B3/$50/$F6/$E3/$2B/$DB/$8A/$9E/col/
  53.      $03/$C3/$03/$C0/$8B/$F8/$be/$00/$00/$8A/$BE/attrib/
  54.      $8a/$8e/str/$22/$c9/$74/$3e/$2b/$c0/$8E/$D8/$A0/$49/$04/
  55.      $1F/$2C/$07/$74/$22/$BA/$00/$B8/$8E/$DA/$BA/$DA/$03/$46/
  56.      $8a/$9A/str/$EC/$A8/$01/$75/$FB/$FA/$EC/$A8/$01/$74/$FB/
  57.      $89/$1D/$47/$47/$E2/$Ea/$2A/$C0/$74/$10/$BA/$00/$B0/
  58.      $8E/$DA/$46/$8a/$9A/str/$89/$1D/$47/$47/$E2/$F5/$1F);
  59. end;
  60.  
  61. begin
  62.   clrscr;
  63.   fastwrite(35,10,$0f,'Get Ready');
  64.   delay(2000);
  65.   For i := 1 to 55 do begin;
  66.   clrscr;
  67.   fastwrite(33,5,$0f,'Fastwriting is');
  68.   fastwrite(35,6,$0f,'faster than');
  69.   fastwrite(32,7,$0f,'a speeding bullet!');
  70.   x:='012345678901234567890123456789012345678901234567890123456789';
  71.   for y:=9 to 18 do
  72.     fastwrite(10,y,$0f,x);
  73.   gotoxy(1,20);
  74.   end;
  75. end.