Program Screen (Input,Output);

{ This is an intermediate level Pascal program which illustrates how one
  can get directly at the screen memory area through Pascal's ADS types.
  The program prompts the user for a character and then flashes this 
  character all over the screen.  A normal attribute is given; this is the
  chr(7) reference... Program illustrates speed of direct Pascal/screen
  output. }

VAR
   Choice: char;

Procedure ScreenWrite (What: char);

TYPE
   ScreenImage = array[1..160] of char;
   ScreenLoc = ADS of ScreenImage;
VAR
   i: integer;
   ScreenLine,TextLine: ScreenImage;
   ScreenPtr, TextPtr: ScreenLoc;
BEGIN
   for i:=1 to 80 do
      BEGIN
         TextLine[2*i-1]:= what;
         TextLine[2*i]:= chr(7);
      END;
   ScreenPtr.S := 16#b000;
   ScreenPtr.R := 0;
   TextPtr := ADS TextLine;
   for i := 0 to 24 do
      BEGIN
         ScreenPtr^ := TextPtr^;
         ScreenPtr.R := ScreenPtr.R + 160
      END
END;

begin
  repeat
    write ('Character? ');
    readln (choice);
    screenwrite (choice);
  until (choice='q');
end.