/***
 *** wait_vsync.h: non-blocking V-synvc wait routine (doesn't hang when no VSYNC)
 *** Copyright (c) 1995 by Koen Gadeyne (kmg@barco.be)
 ***/

#ifndef _WAIT_VSYNC_H
#define _WAIT_VSYNC_H 

#define USE_VSYNC

#ifdef USE_VSYNC
#  define waitframe \
                   while ( !(inb(STATUS1) & 0x08) ); /* wait during active display */ \
                   while ( (inb(STATUS1) & 0x08) ) /* now wait during vert retrace */

#  define wait_vblk \
                   while ( (inb(STATUS1) & 0x08) && !vtimeout ); /* wait during vert retrace */ \
                   while ( !(inb(STATUS1) & 0x08) && !vtimeout )  /* wait during active display */
#else   /* doesn't work. dunno why */
#  define waitframe \
                   while ( (inb(STATUS0)) ); /* wait during active display */ \
                   while ( !(inb(STATUS0)) ) /* now wait during vert retrace */

#  define wait_vblk \
                   while ( !(inb(STATUS0)) && !vtimeout ); /* wait during vert retrace */ \
                   while ( (inb(STATUS0)) && !vtimeout )  /* wait during active display */
#endif

int safe_wait_vsync();

#endif


