diff --git a/Include/dxwnd.h b/Include/dxwnd.h index 18c8458..999e08b 100644 --- a/Include/dxwnd.h +++ b/Include/dxwnd.h @@ -133,6 +133,7 @@ #define NOFLIPEMULATION 0x00020000 // Compensate the effect of Flip-ping through Blt operations #define NOTEXTURES 0x00040000 // Disabled (whitened) textures #define RETURNNULLREF 0x00080000 // IDirectDraw::Release and IDDrawSurface::Release will always return 0 ref. counter +#define FINETIMING 0x00100000 // Fine timeslider coarse, by 10% steps ranging from about :2 to x2 // logging Tflags DWORD: #define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general diff --git a/build/dxwnd.dll b/build/dxwnd.dll index d8ecca9..7447a6c 100644 --- a/build/dxwnd.dll +++ b/build/dxwnd.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f848ba14637f8a11e413b5263df2c0eb3de7c1bba21f2db3602e9971c0f85804 -size 464896 +oid sha256:33ac0e7db3ed4efc6da6c4cc7f0988314aa96698631c5937ccb988ed50a82be3 +size 466432 diff --git a/build/dxwnd.exe b/build/dxwnd.exe index 9a01ae1..d36685a 100644 --- a/build/dxwnd.exe +++ b/build/dxwnd.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ad2a6e8e0b8119551bfb5352ba7c18e3c892b6dbae0a1e6d1be32b2d5bc9c094 +oid sha256:b1ab56aec078a3b4123d5d7fe8319b0c9baea51b7e987f61dfe5c61b47c1c56d size 535552 diff --git a/build/exports/DeathSpank The Baconing.dxw b/build/exports/DeathSpank The Baconing.dxw new file mode 100644 index 0000000..854119a --- /dev/null +++ b/build/exports/DeathSpank The Baconing.dxw @@ -0,0 +1,26 @@ +[target] +title0=DeathSpank: The Baconing +path0=D:\Games\The Baconing\TheBaconing.exe +module0= +opengllib0= +ver0=9 +coord0=0 +flag0=134218272 +flagg0=1207959552 +flagh0=20 +flagi0=4 +tflag0=0 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 diff --git a/build/exports/deadrising2otr1.dxw b/build/exports/Fallout.dxw similarity index 51% rename from build/exports/deadrising2otr1.dxw rename to build/exports/Fallout.dxw index 11f51ac..2a26179 100644 --- a/build/exports/deadrising2otr1.dxw +++ b/build/exports/Fallout.dxw @@ -1,15 +1,15 @@ [target] -title0=deadrising2otr.exe -path0=C:\Program Files (x86)\Capcom\Dead Rising 2 Off The Record\deadrising2otr.exe +title0=Fallout +path0=D:\Games\Fallout\FALLOUTW.EXE module0= opengllib0= -ver0=0 +ver0=1 coord0=0 -flag0=0 +flag0=134218272 flagg0=134217728 -flagh0=16 -flagi0=0 -tflag0=3 +flagh0=20 +flagi0=4 +tflag0=0 initx0=0 inity0=0 minx0=0 @@ -22,3 +22,5 @@ sizx0=800 sizy0=600 maxfps0=0 initts0=0 +winver0=0 +maxres0=-1 diff --git a/build/exports/JetMoto.dxw b/build/exports/JetMoto.dxw new file mode 100644 index 0000000..65069a9 --- /dev/null +++ b/build/exports/JetMoto.dxw @@ -0,0 +1,24 @@ +[target] +title0=JetMoto +path0=D:\Games\Jet_Moto\JETMOTO.EXE +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=671088674 +flagg0=1207959552 +flagh0=20 +flagi0=0 +tflag0=64 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 diff --git a/build/exports/Total Soccer 2000 (DirectX).dxw b/build/exports/Total Soccer 2000 (DirectX).dxw index 454c0eb..eba889f 100644 --- a/build/exports/Total Soccer 2000 (DirectX).dxw +++ b/build/exports/Total Soccer 2000 (DirectX).dxw @@ -5,11 +5,11 @@ module0= opengllib0= ver0=1 coord0=0 -flag0=134234656 +flag0=134234784 flagg0=1208025344 flagh0=20 flagi0=12 -tflag0=5249 +tflag0=0 initx0=0 inity0=0 minx0=0 diff --git a/build/exports/WarWind.dxw b/build/exports/WarWind.dxw new file mode 100644 index 0000000..c16dc11 --- /dev/null +++ b/build/exports/WarWind.dxw @@ -0,0 +1,26 @@ +[target] +title0=WarWind +path0=D:\Games\WarWind\WW.EXE +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134234656 +flagg0=1207959552 +flagh0=20 +flagi0=4 +tflag0=0 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 diff --git a/build/exports/Warcraft 2 Battlenet Ed.dxw b/build/exports/Warcraft 2 Battlenet Ed.dxw index 4cc9791..127c947 100644 --- a/build/exports/Warcraft 2 Battlenet Ed.dxw +++ b/build/exports/Warcraft 2 Battlenet Ed.dxw @@ -5,7 +5,7 @@ module0= opengllib0= ver0=0 coord0=0 -flag0=134217762 +flag0=134218400 flagg0=1207959552 flagh0=20 flagi0=4 @@ -22,3 +22,5 @@ sizx0=800 sizy0=600 maxfps0=0 initts0=0 +winver0=0 +maxres0=0 diff --git a/build/exports/Warwind 2.dxw b/build/exports/Warwind 2.dxw new file mode 100644 index 0000000..8919031 --- /dev/null +++ b/build/exports/Warwind 2.dxw @@ -0,0 +1,26 @@ +[target] +title0=Warwind 2 +path0=D:\Games\Warwind 2\WARWIND2.EXE +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134234656 +flagg0=1207959552 +flagh0=20 +flagi0=4 +tflag0=0 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 diff --git a/build/exports/dxwnd.ini b/build/exports/dxwnd.ini index b98db4d..5dfa345 100644 --- a/build/exports/dxwnd.ini +++ b/build/exports/dxwnd.ini @@ -1,5 +1,5 @@ [window] -posx=1007 -posy=65 -sizx=769 -sizy=832 +posx=1316 +posy=462 +sizx=320 +sizy=200 diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt index 24da705..7fc7b72 100644 --- a/build/readme-relnotes.txt +++ b/build/readme-relnotes.txt @@ -429,7 +429,7 @@ added DirectX "Return 0 ref counter" option as quick & dirty solution to many re fixed DirectDrawCreateEx failing to register the main ddraw session handle fixed palette problem in emulated mode: palette must be applied to backbuffer surface as well. Now "Duckman" and "Total Soccer 2000" show perfect colors. - - - - +v2.02.65 +added "Fine time adjust" flag to finely set timeslider by 10% steps ranging from about :2 to x2 +fixed a bug in DWORD timers introduced in v2.02.60: now "Warcraft 2" timing works again +revised logit to calculate delays to emulate VSync timing - now should be more accurate and depending on actual screen refresh rate diff --git a/dll/ddraw.cpp b/dll/ddraw.cpp index 66e9cba..2631b68 100644 --- a/dll/ddraw.cpp +++ b/dll/ddraw.cpp @@ -283,6 +283,32 @@ FARPROC Remap_ddraw_ProcAddress(LPCSTR proc, HMODULE hModule) // auxiliary (static) functions /* ------------------------------------------------------------------------------ */ +DWORD gdwRefreshRate; +#define MAXREFRESHDELAYCOUNT 20 +int iRefreshDelays[MAXREFRESHDELAYCOUNT]={16, 17}; +int iRefreshDelayCount=2; + +void SetVSyncDelays(LPDIRECTDRAW lpdd) +{ + DDSURFACEDESC ddsdRefreshRate; + int Reminder; + memset(&ddsdRefreshRate, 0, sizeof(ddsdRefreshRate)); + ddsdRefreshRate.dwSize = sizeof(ddsdRefreshRate); + (*pGetDisplayMode)(lpdd, &ddsdRefreshRate); + gdwRefreshRate = ddsdRefreshRate.dwRefreshRate; + if(!gdwRefreshRate) return; + iRefreshDelayCount=0; + Reminder=0; + do{ + iRefreshDelays[iRefreshDelayCount]=(1000+Reminder)/gdwRefreshRate; + Reminder=(1000+Reminder)-(iRefreshDelays[iRefreshDelayCount]*gdwRefreshRate); + iRefreshDelayCount++; + } while(Reminder && (iRefreshDelayCountHeight=(short)dxw.GetScreenHeight(); GetHookInfo()->Width=(short)dxw.GetScreenWidth(); GetHookInfo()->ColorDepth=(short)dxw.VirtualPixelFormat.dwRGBBitCount; @@ -3265,17 +3293,15 @@ HRESULT WINAPI extFlip(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWSURFACE lpddssrc, if((dwflags & DDFLIP_WAIT) || (dxw.dwFlags1 & SAVELOAD)) lpPrimaryDD->WaitForVerticalBlank(DDWAITVB_BLOCKEND , 0); if(dxw.dwFlags4 & NOFLIPEMULATION){ + // create a temporary working surface memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = SurfaceDescrSize(lpdds); - //if(pGetSurfaceDesc1) (*pGetSurfaceDesc1)(lpDDSBack, (LPDDSURFACEDESC)&ddsd); (*pGetSurfaceDescMethod(lpdds))((LPDIRECTDRAWSURFACE2)lpDDSBack, &ddsd); ddsd.dwFlags &= ~DDSD_PITCH; - //DumpSurfaceAttributes((LPDDSURFACEDESC)&ddsd, "[temp]" , __LINE__); res=(*pCreateSurfaceMethod(lpdds))(lpPrimaryDD, &ddsd, &lpddsTmp, NULL); if(res) OutTraceE("CreateSurface: ERROR %x(%s) at %d\n", res, ExplainDDError(res), __LINE__); - OutTrace("DEBUG: copied surface size=(%dx%d)\n", ddsd.dwWidth, ddsd.dwHeight); + //OutTrace("DEBUG: copied surface size=(%dx%d)\n", ddsd.dwWidth, ddsd.dwHeight); // copy front buffer - if(dxw.dwFlags1 & EMULATESURFACE){ // in emulated mode, the primary surface is virtual and you can pick it all // needed for "Gruntz" @@ -3316,7 +3342,7 @@ HRESULT WINAPI extFlip(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWSURFACE lpddssrc, } if(dxw.dwFlags4 & NOFLIPEMULATION){ - // restore flipped backbuffer + // restore flipped backbuffer and delete temporary surface res= (*pBlt)(lpddssrc, NULL, lpddsTmp, NULL, DDBLT_WAIT, NULL); if(res) OutTraceE("Blt: ERROR %x(%s) at %d", res, ExplainDDError(res), __LINE__); (*pReleaseS)(lpddsTmp); @@ -3417,9 +3443,8 @@ HRESULT WINAPI extWaitForVerticalBlank(LPDIRECTDRAW lpdd, DWORD dwflags, HANDLE tmp = (*pGetTickCount)(); if((time - tmp) > 32) time = tmp; (*pSleep)(time - tmp); - if(step) time += 16; - else time += 17; - step ^= 1; + time += iRefreshDelays[step++]; + if(step >= iRefreshDelayCount) step=0; return 0; } @@ -3469,9 +3494,9 @@ HRESULT WINAPI extSetPalette(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWPALETTE lpdd OutTraceDDRAW("SetPalette: lpdds=%x%s lpddp=%x\n", lpdds, isPrim?"(PRIM)":"", lpddp); res=(*pSetPalette)(lpdds, lpddp); - res=DD_OK; if(res)OutTraceE("SetPalette: ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__); else OutTraceDDRAW("SetPalette: OK\n"); + res=DD_OK; if((dxw.dwFlags1 & EMULATESURFACE) && isPrim){ OutTraceDW("SetPalette: register PRIMARY palette lpDDP=%x\n", lpddp); @@ -3485,12 +3510,13 @@ HRESULT WINAPI extSetPalette(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWPALETTE lpdd } // Apply palette to backbuffer surface. This is necessary on some games: "Duckman private dick", "Total Soccer 2000", ... if (lpDDSBack) { + OutTraceDW("SetPalette: apply PRIMARY palette lpDDP=%x to DDSBack=%x\n", lpddp, lpDDSBack); res=(*pSetPalette)(lpDDSBack, lpddp); if(res) OutTraceE("SetPalette: ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__); } // add a reference to simulate what would happen in reality.... lpdds->AddRef(); - res=0; + res=DD_OK; } return res; diff --git a/dll/dxhook.cpp b/dll/dxhook.cpp index 9365f81..4f32445 100644 --- a/dll/dxhook.cpp +++ b/dll/dxhook.cpp @@ -72,8 +72,8 @@ static char *Flag4Names[32]={ "ZBUFFERCLEAN", "ZBUFFER0CLEAN", "ZBUFFERALWAYS", "DISABLEFOGGING", "NOPOWER2FIX", "NOPERFCOUNTER", "ADDPROXYLIBS", "INTERCEPTRDTSC", "LIMITSCREENRES", "NOFILLRECT", "HOOKGLIDE", "HIDEDESKTOP", - "STRETCHTIMERS", "NOFLIPEMULATION", "NOTEXTURES", "", - "", "", "", "", + "STRETCHTIMERS", "NOFLIPEMULATION", "NOTEXTURES", "RETURNNULLREF", + "FINETIMING", "", "", "", "", "", "", "", "", "", "", "", }; diff --git a/dll/dxwcore.cpp b/dll/dxwcore.cpp index f1742f3..6888f0e 100644 --- a/dll/dxwcore.cpp +++ b/dll/dxwcore.cpp @@ -7,6 +7,21 @@ #include "dxhelper.h" #include "resource.h" +/* ------------------------------------------------------------------ */ +// Internal function pointers +/* ------------------------------------------------------------------ */ + +typedef DWORD (*TimeShifter_Type)(DWORD, int); +typedef LARGE_INTEGER (*TimeShifter64_Type)(LARGE_INTEGER, int); + +TimeShifter_Type pTimeShifter; +TimeShifter64_Type pTimeShifter64; + +static DWORD TimeShifterFine(DWORD, int); +static LARGE_INTEGER TimeShifter64Fine(LARGE_INTEGER, int); +static DWORD TimeShifterCoarse(DWORD, int); +static LARGE_INTEGER TimeShifter64Coarse(LARGE_INTEGER, int); + /* ------------------------------------------------------------------ */ // Constructor, destructor, initialization.... /* ------------------------------------------------------------------ */ @@ -75,6 +90,14 @@ void dxwCore::InitTarget(TARGETMAP *target) MaxScreenRes = target->MaxScreenRes; Coordinates = target->coordinates; MustShowOverlay=((dwFlags2 & SHOWFPSOVERLAY) || (dwFlags4 & SHOWTIMESTRETCH)); + if(dwFlags4 & FINETIMING){ + pTimeShifter = TimeShifterFine; + pTimeShifter64 = TimeShifter64Fine; + } + else{ + pTimeShifter = TimeShifterCoarse; + pTimeShifter64 = TimeShifter64Coarse; + } } void dxwCore::SetScreenSize(void) @@ -616,6 +639,23 @@ void dxwCore::UnmapClient(int *nXDest, int *nYDest) if(h) *nYDest= *nYDest * (int)dwScreenHeight / h; } +void dxwCore::UnmapClient(LPRECT lpRect) +{ + RECT client; + int w, h; + (*pGetClientRect)(hWnd, &client); + w = client.right ? client.right : iSizX; + h = client.bottom ? client.bottom : iSizY; + if(w) { + lpRect->left = (lpRect->left * (int)dwScreenWidth) / w; + lpRect->right = (lpRect->right * (int)dwScreenWidth) / w; + } + if(h) { + lpRect->top = (lpRect->top * (int)dwScreenHeight) / h; + lpRect->bottom = (lpRect->bottom * (int)dwScreenHeight) / h; + } +} + void dxwCore::MapWindow(LPRECT rect) { RECT client; @@ -746,7 +786,7 @@ void dxwCore::ScreenRefresh(void) if (tn-t < DXWREFRESHINTERVAL) return; t = tn; - // if not too early, refresh colors on primary surface .... + // if not too early, refresh primary surface .... lpDDSPrim=dxw.GetPrimarySurface(); if (lpDDSPrim) extBlt(lpDDSPrim, NULL, lpDDSPrim, NULL, 0, NULL); @@ -841,8 +881,18 @@ BOOL dxwCore::HandleFPS() if(dwFlags2 & SKIPFPS) if(SkipFrameCount(dxw.MaxFPS)) return TRUE; return FALSE; } + +static float fMul[17]={2.14F, 1.95F, 1.77F, 1.61F, 1.46F, 1.33F, 1.21F, 1.10F, 1.00F, 0.91F, 0.83F, 0.75F, 0.68F, 0.62F, 0.56F, 0.51F, 0.46F}; +//static float fMul[17]={0.46F, 0.51F, 0.56F, 0.62F, 0.68F, 0.75F, 0.83F, 0.91F, 1.00F, 1.10F, 1.21F, 1.33F, 1.46F, 1.61F, 1.77F, 1.95F, 2.14F}; -static DWORD TimeShifter(DWORD val, int shift) +static DWORD TimeShifterFine(DWORD val, int shift) +{ + float fVal; + fVal = (float)val * fMul[shift+8]; + return (DWORD)fVal; +} + +static DWORD TimeShifterCoarse(DWORD val, int shift) { int exp, reminder; if (shift > 0) { @@ -860,7 +910,16 @@ static DWORD TimeShifter(DWORD val, int shift) return val; } -static LARGE_INTEGER TimeShifter64(LARGE_INTEGER val, int shift) +static LARGE_INTEGER TimeShifter64Fine(LARGE_INTEGER val, int shift) +{ + float fVal; + fVal = (float)val.LowPart * fMul[shift+8]; + val.HighPart = 0; + val.LowPart = (DWORD)fVal; + return val; +} + +static LARGE_INTEGER TimeShifter64Coarse(LARGE_INTEGER val, int shift) { int exp, reminder; if (shift > 0) { @@ -884,7 +943,7 @@ DWORD dxwCore::GetTickCount(void) static DWORD dwLastRealTick=0; static DWORD dwLastFakeTick=0; DWORD dwNextRealTick; - BOOL FirstTime = TRUE; + static BOOL FirstTime = TRUE; if(FirstTime){ dwLastRealTick=(*pGetTickCount)(); @@ -894,7 +953,7 @@ DWORD dxwCore::GetTickCount(void) dwNextRealTick=(*pGetTickCount)(); dwTick=(dwNextRealTick-dwLastRealTick); TimeShift=GetHookInfo()->TimeShift; - dwTick = TimeShifter(dwTick, TimeShift); + dwTick = (*pTimeShifter)(dwTick, TimeShift); dwLastFakeTick += dwTick; dwLastRealTick = dwNextRealTick; return dwLastFakeTick; @@ -903,14 +962,14 @@ DWORD dxwCore::GetTickCount(void) DWORD dxwCore::StretchTime(DWORD dwTimer) { TimeShift=GetHookInfo()->TimeShift; - dwTimer = TimeShifter(dwTimer, -TimeShift); + dwTimer = (*pTimeShifter)(dwTimer, -TimeShift); return dwTimer; } DWORD dxwCore::StretchCounter(DWORD dwTimer) { TimeShift=GetHookInfo()->TimeShift; - dwTimer = TimeShifter(dwTimer, TimeShift); + dwTimer = (*pTimeShifter)(dwTimer, TimeShift); return dwTimer; } @@ -920,7 +979,7 @@ LARGE_INTEGER dxwCore::StretchCounter(LARGE_INTEGER dwTimer) LARGE_INTEGER ret; TimeShift=GetHookInfo()->TimeShift; dwTimer.QuadPart += Reminder; - ret = TimeShifter64(dwTimer, TimeShift); + ret = (*pTimeShifter64)(dwTimer, TimeShift); Reminder = (ret.QuadPart==0) ? dwTimer.LowPart : 0; return ret; } @@ -947,7 +1006,7 @@ void dxwCore::GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) dwCurrentTick=(*pGetTickCount)(); dwTick=(dwCurrentTick-dwStartTick); TimeShift=GetHookInfo()->TimeShift; - dwTick = TimeShifter(dwTick, TimeShift); + dwTick = (*pTimeShifter)(dwTick, TimeShift); // From MSDN: Contains a 64-bit value representing the number of // 100-nanosecond intervals since January 1, 1601 (UTC). // So, since 1mSec = 10.000 * 100nSec, you still have to multiply by 10.000. @@ -982,7 +1041,7 @@ void dxwCore::GetSystemTime(LPSYSTEMTIME lpSystemTime) dwCurrentTick=(*pGetTickCount)(); dwTick=(dwCurrentTick-dwStartTick); TimeShift=GetHookInfo()->TimeShift; - dwTick = TimeShifter(dwTick, TimeShift); + dwTick = (*pTimeShifter)(dwTick, TimeShift); // From MSDN: Contains a 64-bit value representing the number of // 100-nanosecond intervals since January 1, 1601 (UTC). // So, since 1mSec = 10.000 * 100nSec, you still have to multiply by 10.000. @@ -1108,20 +1167,27 @@ void dxwCore::ShowTimeStretching(HDC xdc) SetTextColor(xdc,color); //SetBkMode(xdc, TRANSPARENT); SetBkMode(xdc, OPAQUE); - sprintf_s(sBuf, 80, "Time %s", dxw.GetTSCaption()); + sprintf_s(sBuf, 80, "t%s", dxw.GetTSCaption()); TextOut(xdc, x, y, sBuf, strlen(sBuf)); } char *dxwCore::GetTSCaption(int shift) { - static char *sTSCaption[17]={ + static char *sTSCaptionCoarse[17]={ "x16","x12","x8","x6", "x4","x3","x2","x1.5", "x1", ":1.5",":2",":3",":4", ":6",":8",":12",":16"}; + static char *sTSCaptionFine[17]={ + "x2.14","x1.95","x1.77","x1.61", + "x1.46","x1.33","x1.21","x1.10", + "x1.00", + ":1.10",":1.21",":1.33",":1.46", + ":1.61",":1.77",":1.95",":2.14"}; if (shift<(-8) || shift>(+8)) return "???"; - return sTSCaption[shift+8]; + shift += 8; + return (dxw.dwFlags4 & FINETIMING) ? sTSCaptionFine[shift] : sTSCaptionCoarse[shift]; } char *dxwCore::GetTSCaption(void) diff --git a/dll/dxwcore.hpp b/dll/dxwcore.hpp index 685218c..c5200a0 100644 --- a/dll/dxwcore.hpp +++ b/dll/dxwcore.hpp @@ -58,6 +58,7 @@ public: // methods void MapClient(int *, int *); void UnmapClient(LPPOINT); void UnmapClient(int *, int *); + void UnmapClient(LPRECT); void MapWindow(LPPOINT); void MapWindow(LPRECT); void MapWindow(int *, int *, int *, int *); diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp index f6e03aa..3ea0e22 100644 --- a/dll/dxwnd.cpp +++ b/dll/dxwnd.cpp @@ -24,7 +24,7 @@ along with this program. If not, see . #include "dxwnd.h" #include "dxwcore.hpp" -#define VERSION "2.02.64" +#define VERSION "2.02.65" #define DDTHREADLOCK 1 diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo index 1faf035..4fbd3d8 100644 Binary files a/dll/dxwnd.vs2008.suo and b/dll/dxwnd.vs2008.suo differ diff --git a/dll/hd3d.cpp b/dll/hd3d.cpp index 49097f9..df0c5f5 100644 --- a/dll/hd3d.cpp +++ b/dll/hd3d.cpp @@ -924,6 +924,8 @@ HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype, (*pGetAdapterDisplayMode8)(lpd3d, 0, &mode); param[2] = mode.Format; OutTraceDW(" Current Format = 0x%x\n", mode.Format); + OutTraceDW(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height); + OutTraceDW(" Current Refresh Rate = %d\n", mode.RefreshRate); //param[0]=param[1]=0; @@ -1011,6 +1013,8 @@ HRESULT WINAPI extCreateDeviceEx(void *lpd3d, UINT adapter, D3DDEVTYPE devicetyp (*pGetAdapterDisplayMode9)(lpd3d, 0, &mode); param[2] = mode.Format; OutTraceDW(" Current Format = 0x%x\n", mode.Format); + OutTraceDW(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height); + OutTraceDW(" Current Refresh Rate = %d\n", mode.RefreshRate); //param[7] = 0; //hDeviceWindow param[7] = (DWORD)dxw.GethWnd(); //hDeviceWindow @@ -1128,6 +1132,8 @@ HRESULT WINAPI extCreateAdditionalSwapChain(void *lpd3d, D3DPRESENT_PARAMETERS * (*pGetAdapterDisplayMode8)(lpd3d, 0, &mode); param[2] = mode.Format; OutTraceDW(" Current Format = 0x%x\n", mode.Format); + OutTraceDW(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height); + OutTraceDW(" Current Refresh Rate = %d\n", mode.RefreshRate); if(dwD3DVersion == 9){ param[7] = 0; //hDeviceWindow diff --git a/dll/syslibs.h b/dll/syslibs.h index 57bbafe..ca6201c 100644 --- a/dll/syslibs.h +++ b/dll/syslibs.h @@ -193,6 +193,7 @@ typedef HWND (WINAPI *GetActiveWindow_Type)(void); typedef BOOL (WINAPI *IsWindowVisible_Type)(HWND); typedef BOOL (WINAPI *SystemParametersInfo_Type)(UINT, UINT, PVOID, UINT); typedef BOOL (WINAPI *KillTimer_Type)(HWND, UINT_PTR); +typedef BOOL (WINAPI *GetUpdateRect_Type)(HWND, LPRECT, BOOL); // Winmm.dll: typedef MCIERROR(WINAPI *mciSendCommand_Type)(MCIDEVICEID, UINT, DWORD_PTR, DWORD_PTR); @@ -392,6 +393,7 @@ DXWEXTERN GetActiveWindow_Type pGetActiveWindow DXWINITIALIZED; DXWEXTERN IsWindowVisible_Type pIsWindowVisible DXWINITIALIZED; DXWEXTERN SystemParametersInfo_Type pSystemParametersInfoA DXWINITIALIZED; DXWEXTERN KillTimer_Type pKillTimer DXWINITIALIZED; +DXWEXTERN GetUpdateRect_Type pGetUpdateRect DXWINITIALIZED; // Winmm.dll: DXWEXTERN mciSendCommand_Type pmciSendCommand DXWINITIALIZED; @@ -591,6 +593,7 @@ extern HWND WINAPI extGetActiveWindow(void); extern BOOL WINAPI extIsWindowVisible(HWND); extern BOOL WINAPI extSystemParametersInfoA(UINT, UINT, PVOID, UINT); extern BOOL WINAPI extKillTimer(HWND, UINT_PTR); +extern BOOL WINAPI extGetUpdateRect(HWND, LPRECT, BOOL); // Winmm.dll: extern MCIERROR WINAPI extmciSendCommand(MCIDEVICEID, UINT, DWORD_PTR, DWORD_PTR); diff --git a/dll/user32.cpp b/dll/user32.cpp index cdedbf2..c51118b 100644 --- a/dll/user32.cpp +++ b/dll/user32.cpp @@ -91,6 +91,7 @@ static HookEntry_Type RemapHooks[]={ {"GetClientRect", (FARPROC)GetClientRect, (FARPROC *)&pGetClientRect, (FARPROC)extGetClientRect}, {"GetWindowRect", (FARPROC)GetWindowRect, (FARPROC *)&pGetWindowRect, (FARPROC)extGetWindowRect}, {"MapWindowPoints", (FARPROC)MapWindowPoints, (FARPROC *)&pMapWindowPoints, (FARPROC)extMapWindowPoints}, + //{"GetUpdateRect", (FARPROC)GetUpdateRect, (FARPROC *)&pGetUpdateRect, (FARPROC)extGetUpdateRect}, {0, NULL, 0, 0} // terminator }; @@ -2272,3 +2273,20 @@ BOOL WINAPI extKillTimer(HWND hWnd, UINT_PTR uIDEvent) if(ret) dxw.PopTimer(hWnd, uIDEvent); return ret; } + +BOOL WINAPI extGetUpdateRect(HWND hWnd, LPRECT lpRect, BOOL bErase) +{ + BOOL ret; + OutTraceDW("GetUpdateRect: hwnd=%x Erase=%x\n", hWnd, bErase); + ret = (*pGetUpdateRect)(hWnd, lpRect, bErase); + if(ret){ + OutTraceDW("GetUpdateRect: rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); + if(dxw.IsFullScreen()){ + dxw.UnmapClient(lpRect); + OutTraceDW("GetUpdateRect: FIXED rect=(%d,%d)-(%d,%d)\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); + } + } + else + OutTraceE("GetUpdateRect ERROR: err=%d\n", GetLastError()); + return ret; +} \ No newline at end of file diff --git a/host/Resource.h b/host/Resource.h index 11dd3a2..a2f1f49 100644 --- a/host/Resource.h +++ b/host/Resource.h @@ -207,7 +207,7 @@ #define IDC_NOTEXTURES 1166 #define IDC_LIMITSCREENRES 1167 #define IDC_SHOWTIMESTRETCH 1168 - +#define IDC_FINETIMING 1169 #define ID_MODIFY 32771 #define ID_DELETE 32772 #define ID_ADD 32773 diff --git a/host/TabTiming.cpp b/host/TabTiming.cpp index e0c5bc5..6275e2c 100644 --- a/host/TabTiming.cpp +++ b/host/TabTiming.cpp @@ -36,6 +36,7 @@ void CTabTiming::DoDataExchange(CDataExchange* pDX) DDX_Check(pDX, IDC_TIMESTRETCH, cTarget->m_TimeStretch); DDX_Check(pDX, IDC_INTERCEPTRDTSC, cTarget->m_InterceptRDTSC); DDX_Check(pDX, IDC_STRETCHTIMERS, cTarget->m_StretchTimers); + DDX_Check(pDX, IDC_FINETIMING, cTarget->m_FineTiming); DDX_Text(pDX, IDC_MAXFPS, cTarget->m_MaxFPS); DDX_LBIndex(pDX, IDC_LISTTS, cTarget->m_InitTS); //{{AFX_DATA_MAP(CTabTiming) diff --git a/host/TargetDlg.cpp b/host/TargetDlg.cpp index 5fe6a6b..7fade23 100644 --- a/host/TargetDlg.cpp +++ b/host/TargetDlg.cpp @@ -125,6 +125,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/) m_ShowTimeStretch = FALSE; m_TimeStretch = FALSE; m_StretchTimers = FALSE; + m_FineTiming = FALSE; m_InterceptRDTSC = FALSE; m_HookOpenGL = FALSE; m_ForceHookOpenGL = FALSE; diff --git a/host/TargetDlg.h b/host/TargetDlg.h index f9c9186..8e20f1c 100644 --- a/host/TargetDlg.h +++ b/host/TargetDlg.h @@ -106,6 +106,7 @@ public: BOOL m_ShowTimeStretch; BOOL m_TimeStretch; BOOL m_StretchTimers; + BOOL m_FineTiming; BOOL m_InterceptRDTSC; BOOL m_HookOpenGL; BOOL m_ForceHookOpenGL; diff --git a/host/dxwndhost.aps b/host/dxwndhost.aps index 4925763..d3a62db 100644 Binary files a/host/dxwndhost.aps and b/host/dxwndhost.aps differ diff --git a/host/dxwndhost.rc b/host/dxwndhost.rc index 3ad9b2f..8e7d020 100644 --- a/host/dxwndhost.rc +++ b/host/dxwndhost.rc @@ -404,6 +404,7 @@ BEGIN CONTROL "Show time stretch",IDC_SHOWTIMESTRETCH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,134,84,10 CONTROL "Intercept RDTSC opcode",IDC_INTERCEPTRDTSC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,164,127,10 CONTROL "Stretch timers",IDC_STRETCHTIMERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,176,127,10 + CONTROL "Fine time adjust",IDC_FINETIMING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,146,88,10 END IDD_TAB_OUTPUT DIALOGEX 0, 0, 300, 240 diff --git a/host/dxwndhost.vs2008.suo b/host/dxwndhost.vs2008.suo index 764520a..0a385bb 100644 Binary files a/host/dxwndhost.vs2008.suo and b/host/dxwndhost.vs2008.suo differ diff --git a/host/dxwndhostView.cpp b/host/dxwndhostView.cpp index 7647592..18cb5f0 100644 --- a/host/dxwndhostView.cpp +++ b/host/dxwndhostView.cpp @@ -234,6 +234,7 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg) if(dlg->m_ShowTimeStretch) t->flags4 |= SHOWTIMESTRETCH; if(dlg->m_TimeStretch) t->flags2 |= TIMESTRETCH; if(dlg->m_StretchTimers) t->flags4 |= STRETCHTIMERS; + if(dlg->m_FineTiming) t->flags4 |= FINETIMING; if(dlg->m_InterceptRDTSC) t->flags4 |= INTERCEPTRDTSC; if(dlg->m_HookOpenGL) t->flags2 |= HOOKOPENGL; if(dlg->m_ForceHookOpenGL) t->flags3 |= FORCEHOOKOPENGL; @@ -392,6 +393,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg) dlg->m_ShowTimeStretch = t->flags4 & SHOWTIMESTRETCH ? 1 : 0; dlg->m_TimeStretch = t->flags2 & TIMESTRETCH ? 1 : 0; dlg->m_StretchTimers = t->flags4 & STRETCHTIMERS ? 1 : 0; + dlg->m_FineTiming = t->flags4 & FINETIMING ? 1 : 0; dlg->m_InterceptRDTSC = t->flags4 & INTERCEPTRDTSC ? 1 : 0; dlg->m_HookOpenGL = t->flags2 & HOOKOPENGL ? 1 : 0; dlg->m_ForceHookOpenGL = t->flags3 & FORCEHOOKOPENGL ? 1 : 0;