From 5c85f96f33b71b8e8991d6ecbbafac9b1306cb4a Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Fri, 6 Apr 2012 14:49:54 +0200 Subject: [PATCH] ddraw: Improve GetScanLine stub so it's usable for timing related tasks. --- dlls/ddraw/ddraw.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 20df445d67c..2ef51daff17 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -1964,8 +1964,8 @@ static HRESULT WINAPI ddraw7_GetScanLine(IDirectDraw7 *iface, DWORD *Scanline) { struct ddraw *ddraw = impl_from_IDirectDraw7(iface); struct wined3d_display_mode mode; - static DWORD cur_scanline; static BOOL hide = FALSE; + DWORD time, frame_progress, lines; TRACE("iface %p, line %p.\n", iface, Scanline); @@ -1982,11 +1982,20 @@ static HRESULT WINAPI ddraw7_GetScanLine(IDirectDraw7 *iface, DWORD *Scanline) /* Fake the line sweeping of the monitor */ /* FIXME: We should synchronize with a source to keep the refresh rate */ - *Scanline = cur_scanline++; - /* Assume 20 scan lines in the vertical blank */ - if (cur_scanline >= mode.height + 20) - cur_scanline = 0; + /* Simulate a 60Hz display */ + time = GetTickCount(); + frame_progress = time & 15; /* time % (1000 / 60) */ + if (!frame_progress) + { + *Scanline = 0; + return DDERR_VERTICALBLANKINPROGRESS; + } + + /* Convert frame_progress to estimated scan line. Return any line from + * block determined by time. Some lines may be never returned */ + lines = mode.height / 15; + *Scanline = (frame_progress - 1) * lines + time % lines; return DD_OK; } -- 2.11.4.GIT