Solved

I need good timer

Posted on 1998-12-18
6
214 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
Comment Utility
I could give you one.
0
 
LVL 4

Author Comment

by:jack_p50
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 4

Author Comment

by:jack_p50
Comment Utility
thanx
0
 
LVL 1

Expert Comment

by:The_Brain
Comment Utility
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
Comment Utility
:)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now