Category : Pascal Source Code
Archive   : QWIK5X.ZIP
Filename : TIMERD12.INC

 
Output of file : TIMERD12.INC contained in archive : QWIK5X.ZIP
{ Timerd12.inc - DOS event timer ver 1.2, 01-30-87 }
{ by Jim H. LeMay CIS: 76011,217 }
{ A 24 hour timer with resolution of 1/18.2... seconds to measure elapsed time
in seconds. Works on all IBM compatible machines and is interchangeable with
TIMERH.INC. If TIMERH.INC can work on your machine, then use it; if not,
TIMERD.INC will. Both also compile with Turbo87.
TO TEST: Remove the curly braces around "BEGIN ... END". Compile and Run.
TO USE: Place "Timer(Start)" and "Timer(Stop)" as desired in your program.
"ElapsedTime" gives result in seconds. }

type
StartStop = (Start, Stop, SetRead, ReadRead);
TicksArray = array [1..5] of byte;
var
t0,t1,t2,TicksPerDay,TicksPerSec,ElapsedTime: real;
T1array,T2array: TicksArray;
const
FirstTime: boolean = true;

procedure GetTicks (VAR Ticks: TicksArray);
begin
Inline(
$1E { push ds ;Save Turbo DS}
/$31/$C0 { xor ax,ax ;Set ax=0}
/$8E/$D8 { mov ds,ax ;Segment for DOS timer}
/$BE/$6C/$04 { mov si,$046C ;Offset for DOS timer}
/$C4/$7E/ /$FC { cld ;Set direction forward}
/$AB { stosw ;Store zero}
/$FA { cli ;Clear interrupts}
/$A4 { movsb ;Copy DOS low byte}
/$A5 { movsw ;Copy DOS mid word}
/$FB { sti ;Allow interrupts}
/$1F { pop ds ;Restore Turbo DS}
)
end;

function ArrayToReal (Ticks: TicksArray): real;
begin
ArrayToReal := ((Ticks[5]*256.0) + Ticks[4])*256 + Ticks[3]
end;

procedure TimerInit;
begin
FirstTime := false;
TicksPerDay := 1573040.0; { DOS timer ticks/day. }
TicksPerSec := TicksPerDay/86400.0;
t0 := 0.0 { only needed for TIMERH.INC }
end;

procedure Timer (SS: StartStop);
begin
case SS of
Start: begin
if FirstTime then TimerInit;
ElapsedTime:=0;
GetTicks (T1array)
end;
Stop: begin
GetTicks (T2array);
t1 := ArrayToReal(T1array); { Convert AFTER the event! }
t2 := ArrayToReal(T2array);
if t2 ElapsedTime:= (t2-t1)/TicksPerSec { units of seconds }
end
end { end case }
end;

{
var ch: char;

BEGIN
ClrScr;
Writeln('Press any key for a lap; to stop.');
Timer (Start);
repeat
write(chr(16));
read(Kbd,ch);
Timer (Stop);
writeln ('E.T. =',ElapsedTime:10:2,' secs: ticks2=',t2:12:0);
GotoXY (24,wherey); WriteLn ('-ticks1=',t1:12:0);
GotoXY (21,wherey); WriteLn ('E.T. ticks=',(t2-t1):12:0);
writeln;
until ch = chr(27)
END.
}


  3 Responses to “Category : Pascal Source Code
Archive   : QWIK5X.ZIP
Filename : TIMERD12.INC

  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/