1
0
mirror of https://github.com/DxWnd/DxWnd.reloaded synced 2024-12-30 09:25:35 +01:00

v2_02_29_src

Former-commit-id: cbb2b4c3cb8cffd655f385294e22fbb16a4f52eb
This commit is contained in:
gho tik 2013-07-30 12:38:11 -04:00 committed by Refael ACkermann
parent 32641ce288
commit 3ac3a3dfa3
19 changed files with 8752 additions and 2687 deletions

View File

@ -8,6 +8,7 @@
#define MAXTARGETS 256
#define DXWACTIVATESINGLETASK 1 // comment to allow multiple task activations
#define ONEPIXELFIX 1
// first flags DWORD dwFlags1:
#define UNNOTIFY 0x00000001
@ -34,7 +35,7 @@
#define USERGB565 0x00200000
#define SUPPRESSDXERRORS 0x00400000 // suppresses some common dx errors (BUSY)
#define PREVENTMAXIMIZE 0x00800000 // struggle to avoid window maximize
#define ONEPIXELFIX 0x01000000 // don't scale while blitting surfaces just 1 pixel different in size!
#define LOCKEDSURFACE 0x01000000 // emulates the buffer of the primary surface when locked and written directly
#define FIXPARENTWIN 0x02000000 // fixes parent window size & position
#define SWITCHVIDEOMEMORY 0x04000000 // when VIDEO memory is over, switches to SYSTEM memory
#define CLIENTREMAPPING 0x08000000 // hooks CLientToRect, RectToClient, GetClientRect, GetWinRect
@ -100,7 +101,7 @@
#define OUTIMPORTTABLE 0x00000080 // dump import table contents
#define OUTDEBUG 0x00000100 // detailed debugging indormation
#define EMULATEFLAGS (EMULATEBUFFER | EMULATESURFACE)
#define EMULATEFLAGS (EMULATEBUFFER | EMULATESURFACE | LOCKEDSURFACE)
#define HANDLEFPS (SHOWFPS | SHOWFPSOVERLAY | LIMITFPS | SKIPFPS)
// DxWnd host app data to be passed to the hook callback

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:783c26a318be9da75391d757104a7b69b5d7f22ef0dfe84a8b79174e16c824e5
size 350720
oid sha256:c374369324c6043bc75325e062677c9dc8755d0f27d6a013d54eb2065883ea0a
size 352768

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:445871f8075154ab63a9ef75f3b7ffcfe0b96ffec47887290a22d037b0dc50e8
oid sha256:e240953c0bad229baff47ef4265a34e717615da2a784cff305e2983a3bc4467d
size 523264

File diff suppressed because it is too large Load Diff

View File

@ -178,3 +178,12 @@ fixed MapWindowPoints hook (Alien Nations)
fixed desktop detections in some places, now correctly using dxw.IsDesktop() method
Now "Alien Nations" and "Emergency" working (almost) perfectly.
fixed d3d8/9 hook to Get/SetGammaRamp. This should make a great number of recent games playable again.
v2.02.29
CORE:
hooked DirectDrawSurface::Lock method to center primary surface memory updates centered into the window (in no emulated mode)
added "Locked surface" emulation type to enable scaled blitting to primary surface to stretch to the correct area.
Fixed BltFast handling to fix "Duckman" rendering problems.
GUI:
added support for "Locked surface" emulation type

View File

