home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MCGA#03.ZIP / TEST03.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1992-06-11  |  1.5 KB  |  70 lines

  1. Program MCGATest;
  2. uses
  3.   Crt,Dos,MCGA03;
  4. var
  5.   Stop,
  6.   Start  :  LongInt;
  7.   Regs   :  Registers;
  8.   PicBuf :  Pointer;
  9.  
  10. Function Tick : LongInt;
  11. begin
  12.   Regs.ah := 0;
  13.   Intr ($1A,regs);
  14.   Tick := Regs.cx shl 16 + Regs.dx;
  15. end;
  16.  
  17. Procedure ShowAndTell (S:String);
  18. var
  19.   Ch     :  Char;
  20. begin
  21.   Repeat Until Keypressed;
  22.   While Keypressed do Ch := Readkey;
  23.   TextMode (3);
  24.   WriteLn (S);
  25.   WriteLn ('Routine took ',(Stop-Start)/18.2:4:3,' seconds!');
  26.   Write   ('or an average of ');
  27.   WriteLn (1000/((Stop-Start)/18.2):6:1,' lines per second.');
  28.   While KeyPressed do Ch := Readkey;
  29.   Repeat Until Keypressed;
  30.   While Keypressed do Ch := Readkey;
  31. end;
  32.  
  33. Procedure Control;
  34. var
  35.   I :  Integer;
  36. begin
  37.   SetGraphMode ($13);
  38.   Start := Tick;
  39.   For I := 1 to 1000 do
  40.     LineEqu (Random (320),Random (200),
  41.              Random (320),Random(200),Random(256));
  42.   Stop := Tick;
  43.   ShowAndTell ('Equation of a line...');
  44.   SetGraphMode ($13);
  45.   Start := Tick;
  46.   For I := 1 to 1000 do
  47.     LineIndiv (Random (320),Random (200),
  48.                Random (320),Random(200),Random(256));
  49.   Stop := Tick;
  50.   ShowAndTell ('Bresenhan''s algorithm, addressing each pixel individually...');
  51.   SetGraphMode ($13);
  52.   Start := Tick;
  53.   For I := 1 to 1000 do
  54.     Line (Random (320),Random (200),
  55.           Random (320),Random(200),Random(256));
  56.   Stop := Tick;
  57.   ShowAndTell ('Bresenhan''s algorithm, incremental addressing each pixel...');
  58. end;
  59.  
  60. Procedure Init;
  61. begin
  62.   Randomize;
  63. end;
  64.  
  65. Begin
  66.   Init;
  67.   Control;
  68. End.
  69.  
  70.