home *** CD-ROM | disk | FTP | other *** search
- { This program is a demonstration in Turbo Pascal for writing directly to
- video memory. Study this and implement it wherever you'd like faster screen
- output. }
- Var
- Count,Row,Col : Integer;
- Procedure MemoryWrite(Ch: Char);
- { This procedure is a user-written I/O driver for screen output. It writes
- output directly to screen memory. This makes screen output much faster. }
-
- Const
- Seg = $B000; { Video memory address for color system }
- Ofs = $8000; { For monochrome system, make Ofs = $0000 }
- Var
- SChar : Integer;
- Begin { Procedure MemoryWrite }
- If Ch = #13 Then { Test for carriage return }
- Begin { Then }
- Row := Succ(Row); { Adjust row & col for new line }
- Col := 0;
- End { Then }
- Else
- If Ch <> #10 Then { Ignore line feeds }
- Begin { Else }
- Col := Succ(Col); { New column for each character }
- SChar := ((Row-1)*160) + ((Col-1)*2); { Compute starting location }
- Mem[Seg:Ofs + SChar] := Ord(Ch); { Put character in memory }
- End; { Else }
- End; { Procedure MemoryWrite }
-
- Begin { Program }
- ClrScr; { Clear the screen }
- Row := 1; { Manually set row & col values after clearing screen }
- Col := 0; { Set column to 0 after each ClrScr }
- AuxOutPtr := ConOutPtr; { Save standard value for ConOutPtr }
- ConOutPtr := Ofs(MemoryWrite); { Activate I/O driver }
- For Count := 1 To 20 Do
- Writeln('The quick red fox jumped over the lazy brown dog.');
- ConOutPtr := AuxOutPtr; { Restore standard value for ConOutPtr }
- GotoXY(1,24); { Get the cursor out of the way when the program is done }
- End. { Program }