void vsyncarch_verticalblank(video_canvas_t *c, float rate, int frames) { unsigned long nowi, lastx, max, frm, vbl; if (c->refreshrate <= 0.0f) return; nowi = vsyncarch_frequency(); /* calculate counter cycles per frame */ frm = (unsigned long)((float)(nowi * frames) / rate); nowi = vsyncarch_gettime(); lastx = last - (frm * nosynccount); max = (frm * 7) >> 3; vbl = 0; while (max >= (nowi - lastx)) { IDirectDraw2_WaitForVerticalBlank(c->dd_object2, DDWAITVB_BLOCKBEGIN, 0); nowi = vsyncarch_gettime(); vbl = 1; } if ((!vbl) && (nosynccount < 16)) { nosynccount ++; } else { last = nowi; nosynccount = 0; } }
// // Wait for vsync, gross // VOID WaitVbl(VOID) { IDirectDraw2_WaitForVerticalBlank(DDr2, DDWAITVB_BLOCKBEGIN, NULL); }