Category : Pascal Source Code
Archive   : USNGTP.ZIP
Filename : LST07-03.PAS

 
Output of file : LST07-03.PAS contained in archive : USNGTP.ZIP
program Test_Device_Driver;

const VID_MEM = $B000; { Start of video memory for monochrome IBM-PC.}
VID_WIDTH = 80; { Maximum number of video columns. }
MAX_ROWS = 24; { Number of video lines. }
MAX_OFFSET = 1920; { Maximim number of characters. 24 * 80 }
BRIGHT = $0F; { Some attribute values to experiment with. }
DIM = $07;
U_LINE = $01;
BLINK_REV = $F0;
HAPPY_FACE = #2; { Special character on IBM-PC video Monitor. }

type Str_255 = string[255];
PC_Char = record
character : Char;
attribute : Byte;
end;

var usr_ptr : array[1..2] of Integer absolute UsrOutPtr;
{ Note that usr_ptr overlays UsrOutPtr in memory }
vid_scrn : array[1..2000] of PC_Char absolute VID_MEM:0000;
line, max,
count, i,
cur_pos : Integer; { Used to store the relative cursor position. }
vid_attr : Byte; { Used to store the video attribute value. }
txt_str : Str_255;

procedure Usr_Out_Driver(out_chr: Char);
var vid_char : PC_Char;

{ A simple video output driver written as a Turbo Pascal procedure.}

begin
vid_char.attribute := vid_attr; vid_char.character := out_chr;
vid_scrn[cur_pos] := vid_char;
cur_pos := Succ(cur_pos) mod MAX_OFFSET;
end; { Usr_Out_Driver }

(* {$I LST07-07.PAS} { Include inline version of Usr_Out_Driver. } *)

(* {$I LST07-08.PAS} { Include external version of Usr_Out_Driver. } *)

procedure Write_Usr_Str(out_str: Str_255);
var i : Integer;
begin
for i := 1 to Length(out_str) do { Outputs out_str via the }
Write(Usr,out_str[i]); { Usr output device }
end; { Write_Usr_Str }

procedure GoTo_XY(col, row: Integer); { Used to position }
begin { cur_pos for output }
col := Pred(col) mod VID_WIDTH;
row := Pred(row) mod MAX_ROWS;
cur_pos := (row * VID_WIDTH + col); { Calculate cur_pos as }
end; { GoTo_XY } { offset into video RAM }

procedure Fill_Screen(out_chr: Char);
begin
for i := 1 to MAX_OFFSET do
Write(Usr,out_chr);
end; { Fill_Screen }
{ }
begin { Test_Usr_Driver }
usr_ptr[1] := Ofs(Usr_Out_Driver); { Point usr_ptr to Usr_Out_Driver }
usr_ptr[2] := Cseg; { Note: the Segment:Offset address }
count := 0; { is stored in reverse order. }
ClrScr; GoToXY(1,25);
Write('Enter number of iterations. ==> ');
Read(max);
repeat
GoTo_XY(1,1);
vid_attr := U_LINE;
Fill_Screen(HAPPY_FACE); { Fill screen with happy faces }
vid_attr := BRIGHT;
for line := MAX_ROWS downto 1 do { Write centered message MAX_ROWS }
begin { times starting at the bottom line }
GoTo_XY(27,line);
Write_Usr_Str(' Turbo Pascal is Quick ');
end;
Delay(500); { Wait a half second or so }
vid_attr := BLINK_REV;
for line := 1 to MAX_ROWS do { Write centered blinking stars }
begin { starting at the top }
GoTo_XY(27,line);
Write_Usr_Str(' * * * * * * * * * * * ');
end;
Delay(500);
count := Succ(count); { Increment counter }
until (count = max); { Quit after max times }
ClrScr;
end. { Test_Usr_Driver }

Note: To test the variations of this program using the inline statement
or an external machine language procedure, delete or comment out the
Usr_Out_Driver procedure and remove the outer comment delimiters (* *)
so that the appropriate code will be included.

Listing 7-3 Test program for Usr_Out_Driver routines.



  3 Responses to “Category : Pascal Source Code
Archive   : USNGTP.ZIP
Filename : LST07-03.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/