diff --git a/Include/dxwnd.h b/Include/dxwnd.h index 7e53f52..95d7871 100644 --- a/Include/dxwnd.h +++ b/Include/dxwnd.h @@ -87,7 +87,7 @@ #define FIXD3DFRAME 0x00000020 // Preserve windows frame in D3D9 programs #define FORCE16BPP 0x00000040 // Forces 16BPP desktop color depth #define BLACKWHITE 0x00000080 // Simulate a B&W screen monitor mapping colors to grayscales -//#define SAVECAPS 0x00000100 // Saves and restores original surface flags & capabilities (UNUSED) +#define MARKLOCK 0x00000100 // higlights the locked/unlocked surfaces by surroundig the rect in color #define SINGLEPROCAFFINITY 0x00000200 // Set Process Affinity to a single core #define EMULATEREGISTRY 0x00000400 // Emulate registry api to read extra keys #define CDROMDRIVETYPE 0x00000800 // Pretends that GetDriveType() always returns DRIVE_CDROM @@ -189,6 +189,8 @@ #define FIXMOVIESCOLOR 0x00000020 // Fixes vfw movies color depth forcing the virtual value #define WOW64REGISTRY 0x00000040 // Sets KEY_WOW64_64KEY registry flag #define DISABLEMAXWINMODE 0x00000080 // invoke ddraw SetAppCompatData(12,0) to set DisableMaxWindowedMode +#define FIXPITCH 0x00000100 // Fixes surface filling made with no concern to actual pitch value +#define POWER2WIDTH 0x00000200 // Fixes ..... // logging Tflags DWORD: #define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general diff --git a/build/dxwnd.dll b/build/dxwnd.dll index 19584bf..3256573 100644 --- a/build/dxwnd.dll +++ b/build/dxwnd.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0f050a1ea1f36d6ac4045aee71626b4727670871e418331417ef4f2ad22a1e42 -size 577536 +oid sha256:bd9f3a8d1c620b34bb5d445bab38ed6510a486f2f3bdbde661a4a8d3d3c2052f +size 578048 diff --git a/build/dxwnd.exe b/build/dxwnd.exe index fd7dcf6..9003103 100644 --- a/build/dxwnd.exe +++ b/build/dxwnd.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:08eab14d883756898f5ba78147dee338e120fd229891eb8ed192c22faafa2a6e -size 540160 +oid sha256:5be9b2e6e65b9ed2d920418acc46bbfb48166515b1ad5d47f5c17854d73c5041 +size 540672 diff --git a/build/exports/Microsoft Midtown Madness.dxw b/build/exports/Microsoft Midtown Madness.dxw index 38f828e..2502ca3 100644 --- a/build/exports/Microsoft Midtown Madness.dxw +++ b/build/exports/Microsoft Midtown Madness.dxw @@ -12,8 +12,8 @@ flagg0=1207959552 flagh0=20 flagi0=138412036 flagj0=4224 -flagk0=0 -tflag0=-2147477245 +flagk0=512 +tflag0=0 initx0=0 inity0=0 minx0=0 diff --git a/build/exports/Snowboard Racer.dxw b/build/exports/Snowboard Racer.dxw new file mode 100644 index 0000000..a668ecc --- /dev/null +++ b/build/exports/Snowboard Racer.dxw @@ -0,0 +1,31 @@ +[target] +title0=Snowboard Racer +path0=D:\Games\Snowboard Racer\snowboard\SnowBoard.exe +launchpath0= +module0= +opengllib0= +notes0= +ver0=0 +coord0=0 +flag0=136314914 +flagg0=1207959552 +flagh0=33554452 +flagi0=138412036 +flagj0=4224 +flagk0=256 +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 +swapeffect0=0 diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt index c318c76..4819f8b 100644 --- a/build/readme-relnotes.txt +++ b/build/readme-relnotes.txt @@ -842,3 +842,8 @@ add: dxwnd proxyes to get standalone windowed mode (ask for instructions) fix: added SetAppCompatData(1, 0) to AERO compatibility for lock operations - improves AERO compatibility, e.g. "Age of Empires" intro movie add: added "Disable max window mode" flag for better compatibility with Win8/8.1 fix: cleaned up some opengl hooking code. Mind possible regressions .... + +v2.03.28: +add: added "Lock / Unlock pitch fix" flag to compensate for pitch change in emulation mode. Fixes "Snowboard racer" slanted graphic +add: added "Width not power of 2 fix" flag to compensate for pitch change in emulation mode. Fixes "Microsoft Midtown Madness" slanted graphic +add: debug flag "Highlight Locked surfaces" to highlight service surfaces that are Lock-ed and Unlock-ed. \ No newline at end of file diff --git a/dll/ddraw.cpp b/dll/ddraw.cpp index 6edb0b1..a9dddd9 100644 --- a/dll/ddraw.cpp +++ b/dll/ddraw.cpp @@ -2482,6 +2482,17 @@ static HRESULT BuildGenericEmu(LPDIRECTDRAW lpdd, CreateSurface_Type pCreateSurf // on WinXP Fifa 99 doesn't like DDSCAPS_SYSTEMMEMORY cap, so better to leave a way to unset it.... if(dxw.dwFlags5 & NOSYSTEMMEMORY) ddsd.ddsCaps.dwCaps &= ~DDSCAPS_SYSTEMMEMORY; + if(dxw.dwFlags6 & POWER2WIDTH){ // v2.03.28: POWER2WIDTH to fix "Midtown Madness" in surface emulation mode + if(((ddsd.dwFlags & (DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH)) == (DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH)) && + (ddsd.ddsCaps.dwCaps & DDSCAPS_OFFSCREENPLAIN) + ){ + DWORD dwWidth; + dwWidth = ((ddsd.dwWidth + 3) >> 2) << 2; + if(dwWidth != ddsd.dwWidth) OutTraceDW("CreateSurface: fixed surface width %d->%d\n", ddsd.dwWidth, dwWidth); + ddsd.dwWidth = dwWidth; + } + } + res=(*pCreateSurface)(lpdd, &ddsd, lplpdds, pu); if ((dxw.dwFlags1 & SWITCHVIDEOMEMORY) && (res!=DD_OK)){ OutTraceDW("CreateSurface ERROR: res=%x(%s) at %d, retry\n", res, ExplainDDError(res), __LINE__); @@ -2494,11 +2505,9 @@ static HRESULT BuildGenericEmu(LPDIRECTDRAW lpdd, CreateSurface_Type pCreateSurf return res; } - OutTraceDW("CreateSurface: %s\n", LogSurfaceAttributes((LPDDSURFACEDESC)&ddsd, "[Emu Generic]", __LINE__)); + OutTraceDW("CreateSurface: CREATED lpddsd=%x version=%d %s\n", + *lplpdds, dxversion, LogSurfaceAttributes((LPDDSURFACEDESC)&ddsd, "[Dir Generic]", __LINE__)); - OutTraceDW("CreateSurface: created Emu_Generic dds=%x\n", *lplpdds); - if(IsDebug) DescribeSurface(*lplpdds, dxversion, "DDSEmu_Generic", __LINE__); - // v2.02.66: if 8BPP paletized surface and a primary palette exixts, apply. // fixes "Virtua Fighter PC" palette bug if(lpDDP && (ddsd.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)){ @@ -2535,14 +2544,13 @@ static HRESULT BuildGenericDir(LPDIRECTDRAW lpdd, CreateSurface_Type pCreateSurf return res; } } - OutTraceDW("CreateSurface: created GENERIC surface dds=%x flags=%x(%s) caps=%x(%s)\n", - *lplpdds, lpddsd->dwFlags, ExplainFlags(lpddsd->dwFlags), lpddsd->ddsCaps.dwCaps, ExplainDDSCaps(lpddsd->ddsCaps.dwCaps)); + + OutTraceDW("CreateSurface: CREATED lpddsd=%x version=%d %s\n", + *lplpdds, dxversion, LogSurfaceAttributes((LPDDSURFACEDESC)lpddsd, "[Dir Generic]", __LINE__)); // hooks .... HookDDSurfaceGeneric(lplpdds, dxversion); - OutTraceDW("CreateSurface: created lpdds=%x type=Generic ret=%x\n", *lplpdds, res); - if(IsDebug) DescribeSurface(*lplpdds, dxversion, "Generic", __LINE__); //v2.02.44 bug fix return DD_OK; } @@ -3522,6 +3530,9 @@ HRESULT WINAPI extSetClipper(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWCLIPPER lpdd return res; } +DDSURFACEDESC SaveSurfaceDesc; +LPDIRECTDRAWSURFACE SaveSurface = NULL; + HRESULT WINAPI extLock(LPDIRECTDRAWSURFACE lpdds, LPRECT lprect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD flags, HANDLE hEvent) { HRESULT res; @@ -3553,6 +3564,11 @@ HRESULT WINAPI extLock(LPDIRECTDRAWSURFACE lpdds, LPRECT lprect, LPDDSURFACEDESC lpDDSurfaceDesc->lPitch, lpDDSurfaceDesc->lpSurface, LogSurfaceAttributes(lpDDSurfaceDesc, "[Locked]", __LINE__)); if(dxw.dwFlags1 & SUPPRESSDXERRORS) res=DD_OK; + if((dxw.dwFlags6 & FIXPITCH) || (dxw.dwFlags3 & MARKLOCK)){ + SaveSurfaceDesc = *lpDDSurfaceDesc; + SaveSurface = lpdds; + } + return res; } @@ -3635,6 +3651,9 @@ HRESULT WINAPI extLockDir(LPDIRECTDRAWSURFACE lpdds, LPRECT lprect, LPDDSURFACED return res; } +#define MARK16COLOR 0x7C1F +#define MARK32COLOR 0x00FF00FF + HRESULT WINAPI extUnlock(int dxversion, Unlock4_Type pUnlock, LPDIRECTDRAWSURFACE lpdds, LPRECT lprect) { HRESULT res; @@ -3668,6 +3687,47 @@ HRESULT WINAPI extUnlock(int dxversion, Unlock4_Type pUnlock, LPDIRECTDRAWSURFAC } } + if((dxw.dwFlags6 & FIXPITCH) && !(IsPrim||IsBack) && (lpdds == SaveSurface)){ + OutTrace("DEBUG: fixing lpdds=%x size=(%dx%d) surface=%x pitch=%d bpp=%d\n", + lpdds, SaveSurfaceDesc.dwWidth, SaveSurfaceDesc.dwHeight, SaveSurfaceDesc.lpSurface, SaveSurfaceDesc.lPitch, SaveSurfaceDesc.ddpfPixelFormat.dwRGBBitCount); + int y; + LONG lVirtualPitch; + LPVOID p1, p2; + lVirtualPitch = (((SaveSurfaceDesc.dwWidth+1)>>1) * SaveSurfaceDesc.ddpfPixelFormat.dwRGBBitCount) >> 2; + if(lVirtualPitch != SaveSurfaceDesc.lPitch){ // do just if necessary ... + for (y=SaveSurfaceDesc.dwHeight-1; y; y--){ // for each scan line ... + p1 = (LPVOID)((DWORD)SaveSurfaceDesc.lpSurface + (y * lVirtualPitch)); + p2 = (LPVOID)((DWORD)SaveSurfaceDesc.lpSurface + (y * SaveSurfaceDesc.lPitch)); + memcpy(p2, p1, SaveSurfaceDesc.lPitch); // copy line to correct offset + } + } + } + + if((dxw.dwFlags3 & MARKLOCK) && !(IsPrim||IsBack) && (lpdds == SaveSurface)){ + switch(SaveSurfaceDesc.ddpfPixelFormat.dwRGBBitCount){ + case 16: + for (UINT y=0; y. #include "TlHelp32.h" -#define VERSION "2.03.27" +#define VERSION "2.03.28" #define DDTHREADLOCK 1 //#define LOCKTHREADS diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo index fce89e5..60e1a66 100644 Binary files a/dll/dxwnd.vs2008.suo and b/dll/dxwnd.vs2008.suo differ diff --git a/host/TabDebug.cpp b/host/TabDebug.cpp index 91b4348..160dc1a 100644 --- a/host/TabDebug.cpp +++ b/host/TabDebug.cpp @@ -32,6 +32,7 @@ void CTabDebug::DoDataExchange(CDataExchange* pDX) DDX_Check(pDX, IDC_DXPROXED, cTarget->m_DXProxed); DDX_Check(pDX, IDC_ASSERT, cTarget->m_AssertDialog); DDX_Check(pDX, IDC_MARKBLIT, cTarget->m_MarkBlit); + DDX_Check(pDX, IDC_MARKLOCK, cTarget->m_MarkLock); DDX_Check(pDX, IDC_NOBLT, cTarget->m_NoBlt); DDX_Check(pDX, IDC_FASTBLT, cTarget->m_FastBlt); DDX_Check(pDX, IDC_GDICOLORCONV, cTarget->m_GDIColorConv); diff --git a/host/TabDirect3D.cpp b/host/TabDirect3D.cpp index b28dcca..21b065d 100644 --- a/host/TabDirect3D.cpp +++ b/host/TabDirect3D.cpp @@ -34,7 +34,11 @@ void CTabDirect3D::DoDataExchange(CDataExchange* pDX) DDX_Check(pDX, IDC_NOD3DRESET, cTarget->m_NoD3DReset); DDX_Check(pDX, IDC_SUPPRESSD3DEXT, cTarget->m_SuppressD3DExt); DDX_Check(pDX, IDC_FORCESHEL, cTarget->m_ForcesHEL); + + // Ddraw tweaks DDX_Check(pDX, IDC_NOSYSTEMEMULATED, cTarget->m_NoSystemEmulated); + DDX_Check(pDX, IDC_FIXPITCH, cTarget->m_FixPitch); + DDX_Check(pDX, IDC_POWER2WIDTH, cTarget->m_Power2Width); // Texture management DDX_Radio(pDX, IDC_TEXTURENONE, cTarget->m_TextureHandling); diff --git a/host/TargetDlg.cpp b/host/TargetDlg.cpp index 5b3d512..a92a1ba 100644 --- a/host/TargetDlg.cpp +++ b/host/TargetDlg.cpp @@ -121,6 +121,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/) m_UseRGB565 = TRUE; // seems the default for 16bit video mode m_SuppressDXErrors = FALSE; m_MarkBlit = FALSE; + m_MarkLock = FALSE; m_NoSystemMemory = FALSE; m_NoSystemEmulated = FALSE; m_NoBlt = FALSE; diff --git a/host/TargetDlg.h b/host/TargetDlg.h index 4353f98..5b6d793 100644 --- a/host/TargetDlg.h +++ b/host/TargetDlg.h @@ -96,6 +96,7 @@ public: BOOL m_UseRGB565; BOOL m_SuppressDXErrors; BOOL m_MarkBlit; + BOOL m_MarkLock; BOOL m_NoSystemMemory; BOOL m_NoSystemEmulated; BOOL m_NoBlt; @@ -166,6 +167,8 @@ public: BOOL m_NoPerfCounter; BOOL m_DisableFogging; BOOL m_ClearTarget; + BOOL m_FixPitch; + BOOL m_Power2Width; BOOL m_SuppressIME; BOOL m_SetCompatibility; BOOL m_AEROBoost; diff --git a/host/dxwndhost.aps b/host/dxwndhost.aps index 11e1fb7..b695693 100644 Binary files a/host/dxwndhost.aps and b/host/dxwndhost.aps differ diff --git a/host/dxwndhost.rc b/host/dxwndhost.rc index 036195b..9cef16a 100644 Binary files a/host/dxwndhost.rc and b/host/dxwndhost.rc differ diff --git a/host/dxwndhost.vs2008.suo b/host/dxwndhost.vs2008.suo index 55d62e0..8b0b821 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 b3146c9..5d019af 100644 --- a/host/dxwndhostView.cpp +++ b/host/dxwndhostView.cpp @@ -268,6 +268,8 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg) if(dlg->m_NoPerfCounter) t->flags4 |= NOPERFCOUNTER; if(dlg->m_DisableFogging) t->flags4 |= DISABLEFOGGING; if(dlg->m_ClearTarget) t->flags5 |= CLEARTARGET; + if(dlg->m_FixPitch) t->flags6 |= FIXPITCH; + if(dlg->m_Power2Width) t->flags6 |= POWER2WIDTH; if(dlg->m_SuppressIME) t->flags2 |= SUPPRESSIME; if(dlg->m_SuppressD3DExt) t->flags3 |= SUPPRESSD3DEXT; if(dlg->m_SetCompatibility) t->flags2 |= SETCOMPATIBILITY; @@ -317,6 +319,7 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg) if(dlg->m_UseRGB565) t->flags |= USERGB565; if(dlg->m_SuppressDXErrors) t->flags |= SUPPRESSDXERRORS; if(dlg->m_MarkBlit) t->flags3 |= MARKBLIT; + if(dlg->m_MarkLock) t->flags3 |= MARKLOCK; if(dlg->m_NoSystemMemory) t->flags5 |= NOSYSTEMMEMORY; if(dlg->m_NoSystemEmulated) t->flags5 |= NOSYSTEMEMULATED; if(dlg->m_NoBlt) t->flags5 |= NOBLT; @@ -515,6 +518,8 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg) dlg->m_NoPerfCounter = t->flags4 & NOPERFCOUNTER ? 1 : 0; dlg->m_DisableFogging = t->flags4 & DISABLEFOGGING ? 1 : 0; dlg->m_ClearTarget = t->flags5 & CLEARTARGET ? 1 : 0; + dlg->m_FixPitch = t->flags6 & FIXPITCH ? 1 : 0; + dlg->m_Power2Width = t->flags6 & POWER2WIDTH ? 1 : 0; dlg->m_SaveLoad = t->flags & SAVELOAD ? 1 : 0; dlg->m_SlowDown = t->flags & SLOWDOWN ? 1 : 0; dlg->m_BlitFromBackBuffer = t->flags & BLITFROMBACKBUFFER ? 1 : 0; @@ -538,6 +543,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg) dlg->m_UseRGB565 = t->flags & USERGB565 ? 1 : 0; dlg->m_SuppressDXErrors = t->flags & SUPPRESSDXERRORS ? 1 : 0; dlg->m_MarkBlit = t->flags3 & MARKBLIT ? 1 : 0; + dlg->m_MarkLock = t->flags3 & MARKLOCK ? 1 : 0; dlg->m_NoSystemMemory = t->flags5 & NOSYSTEMMEMORY ? 1 : 0; dlg->m_NoSystemEmulated = t->flags5 & NOSYSTEMEMULATED ? 1 : 0; dlg->m_NoBlt = t->flags5 & NOBLT ? 1 : 0; diff --git a/host/resource b/host/resource index b1b6a4b..6e962ac 100644 Binary files a/host/resource and b/host/resource differ