Vertical Retrace.
How to avoid flicker. In general.

VSYNC: Vertical retrace SYNChronization. It is a technique used to avoid flickering sending data to the graphics card when the image is fixed and it is not in the process of updating. This is done just with two sentences:

WAIT &H3DA,8,8

The first sentence just WAITS unil the CRT (cathodic ray tube) finishes its way over the screen, i.e. the screen is completely drawn by the monitor, nothing to do with your program. It is kinda a delay to prevent the program to change the contents of the screen while the CRT is updating it. This reduces flickers, snow and things.

The WAIT &H3DA,8,8 makes the opposite, it waits until the CRT is positioned again at the top left of the screen. That's why you have to put them together.

The correct way to animate a game without any flicker is drawing to another buffer (double buffering) or to a non visible page, wait for the retrace (CRT walkin' over screen) and then copy page or blit buffer or whatever. This is better 'cause you are updating the whole screen at once, so the animation will appear to be happenning at once, although it isn't:

' DRAW everything on a buffer
WAIT &H3da,8
WAIT &H3da,8,8
' copy buffer to screen

I call this the "never will flicker" loop. I use it in my games lol.


WAIT &H3DA,8 ' Waits till the CRT reaches the bottom of the screen.
WAIT &H3DA,8,8 ' Waits till the CRT starts all over again.

To understand it: it's like the ol' routine which waits a key to be pressed cleaning the buffer before, that is:

WHILE INKEY$<>"":WEND ' Clears buffer
WHILE INKEY$="":WEND ' Waits for a key

Think about it: WAIT &H3DA,8 waits until BIT 3 from port &H3DA is 1, WAIT &H3DA,8,8 is XORing an 8 so it waits until bit 3 from port &H3DA is again 0.

Hope this helps!


VerticalRetraceGeneral - page last edited 2004-02-10 10:47:53 by (home) (edit)
Blast WIKI - by RoboticBoy - edited and tweaked for our evil purposes by Hexadecimal Disaster