@ -77,12 +77,15 @@ HRESULT WINAPI extGetSurfaceDesc1(LPDIRECTDRAWSURFACE lpdds, LPDDSURFACEDESC lpd
HRESULT WINAPI extGetSurfaceDesc2(LPDIRECTDRAWSURFACE2 lpdds, LPDDSURFACEDESC2 lpddsd);
// STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC2) PURE;
HRESULT WINAPI extLock(LPDIRECTDRAWSURFACE, LPRECT, LPDIRECTDRAWSURFACE, DWORD, HANDLE);
HRESULT WINAPI extLockDir(LPDIRECTDRAWSURFACE, LPRECT, LPDIRECTDRAWSURFACE, DWORD, HANDLE);
HRESULT WINAPI extReleaseDC(LPDIRECTDRAWSURFACE, HDC);
HRESULT WINAPI extSetClipper(LPDIRECTDRAWSURFACE, LPDIRECTDRAWCLIPPER);
HRESULT WINAPI extSetColorKey(LPDIRECTDRAWSURFACE, DWORD, LPDDCOLORKEY);
HRESULT WINAPI extSetPalette(LPDIRECTDRAWSURFACE, LPDIRECTDRAWPALETTE);
HRESULT WINAPI extUnlock4(LPDIRECTDRAWSURFACE, LPRECT);
HRESULT WINAPI extUnlock1(LPDIRECTDRAWSURFACE, LPVOID);
HRESULT WINAPI extUnlockDir4(LPDIRECTDRAWSURFACE, LPRECT);
HRESULT WINAPI extUnlockDir1(LPDIRECTDRAWSURFACE, LPVOID);
HRESULT WINAPI extCreateSurface(int, CreateSurface_Type, LPDIRECTDRAW, DDSURFACEDESC2 *, LPDIRECTDRAWSURFACE *, void *);
@ -667,6 +670,8 @@ Unlock4_Type pUnlockMethod(LPDIRECTDRAWSURFACE lpdds)
extUnlock=(void *)*(DWORD *)(*(DWORD *)lpdds + 128);
if(extUnlock==(void *)extUnlock1) return (Unlock4_Type)pUnlock1;
if(extUnlock==(void *)extUnlock4) return (Unlock4_Type)pUnlock4;
if(extUnlock==(void *)extUnlockDir1) return (Unlock4_Type)pUnlock1;
if(extUnlock==(void *)extUnlockDir4) return (Unlock4_Type)pUnlock4;
sprintf_s(sMsg, 80, "pUnlockMethod: pUnlock(%x) can't match %x\n", lpdds, extUnlock);
OutTraceD(sMsg);
if (IsAssertEnabled) MessageBox(0, sMsg, "pUnlockMethod", MB_OK | MB_ICONEXCLAMATION);
@ -681,6 +686,8 @@ CreateSurface2_Type pCreateSurfaceMethod(LPDIRECTDRAWSURFACE lpdds)
extUnlock=(void *)*(DWORD *)(*(DWORD *)lpdds + 128);
if(extUnlock==(void *)extUnlock1) return (CreateSurface2_Type)pCreateSurface1;
if(extUnlock==(void *)extUnlock4) return (CreateSurface2_Type)pCreateSurface4;
if(extUnlock==(void *)extUnlockDir1) return (CreateSurface2_Type)pCreateSurface1;
if(extUnlock==(void *)extUnlockDir4) return (CreateSurface2_Type)pCreateSurface4;
sprintf_s(sMsg, 80, "pCreateSurfaceMethod: pUnlock(%x) can't match %x\n", lpdds, extUnlock);
OutTraceD(sMsg);
if (IsAssertEnabled) MessageBox(0, sMsg, "pCreateSurfaceMethod", MB_OK | MB_ICONEXCLAMATION);
@ -688,6 +695,21 @@ CreateSurface2_Type pCreateSurfaceMethod(LPDIRECTDRAWSURFACE lpdds)
return (CreateSurface2_Type)pCreateSurface1;
}
int SurfaceDescrSize(LPDIRECTDRAWSURFACE lpdds)
{
char sMsg[81];
void * extUnlock;
extUnlock=(void *)*(DWORD *)(*(DWORD *)lpdds + 128);
if(extUnlock==(void *)extUnlock1) return sizeof(DDSURFACEDESC);
if(extUnlock==(void *)extUnlock4) return sizeof(DDSURFACEDESC2);
if(extUnlock==(void *)extUnlockDir1) return sizeof(DDSURFACEDESC);
if(extUnlock==(void *)extUnlockDir4) return sizeof(DDSURFACEDESC2);
sprintf_s(sMsg, 80, "pCreateSurfaceMethod: pUnlock(%x) can't match %x\n", lpdds, extUnlock);
OutTraceD(sMsg);
if (IsAssertEnabled) MessageBox(0, sMsg, "SurfaceDescrSize", MB_OK | MB_ICONEXCLAMATION);
return sizeof(DDSURFACEDESC);
}
int lpddsHookedVersion(LPDIRECTDRAWSURFACE lpdds)
{
char sMsg[81];
@ -1063,6 +1085,15 @@ static void HookDDSurfacePrim(LPDIRECTDRAWSURFACE *lplpdds, int dxversion)
else
SetHook((void *)(**(DWORD **)lplpdds + 128), extUnlock4, (void **)&pUnlock4, "Unlock(S4)");
}
else {
// IDirectDrawSurface::Lock
SetHook((void *)(**(DWORD **)lplpdds + 100), extLockDir, (void **)&pLock, "Lock(S)");
// IDirectDrawSurface::Unlock
if (dxversion < 4)
SetHook((void *)(**(DWORD **)lplpdds + 128), extUnlockDir1, (void **)&pUnlock1, "Unlock(S1)");
else
SetHook((void *)(**(DWORD **)lplpdds + 128), extUnlockDir4, (void **)&pUnlock4, "Unlock(S4)");
}
if (!(dxw.dwTFlags & OUTPROXYTRACE)) return;
@ -1140,6 +1171,8 @@ static void HookDDSurfaceGeneric(LPDIRECTDRAWSURFACE *lplpdds, int dxversion)
SetHook((void *)(**(DWORD **)lplpdds + 56), extGetCaps7S, (void **)&pGetCaps7S, "GetCaps(S7)");
break;
}
// IDirectDrawSurface::GetDC
SetHook((void *)(**(DWORD **)lplpdds + 68), extGetDC, (void **)&pGetDC, "GetDC(S)"); // IDirectDrawSurface::GetSurfaceDesc
// IDirectDrawSurface::GetSurfaceDesc
if (dxversion < 4) {
SetHook((void *)(**(DWORD **)lplpdds + 88), extGetSurfaceDesc1, (void **)&pGetSurfaceDesc1, "GetSurfaceDesc(S1)");
@ -1722,13 +1755,36 @@ static char *FixSurfaceCaps(LPDDSURFACEDESC2 lpddsd)
case DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PITCH:
switch (lpddsd->ddsCaps.dwCaps){
case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY:
OutTrace("FixSurfaceCaps: null action (Airline Tycoon Evolution)\n");
// Airline Tycoon Evolution
OutTrace("FixSurfaceCaps: no PixelFormat\n");
return "null";
break;
//case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY|DDSCAPS_3DDEVICE:
// OutTrace("FixSurfaceCaps: ??? (Dungeon Keeper D3D)\n");
// //return SetPixFmt(lpddsd);
// return "null";
// break;
default:
break;
}
case DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT:
// Duckman
OutTrace("FixSurfaceCaps: SystemMemory OffScreen PixelFormat\n");
lpddsd->ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY;
lpddsd->ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN;
return SetPixFmt(lpddsd);
case DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH:
switch (lpddsd->ddsCaps.dwCaps){
case DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY:
// Alien Nations
OutTrace("FixSurfaceCaps: Alien Nations (1)\n");
lpddsd->dwFlags |= DDSD_PIXELFORMAT;
lpddsd->ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY;
return SetPixFmt(lpddsd);
break;
default:
break;
}
default:
break;
}
@ -2328,7 +2384,7 @@ static void BlitError(HRESULT res, LPRECT lps, LPRECT lpd, int line)
return;
}
static void BlitTrace(char *label, LPRECT lps, LPRECT lpd, int line)
static void BlitTrace(char *label, LPRECT lps, LPRECT lpd, DWORD flags, int line)
{
OutTrace("Blt: %s", label);
if (lps)
@ -2339,7 +2395,7 @@ static void BlitTrace(char *label, LPRECT lps, LPRECT lpd, int line)
OutTrace(" dest=(%d,%d)-(%d,%d)",lpd->left, lpd->top, lpd->right, lpd->bottom);
else
OutTrace(" dest=(NULL)");
OutTrace(" at %d\n", __LINE__);
OutTrace(" flags=%x(%s) at %d\n", flags, ExplainBltFlags(flags), line);
return;
}
@ -2455,21 +2511,21 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
}
}
if (IsDebug) BlitTrace("NOPRIM", lpsrcrect, lpdestrect, __LINE__);
if (IsDebug) BlitTrace("NOPRIM", lpsrcrect, lpdestrect, dwflags, __LINE__);
res= (*pBlt)(lpdds, lpdestrect, lpddssrc, lpsrcrect ? &srcrect : NULL, dwflags, lpddbltfx);
// Blitting compressed data may work to screen surfaces only. In this case, it may be worth
// trying blitting directly to lpDDSEmu_Prim: it makes DK2 intro movies working.
switch(res){
case DDERR_UNSUPPORTED:
if (dxw.dwFlags1 & EMULATESURFACE){
if (IsDebug) BlitTrace("UNSUPP", lpsrcrect ? &srcrect : NULL, lpdestrect, __LINE__);
if (IsDebug) BlitTrace("UNSUPP", lpsrcrect ? &srcrect : NULL, lpdestrect, dwflags, __LINE__);
res=(*pBlt)(lpDDSEmu_Prim, lpdestrect, lpddssrc, lpsrcrect ? &srcrect : NULL, dwflags, lpddbltfx);
}
break;
case DDERR_SURFACEBUSY:
(*pUnlockMethod(lpdds))(lpdds, NULL);
if (lpddssrc) (*pUnlockMethod(lpddssrc))(lpddssrc, NULL);
if (IsDebug) BlitTrace("BUSY", lpsrcrect ? &srcrect : NULL, lpdestrect, __LINE__);
if (IsDebug) BlitTrace("BUSY", lpsrcrect ? &srcrect : NULL, lpdestrect, dwflags, __LINE__);
res=(*pBlt)(lpdds, lpdestrect, lpddssrc, lpsrcrect ? &srcrect : NULL, dwflags|DDBLT_WAIT, lpddbltfx);
break;
default:
@ -2491,7 +2547,7 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
// blit only when source and dest surface are different. Should make ScreenRefresh faster.
if (lpdds != lpddssrc) {
if (dxw.dwFlags2 & SHOWFPSOVERLAY) dxw.ShowFPS(lpddssrc);
if (IsDebug) BlitTrace("PRIM-NOEMU", lpsrcrect, &destrect, __LINE__);
if (IsDebug) BlitTrace("PRIM-NOEMU", lpsrcrect, &destrect, dwflags, __LINE__);
res= (*pBlt)(lpdds, &destrect, lpddssrc, lpsrcrect, dwflags, lpddbltfx);
}
if(res){
@ -2499,7 +2555,7 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
// Try to handle HDC lock concurrency....
if(res==DDERR_SURFACEBUSY){
(*pUnlockMethod(lpdds))(lpdds, NULL);
if (IsDebug) BlitTrace("BUSY", lpsrcrect, &destrect, __LINE__);
if (IsDebug) BlitTrace("BUSY", lpsrcrect, &destrect, dwflags, __LINE__);
res= (*pBlt)(lpdds, &destrect, lpddssrc, lpsrcrect, dwflags, lpddbltfx);
if (res) BlitError(res, lpsrcrect, &destrect, __LINE__);
}
@ -2535,7 +2591,7 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
res=0;
// blit only when source and dest surface are different. Should make ScreenRefresh faster.
if (lpdds != lpddssrc){
if (IsDebug) BlitTrace("SRC2EMU", &emurect, &destrect, __LINE__);
if (IsDebug) BlitTrace("SRC2EMU", &emurect, &destrect, dwflags, __LINE__);
res=(*pBlt)(lpdds, &emurect, lpddssrc, lpsrcrect, dwflags, lpddbltfx);
}
@ -2549,7 +2605,7 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
*/
if(res==DDERR_UNSUPPORTED){
if (dxw.dwFlags2 & SHOWFPSOVERLAY) dxw.ShowFPS(lpddssrc);
if (IsDebug) BlitTrace("UNSUPP", &emurect, &destrect, __LINE__);
if (IsDebug) BlitTrace("UNSUPP", &emurect, &destrect, dwflags, __LINE__);
res=(*pBlt)(lpDDSEmu_Prim, &destrect, lpddssrc, lpsrcrect, dwflags, lpddbltfx);
if (res) BlitError(res, lpsrcrect, &destrect, __LINE__);
}
@ -2558,7 +2614,7 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
if(res==DDERR_SURFACEBUSY){
res=(*pUnlockMethod(lpddssrc))(lpddssrc, NULL);
if(res) OutTraceE("Unlock ERROR: err=%x(%s)\n", res, ExplainDDError(res));
if (IsDebug) BlitTrace("BUSY", &emurect, &destrect, __LINE__);
if (IsDebug) BlitTrace("BUSY", &emurect, &destrect, dwflags, __LINE__);
res=(*pBlt)(lpdds, &emurect, lpddssrc, lpsrcrect, dwflags, lpddbltfx);
if (res) BlitError(res, lpsrcrect, &destrect, __LINE__);
}
@ -2587,11 +2643,11 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
}
if (dxw.dwFlags2 & SHOWFPSOVERLAY) dxw.ShowFPS(lpDDSSource);
if (IsDebug) BlitTrace("BACK2PRIM", &emurect, &destrect, __LINE__);
if (IsDebug) BlitTrace("BACK2PRIM", &emurect, &destrect, dwflags, __LINE__);
res=(*pBlt)(lpDDSEmu_Prim, &destrect, lpDDSSource, &emurect, DDBLT_WAIT, 0);
if (res==DDERR_NOCLIPLIST){
RenewClipper(lpDD, lpDDSEmu_Prim);
if (IsDebug) BlitTrace("NOCLIP", &emurect, &destrect, __LINE__);
if (IsDebug) BlitTrace("NOCLIP", &emurect, &destrect, dwflags, __LINE__);
res=(*pBlt)(lpDDSEmu_Prim, &destrect, lpDDSSource, &emurect, DDBLT_WAIT, 0);
}
@ -2945,6 +3001,79 @@ HRESULT WINAPI extLock(LPDIRECTDRAWSURFACE lpdds, LPRECT lprect, LPDIRECTDRAWSUR
return res;
}
LPDIRECTDRAWSURFACE2 lpDDSBuffer = NULL;
HRESULT WINAPI extLockDir(LPDIRECTDRAWSURFACE lpdds, LPRECT lprect, LPDIRECTDRAWSURFACE lpdds2, DWORD flags, HANDLE hEvent)
{
HRESULT res;
static RECT client;
POINT upleft={0,0};
LPDIRECTDRAWSURFACE lpDDSPrim;
// this hooker operates on
// Beware!!! for strange reason, the function gets hooked to ANY surface, also non primary ones!!!
// to find out whether it is the primary or not, using lpdds==lpDD->GetGDISurface(&lpDDSPrim);
if(IsTraceD){
OutTrace("Lock: lpdds=%x flags=%x(%s) lpdds2=%x",
lpdds, flags, ExplainLockFlags(flags), lpdds2);
if (lprect)
OutTrace(" rect=(%d,%d)-(%d,%d)\n", lprect->left, lprect->top, lprect->right, lprect->bottom);
else
OutTrace(" rect=(NULL)\n");
}
(*pGetGDISurface)(lpDD, &lpDDSPrim);
if(lpdds==lpDDSPrim){
if(dxw.dwFlags1 & LOCKEDSURFACE){
DDSURFACEDESC2 ddsd;
DDBLTFX fx;
memset(&ddsd, 0, sizeof(ddsd));
//ddsd.dwSize=SurfaceDescrSize(lpdds);
ddsd.dwSize=sizeof(DDSURFACEDESC);
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
ddsd.dwWidth = dxw.GetScreenWidth();
ddsd.dwHeight = dxw.GetScreenHeight();
ddsd.ddsCaps.dwCaps = 0;
//if (SurfaceDescrSize(lpdds)==sizeof(DDSURFACEDESC2)) ddsd.ddsCaps.dwCaps |= DDSCAPS_OFFSCREENPLAIN;
DumpSurfaceAttributes((LPDDSURFACEDESC)&ddsd, "[Dir FixBuf]" , __LINE__);
//res=(*pCreateSurfaceMethod(lpdds))(lpDD, &ddsd, (LPDIRECTDRAWSURFACE *)&lpDDSBuffer, 0);
res=(*pCreateSurface1)(lpDD, (DDSURFACEDESC *)&ddsd, (LPDIRECTDRAWSURFACE *)&lpDDSBuffer, 0);
if(res){
OutTraceE("CreateSurface: ERROR on DDSBuffer res=%x(%s) at %d\n",res, ExplainDDError(res), __LINE__);
return res;
}
memset(&fx, 0, sizeof(fx));
fx.dwSize=sizeof(DDBLTFX);
fx.dwFillColor=0;
res=(*pBlt)((LPDIRECTDRAWSURFACE)lpDDSBuffer, NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
if(res){
OutTraceE("Blt: ERROR on DDSBuffer res=%x(%s) at %d\n",res, ExplainDDError(res), __LINE__);
}
lpdds=(LPDIRECTDRAWSURFACE)lpDDSBuffer;
}
else{
// since it can't scale, at least the updated rect is centered into the window.
(*pGetClientRect)(dxw.GethWnd(), &client);
(*pClientToScreen)(dxw.GethWnd(), &upleft);
if (!lprect) lprect=&client;
OffsetRect(lprect,
upleft.x+(client.right-dxw.GetScreenWidth())/2,
upleft.y+(client.bottom-dxw.GetScreenHeight())/2);
OutTraceD("Lock: NULL rect remapped to (%d,%d)-(%d,%d)\n",
lprect->left, lprect->top, lprect->right, lprect->bottom);
}
}
res=(*pLock)(lpdds, lprect, lpdds2, flags, hEvent);
if(res) OutTraceE("Lock ERROR: ret=%x(%s)\n", res, ExplainDDError(res));
DumpSurfaceAttributes((LPDDSURFACEDESC)lpdds2, "[Locked]" , __LINE__);
if(dxw.dwFlags1 & SUPPRESSDXERRORS) res=DD_OK;
return res;
}
HRESULT WINAPI extUnlock(int dxversion, Unlock4_Type pUnlock, LPDIRECTDRAWSURFACE lpdds, LPRECT lprect)
{
HRESULT res;
@ -2985,6 +3114,62 @@ HRESULT WINAPI extUnlock1(LPDIRECTDRAWSURFACE lpdds, LPVOID lpvoid)
return extUnlock(1, (Unlock4_Type)pUnlock1, lpdds, (LPRECT)lpvoid);
}
HRESULT WINAPI extUnlockDir(int dxversion, Unlock4_Type pUnlock, LPDIRECTDRAWSURFACE lpdds, LPRECT lprect)
{
HRESULT res;
//RECT screen, rect;
BOOL IsPrim;
LPDIRECTDRAWSURFACE lpDDSPrim;
IsPrim=dxw.IsAPrimarySurface(lpdds);
if ((dxversion == 4) && lprect) CleanRect(&lprect,__LINE__);
if(IsTraceD){
OutTrace("Unlock: lpdds=%x%s ", lpdds, (IsPrim ? "(PRIM)":""));
if (dxversion == 4){
if (lprect){
OutTrace("rect=(%d,%d)-(%d,%d)\n", lprect->left, lprect->top, lprect->right, lprect->bottom);
}
else
OutTrace("rect=(NULL)\n");
}
else
OutTrace("lpvoid=%x\n", lprect);
}
(*pGetGDISurface)(lpDD, &lpDDSPrim);
if((lpdds==lpDDSPrim) && (dxw.dwFlags1 & LOCKEDSURFACE)){
RECT client;
POINT upleft={0,0};
(*pGetClientRect)(dxw.GethWnd(), &client);
(*pClientToScreen)(dxw.GethWnd(), &upleft);
if (!lprect) lprect=&client;
OffsetRect(lprect, upleft.x, upleft.y);
res=(*pUnlock)((LPDIRECTDRAWSURFACE)lpDDSBuffer, lprect);
(*pBlt)(lpdds, lprect, (LPDIRECTDRAWSURFACE)lpDDSBuffer, NULL, DDBLT_WAIT, 0);
if(lpDDSBuffer) (*pReleaseS)((LPDIRECTDRAWSURFACE)lpDDSBuffer);
lpDDSBuffer = NULL;
}
else{
res=(*pUnlock)(lpdds, lprect);
}
if (res) OutTraceE("Unlock ERROR res=%x(%s) at %d\n",res, ExplainDDError(res), __LINE__);
if (IsPrim && res==DD_OK) sBlt("Unlock", lpdds, NULL, lpdds, NULL, NULL, 0, FALSE);
if(dxw.dwFlags1 & SUPPRESSDXERRORS) res=0;
return res;
}
HRESULT WINAPI extUnlockDir4(LPDIRECTDRAWSURFACE lpdds, LPRECT lprect)
{
return extUnlockDir(4, pUnlock4, lpdds, lprect);
}
HRESULT WINAPI extUnlockDir1(LPDIRECTDRAWSURFACE lpdds, LPVOID lpvoid)
{
return extUnlockDir(1, (Unlock4_Type)pUnlock1, lpdds, (LPRECT)lpvoid);
}
/* to do: instead of calling GDI GetDC, try to map GetDC with Lock and
ReleaseDC with Unlock, returning the surface memory ptr (???) as HDC
and avoiding the consistency check performed by surface::GetDC (why

View File

@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dxwnd.h"
#include "dxwcore.hpp"
#define VERSION "2.02.28"
#define VERSION "2.02.29"
LRESULT CALLBACK HookProc(int ncode, WPARAM wparam, LPARAM lparam);

Binary file not shown.

View File

@ -473,7 +473,7 @@ HRESULT WINAPI extGetAdapterIdentifier(void *pd3dd, UINT Adapter, DWORD Flags, D
{
HRESULT res;
OutTraceD("GetAdapterIdentifier: Adapter=%d flags=%x\n", Adapter, Flags);
res=pGetAdapterIdentifier(pd3dd, Adapter, Flags, pIdentifier);
res=(*pGetAdapterIdentifier)(pd3dd, Adapter, Flags, pIdentifier);
OutTraceD("GetAdapterIdentifier: ret=%x\n", res);
return res;
}

View File

@ -400,6 +400,8 @@ BOOL WINAPI extDDInvalidateRect(HWND hwnd, RECT *lpRect, BOOL bErase)
OutTraceD("InvalidateRect: hwnd=%x rect=NULL erase=%x\n",
hwnd, bErase);
if(dxw.IsFullScreen() && dxw.IsDesktop(hwnd)) hwnd=dxw.GethWnd();
return (*pInvalidateRect)(hwnd, NULL, bErase);
}
@ -412,6 +414,8 @@ BOOL WINAPI extInvalidateRect(HWND hwnd, RECT *lpRect, BOOL bErase)
OutTraceD("InvalidateRect: hwnd=%x rect=NULL erase=%x\n",
hwnd, bErase);
if(dxw.IsFullScreen() && dxw.IsDesktop(hwnd)) hwnd=dxw.GethWnd();
return (*pInvalidateRect)(hwnd, NULL, bErase);
}

View File

@ -36,6 +36,7 @@
#define IDD_TAB_COMPAT 160
#define IDD_TAB_GDI 161
#define IDD_TAB_COLOR 162
#define IDC_AUTO 300
#define IDC_DIRECTX1 301
#define IDC_DIRECTX7 302
@ -44,15 +45,18 @@
#define IDC_NODIRECTX 305
#define IDC_DIRECTX10 306
#define IDC_DIRECTX11 307
#define IDC_FILE 1000
#define IDC_OPEN 1001
#define IDC_STATUSINFO 1005
#define IDC_VERSION 1006
#define IDC_UNNOTIFY 1007
#define IDC_EMULATESURFACE 1008
#define IDC_NOEMULATESURFACE 1008
#define IDC_EMULATEBUFFER 1009
#define IDC_NOEMULATESURFACE 1010
#define IDC_HOOKDI 1011
#define IDC_LOCKEDSURFACE 1010
#define IDC_EMULATESURFACE 1011
#define IDC_MODIFYMOUSE 1012
#define IDC_OUTTRACE 1013
#define IDC_HANDLEDC 1014
@ -153,6 +157,7 @@
#define IDC_BLACKWHITE 1109
#define IDC_SAVECAPS 1110
#define IDC_SINGLEPROCAFFINITY 1111
#define IDC_HOOKDI 1112
#define ID_MODIFY 32771
#define ID_DELETE 32772
#define ID_ADD 32773

View File

@ -27,10 +27,7 @@ void CTabDirectX::DoDataExchange(CDataExchange* pDX)
CDialog::DoDataExchange(pDX);
CTargetDlg *cTarget = ((CTargetDlg *)(this->GetParent()->GetParent()));
DDX_Radio(pDX, IDC_AUTO, cTarget->m_DXVersion);
DDX_Check(pDX, IDC_EMULATESURFACE, cTarget->m_EmulateSurface);
DDX_Check(pDX, IDC_NOEMULATESURFACE, cTarget->m_NoEmulateSurface);
DDX_Check(pDX, IDC_EMULATEBUFFER, cTarget->m_EmulateBuffer);
DDX_Radio(pDX, IDC_NOEMULATESURFACE, cTarget->m_DxEmulationMode);
DDX_Check(pDX, IDC_HANDLEDC, cTarget->m_HandleDC);
DDX_Check(pDX, IDC_SUPPRESSCLIPPING, cTarget->m_SuppressClipping);
DDX_Check(pDX, IDC_BLITFROMBACKBUFFER, cTarget->m_BlitFromBackBuffer);

View File

@ -22,9 +22,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
//{{AFX_DATA_INIT(CTargetDlg)
m_DXVersion = -1;
m_Coordinates = 0;
m_EmulateSurface = FALSE;
m_NoEmulateSurface = TRUE; // current default
m_EmulateBuffer = FALSE;
m_DxEmulationMode = 0; // default: no emulation
m_HookDI = FALSE;
m_ModifyMouse = FALSE;
m_OutTrace = FALSE;

View File

@ -25,9 +25,7 @@ public:
CEdit m_File;
int m_DXVersion;
int m_Coordinates;
BOOL m_EmulateSurface;
BOOL m_NoEmulateSurface;
BOOL m_EmulateBuffer;
int m_DxEmulationMode;
BOOL m_HookDI;
BOOL m_ModifyMouse;
BOOL m_OutTrace;

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -304,11 +304,12 @@ BEGIN
CONTROL "DirectX10",IDC_DIRECTX10,"Button",BS_AUTORADIOBUTTON,14,70,47,12
CONTROL "DirectX11",IDC_DIRECTX11,"Button",BS_AUTORADIOBUTTON,14,81,47,12
CONTROL "None",IDC_NODIRECTX,"Button",BS_AUTORADIOBUTTON,14,92,71,12
CONTROL "None",IDC_NOEMULATESURFACE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,14,131,77,12
CONTROL "Primary Surface",IDC_EMULATESURFACE,"Button",BS_AUTORADIOBUTTON,14,154,77,12
CONTROL "Primary Buffer",IDC_EMULATEBUFFER,"Button",BS_AUTORADIOBUTTON,14,142,67,12
CONTROL "None",IDC_NOEMULATESURFACE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,14,120,77,12
CONTROL "Primary Buffer",IDC_EMULATEBUFFER,"Button",BS_AUTORADIOBUTTON,14,132,67,12
CONTROL "Locked Surface",IDC_LOCKEDSURFACE,"Button",BS_AUTORADIOBUTTON,14,144,67,12
CONTROL "Primary Surface",IDC_EMULATESURFACE,"Button",BS_AUTORADIOBUTTON,14,156,77,12
GROUPBOX "DirectX Version Hook",IDC_STATIC,6,3,98,103,WS_GROUP
GROUPBOX "Emulation",IDC_STATIC,6,120,98,49,WS_GROUP
GROUPBOX "Emulation",IDC_STATIC,7,109,98,61,WS_GROUP
CONTROL "Handle DC",IDC_HANDLEDC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,26,78,12
CONTROL "Auto Primary Surface Refresh",IDC_AUTOREFRESH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,38,126,9
GROUPBOX "DirectDraw Surface handling",IDC_STATIC,112,3,181,167

Binary file not shown.

View File

@ -114,22 +114,13 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
if(dlg->m_HookEnabled) t->flags3 |= HOOKENABLED;
if(dlg->m_NoBanner) t->flags2 |= NOBANNER;
if(dlg->m_StartDebug) t->flags2 |= STARTDEBUG;
if(dlg->m_NoEmulateSurface) {
dlg->m_EmulateSurface = FALSE;
dlg->m_EmulateBuffer = FALSE;
t->flags &= ~EMULATEFLAGS;
}
if(dlg->m_EmulateSurface) {
dlg->m_NoEmulateSurface = FALSE;
dlg->m_EmulateBuffer = FALSE;
t->flags &= ~EMULATEFLAGS;
t->flags |= EMULATESURFACE;
}
if(dlg->m_EmulateBuffer) {
dlg->m_NoEmulateSurface = FALSE;
dlg->m_EmulateSurface = FALSE;
t->flags &= ~EMULATEFLAGS;
t->flags |= EMULATEBUFFER;
t->flags &= ~EMULATEFLAGS;
switch(dlg->m_DxEmulationMode){
case 0: break;
case 1: t->flags |= EMULATEBUFFER; break;
case 2: t->flags |= LOCKEDSURFACE; break;
case 3: t->flags |= EMULATESURFACE; break;
}
if(dlg->m_HookDI) t->flags |= HOOKDI;
if(dlg->m_ModifyMouse) t->flags |= MODIFYMOUSE;
@ -234,9 +225,12 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
dlg->m_HookEnabled = t->flags3 & HOOKENABLED ? 1 : 0;
dlg->m_NoBanner = t->flags2 & NOBANNER ? 1 : 0;
dlg->m_StartDebug = t->flags2 & STARTDEBUG ? 1 : 0;
dlg->m_EmulateSurface = t->flags & EMULATESURFACE ? 1 : 0;
dlg->m_NoEmulateSurface = t->flags & EMULATEFLAGS ? 0 : 1;
dlg->m_EmulateBuffer = t->flags & EMULATEBUFFER ? 1 : 0;
dlg->m_DxEmulationMode = 0;
if(t->flags & EMULATEBUFFER) dlg->m_DxEmulationMode = 1;
if(t->flags & LOCKEDSURFACE) dlg->m_DxEmulationMode = 2;
if(t->flags & EMULATESURFACE) dlg->m_DxEmulationMode = 3;
dlg->m_HookDI = t->flags & HOOKDI ? 1 : 0;
dlg->m_ModifyMouse = t->flags & MODIFYMOUSE ? 1 : 0;
dlg->m_OutTrace = t->tflags & OUTDDRAWTRACE ? 1 : 0;
@ -442,6 +436,7 @@ static void ClearTarget(int i, char *InitPath)
static int LoadConfigItem(TARGETMAP *TargetMap, char *Title, int i, char *InitPath)
{
char key[32];
DWORD flags;
sprintf_s(key, sizeof(key), "path%i", i);
GetPrivateProfileString("target", key, "", TargetMap->path, MAX_PATH, InitPath);
if(!TargetMap->path[0]) return FALSE;
@ -455,8 +450,18 @@ static int LoadConfigItem(TARGETMAP *TargetMap, char *Title, int i, char *InitPa
TargetMap->dxversion = GetPrivateProfileInt("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "coord%i", i);
TargetMap->coordinates = GetPrivateProfileInt("target", key, 0, InitPath);
// be sure just one of the emulation flags is set
sprintf_s(key, sizeof(key), "flag%i", i);
TargetMap->flags = GetPrivateProfileInt("target", key, 0, InitPath);
flags = TargetMap->flags;
TargetMap->flags &= ~EMULATEFLAGS;
do{
if(flags & EMULATESURFACE) {TargetMap->flags |= EMULATESURFACE; break;}
if(flags & EMULATEBUFFER) {TargetMap->flags |= EMULATEBUFFER; break;}
if(flags & LOCKEDSURFACE) {TargetMap->flags |= LOCKEDSURFACE; break;}
} while (0);
sprintf_s(key, sizeof(key), "flagg%i", i);
TargetMap->flags2 = GetPrivateProfileInt("target", key, 0, InitPath);
sprintf_s(key, sizeof(key), "flagh%i", i);
@ -1021,6 +1026,7 @@ void CDxwndhostView::OnAdd()
dlg.m_Coordinates = 0;
dlg.m_MaxX = 0; //639;
dlg.m_MaxY = 0; //479;
dlg.m_DxEmulationMode = 0;
for(i = 0; i < MAXTARGETS; i ++) if(!TargetMaps[i].path[0]) break;
if(i>=MAXTARGETS){
MessageBoxEx(0, "Maximum entries number reached.\nDelete some entry to add a new one.", "Warning", MB_OK | MB_ICONEXCLAMATION, NULL);