Board index » delphi » Detecting Screen Refresh Rate

Detecting Screen Refresh Rate

Hi. I need to control as closely as possible how long material is
presented on the screen, so each time I write to the screen I want to do
it at the same place in the screen refresh cycle (e.g., when th e top
left corner is about to be written to). How do I detect this?  Also, is
there is any difference when dealing with LED screens. Thanks.
 

Re:Detecting Screen Refresh Rate


Quote
Jackie Braun wrote:
> Hi. I need to control as closely as possible how long material is
> presented on the screen, so each time I write to the screen I want to do
> it at the same place in the screen refresh cycle (e.g., when th e top
> left corner is about to be written to). How do I detect this?  Also, is
> there is any difference when dealing with LED screens. Thanks.

The procedure

  Procedure WaitVRetrace; ASSEMBLER;
  asm
    MOV  DX,03DAh
   @J1:
    IN AL,DX
    TEST Al,8
    JZ @J1
   @J2:
    IN AL,DX
    TEST AL,8
    JNZ @J2
  end;

waits for the vertical retrace to start. The procedure exits as soon as the
cathod ray reaches the screen's lower right corner and starts moving back
to the upper left.

        Bye,
          Ingo

Re:Detecting Screen Refresh Rate


Quote
On Tue, 8 Dec 1998, Jackie Braun wrote:
> Hi. I need to control as closely as possible how long material is
> presented on the screen, so each time I write to the screen I want to do
> it at the same place in the screen refresh cycle (e.g., when th e top
> left corner is about to be written to). How do I detect this?  Also, is
> there is any difference when dealing with LED screens. Thanks.

What you need to do is to check whether the 'verticar retrace bit' (or
v-sync) in one of your video card registers is set.
Here is an 'assembler' procedure which works *only* for VGA adapter
in color mode (resolution doesn't matter). It waits until the v-sync
bit is set. This is used mainly to remove flickering in animation,
but it may also serve your purposes.

procedure WaitRetrace; assembler;
asm
           mov dx,3dah { read COLOR MODE VGA input status register #0 }
@@loop1:   in   al, dx
           and  al, 8
           jnzloop1;
@@loop2:   in   al, dx
           and  al, 8  { check if vertical retrace is set (bit 3)  }
           jloop2
end;

bye

/\/\atjaz Kovac
FRI Ljubljana

Other Threads