home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / MEMWRITE.ZIP / MEMWRITE.PAS
Encoding:
Pascal/Delphi Source File  |  1986-03-15  |  1.6 KB  |  41 lines

  1. { This program is a demonstration in Turbo Pascal for writing directly to
  2.   video memory. Study this and implement it wherever you'd like faster screen
  3.   output. }
  4. Var
  5.   Count,Row,Col : Integer;
  6. Procedure MemoryWrite(Ch: Char);
  7. { This procedure is a user-written I/O driver for screen output. It writes
  8.   output directly to screen memory. This makes screen output much faster. }
  9.  
  10.   Const
  11.     Seg = $B000; { Video memory address for color system  }
  12.     Ofs = $8000; { For monochrome system, make Ofs = $0000 }
  13.   Var
  14.     SChar : Integer;
  15.   Begin { Procedure MemoryWrite }
  16.     If Ch = #13 Then { Test for carriage return }
  17.       Begin { Then }
  18.         Row := Succ(Row); { Adjust row & col for new line }
  19.         Col := 0;
  20.       End { Then }
  21.     Else
  22.       If Ch <> #10 Then { Ignore line feeds }
  23.         Begin { Else }
  24.           Col := Succ(Col); { New column for each character }
  25.           SChar := ((Row-1)*160) + ((Col-1)*2); { Compute starting location }
  26.           Mem[Seg:Ofs + SChar] := Ord(Ch); { Put character in memory }
  27.         End; { Else }
  28.   End; { Procedure MemoryWrite }
  29.  
  30.   Begin { Program }
  31.     ClrScr; { Clear the screen }
  32.     Row := 1; { Manually set row & col values after clearing screen }
  33.     Col := 0; { Set column to 0 after each ClrScr }
  34.     AuxOutPtr := ConOutPtr; { Save standard value for ConOutPtr }
  35.     ConOutPtr := Ofs(MemoryWrite); { Activate I/O driver }
  36.     For Count := 1 To 20 Do
  37.       Writeln('The quick red fox jumped over the lazy brown dog.');
  38.     ConOutPtr := AuxOutPtr; { Restore standard value for ConOutPtr }
  39.     GotoXY(1,24); { Get the cursor out of the way when the program is done }
  40.   End. { Program }
  41.