Solved

I need good timer

Posted on 1998-12-18
6
224 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
  • 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

This tutorial shows how to create a greeting card by combining two image layers and a text layer on a PC using a free image editing app.
An article on effective troubleshooting
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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