Solved

I need good timer

Posted on 1998-12-18
6
245 Views
Last Modified: 2010-04-16
I need good timer, fast-working and high-resolution (not lower 72 Hz). Not this :
function getclock: longint;assembler;
asm
  xor   ah,ah           { get tick count from Dos and use For hi 3 Bytes }
  int   01Ah            { lo order count in DX, hi order in CX }
  mov   ah,dl
  mov   dl,dh
  mov   dh,cl
  xor   al,al           { read lo Byte straight from timer chip }
  out   43h,al          { latch count }

  mov   al,1
  out   43h,al          { set up to read count }
  in    al,40h          { read in lo Byte (and discard) }
  in    al,40h          { hi Byte into al }
  neg   al              { make it so counting up instead of down }
end;
and this :
function currenttime : longint;assembler;
asm
  mov   es,[seg0040]
  mov   ax,es:[6Ch]
  mov   dx,es:[6Eh]
end;
0
Comment
Question by:jack_p50
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 1

Expert Comment

by:The_Brain
ID: 1216572
I could give you one.
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1216573
when i use getclock, my images etc.. flickers sometimes, and currenttime is to low-res
0
 
LVL 1

Accepted Solution

by:
The_Brain earned 20 total points
ID: 1216574
Try this, this is a little something I found.


Unit Timer2;

{ 1 Ms timer Unit }

InterFace

var TimerTick: LongInt;    


procedure TDelay(Ms: LongInt);


Implementation

Uses Dos;                 { For the Registers type used in NewTimer }

const SaveInt = $67;    
      Base = 55;

var OldExitProc: Pointer;
       Counter: Word;
    DTick: LongInt;    


procedure TDelay(Ms: LongInt);
begin
  if Ms <= 0 then Exit;
  DTick := 0;
  repeat until DTick >= Ms;
end;



procedure NewTimer; INTERRUPT;
var R: Registers;                    
begin
  Dec(Counter);                  
  if (Counter = 0) then
  begin
    Intr(SaveInt,R);  
    Counter := Base;
  end
  Else Port[$20] := $20;
  Inc(TimerTick);      
  Inc(DTick);          
end;


procedure InitTimer;
const Freq = 1000;
var InitialCount: Word;
    OldVector: Pointer;
begin
  TimerTick := 0;
  DTick := 0;
  Inline($FA);
  InitialCount := 1193180 div Freq;
  Port[$43] := $36;                    
  Port[$40] := Lo(InitialCount);        
  Port[$40] := Hi(InitialCount);        
  GetIntVec(8, OldVector);              
  SetIntVec(SaveInt,OldVector);        
  SetIntVec(8, @NewTimer);              
  Inline($FB);                          
end;




procedure SaveExitProc; Far;
var OldVector: Pointer;
begin
  Inline($FA);                        
  Port[$43] := $36;                  
  Port[$40] := $FF;                  
  Port[$40] := $FF;                  
  GetIntVec(SaveInt, OldVector);      
  SetIntVec(8, OldVector);            
  Inline($FA);                        
  ExitProc := OldExitProc;            
ExitProc:=oldexitproc;
end;


begin
  OldExitProc :=ExitProc;
  ExitProc := @SaveExitProc;
  InitTimer;
end.

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 4

Author Comment

by:jack_p50
ID: 1216575
thanx
0
 
LVL 1

Expert Comment

by:The_Brain
ID: 1216576
It is always a pleasure to work with someone who checks their question frequently :)  I find it so frustrating I am still waiting for 4 people to grade me in various places,some are weeks old. :(

oh well thanks man. :)
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1216577
:)
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
Let's recap what we learned from yesterday's Skyport Systems webinar.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question