home *** CD-ROM | disk | FTP | other *** search
- { This progam is meant to demonstrate the increase in speed achieved
- by using the WriteChar procedure which writes directly to screen memory
- instead of going through the BIOS interrupt INT 10. In Turbo Pascal 2.0
- I noticed a speed increase of 5 to 1 when there are no scrolls involved
- and 3.5 to 1 when the screen has to be scrolled on my AT&T 6300 machine.
- Turbo Pascal 3.0 apparently uses direct screen memory access already, so
- speed increases may not be that drastic.. and these numbers might be
- different on the IBM, since the AT&T with its 16 bit bus can write to memory
- faster when writing 16 bit words (The screen output routine does that since
- it outputs the character and its attribute together as a word) }
-
-
- const
- Attribute:byte =15; {Attribute of characters to be written}
- Out_Page: byte =0; {Page to which Write and Writeln procedures
- would output characters to}
-
-
- Procedure Textcolor(a:byte);
- {****************************************************************************
- Replaces Standard Turbo Procedure TextColor
- *****************************************************************************}
- begin
- Attribute:=(Attribute and $70)+(a and 15)+((a and 16) shl 3)
- end;
-
- Procedure Textbackground(a:byte);
- {****************************************************************************
- Replaces Standard Turbo Procedure TextBackground.
- *****************************************************************************}
- begin
- Attribute:=(Attribute and $8F) + ((a and 7) shl 4)
- end;
-
-
- Procedure Writechar(InChar:Char);
- {**************************************************************************
- This procedure outputs the character "Inchar" to the page defined by
- Out_Page. Direct output to screen memory is utilized to obtain high speed
- display.The attribute of characters written is the one defined as "Attribute".
- It may be noted that procedures standard Turbo Procedures TextColor and
- Textbackground also have been redefined, so that these statements can change
- the value of the "Attribute" byte.
- *****************************************************************************}
- begin
- Inline ($FB/$33/$DB/$1E/$BA/$40/$00/$8E/$DA/$2E/$8A/$1E/Out_page/$80/$E3/
- $07/$D1/$E3/$8B/$57/$50/$B9/$00/$B8/$8E/$C1/$52/$B8/$00/$08/$F7/
- $E3/$5A/$8B/$C8/$8B/$86/Inchar/$2E/$8A/$26/Attribute/$8B/$F0/$3C/
- $07/$75/$08/$B4/$0E/$CD/$10/$FE/$C2/$EB/$44/$3C/$0D/$74/$3C/$3C/
- $0A/$74/$2F/$3C/$08/$74/$38/$8B/$F9/$B8/$50/$00/$F6/$E6/$52/$32/
- $F6/$03/$C2/$D1/$E0/$03/$F8/$BA/$DA/$03/$EC/$D0/$D8/$72/$FB/$FA/
- $EC/$D0/$D8/$73/$FB/$8B/$C6/$AB/$FB/$5A/$42/$80/$FA/$50/$72/$59/
- $32/$D2/$80/$FE/$18/$73/$10/$FE/$C6/$EB/$4E/$32/$D2/$EB/$4A/$0A/
- $D2/$74/$75/$FE/$CA/$EB/$42/$1E/$52/$BA/$00/$B8/$8E/$C2/$8E/$DA/
- $8B/$F9/$8B/$C6/$8B/$F1/$81/$C6/$A0/$00/$B9/$B0/$07/$B0/$20/$BA/
- $DA/$03/$EC/$A8/$08/$74/$FB/$BA/$D8/$03/$B0/$01/$EE/$FA/$FC/$F3/
- $A5/$B9/$50/$00/$B0/$20/$F3/$AB/$BA/$DA/$03/$EC/$A8/$08/$74/$FB/
- $BA/$D8/$03/$B0/$09/$EE/$FB/$5A/$1F/$89/$57/$50/$D1/$EB/$3A/$1E/
- $62/$00/$75/$24/$B0/$A0/$F6/$E6/$30/$F6/$D1/$E2/$01/$D0/$03/$06/
- $4E/$00/$D1/$E8/$BA/$D4/$03/$89/$C1/$B0/$0E/$EE/$42/$88/$E8/$EE/
- $B0/$0F/$4A/$EE/$42/$88/$C8/$EE/$1F)
- end;
-
- Procedure Display_Page(a:byte);
- {****************************************************************************
- This procedure is used to switch screen display pages.4 pages (0 to 3) are
- available with the color graphics adapter in the 80 column display mode.
- *****************************************************************************}
- begin
- Inline($B4/$05/$8A/$86/a/$24/$03/$CD/$10)
- end;
-
- var
- i,j:byte;
- C:char;
- p:integer absolute $0040:$006C;
- p1,p2:integer;
- t1,t2,t3,t4,t:real;
-
- {Main program
- Compares time difference between standard and Direct screenwrite}
- begin
- ClrScr;
- p1:=p;
- For j:= 1 to 20 do
- begin
- Writeln('ABCD',j:75)
- end;
- p2:=p;
- t:=(p2-p1)/18.2;
- t1:=t;
- Writeln('Turbo Standard output....20 lines of 79 characters, no scroll');
- Writeln('Start Count:',p1:7,' End Count:',p2:7,' Time taken:',t:9:6,' seconds');
- Writeln('Press any key to continue...');
- Read(kbd,C);
- Writeln('');
- Writeln('');
- p1:=p;
- For j:= 1 to 20 do
- begin
- Writeln('ABCD',j:75)
- end;
- p2:=p;
- t:=(p2-p1)/18.2;
- t2:=t;
- Writeln('Turbo Standard output....20 lines of 79 characters, 20 scrolls');
- Writeln('Start Count:',p1:7,' End Count:',p2:7,' Time taken:',t:9:6,' seconds');
- Writeln('Press any key to continue...');
- Read(Kbd,C);
- ConOutPtr:=Ofs(WriteChar); {Use the procedure Writechar for outputs to screen}
- ClrScr;
- p1:=p;
- For j:= 1 to 20 do
- begin
- Writeln('ABCD',j:75)
- end;
- p2:=p;
- t:=(p2-p1)/18.2;
- t3:=t;
- Writeln('Direct screen output....20 lines of 79 characters, No scrolls');
- Writeln('Start Count:',p1:7,' End Count:',p2:7,' Time taken:',t:9:6,' seconds');
- Writeln('Press any key to continue...');
- Read(kbd,C);
- Writeln('');
- Writeln('');
- p1:=p;
- For j:= 1 to 20 do
- begin
- Writeln('ABCD',j:75)
- end;
- p2:=p;
- t:=(p2-p1)/18.2;
- t4:=t;
- Writeln('Direct screen output....20 lines of 79 characters, 20 scrolls');
- Writeln('Start Count:',p1:7,' End Count:',p2:7,' Time taken:',t:9:6,' seconds');
- Writeln('Press any key to continue...');
- Read(Kbd,C);
- ClrScr;
- Writeln('':30,'Turbo Standard':15,'Direct screen':15,'Comparison':15);
- Writeln('20 lines,no scrolls':20,'':10,t1:15:6,t3:15:6,t1/t3:12:3,':1');
- Writeln('20 lines,20 scrolls':20,'':10,t2:15:6,t4:15:6,t2/t4:12:3,':1');
- end.