mirror of
https://github.com/DxWnd/DxWnd.reloaded
synced 2024-12-30 09:25:35 +01:00
v2_03_22_src
Former-commit-id: 96d72e2886d6e4e1bb8957d27c127aab6064cde4
This commit is contained in:
parent
d3dab9deb9
commit
f386bd1d35
@ -310,11 +310,6 @@ LRESULT CALLBACK extDialogWindowProc(HWND, UINT, WPARAM, LPARAM);
|
||||
#define IsAssertEnabled (dxw.dwTFlags & ASSERTDIALOG)
|
||||
#define STEP OutTrace("STEP at %s:%d\n", __FILE__, __LINE__)
|
||||
|
||||
extern BOOL WinDBGetSize(HWND, int *, int *);
|
||||
extern WNDPROC WinDBGetProc(HWND);
|
||||
extern void WinDBPutProc(HWND, WNDPROC);
|
||||
extern void WinDBPutSize(HWND, int, int);
|
||||
|
||||
typedef enum {
|
||||
DXW_SET_COORDINATES = 0,
|
||||
DXW_DESKTOP_CENTER,
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:95762cfc50b158119d3bcb3d7a613dd13ae5abc3555c4c8153d9560bdafad4e6
|
||||
size 577536
|
||||
oid sha256:685801c38436f785e2d29010e560c7eb98e07adb83ae0bf0593f089a2d2ed043
|
||||
size 572928
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c1bb172dc721bb8db528e064c3bc6acb78a0107c298e11368d28b36bb636dae6
|
||||
oid sha256:ea58d479ffbb81c24c0282a35b7e8203848d66799bf047ad7d662e4fc53d0470
|
||||
size 539648
|
||||
|
31
build/exports/Gorky 17.dxw
Normal file
31
build/exports/Gorky 17.dxw
Normal file
@ -0,0 +1,31 @@
|
||||
[target]
|
||||
title0=Gorky 17
|
||||
path0=D:\Games\Gorky 17\gorky17.exe
|
||||
launchpath0=
|
||||
module0=
|
||||
opengllib0=
|
||||
notes0=
|
||||
ver0=0
|
||||
coord0=0
|
||||
flag0=134217762
|
||||
flagg0=1207959552
|
||||
flagh0=20
|
||||
flagi0=134217732
|
||||
flagj0=4224
|
||||
flagk0=0
|
||||
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
|
31
build/exports/Outwars.dxw
Normal file
31
build/exports/Outwars.dxw
Normal file
@ -0,0 +1,31 @@
|
||||
[target]
|
||||
title0=Outwars
|
||||
path0=D:\Games\OUTWARS\outwars.exe
|
||||
launchpath0=
|
||||
module0=
|
||||
opengllib0=
|
||||
notes0=
|
||||
ver0=0
|
||||
coord0=0
|
||||
flag0=671088678
|
||||
flagg0=1207959552
|
||||
flagh0=20
|
||||
flagi0=138412036
|
||||
flagj0=4224
|
||||
flagk0=0
|
||||
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
|
5
build/exports/dxwnd.ini
Normal file
5
build/exports/dxwnd.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[window]
|
||||
posx=1477
|
||||
posy=150
|
||||
sizx=320
|
||||
sizy=749
|
@ -805,4 +805,11 @@ fix: fully revised ddraw surface handling in d3d1-7 versions. Now "Might & Magic
|
||||
|
||||
v2.03.21:
|
||||
fix: full re-design of ddraw "special" surface management (primary & backbuffer): greater compatibility for emulation mode
|
||||
fix: GDI edit window positioning for "Imperialism" city name selection
|
||||
fix: GDI edit window positioning for "Imperialism" city name selection
|
||||
|
||||
v2.03.22:
|
||||
more code reorganization and cleanup
|
||||
eliminated GDI over directdraw emulation (MAPGDITOPRIMARY flag)
|
||||
add: support for texture D3DFMT_L8 dump ("Turok")
|
||||
fix: eliminate a possible divide by zero error
|
||||
fix: avoid intercepting WindowProc routines when set to special values 0xFFFFxxxx - makes "The Hulk" demo working
|
||||
|
@ -204,6 +204,7 @@ void D3DTextureDump(D3DSURFACE_DESC Desc, D3DLOCKED_RECT LockedRect)
|
||||
case D3DFMT_X1R5G5B5:
|
||||
case D3DFMT_A1R5G5B5:
|
||||
case D3DFMT_A8:
|
||||
case D3DFMT_L8:
|
||||
hash = HashSurface((BYTE *)LockedRect.pBits, LockedRect.Pitch, Desc.Width, Desc.Height);
|
||||
break;
|
||||
case D3DFMT_DXT1:
|
||||
@ -274,6 +275,7 @@ void D3DTextureDump(D3DSURFACE_DESC Desc, D3DLOCKED_RECT LockedRect)
|
||||
case D3DFMT_DXT4:
|
||||
case D3DFMT_DXT5:
|
||||
case D3DFMT_A8:
|
||||
case D3DFMT_L8:
|
||||
pbi.bV4BitCount = 32;
|
||||
pbi.bV4RedMask = 0x00FF0000;
|
||||
pbi.bV4GreenMask = 0x0000FF00;
|
||||
@ -343,6 +345,7 @@ void D3DTextureDump(D3DSURFACE_DESC Desc, D3DLOCKED_RECT LockedRect)
|
||||
}
|
||||
break;
|
||||
case D3DFMT_A8:
|
||||
case D3DFMT_L8:
|
||||
{
|
||||
// Copy the array of color indices into the .BMP file.
|
||||
BYTE *p = (BYTE *)LockedRect.pBits;
|
||||
|
@ -34,7 +34,7 @@ static HRESULT sBltNoPrimary(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdest
|
||||
//extern PrimaryBlt_Type pPrimaryBlt;
|
||||
//CkArg arg;
|
||||
|
||||
FromScreen=dxw.IsAPrimarySurface(lpddssrc) && !(dxw.dwFlags1 & EMULATESURFACE) && !(dxw.dwFlags1 & EMULATEBUFFER); // v2.02.77
|
||||
FromScreen=dxwss.IsAPrimarySurface(lpddssrc) && !(dxw.dwFlags1 & EMULATESURFACE) && !(dxw.dwFlags1 & EMULATEBUFFER); // v2.02.77
|
||||
|
||||
// make a working copy of srcrect if not NULL
|
||||
if (lpsrcrect){
|
||||
@ -48,7 +48,7 @@ static HRESULT sBltNoPrimary(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdest
|
||||
// In "The Sims" there is no quality loss, but some scrolling artifact.
|
||||
if(lpsrcrect && FromScreen){
|
||||
LPDIRECTDRAWSURFACE lpDDSBack;
|
||||
lpDDSBack = dxw.GetBackBufferSurface();
|
||||
lpDDSBack = dxwss.GetBackBufferSurface();
|
||||
if(lpDDSBack && (dxw.dwFlags1 & BLITFROMBACKBUFFER)){
|
||||
lpddssrc=lpDDSBack;
|
||||
srcrect=dxw.GetScreenRect();
|
||||
@ -154,7 +154,7 @@ static HRESULT sBltToPrimary(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdest
|
||||
if (isFlipping){
|
||||
// handle the flipping chain ...
|
||||
//lpddssrc=lpDDSBack;
|
||||
lpddssrc = dxw.GetBackBufferSurface();
|
||||
lpddssrc = dxwss.GetBackBufferSurface();
|
||||
OutTraceDW("Flip: setting flip chain to lpdds=%x\n", lpddssrc);
|
||||
}
|
||||
}
|
||||
@ -324,8 +324,8 @@ HRESULT WINAPI sBlt(char *api, LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
|
||||
}
|
||||
}
|
||||
|
||||
ToPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
FromPrim=dxw.IsAPrimarySurface(lpddssrc);
|
||||
ToPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
FromPrim=dxwss.IsAPrimarySurface(lpddssrc);
|
||||
ToScreen=ToPrim && !(dxw.dwFlags1 & EMULATESURFACE);
|
||||
FromScreen=FromPrim && !(dxw.dwFlags1 & EMULATESURFACE) && !(dxw.dwFlags1 & EMULATEBUFFER); // v2.02.77
|
||||
|
||||
|
123
dll/ddraw.cpp
123
dll/ddraw.cpp
@ -260,9 +260,6 @@ LPDIRECTDRAWPALETTE lpDDP=NULL;
|
||||
|
||||
// v2.02.37: globals to store requested main surface capabilities
|
||||
DDSURFACEDESC2 DDSD_Prim;
|
||||
DDSURFACEDESC2 DDSD_Back;
|
||||
DDSURFACEDESC2 DDSD_ZBuffer;
|
||||
|
||||
DWORD DDZBufferCaps;
|
||||
DWORD PaletteEntries[256];
|
||||
DWORD *Palette16BPP = NULL;
|
||||
@ -1786,10 +1783,10 @@ HRESULT WINAPI extQueryInterfaceS(void *lpdds, REFIID riid, LPVOID *obp)
|
||||
unsigned int dwLocalDDVersion;
|
||||
unsigned int dwLocalTexVersion;
|
||||
|
||||
IsPrim=dxw.IsAPrimarySurface((LPDIRECTDRAWSURFACE)lpdds);
|
||||
IsBack=dxw.IsABackBufferSurface((LPDIRECTDRAWSURFACE)lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface((LPDIRECTDRAWSURFACE)lpdds);
|
||||
IsBack=dxwss.IsABackBufferSurface((LPDIRECTDRAWSURFACE)lpdds);
|
||||
OutTraceDDRAW("QueryInterface(S): lpdds=%x%s REFIID=%x(%s)\n",
|
||||
lpdds, dxw.ExplainSurfaceRole((LPDIRECTDRAWSURFACE)lpdds), riid.Data1, ExplainGUID((GUID *)&riid));
|
||||
lpdds, dxwss.ExplainSurfaceRole((LPDIRECTDRAWSURFACE)lpdds), riid.Data1, ExplainGUID((GUID *)&riid));
|
||||
|
||||
IsGammaRamp=FALSE;
|
||||
|
||||
@ -1849,7 +1846,7 @@ HRESULT WINAPI extQueryInterfaceS(void *lpdds, REFIID riid, LPVOID *obp)
|
||||
}
|
||||
|
||||
// fix the target for gamma ramp creation: if it is a primary surface, use the real one!!
|
||||
if(dxw.IsAPrimarySurface((LPDIRECTDRAWSURFACE)lpdds) && IsGammaRamp) lpdds = lpDDSEmu_Prim;
|
||||
if(dxwss.IsAPrimarySurface((LPDIRECTDRAWSURFACE)lpdds) && IsGammaRamp) lpdds = lpDDSEmu_Prim;
|
||||
|
||||
res = (*pQueryInterfaceS)(lpdds, riid, obp);
|
||||
|
||||
@ -1879,12 +1876,12 @@ HRESULT WINAPI extQueryInterfaceS(void *lpdds, REFIID riid, LPVOID *obp)
|
||||
dxw.dwDDVersion=dwLocalDDVersion;
|
||||
if(IsPrim){
|
||||
OutTraceDW("QueryInterface(S): primary=%x new=%x\n", lpdds, *obp);
|
||||
dxw.MarkPrimarySurface((LPDIRECTDRAWSURFACE)*obp, dwLocalDDVersion);
|
||||
dxwss.PushPrimarySurface((LPDIRECTDRAWSURFACE)*obp, dwLocalDDVersion);
|
||||
HookDDSurfacePrim((LPDIRECTDRAWSURFACE *)obp, dxw.dwDDVersion);
|
||||
}
|
||||
else{
|
||||
if(IsBack) dxw.MarkBackBufferSurface((LPDIRECTDRAWSURFACE)*obp, dwLocalDDVersion);
|
||||
else dxw.MarkRegularSurface((LPDIRECTDRAWSURFACE)*obp);
|
||||
if(IsBack) dxwss.PushBackBufferSurface((LPDIRECTDRAWSURFACE)*obp, dwLocalDDVersion);
|
||||
else dxwss.PopSurface((LPDIRECTDRAWSURFACE)*obp);
|
||||
// v2.02.13: seems that hooking inconditionally gives troubles. What is the proper safe hook condition?
|
||||
HookDDSurfaceGeneric((LPDIRECTDRAWSURFACE *)obp, dxw.dwDDVersion);
|
||||
}
|
||||
@ -2260,7 +2257,7 @@ static HRESULT BuildPrimaryEmu(LPDIRECTDRAW lpdd, CreateSurface_Type pCreateSurf
|
||||
OutTraceDW("CreateSurface: created new DDSEmu_Prim=%x\n",lpDDSEmu_Prim);
|
||||
if(IsDebug) DescribeSurface(lpDDSEmu_Prim, dxversion, "DDSEmu_Prim", __LINE__);
|
||||
InitDSScreenParameters(lpDDSEmu_Prim);
|
||||
dxw.MarkRegularSurface(lpDDSEmu_Prim);
|
||||
dxwss.PopSurface(lpDDSEmu_Prim);
|
||||
// can't hook lpDDSEmu_Prim as generic, since the Flip method is unimplemented for a PRIMARY surface!
|
||||
// better avoid it or hook just useful methods.
|
||||
//if (dxw.dwTFlags & OUTPROXYTRACE) HookDDSurfaceGeneric(&lpDDSEmu_Prim, dxw.dwDDVersion);
|
||||
@ -2288,12 +2285,12 @@ static HRESULT BuildPrimaryEmu(LPDIRECTDRAW lpdd, CreateSurface_Type pCreateSurf
|
||||
}
|
||||
OutTraceDW("CreateSurface: created new DDSEmu_Back=%x\n", lpDDSEmu_Back);
|
||||
if(IsDebug) DescribeSurface(lpDDSEmu_Back, dxversion, "DDSEmu_Back", __LINE__);
|
||||
dxw.MarkRegularSurface(lpDDSEmu_Back);
|
||||
dxwss.PopSurface(lpDDSEmu_Back);
|
||||
if (dxw.dwTFlags & OUTPROXYTRACE) HookDDSurfaceGeneric(&lpDDSEmu_Back, dxversion);
|
||||
}
|
||||
|
||||
bFlippedDC = TRUE;
|
||||
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
@ -2334,7 +2331,7 @@ static HRESULT BuildPrimaryDir(LPDIRECTDRAW lpdd, CreateSurface_Type pCreateSurf
|
||||
|
||||
if(dxw.dwFlags1 & EMULATEBUFFER){
|
||||
lpDDSEmu_Prim = *lplpdds;
|
||||
dxw.MarkRegularSurface(lpDDSEmu_Prim);
|
||||
dxwss.PopSurface(lpDDSEmu_Prim);
|
||||
|
||||
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
|
||||
// warning: can't create zero sized backbuffer surface !!!!
|
||||
@ -2598,10 +2595,10 @@ static HRESULT WINAPI extCreateSurface(int dxversion, CreateSurface_Type pCreate
|
||||
if (lpDDSEmu_Back) while(lpDDSEmu_Back->Release());
|
||||
if (lpDDSEmu_Prim) while(lpDDSEmu_Prim->Release());
|
||||
if (ddsd.dwFlags & DDSD_BACKBUFFERCOUNT) { // Praetorians !!!!
|
||||
lpDDSBack = dxw.GetBackBufferSurface();
|
||||
lpDDSBack = dxwss.GetBackBufferSurface();
|
||||
if (lpDDSBack) {
|
||||
while(lpDDSBack->Release());
|
||||
dxw.MarkRegularSurface(lpDDSBack);
|
||||
dxwss.PopSurface(lpDDSBack);
|
||||
lpDDSBack = NULL;
|
||||
}
|
||||
}
|
||||
@ -2630,14 +2627,14 @@ static HRESULT WINAPI extCreateSurface(int dxversion, CreateSurface_Type pCreate
|
||||
res=BuildPrimary(lpdd, pCreateSurface, lpddsd, dxversion, lplpdds, NULL);
|
||||
if(res) return res;
|
||||
lpDDSPrim = *lplpdds;
|
||||
dxw.MarkPrimarySurface(lpDDSPrim, dxversion);
|
||||
dxwss.PushPrimarySurface(lpDDSPrim, dxversion);
|
||||
RegisterPixelFormat(lpDDSPrim);
|
||||
|
||||
if (BBCount){
|
||||
// build emulated backbuffer surface
|
||||
res=BuildBackBuffer(lpdd, pCreateSurface, lpddsd, dxversion, &lpDDSBack, NULL);
|
||||
if(res) return res;
|
||||
dxw.MarkBackBufferSurface(lpDDSBack, dxversion);
|
||||
dxwss.PushBackBufferSurface(lpDDSBack, dxversion);
|
||||
|
||||
// V2.1.85/V2.2.34: tricky !!!!
|
||||
// When a real backbuffer is created, it has a reference to its frontbuffer.
|
||||
@ -2678,7 +2675,7 @@ static HRESULT WINAPI extCreateSurface(int dxversion, CreateSurface_Type pCreate
|
||||
}
|
||||
|
||||
res=BuildBackBuffer(lpdd, pCreateSurface, lpddsd, dxversion, lplpdds, NULL);
|
||||
if(res == DD_OK) dxw.MarkBackBufferSurface(*lplpdds, dxversion);
|
||||
if(res == DD_OK) dxwss.PushBackBufferSurface(*lplpdds, dxversion);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -2686,7 +2683,7 @@ static HRESULT WINAPI extCreateSurface(int dxversion, CreateSurface_Type pCreate
|
||||
|
||||
res=BuildGeneric(lpdd, pCreateSurface, lpddsd, dxversion, lplpdds, pu);
|
||||
if(!res) {
|
||||
dxw.MarkRegularSurface(*lplpdds);
|
||||
dxwss.PopSurface(*lplpdds);
|
||||
if(lpddsd->ddsCaps.dwCaps & DDSCAPS_ZBUFFER) {
|
||||
lpDDZBuffer=*lplpdds;
|
||||
DDZBufferCaps = lpddsd->ddsCaps.dwCaps;
|
||||
@ -2727,8 +2724,8 @@ HRESULT WINAPI extGetAttachedSurface(int dxversion, GetAttachedSurface_Type pGet
|
||||
BOOL IsPrim;
|
||||
BOOL IsBack;
|
||||
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsBack=dxw.IsABackBufferSurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
IsBack=dxwss.IsABackBufferSurface(lpdds);
|
||||
OutTraceDDRAW("GetAttachedSurface(%d): lpdds=%x%s caps=%x(%s)\n",
|
||||
dxversion, lpdds, (IsPrim?"(PRIM)":(IsBack ? "(BACK)":"")), lpddsc->dwCaps, ExplainDDSCaps(lpddsc->dwCaps));
|
||||
|
||||
@ -2754,7 +2751,7 @@ HRESULT WINAPI extGetAttachedSurface(int dxversion, GetAttachedSurface_Type pGet
|
||||
if(IsPrim && (lpddsc->dwCaps & (DDSCAPS_BACKBUFFER|DDSCAPS_FLIP))) { // v2.02.42 added DDSCAPS_FLIP for Empire Earth
|
||||
// in "Tomb Raider III" GOG release, the primary surface is queryed and has no attached
|
||||
// backbuffer, but a backbuffer does exist and has to be retrieved by GetBackBufferSurface.
|
||||
LPDIRECTDRAWSURFACE lpddsback = dxw.GetBackBufferSurface();
|
||||
LPDIRECTDRAWSURFACE lpddsback = dxwss.GetBackBufferSurface();
|
||||
if (lpddsback) {
|
||||
*lplpddas = lpddsback;
|
||||
OutTraceDW("GetAttachedSurface(%d): BACKBUFFER attached=%x\n", dxversion, *lplpddas);
|
||||
@ -3137,7 +3134,7 @@ HRESULT WINAPI extFlip(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWSURFACE lpddssrc,
|
||||
LPDIRECTDRAWSURFACE lpddsTmp;
|
||||
LPDIRECTDRAWSURFACE lpDDSBack;
|
||||
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
OutTraceDDRAW("Flip: lpdds=%x%s, src=%x, flags=%x(%s)\n",
|
||||
lpdds, IsPrim?"(PRIM)":"", lpddssrc, dwflags, ExplainFlipFlags(dwflags));
|
||||
|
||||
@ -3178,7 +3175,7 @@ HRESULT WINAPI extFlip(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWSURFACE lpddssrc,
|
||||
|
||||
if((dwflags & DDFLIP_WAIT) || (dxw.dwFlags1 & SAVELOAD)) lpPrimaryDD->WaitForVerticalBlank(DDWAITVB_BLOCKEND , 0);
|
||||
|
||||
lpDDSBack = dxw.GetBackBufferSurface();
|
||||
lpDDSBack = dxwss.GetBackBufferSurface();
|
||||
|
||||
if(dxw.dwFlags4 & NOFLIPEMULATION){
|
||||
HRESULT res2;
|
||||
@ -3260,7 +3257,7 @@ HRESULT WINAPI extFlip(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWSURFACE lpddssrc,
|
||||
HRESULT WINAPI extBlt(LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect,
|
||||
LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect, DWORD dwflags, LPDDBLTFX lpddbltfx)
|
||||
{
|
||||
if ((dxw.dwFlags2 & FULLRECTBLT) && dxw.IsAPrimarySurface(lpdds)){
|
||||
if ((dxw.dwFlags2 & FULLRECTBLT) && dxwss.IsAPrimarySurface(lpdds)){
|
||||
lpsrcrect=NULL;
|
||||
lpdestrect=NULL;
|
||||
}
|
||||
@ -3281,8 +3278,8 @@ HRESULT WINAPI extBltFast(LPDIRECTDRAWSURFACE lpdds, DWORD dwx, DWORD dwy,
|
||||
HRESULT ret;
|
||||
BOOL ToPrim, FromPrim;
|
||||
|
||||
ToPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
FromPrim=dxw.IsAPrimarySurface(lpddssrc);
|
||||
ToPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
FromPrim=dxwss.IsAPrimarySurface(lpddssrc);
|
||||
|
||||
CleanRect(&lpsrcrect,__LINE__);
|
||||
|
||||
@ -3381,8 +3378,8 @@ HRESULT WINAPI extGetPalette(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWPALETTE *lpl
|
||||
HRESULT res;
|
||||
BOOL isPrim, isBack;
|
||||
|
||||
isPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
isBack=dxw.IsABackBufferSurface(lpdds);
|
||||
isPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
isBack=dxwss.IsABackBufferSurface(lpdds);
|
||||
OutTraceDDRAW("GetPalette: lpdds=%x%s%s\n", lpdds, isPrim?"(PRIM)":"", isBack?"(BACK)":"");
|
||||
|
||||
res=(*pGetPalette)(lpdds, lplpddp);
|
||||
@ -3407,7 +3404,7 @@ HRESULT WINAPI extSetPalette(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWPALETTE lpdd
|
||||
BOOL isPrim;
|
||||
HRESULT res;
|
||||
|
||||
isPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
isPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
OutTraceDDRAW("SetPalette: lpdds=%x%s lpddp=%x\n", lpdds, isPrim?"(PRIM)":"", lpddp);
|
||||
|
||||
res=(*pSetPalette)(lpdds, lpddp);
|
||||
@ -3427,7 +3424,7 @@ HRESULT WINAPI extSetPalette(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWPALETTE lpdd
|
||||
mySetPalette(0, 256, lpentries); // v2.02.76: necessary for "Requiem Avenging Angel" in SURFACEEMULATION mode
|
||||
}
|
||||
// Apply palette to backbuffer surface. This is necessary on some games: "Duckman private dick", "Total Soccer 2000", ...
|
||||
lpDDSBack = dxw.GetBackBufferSurface();
|
||||
lpDDSBack = dxwss.GetBackBufferSurface();
|
||||
if (lpDDSBack){
|
||||
OutTraceDW("SetPalette: apply PRIMARY palette lpDDP=%x to DDSBack=%x\n", lpddp, lpDDSBack);
|
||||
res=(*pSetPalette)(lpDDSBack, lpddp);
|
||||
@ -3477,7 +3474,7 @@ HRESULT WINAPI extSetClipper(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWCLIPPER lpdd
|
||||
{
|
||||
HRESULT res;
|
||||
BOOL isPrim;
|
||||
isPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
isPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
OutTraceDDRAW("SetClipper: lpdds=%x%s lpddc=%x\n", lpdds, isPrim?"(PRIM)":"", lpddc);
|
||||
|
||||
// v2.1.84: SUPPRESSCLIPPING flag - improves "Monopoly Edition 3D" where continuous
|
||||
@ -3487,7 +3484,7 @@ HRESULT WINAPI extSetClipper(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWCLIPPER lpdd
|
||||
|
||||
if(dxw.dwFlags1 & (EMULATESURFACE|EMULATEBUFFER)){
|
||||
if ((isPrim && lpDDSEmu_Prim) ||
|
||||
(dxw.IsABackBufferSurface(lpdds) && lpDDSEmu_Back)){
|
||||
(dxwss.IsABackBufferSurface(lpdds) && lpDDSEmu_Back)){
|
||||
OutTraceDW("SetClipper: skip primary/backbuffer lpdds=%x\n", lpdds);
|
||||
res=0;
|
||||
}
|
||||
@ -3509,7 +3506,7 @@ HRESULT WINAPI extLock(LPDIRECTDRAWSURFACE lpdds, LPRECT lprect, LPDDSURFACEDESC
|
||||
CleanRect(&lprect, __LINE__);
|
||||
|
||||
if(IsTraceDDRAW){
|
||||
BOOL IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
BOOL IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
char sRect[81];
|
||||
if (lprect) sprintf_s(sRect, 80, "(%d,%d)-(%d,%d)", lprect->left, lprect->top, lprect->right, lprect->bottom);
|
||||
else strcpy(sRect, "(NULL)");
|
||||
@ -3550,7 +3547,7 @@ HRESULT WINAPI extLockDir(LPDIRECTDRAWSURFACE lpdds, LPRECT lprect, LPDDSURFACED
|
||||
// to find out whether it is the primary or not, using lpdds==lpPrimaryDD->GetGDISurface(&lpDDSPrim);
|
||||
|
||||
if(IsTraceDDRAW){
|
||||
BOOL IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
BOOL IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
char sRect[81];
|
||||
if (lprect) sprintf_s(sRect, 80, "(%d,%d)-(%d,%d)", lprect->left, lprect->top, lprect->right, lprect->bottom);
|
||||
else strcpy(sRect, "(NULL)");
|
||||
@ -3622,8 +3619,8 @@ HRESULT WINAPI extUnlock(int dxversion, Unlock4_Type pUnlock, LPDIRECTDRAWSURFAC
|
||||
BOOL IsBack;
|
||||
RECT rect;
|
||||
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsBack=dxw.IsABackBufferSurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
IsBack=dxwss.IsABackBufferSurface(lpdds);
|
||||
|
||||
if(IsTraceDDRAW){
|
||||
char sRect[81];
|
||||
@ -3682,7 +3679,7 @@ HRESULT WINAPI extUnlockDir(int dxversion, Unlock4_Type pUnlock, LPDIRECTDRAWSUR
|
||||
BOOL IsPrim;
|
||||
LPDIRECTDRAWSURFACE lpDDSPrim;
|
||||
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
|
||||
if ((dxversion >= 4) && lprect) CleanRect(&lprect,__LINE__);
|
||||
|
||||
@ -3742,7 +3739,7 @@ HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE lpdds, HDC FAR *pHDC)
|
||||
HRESULT res;
|
||||
BOOL IsPrim;
|
||||
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
OutTraceDDRAW("GetDC: lpdss=%x%s\n",lpdds, IsPrim?"(PRIM)":"");
|
||||
res=(*pGetDC)(lpdds, pHDC);
|
||||
|
||||
@ -3778,7 +3775,7 @@ HRESULT WINAPI extReleaseDC(LPDIRECTDRAWSURFACE lpdds, HDC FAR hdc)
|
||||
HRESULT res;
|
||||
BOOL IsPrim;
|
||||
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
OutTraceDDRAW("ReleaseDC: lpdss=%x%s hdc=%x\n",lpdds, IsPrim?"(PRIM)":"", hdc);
|
||||
res=(*pReleaseDC)(lpdds, hdc);
|
||||
if((IsPrim) && (dxw.dwFlags1 & EMULATESURFACE)) sBlt("ReleaseDC", lpdds, NULL, lpdds, NULL, 0, NULL, FALSE);
|
||||
@ -3811,7 +3808,7 @@ HRESULT WINAPI extGetGDISurface(LPDIRECTDRAW lpdd, LPDIRECTDRAWSURFACE *w)
|
||||
// v2.02.31:
|
||||
// in EMULATED mode, should not return the actual ddraw primary surface, but the virtual one.
|
||||
if(dxw.dwFlags1 & EMULATESURFACE){
|
||||
*w=dxw.GetPrimarySurface();
|
||||
*w=dxwss.GetPrimarySurface();
|
||||
OutTraceDW("GetGDISurface: EMULATED lpdd=%x w=%x\n", lpdd, *w);
|
||||
return DD_OK;
|
||||
}
|
||||
@ -4067,7 +4064,7 @@ HRESULT WINAPI extGetPixelFormat(LPDIRECTDRAWSURFACE lpdds, LPDDPIXELFORMAT p)
|
||||
DWORD res;
|
||||
BOOL IsPrim;
|
||||
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
OutTraceDDRAW("GetPixelFormat: lpdds=%x%s\n", lpdds, IsPrim?"(PRIM)":"");
|
||||
res=(*pGetPixelFormat)(lpdds, p);
|
||||
if(res){
|
||||
@ -4112,17 +4109,17 @@ HRESULT WINAPI extReleaseS(LPDIRECTDRAWSURFACE lpdds)
|
||||
BOOL IsPrim;
|
||||
BOOL IsBack;
|
||||
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsBack=dxw.IsABackBufferSurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
IsBack=dxwss.IsABackBufferSurface(lpdds);
|
||||
|
||||
res = (*pReleaseS)(lpdds);
|
||||
|
||||
OutTraceDDRAW("Release(S): lpdds=%x%s refcount=%d\n", lpdds, dxw.ExplainSurfaceRole(lpdds), res);
|
||||
OutTraceDDRAW("Release(S): lpdds=%x%s refcount=%d\n", lpdds, dxwss.ExplainSurfaceRole(lpdds), res);
|
||||
if (res==0) { // common precondition
|
||||
// erase surface from primary or backbuffer list
|
||||
// v2-03-20: d3d 1-7 play a dirty trick: it Release the surface passed as argument until refcount == 0,
|
||||
// but then rebuilds it with the original attributes! So, better not forget them.
|
||||
if(IsPrim || IsBack) dxw.UnrefSurface(lpdds);
|
||||
if(IsPrim || IsBack) dxwss.UnrefSurface(lpdds);
|
||||
|
||||
// when releasing primary surface, erase clipping region
|
||||
if(IsPrim && (dxw.dwFlags1 & CLIPCURSOR)) dxw.EraseClipCursor();
|
||||
@ -4137,10 +4134,6 @@ HRESULT WINAPI extReleaseS(LPDIRECTDRAWSURFACE lpdds)
|
||||
OutTraceDW("Release(S): Clearing lpDDSEmu_Back pointer\n");
|
||||
lpDDSEmu_Back=NULL;
|
||||
}
|
||||
if(lpdds==dxw.lpDDSPrimary) {
|
||||
OutTraceDW("Release(S): Clearing lpDDSPrimary pointer\n");
|
||||
dxw.ResetPrimarySurface();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4152,7 +4145,7 @@ HRESULT WINAPI extSetColorKey(LPDIRECTDRAWSURFACE lpdds, DWORD flags, LPDDCOLORK
|
||||
{
|
||||
HRESULT res;
|
||||
BOOL IsPrim;
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
if(IsTraceDDRAW){
|
||||
char sInfo[81];
|
||||
if (lpDDColorKey) sprintf(sInfo, "(L:%x,H:%x)",lpDDColorKey->dwColorSpaceLowValue, lpDDColorKey->dwColorSpaceHighValue);
|
||||
@ -4171,7 +4164,7 @@ HRESULT WINAPI extGetColorKey(LPDIRECTDRAWSURFACE lpdds, DWORD flags, LPDDCOLORK
|
||||
{
|
||||
HRESULT res;
|
||||
BOOL IsPrim;
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
OutTraceDDRAW("GetColorKey(S): lpdds=%x%s flags=%x(%s)\n",
|
||||
lpdds, (IsPrim ? "(PRIM)" : ""), flags, ExplainColorKeyFlag(flags));
|
||||
res=(*pGetColorKey)(lpdds, flags, lpDDColorKey);
|
||||
@ -4188,7 +4181,7 @@ HRESULT WINAPI extEnumAttachedSurfaces(LPDIRECTDRAWSURFACE lpdds, LPVOID lpConte
|
||||
HRESULT res;
|
||||
BOOL IsPrim;
|
||||
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
|
||||
OutTraceDDRAW("EnumAttachedSurfaces: lpdds=%x%s Context=%x Callback=%x\n",
|
||||
lpdds, (IsPrim ? "(PRIM)":""), lpContext, lpEnumSurfacesCallback);
|
||||
@ -4203,7 +4196,7 @@ HRESULT WINAPI extEnumAttachedSurfaces(LPDIRECTDRAWSURFACE lpdds, LPVOID lpConte
|
||||
res=(*pEnumAttachedSurfaces)(lpdds, lpContext, lpEnumSurfacesCallback);
|
||||
if (res)
|
||||
OutTraceE("EnumAttachedSurfaces: ERROR %x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
if(lpDDSBack = dxw.GetBackBufferSurface()){
|
||||
if(lpDDSBack = dxwss.GetBackBufferSurface()){
|
||||
ddsd.dwSize=Set_dwSize_From_Surface(lpDDSBack);
|
||||
res=lpDDSBack->GetSurfaceDesc((LPDDSURFACEDESC)&ddsd);
|
||||
if(res){
|
||||
@ -4235,8 +4228,8 @@ HRESULT WINAPI extAddAttachedSurface(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWSURF
|
||||
// just remember this for further handling in the Flip operation.
|
||||
// But beware: this holds to BACKBUFFER surfaces only, and NOT for attached ZBUFFERS or similar!
|
||||
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsBack=dxw.IsABackBufferSurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
IsBack=dxwss.IsABackBufferSurface(lpdds);
|
||||
OutTraceDDRAW("AddAttachedSurface: lpdds=%x%s lpddsadd=%x%s\n", lpdds, IsPrim?"(PRIM)":(IsBack?"(BACK)":""), lpddsadd, (lpddsadd==lpDDZBuffer)?"(ZBUF)":"");
|
||||
|
||||
//if(!lpddsadd) return DDERR_CANNOTATTACHSURFACE; // to avoid a crash...
|
||||
@ -4256,7 +4249,7 @@ HRESULT WINAPI extAddAttachedSurface(LPDIRECTDRAWSURFACE lpdds, LPDIRECTDRAWSURF
|
||||
if ((dxw.dwFlags1 & EMULATESURFACE) && (res==DDERR_CANNOTATTACHSURFACE) ||
|
||||
(res==DDERR_NOEXCLUSIVEMODE))
|
||||
OutTraceDW("AddAttachedSurface: emulating BACKBUFFER attach on PRIMARY\n");
|
||||
dxw.MarkBackBufferSurface(lpddsadd, 1);
|
||||
dxwss.PushBackBufferSurface(lpddsadd, 1);
|
||||
if (pAddRefS) (*pAddRefS)(lpdds);
|
||||
res=DD_OK;
|
||||
}
|
||||
@ -4282,7 +4275,7 @@ HRESULT WINAPI extDeleteAttachedSurface(LPDIRECTDRAWSURFACE lpdds, DWORD dwflag
|
||||
OutTraceDDRAW("DeleteAttachedSurface: lpdds=%x flags=%x lpddsdel=%x\n", lpdds, dwflags, lpddsdel);
|
||||
res=(*pDeleteAttachedSurface)(lpdds, dwflags, lpddsdel);
|
||||
if(res) OutTraceE("DeleteAttachedSurface: ERROR %x(%s)\n", res, ExplainDDError(res));
|
||||
if (res && dxw.IsABackBufferSurface(lpddsdel)){
|
||||
if (res && dxwss.IsABackBufferSurface(lpddsdel)){
|
||||
OutTraceDW("DeleteAttachedSurface: emulating surface detach lpdds=%x\n", lpddsdel);
|
||||
res = DD_OK;
|
||||
}
|
||||
@ -4301,8 +4294,8 @@ HRESULT WINAPI extGetCapsS(int dxInterface, GetCapsS_Type pGetCapsS, LPDIRECTDRA
|
||||
{
|
||||
HRESULT res;
|
||||
BOOL IsPrim, IsBack, IsFixed;
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsBack=dxw.IsABackBufferSurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
IsBack=dxwss.IsABackBufferSurface(lpdds);
|
||||
IsFixed=FALSE;
|
||||
char *sLabel;
|
||||
|
||||
@ -4384,7 +4377,7 @@ ULONG WINAPI extReleaseD(LPDIRECTDRAW lpdd)
|
||||
if(dxw.dwFlags4 & FIXREFCOUNTER){
|
||||
// v2.02.41: fix the ref counter to sumulate the unwindowed original situation
|
||||
--VirtualRef; // why ????
|
||||
if(dxw.GetBackBufferSurface()) --VirtualRef;
|
||||
if(dxwss.GetBackBufferSurface()) --VirtualRef;
|
||||
if(dxw.dwFlags1 & EMULATESURFACE){
|
||||
if(lpDDSEmu_Prim) --VirtualRef;
|
||||
if(lpDDSEmu_Back) --VirtualRef;
|
||||
@ -4494,8 +4487,8 @@ HRESULT WINAPI extGetSurfaceDesc(GetSurfaceDesc_Type pGetSurfaceDesc, LPDIRECTDR
|
||||
{
|
||||
HRESULT res;
|
||||
BOOL IsPrim, IsBack, IsFixed;
|
||||
IsPrim=dxw.IsAPrimarySurface(lpdds);
|
||||
IsBack=dxw.IsABackBufferSurface(lpdds);
|
||||
IsPrim=dxwss.IsAPrimarySurface(lpdds);
|
||||
IsBack=dxwss.IsABackBufferSurface(lpdds);
|
||||
IsFixed=FALSE;
|
||||
|
||||
if (!pGetSurfaceDesc) {
|
||||
@ -4699,7 +4692,7 @@ HRESULT WINAPI extDDGetGammaRamp(LPDIRECTDRAWSURFACE lpdds, DWORD dwFlags, LPDDG
|
||||
HRESULT ret;
|
||||
OutTraceDDRAW("GetGammaRamp: dds=%x dwFlags=%x\n", lpdds, dwFlags);
|
||||
|
||||
if(dxw.IsAPrimarySurface(lpdds)) lpdds=lpDDSEmu_Prim;
|
||||
if(dxwss.IsAPrimarySurface(lpdds)) lpdds=lpDDSEmu_Prim;
|
||||
|
||||
ret=(*pDDGetGammaRamp)(lpdds, dwFlags, lpgr);
|
||||
if(ret) {
|
||||
|
@ -39,10 +39,10 @@ void DDrawScreenShot()
|
||||
}
|
||||
|
||||
if(dxw.dwFlags5 & GDIMODE){
|
||||
s = dxw.GetBackBufferSurface();
|
||||
s = dxwss.GetBackBufferSurface();
|
||||
}
|
||||
else{
|
||||
s = dxw.GetPrimarySurface();
|
||||
s = dxwss.GetPrimarySurface();
|
||||
}
|
||||
if(!s) return;
|
||||
|
||||
|
@ -42,6 +42,7 @@ unsigned int HashSurface(BYTE *buf, int pitch, int width, int height)
|
||||
int pixelsize;
|
||||
DWORD hash = 0;
|
||||
// integer divide, intentionally throwing reminder away
|
||||
if (width == 0) return 0; // avoid DivBy0 error
|
||||
pixelsize = pitch / width;
|
||||
for(int y = 0; y < height; y++){
|
||||
BYTE *p = buf + (y * pitch);
|
||||
@ -114,7 +115,7 @@ void TextureHighlight(LPDIRECTDRAWSURFACE s)
|
||||
OutTraceE("TextureHigh: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
return;
|
||||
}
|
||||
if((ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE) && !dxw.IsABackBufferSurface(s)) {
|
||||
if((ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE) && !dxwss.IsABackBufferSurface(s)) {
|
||||
OutTrace("TextureHigh: lpdds=%x BitCount=%d size=(%dx%d)\n",
|
||||
s, ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.dwWidth, ddsd.dwHeight);
|
||||
w = ddsd.dwWidth;
|
||||
@ -204,7 +205,7 @@ static void TextureDump(LPDIRECTDRAWSURFACE s)
|
||||
return;
|
||||
}
|
||||
|
||||
if((ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE) && !dxw.IsABackBufferSurface(s)) while (TRUE) {
|
||||
if((ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE) && !dxwss.IsABackBufferSurface(s)) while (TRUE) {
|
||||
OutTrace("TextureDump: lpdds=%x BitCount=%d size=(%dx%d)\n",
|
||||
s, ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.dwWidth, ddsd.dwHeight);
|
||||
w = ddsd.dwWidth;
|
||||
@ -281,16 +282,8 @@ static void TextureDump(LPDIRECTDRAWSURFACE s)
|
||||
|
||||
// Copy the RGBQUAD array into the file.
|
||||
if(pbi.bV4ClrUsed){
|
||||
//DWORD PaletteEntries[256];
|
||||
//LPDIRECTDRAWSURFACE lpDDS=NULL;
|
||||
//LPDIRECTDRAWPALETTE lpDDP=NULL;
|
||||
//lpDDS=dxw.GetPrimarySurface();
|
||||
//if(lpDDS) lpDDS->GetPalette(&lpDDP);
|
||||
//if(lpDDP) lpDDP->GetEntries(0, 0, 256, (LPPALETTEENTRY)PaletteEntries);
|
||||
//for(int i=0; i<256; i++) PaletteEntries[i]=0xff0000;
|
||||
extern DWORD PaletteEntries[256];
|
||||
fwrite((LPVOID)PaletteEntries, pbi.bV4ClrUsed * sizeof (RGBQUAD), 1, hf);
|
||||
//fwrite((LPBYTE)PaletteEntries, pbi.bV4ClrUsed * sizeof (RGBQUAD), 1, hf);
|
||||
}
|
||||
|
||||
// Copy the array of color indices into the .BMP file.
|
||||
@ -318,7 +311,7 @@ static void TextureHack(LPDIRECTDRAWSURFACE s)
|
||||
OutTraceE("TextureHack: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
return;
|
||||
}
|
||||
if((ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE) && !dxw.IsABackBufferSurface(s)) while (TRUE) { // fake loop to ensure final Unlock
|
||||
if((ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE) && !dxwss.IsABackBufferSurface(s)) while (TRUE) { // fake loop to ensure final Unlock
|
||||
OutTrace("TextureHack: lpdds=%x BitCount=%d size=(%dx%d)\n",
|
||||
s, ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.dwWidth, ddsd.dwHeight);
|
||||
w = ddsd.dwWidth;
|
||||
|
@ -25,6 +25,8 @@
|
||||
#define SKIPIMEWINDOW TRUE
|
||||
|
||||
dxwCore dxw;
|
||||
dxwSStack dxwss;
|
||||
dxwWStack dxwws;
|
||||
|
||||
typedef char *(*Geterrwarnmessage_Type)(unsigned long, unsigned long);
|
||||
typedef int (*Preparedisasm_Type)(void);
|
||||
@ -594,18 +596,26 @@ void HookWindowProc(HWND hwnd)
|
||||
{
|
||||
WNDPROC pWindowProc;
|
||||
pWindowProc = (WNDPROC)(*pGetWindowLongA)(hwnd, GWL_WNDPROC);
|
||||
// don't hook twice ....
|
||||
if ((pWindowProc == extWindowProc) ||
|
||||
(pWindowProc == extChildWindowProc) ||
|
||||
(pWindowProc == extDialogWindowProc)){
|
||||
// hooked already !!!
|
||||
OutTraceDW("GetWindowLong: hwnd=%x WindowProc HOOK already in place\n", hwnd);
|
||||
return;
|
||||
}
|
||||
else {// don't hook twice ....
|
||||
long lres;
|
||||
WinDBPutProc(hwnd, pWindowProc);
|
||||
lres=(*pSetWindowLongA)(hwnd, GWL_WNDPROC, (LONG)extWindowProc);
|
||||
OutTraceDW("SetWindowLong: hwnd=%x HOOK WindowProc=%x->%x\n", hwnd, lres, (LONG)extWindowProc);
|
||||
|
||||
// v2.03.22: don't remap WindowProc in case of special address 0xFFFFnnnn.
|
||||
// This makes "The Hulk demo" work avoiding WindowProc recursion and stack overflow
|
||||
if (((DWORD)pWindowProc & 0xFFFF0000) == 0xFFFF0000){
|
||||
OutTraceDW("GetWindowLong: hwnd=%x WindowProc HOOK %x not updated\n", hwnd, pWindowProc);
|
||||
return;
|
||||
}
|
||||
|
||||
long lres;
|
||||
dxwws.PutProc(hwnd, pWindowProc);
|
||||
lres=(*pSetWindowLongA)(hwnd, GWL_WNDPROC, (LONG)extWindowProc);
|
||||
OutTraceDW("SetWindowLong: hwnd=%x HOOK WindowProc=%x->%x\n", hwnd, lres, (LONG)extWindowProc);
|
||||
}
|
||||
|
||||
void AdjustWindowFrame(HWND hwnd, DWORD width, DWORD height)
|
||||
@ -670,8 +680,8 @@ LRESULT CALLBACK extDialogWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPA
|
||||
t=tn;
|
||||
}
|
||||
|
||||
pWindowProc=WinDBGetProc(hwnd);
|
||||
if(pWindowProc) return(*pCallWindowProc)(pWindowProc, hwnd, message, wparam, lparam);
|
||||
pWindowProc=dxwws.GetProc(hwnd);
|
||||
if(pWindowProc) return(*pCallWindowProcA)(pWindowProc, hwnd, message, wparam, lparam);
|
||||
char *sMsg="ASSERT: DialogWinMsg pWindowProc=NULL !!!\n";
|
||||
OutTraceDW(sMsg);
|
||||
if (IsAssertEnabled) MessageBox(0, sMsg, "WindowProc", MB_OK | MB_ICONEXCLAMATION);
|
||||
@ -726,10 +736,10 @@ LRESULT CALLBACK extChildWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPAR
|
||||
}
|
||||
}
|
||||
|
||||
pWindowProc=WinDBGetProc(hwnd);
|
||||
pWindowProc=dxwws.GetProc(hwnd);
|
||||
|
||||
// v2.02.82: use CallWindowProc that handles WinProc handles
|
||||
if(pWindowProc) return(*pCallWindowProc)(pWindowProc, hwnd, message, wparam, lparam);
|
||||
if(pWindowProc) return(*pCallWindowProcA)(pWindowProc, hwnd, message, wparam, lparam);
|
||||
// should never get here ....
|
||||
OutTraceDW("ChildWindowProc: no WndProc for CHILD hwnd=%x\n", hwnd);
|
||||
return DefWindowProc(hwnd, message, wparam, lparam);
|
||||
@ -1116,15 +1126,15 @@ LRESULT CALLBACK extWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
|
||||
}
|
||||
if (dxw.dwFlags1 & AUTOREFRESH) dxw.ScreenRefresh();
|
||||
|
||||
pWindowProc=WinDBGetProc(hwnd);
|
||||
pWindowProc=dxwws.GetProc(hwnd);
|
||||
//OutTraceB("WindowProc: pWindowProc=%x extWindowProc=%x message=%x(%s) wparam=%x lparam=%x\n",
|
||||
// (*pWindowProc), extWindowProc, message, ExplainWinMessage(message), wparam, lparam);
|
||||
if(pWindowProc) {
|
||||
LRESULT ret;
|
||||
|
||||
// v2.02.36: use CallWindowProc that handles WinProc handles
|
||||
ret=(*pCallWindowProc)(pWindowProc, hwnd, message, wparam, lparam);
|
||||
|
||||
ret=(*pCallWindowProcA)(pWindowProc, hwnd, message, wparam, lparam);
|
||||
|
||||
// save last NCHITTEST cursor position for use with KEEPASPECTRATIO scaling
|
||||
if(message==WM_NCHITTEST) LastCursorPos=ret;
|
||||
// v2.1.89: if FORCEWINRESIZE add standard processing for the missing WM_NC* messages
|
||||
|
242
dll/dxwcore.cpp
242
dll/dxwcore.cpp
@ -8,12 +8,6 @@
|
||||
#include "resource.h"
|
||||
#include "d3d9.h"
|
||||
|
||||
#if 1
|
||||
#define OutTraceSDB OutTrace
|
||||
#else
|
||||
#define OutTraceSDB if(0) OutTrace
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
// Internal function pointers
|
||||
/* ------------------------------------------------------------------ */
|
||||
@ -36,7 +30,6 @@ static LARGE_INTEGER TimeShifter64Coarse(LARGE_INTEGER, int);
|
||||
dxwCore::dxwCore()
|
||||
{
|
||||
// initialization stuff ....
|
||||
extern void WinDBInit();
|
||||
FullScreen=FALSE;
|
||||
SethWnd(NULL);
|
||||
SetScreenSize();
|
||||
@ -46,12 +39,9 @@ dxwCore::dxwCore()
|
||||
bActive = TRUE;
|
||||
bDInputAbs = 0;
|
||||
TimeShift = 0;
|
||||
lpDDSPrimary = NULL;
|
||||
memset(SurfaceDB, 0, sizeof(SurfaceDB));
|
||||
ResetEmulatedDC();
|
||||
MustShowOverlay=FALSE;
|
||||
TimerEvent.dwTimerType = TIMER_TYPE_NONE;
|
||||
WinDBInit();
|
||||
// initialization of default vsync emulation array
|
||||
iRefreshDelays[0]=16;
|
||||
iRefreshDelays[1]=17;
|
||||
@ -228,234 +218,6 @@ void dxwCore::DumpDesktopStatus()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
// Primary surfaces auxiliary functions
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
//#define DXW_SURFACE_STACK_TRACING
|
||||
|
||||
static char *sRole(USHORT role)
|
||||
{
|
||||
char *s;
|
||||
switch (role){
|
||||
case 0: s="(NULL)"; break; // should never happen ...
|
||||
case SURFACE_ROLE_PRIMARY: s="(PRIM)"; break;
|
||||
case SURFACE_ROLE_BACKBUFFER: s="(BACK)"; break;
|
||||
default: s="??"; break; // should never happen ...
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
static void CheckSurfaceList(SurfaceDB_Type *SurfaceDB)
|
||||
{
|
||||
char sMsg[81];
|
||||
int iPCount = 0;
|
||||
int iBCount = 0;
|
||||
for (int i=0;i<DDSQLEN;i++) {
|
||||
if (SurfaceDB[i].lpdds == NULL) break;
|
||||
if ((SurfaceDB[i].uRole == SURFACE_ROLE_PRIMARY) && SurfaceDB[i].uRef) iPCount++;
|
||||
if ((SurfaceDB[i].uRole == SURFACE_ROLE_BACKBUFFER) && SurfaceDB[i].uRef) iBCount++;
|
||||
}
|
||||
if(iPCount > 1) {
|
||||
sprintf(sMsg, "Primary count = %d", iPCount);
|
||||
MessageBox(0, sMsg, "DxWnd SurfaceList", MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
if(iBCount > 1) {
|
||||
sprintf(sMsg, "Backbuffer count = %d", iPCount);
|
||||
MessageBox(0, sMsg, "DxWnd SurfaceList", MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
|
||||
static void DumpSurfaceList(SurfaceDB_Type *SurfaceDB)
|
||||
{
|
||||
for (int i=0;i<DDSQLEN;i++) {
|
||||
if (SurfaceDB[i].lpdds == NULL) break;
|
||||
OutTrace("--- SURFACELIST DUMP: i=%d lpssd=%x%s ref=%d vers=%d\n", i,
|
||||
SurfaceDB[i].lpdds, sRole(SurfaceDB[i].uRole), SurfaceDB[i].uRef, SurfaceDB[i].uVersion);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
char *dxwCore::ExplainSurfaceRole(LPDIRECTDRAWSURFACE ps)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<DDSQLEN;i++) {
|
||||
if (SurfaceDB[i].lpdds==ps) return sRole(SurfaceDB[i].uRole);
|
||||
if (SurfaceDB[i].lpdds==0) break;
|
||||
}
|
||||
// this should NEVER happen, but ...
|
||||
extern LPDIRECTDRAWSURFACE lpDDSEmu_Back, lpDDSEmu_Prim;
|
||||
if(lpDDSEmu_Back && (ps==lpDDSEmu_Back)) return "(emu.BACK)";
|
||||
if(lpDDSEmu_Prim && (ps==lpDDSEmu_Prim)) return "(emu.PRIM)";
|
||||
// ... just in case!
|
||||
return "";
|
||||
}
|
||||
|
||||
void dxwCore::ClearSurfaceList()
|
||||
{
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
OutTrace(">>> SURFACELIST CLEAR ALL\n");
|
||||
#endif
|
||||
for (int i=0;i<DDSQLEN;i++) {
|
||||
SurfaceDB[i].lpdds = NULL;
|
||||
SurfaceDB[i].uRef = FALSE;
|
||||
SurfaceDB[i].uRole = 0;
|
||||
SurfaceDB[i].uVersion = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void dxwCore::UnrefSurface(LPDIRECTDRAWSURFACE ps)
|
||||
{
|
||||
int i;
|
||||
// look for entry
|
||||
for (i=0;i<DDSQLEN;i++)
|
||||
if ((SurfaceDB[i].lpdds==ps) || SurfaceDB[i].lpdds==0) break;
|
||||
// if found, delete it by left-copying each entry until end of array
|
||||
if (SurfaceDB[i].lpdds == ps) {
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
OutTraceSDB(">>> SURFACELIST UNREF: lpdds=%x%s ref=%x vers=%d\n", ps, sRole(SurfaceDB[i].uRole), SurfaceDB[i].uRef, SurfaceDB[i].uVersion);
|
||||
#endif
|
||||
SurfaceDB[i].uRef = FALSE;
|
||||
}
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
DumpSurfaceList(SurfaceDB);
|
||||
#endif
|
||||
}
|
||||
|
||||
void dxwCore::MarkSurfaceByRole(LPDIRECTDRAWSURFACE ps, USHORT role, USHORT version)
|
||||
{
|
||||
int i;
|
||||
SurfaceDB_Type *e;
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
OutTraceSDB(">>> SURFACELIST MARK: lpdds=%x%s vers=%d\n", ps, sRole(role), version);
|
||||
#endif
|
||||
for (i=0;i<DDSQLEN;i++) {
|
||||
e=&SurfaceDB[i];
|
||||
if ((e->lpdds==ps) || (e->lpdds==(DWORD)0)) break; // got matching entry or end of the list
|
||||
}
|
||||
if(i == DDSQLEN) {
|
||||
MessageBox(0, "Surface stack is full", "DxWnd SurfaceList", MB_OK | MB_ICONEXCLAMATION);
|
||||
return;
|
||||
}
|
||||
e->lpdds=ps;
|
||||
e->uRole = role;
|
||||
e->uRef = TRUE;
|
||||
e->uVersion = version;
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
DumpSurfaceList(SurfaceDB);
|
||||
#endif
|
||||
}
|
||||
|
||||
void dxwCore::MarkPrimarySurface(LPDIRECTDRAWSURFACE ps, int version)
|
||||
{
|
||||
MarkSurfaceByRole(ps, SURFACE_ROLE_PRIMARY, (USHORT)version);
|
||||
}
|
||||
|
||||
void dxwCore::MarkBackBufferSurface(LPDIRECTDRAWSURFACE ps, int version)
|
||||
{
|
||||
MarkSurfaceByRole(ps, SURFACE_ROLE_BACKBUFFER, (USHORT)version);
|
||||
}
|
||||
|
||||
void dxwCore::MarkRegularSurface(LPDIRECTDRAWSURFACE ps)
|
||||
{
|
||||
int i;
|
||||
// look for entry
|
||||
for (i=0;i<DDSQLEN;i++) {
|
||||
if (SurfaceDB[i].lpdds==0) return;
|
||||
if (SurfaceDB[i].lpdds==ps) break;
|
||||
}
|
||||
// if found, delete it by left-copying each entry until end of array
|
||||
if (SurfaceDB[i].lpdds==ps){
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
OutTraceSDB(">>> SURFACELIST CLEAR: i=%d lpdds=%x%s ref=%x vers=%d\n",
|
||||
i, ps, sRole(SurfaceDB[i].uRole), SurfaceDB[i].uRef, SurfaceDB[i].uVersion);
|
||||
#endif
|
||||
for (; i<DDSQLEN; i++){
|
||||
SurfaceDB[i]=SurfaceDB[i+1];
|
||||
if (SurfaceDB[i].lpdds==0) break;
|
||||
}
|
||||
SurfaceDB[DDSQLEN].lpdds=0;
|
||||
SurfaceDB[DDSQLEN].uRole=0;
|
||||
SurfaceDB[DDSQLEN].uRef=0;
|
||||
SurfaceDB[DDSQLEN].uVersion=0;
|
||||
}
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
DumpSurfaceList(&SurfaceDB[0]);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Note: since MS itself declares that the object refcount is not reliable and should
|
||||
// be used for debugging only, it's not safe to rely on refcount==0 when releasing a
|
||||
// surface to terminate its classification as primary. As an alternate and more reliable
|
||||
// way, we use UnmarkPrimarySurface each time you create a new not primary surface,
|
||||
// eliminating the risk that a surface previously classified as primary and then closed
|
||||
// had the same surface handle than this new one that is not primary at all.
|
||||
|
||||
BOOL dxwCore::IsAPrimarySurface(LPDIRECTDRAWSURFACE ps)
|
||||
{
|
||||
int i;
|
||||
// treat NULL surface ptr as a non primary
|
||||
if(!ps) return FALSE;
|
||||
for (i=0;i<DDSQLEN;i++) {
|
||||
if (SurfaceDB[i].lpdds==0) return FALSE;
|
||||
if (SurfaceDB[i].lpdds==ps) return (SurfaceDB[i].uRole == SURFACE_ROLE_PRIMARY);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL dxwCore::IsABackBufferSurface(LPDIRECTDRAWSURFACE ps)
|
||||
{
|
||||
int i;
|
||||
// treat NULL surface ptr as a non primary
|
||||
if(!ps) return FALSE;
|
||||
for (i=0;i<DDSQLEN;i++) {
|
||||
if (SurfaceDB[i].lpdds==0) return FALSE;
|
||||
if (SurfaceDB[i].lpdds==ps) return (SurfaceDB[i].uRole == SURFACE_ROLE_BACKBUFFER);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LPDIRECTDRAWSURFACE dxwCore::GetSurfaceByRole(USHORT role)
|
||||
{
|
||||
// Get a surface marked for the desired role (either PRIMARY or BACKBUFFER) and
|
||||
// whith a not null reference counter. In case of multiple choices, it has to
|
||||
// return the most recent reference!!!
|
||||
// tested with "101 the Airborne Invasion of Normandy" and "Armored Fist 3"
|
||||
int i;
|
||||
LPDIRECTDRAWSURFACE ret = NULL;
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
if (IsAssertEnabled) CheckSurfaceList(SurfaceDB);
|
||||
#endif
|
||||
for (i=0;i<DDSQLEN;i++) {
|
||||
if ((SurfaceDB[i].uRole == role) && (SurfaceDB[i].uRef)) ret = SurfaceDB[i].lpdds;
|
||||
if (SurfaceDB[i].lpdds==NULL) break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
LPDIRECTDRAWSURFACE dxwCore::GetPrimarySurface(void)
|
||||
{
|
||||
return GetSurfaceByRole(SURFACE_ROLE_PRIMARY);
|
||||
}
|
||||
|
||||
LPDIRECTDRAWSURFACE dxwCore::GetBackBufferSurface(void)
|
||||
{
|
||||
return GetSurfaceByRole(SURFACE_ROLE_BACKBUFFER);
|
||||
}
|
||||
|
||||
void dxwCore::SetPrimarySurface(void)
|
||||
{
|
||||
if (!lpDDSPrimary) lpDDSPrimary=GetPrimarySurface();
|
||||
}
|
||||
|
||||
void dxwCore::ResetPrimarySurface(void)
|
||||
{
|
||||
lpDDSPrimary=NULL;
|
||||
}
|
||||
|
||||
void dxwCore::InitWindowPos(int x, int y, int w, int h)
|
||||
{
|
||||
iPosX = x;
|
||||
@ -1118,7 +880,7 @@ void dxwCore::ScreenRefresh(void)
|
||||
t = tn;
|
||||
|
||||
// if not too early, refresh primary surface ....
|
||||
lpDDSPrim=dxw.GetPrimarySurface();
|
||||
lpDDSPrim=dxwss.GetPrimarySurface();
|
||||
if (lpDDSPrim) extBlt(lpDDSPrim, NULL, lpDDSPrim, NULL, 0, NULL);
|
||||
|
||||
// v2.02.44 - used for what? Commenting out seems to fix the palette update glitches
|
||||
@ -1793,7 +1555,7 @@ HDC dxwCore::AcquireEmulatedDC(LPDIRECTDRAWSURFACE lpdds)
|
||||
typedef HRESULT (WINAPI *GetDC_Type) (LPDIRECTDRAWSURFACE, HDC FAR *);
|
||||
extern GetDC_Type pGetDC;
|
||||
if((*pGetDC)(lpdds, &ddc))
|
||||
OutTraceE("GetDC: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
|
||||
OutTraceE("GetDC: ERROR err=%d at=%d\n", GetLastError(), __LINE__);
|
||||
return AcquireEmulatedDC(ddc);
|
||||
}
|
||||
|
||||
|
@ -91,18 +91,6 @@ public: // methods
|
||||
BOOL HandleFPS(void);
|
||||
BOOL ishWndFPS(HWND);
|
||||
DWORD GetTickCount(void);
|
||||
char *ExplainSurfaceRole(LPDIRECTDRAWSURFACE);
|
||||
void ClearSurfaceList();
|
||||
void MarkPrimarySurface(LPDIRECTDRAWSURFACE, int);
|
||||
BOOL IsAPrimarySurface(LPDIRECTDRAWSURFACE);
|
||||
void UnrefSurface(LPDIRECTDRAWSURFACE);
|
||||
LPDIRECTDRAWSURFACE GetPrimarySurface(void);
|
||||
void MarkBackBufferSurface(LPDIRECTDRAWSURFACE, int);
|
||||
BOOL IsABackBufferSurface(LPDIRECTDRAWSURFACE);
|
||||
LPDIRECTDRAWSURFACE GetBackBufferSurface(void);
|
||||
void MarkRegularSurface(LPDIRECTDRAWSURFACE);
|
||||
void SetPrimarySurface(void);
|
||||
void ResetPrimarySurface(void);
|
||||
void GetSystemTime(LPSYSTEMTIME);
|
||||
void GetSystemTimeAsFileTime(LPFILETIME);
|
||||
DWORD StretchTime(DWORD);
|
||||
@ -164,7 +152,6 @@ public: // simple data variables
|
||||
DWORD SwapEffect;
|
||||
char *gsModules;
|
||||
int TimeShift;
|
||||
LPDIRECTDRAWSURFACE lpDDSPrimary;
|
||||
short iPosX;
|
||||
short iPosY;
|
||||
short iSizX;
|
||||
@ -187,16 +174,10 @@ protected:
|
||||
DWORD dwScreenHeight;
|
||||
BOOL FullScreen;
|
||||
HWND hWnd, hWndFPS;
|
||||
SurfaceDB_Type SurfaceDB[DDSQLEN+1];
|
||||
//DWORD PrimSurfaces[DDSQLEN+1];
|
||||
//DWORD BackSurfaces[DDSQLEN+1];
|
||||
HBITMAP VirtualPic;
|
||||
RECT VirtualPicRect;
|
||||
|
||||
private:
|
||||
void MarkSurfaceByRole(LPDIRECTDRAWSURFACE, USHORT, USHORT);
|
||||
LPDIRECTDRAWSURFACE GetSurfaceByRole(USHORT);
|
||||
void SetSurfaceEntry(LPDIRECTDRAWSURFACE, USHORT, USHORT);
|
||||
BOOL MustShowOverlay;
|
||||
void ShowFPS(HDC, int, int);
|
||||
void ShowTimeStretching(HDC, int, int);
|
||||
@ -207,7 +188,64 @@ private:
|
||||
int iRefreshDelayCount;
|
||||
};
|
||||
|
||||
class dxwSStack
|
||||
{
|
||||
public:
|
||||
dxwSStack();
|
||||
virtual ~dxwSStack();
|
||||
|
||||
public:
|
||||
char *ExplainSurfaceRole(LPDIRECTDRAWSURFACE);
|
||||
void ClearSurfaceList();
|
||||
void PushPrimarySurface(LPDIRECTDRAWSURFACE, int);
|
||||
BOOL IsAPrimarySurface(LPDIRECTDRAWSURFACE);
|
||||
void UnrefSurface(LPDIRECTDRAWSURFACE);
|
||||
LPDIRECTDRAWSURFACE GetPrimarySurface(void);
|
||||
void PushBackBufferSurface(LPDIRECTDRAWSURFACE, int);
|
||||
BOOL IsABackBufferSurface(LPDIRECTDRAWSURFACE);
|
||||
LPDIRECTDRAWSURFACE GetBackBufferSurface(void);
|
||||
void PopSurface(LPDIRECTDRAWSURFACE);
|
||||
|
||||
protected:
|
||||
SurfaceDB_Type SurfaceDB[DDSQLEN+1];
|
||||
LPDIRECTDRAWSURFACE lpDDSPrimary;
|
||||
LPDIRECTDRAWSURFACE lpDDSBackBuffer;
|
||||
|
||||
private:
|
||||
void PushSurface(LPDIRECTDRAWSURFACE, USHORT, USHORT);
|
||||
LPDIRECTDRAWSURFACE GetSurfaceByRole(USHORT);
|
||||
void SetSurfaceEntry(LPDIRECTDRAWSURFACE, USHORT, USHORT);
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
HWND hwnd;
|
||||
WNDPROC wndproc;
|
||||
int w;
|
||||
int h;
|
||||
} wndstack_entry;
|
||||
|
||||
class dxwWStack
|
||||
{
|
||||
public:
|
||||
dxwWStack();
|
||||
virtual ~dxwWStack();
|
||||
|
||||
public:
|
||||
void Put(HWND, WNDPROC, int, int);
|
||||
void PutProc(HWND, WNDPROC);
|
||||
void PutSize(HWND, int, int);
|
||||
BOOL GetSize(HWND, int *, int *);
|
||||
WNDPROC GetProc(HWND);
|
||||
|
||||
private:
|
||||
wndstack_entry *WhndStack;
|
||||
int WhndTOS;
|
||||
int WhndSize;
|
||||
};
|
||||
|
||||
extern dxwCore dxw;
|
||||
extern dxwSStack dxwss;
|
||||
extern dxwWStack dxwws;
|
||||
|
||||
typedef enum {
|
||||
SYSLIBIDX_KERNEL32 = 0,
|
||||
|
BIN
dll/dxwnd.aps
BIN
dll/dxwnd.aps
Binary file not shown.
@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "TlHelp32.h"
|
||||
|
||||
#define VERSION "2.03.21"
|
||||
#define VERSION "2.03.22"
|
||||
|
||||
#define DDTHREADLOCK 1
|
||||
//#define LOCKTHREADS
|
||||
|
Binary file not shown.
@ -361,6 +361,14 @@
|
||||
RelativePath=".\dxwnd.rc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\dxwsstack.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\dxwwstack.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\gdi32.cpp"
|
||||
>
|
||||
@ -461,10 +469,6 @@
|
||||
RelativePath=".\wintrust.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\wndproc.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
|
242
dll/dxwsstack.cpp
Normal file
242
dll/dxwsstack.cpp
Normal file
@ -0,0 +1,242 @@
|
||||
/* ------------------------------------------------------------------ */
|
||||
// DirectDraw Surface Stack implementation
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#include <stdio.h>
|
||||
#include "dxwnd.h"
|
||||
#include "dxwcore.hpp"
|
||||
|
||||
//#define DXW_SURFACE_STACK_TRACING
|
||||
|
||||
dxwSStack::dxwSStack()
|
||||
{
|
||||
lpDDSPrimary = NULL;
|
||||
lpDDSBackBuffer = NULL;
|
||||
memset(SurfaceDB, 0, sizeof(SurfaceDB));
|
||||
}
|
||||
|
||||
dxwSStack::~dxwSStack()
|
||||
{
|
||||
}
|
||||
|
||||
static char *sRole(USHORT role)
|
||||
{
|
||||
char *s;
|
||||
switch (role){
|
||||
case 0: s="(NULL)"; break; // should never happen ...
|
||||
case SURFACE_ROLE_PRIMARY: s="(PRIM)"; break;
|
||||
case SURFACE_ROLE_BACKBUFFER: s="(BACK)"; break;
|
||||
default: s="??"; break; // should never happen ...
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
static void CheckSurfaceList(SurfaceDB_Type *SurfaceDB)
|
||||
{
|
||||
char sMsg[81];
|
||||
int iPCount = 0;
|
||||
int iBCount = 0;
|
||||
for (int i=0;i<DDSQLEN;i++) {
|
||||
if (SurfaceDB[i].lpdds == NULL) break;
|
||||
if ((SurfaceDB[i].uRole == SURFACE_ROLE_PRIMARY) && SurfaceDB[i].uRef) iPCount++;
|
||||
if ((SurfaceDB[i].uRole == SURFACE_ROLE_BACKBUFFER) && SurfaceDB[i].uRef) iBCount++;
|
||||
}
|
||||
if(iPCount > 1) {
|
||||
sprintf(sMsg, "Primary count = %d", iPCount);
|
||||
MessageBox(0, sMsg, "DxWnd SurfaceList", MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
if(iBCount > 1) {
|
||||
sprintf(sMsg, "Backbuffer count = %d", iPCount);
|
||||
MessageBox(0, sMsg, "DxWnd SurfaceList", MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
|
||||
static void DumpSurfaceList(SurfaceDB_Type *SurfaceDB)
|
||||
{
|
||||
for (int i=0;i<DDSQLEN;i++) {
|
||||
if (SurfaceDB[i].lpdds == NULL) break;
|
||||
OutTrace("--- SURFACELIST DUMP: i=%d lpssd=%x%s ref=%d vers=%d\n", i,
|
||||
SurfaceDB[i].lpdds, sRole(SurfaceDB[i].uRole), SurfaceDB[i].uRef, SurfaceDB[i].uVersion);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
char *dxwSStack::ExplainSurfaceRole(LPDIRECTDRAWSURFACE ps)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<DDSQLEN;i++) {
|
||||
if (SurfaceDB[i].lpdds==ps) return sRole(SurfaceDB[i].uRole);
|
||||
if (SurfaceDB[i].lpdds==0) break;
|
||||
}
|
||||
// this should NEVER happen, but ...
|
||||
extern LPDIRECTDRAWSURFACE lpDDSEmu_Back, lpDDSEmu_Prim;
|
||||
if(lpDDSEmu_Back && (ps==lpDDSEmu_Back)) return "(emu.BACK)";
|
||||
if(lpDDSEmu_Prim && (ps==lpDDSEmu_Prim)) return "(emu.PRIM)";
|
||||
// ... just in case!
|
||||
return "";
|
||||
}
|
||||
|
||||
void dxwSStack::ClearSurfaceList()
|
||||
{
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
OutTrace(">>> SURFACELIST CLEAR ALL\n");
|
||||
#endif
|
||||
for (int i=0;i<DDSQLEN;i++) {
|
||||
SurfaceDB[i].lpdds = NULL;
|
||||
SurfaceDB[i].uRef = FALSE;
|
||||
SurfaceDB[i].uRole = 0;
|
||||
SurfaceDB[i].uVersion = 0;
|
||||
}
|
||||
lpDDSPrimary = NULL;
|
||||
lpDDSBackBuffer = NULL;
|
||||
}
|
||||
|
||||
void dxwSStack::UnrefSurface(LPDIRECTDRAWSURFACE ps)
|
||||
{
|
||||
int i;
|
||||
// look for entry
|
||||
for (i=0;i<DDSQLEN;i++)
|
||||
if ((SurfaceDB[i].lpdds==ps) || SurfaceDB[i].lpdds==0) break;
|
||||
// if found, delete it by left-copying each entry until end of array
|
||||
if (SurfaceDB[i].lpdds == ps) {
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
OutTraceSDB(">>> SURFACELIST UNREF: lpdds=%x%s ref=%x vers=%d\n", ps, sRole(SurfaceDB[i].uRole), SurfaceDB[i].uRef, SurfaceDB[i].uVersion);
|
||||
#endif
|
||||
SurfaceDB[i].uRef = FALSE;
|
||||
if(ps == lpDDSPrimary) lpDDSPrimary = GetSurfaceByRole(SURFACE_ROLE_PRIMARY);
|
||||
if(ps == lpDDSBackBuffer) lpDDSBackBuffer = GetSurfaceByRole(SURFACE_ROLE_BACKBUFFER);
|
||||
}
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
DumpSurfaceList(SurfaceDB);
|
||||
#endif
|
||||
}
|
||||
|
||||
void dxwSStack::PushSurface(LPDIRECTDRAWSURFACE ps, USHORT role, USHORT version)
|
||||
{
|
||||
int i;
|
||||
SurfaceDB_Type *e;
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
OutTraceSDB(">>> SURFACELIST MARK: lpdds=%x%s vers=%d\n", ps, sRole(role), version);
|
||||
#endif
|
||||
for (i=0;i<DDSQLEN;i++) {
|
||||
e=&SurfaceDB[i];
|
||||
if ((e->lpdds==ps) || (e->lpdds==(DWORD)0)) break; // got matching entry or end of the list
|
||||
}
|
||||
if(i == DDSQLEN) {
|
||||
MessageBox(0, "Surface stack is full", "DxWnd SurfaceList", MB_OK | MB_ICONEXCLAMATION);
|
||||
return;
|
||||
}
|
||||
e->lpdds=ps;
|
||||
e->uRole = role;
|
||||
e->uRef = TRUE;
|
||||
e->uVersion = version;
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
DumpSurfaceList(SurfaceDB);
|
||||
#endif
|
||||
}
|
||||
|
||||
void dxwSStack::PushPrimarySurface(LPDIRECTDRAWSURFACE ps, int version)
|
||||
{
|
||||
PushSurface(ps, SURFACE_ROLE_PRIMARY, (USHORT)version);
|
||||
lpDDSPrimary = ps;
|
||||
}
|
||||
|
||||
void dxwSStack::PushBackBufferSurface(LPDIRECTDRAWSURFACE ps, int version)
|
||||
{
|
||||
PushSurface(ps, SURFACE_ROLE_BACKBUFFER, (USHORT)version);
|
||||
lpDDSBackBuffer = ps;
|
||||
}
|
||||
|
||||
void dxwSStack::PopSurface(LPDIRECTDRAWSURFACE ps)
|
||||
{
|
||||
int i;
|
||||
// look for entry
|
||||
for (i=0;i<DDSQLEN;i++) {
|
||||
if (SurfaceDB[i].lpdds==0) return;
|
||||
if (SurfaceDB[i].lpdds==ps) break;
|
||||
}
|
||||
// if found, delete it by left-copying each entry until end of array
|
||||
if (SurfaceDB[i].lpdds==ps){
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
OutTraceSDB(">>> SURFACELIST CLEAR: i=%d lpdds=%x%s ref=%x vers=%d\n",
|
||||
i, ps, sRole(SurfaceDB[i].uRole), SurfaceDB[i].uRef, SurfaceDB[i].uVersion);
|
||||
#endif
|
||||
for (; i<DDSQLEN; i++){
|
||||
SurfaceDB[i]=SurfaceDB[i+1];
|
||||
if (SurfaceDB[i].lpdds==0) break;
|
||||
}
|
||||
SurfaceDB[DDSQLEN].lpdds=0;
|
||||
SurfaceDB[DDSQLEN].uRole=0;
|
||||
SurfaceDB[DDSQLEN].uRef=0;
|
||||
SurfaceDB[DDSQLEN].uVersion=0;
|
||||
if (ps == lpDDSPrimary) lpDDSPrimary = GetSurfaceByRole(SURFACE_ROLE_PRIMARY);
|
||||
if (ps == lpDDSBackBuffer) lpDDSBackBuffer = GetSurfaceByRole(SURFACE_ROLE_BACKBUFFER);
|
||||
}
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
DumpSurfaceList(&SurfaceDB[0]);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Note: since MS itself declares that the object refcount is not reliable and should
|
||||
// be used for debugging only, it's not safe to rely on refcount==0 when releasing a
|
||||
// surface to terminate its classification as primary. As an alternate and more reliable
|
||||
// way, we use UnmarkPrimarySurface each time you create a new not primary surface,
|
||||
// eliminating the risk that a surface previously classified as primary and then closed
|
||||
// had the same surface handle than this new one that is not primary at all.
|
||||
|
||||
BOOL dxwSStack::IsAPrimarySurface(LPDIRECTDRAWSURFACE ps)
|
||||
{
|
||||
int i;
|
||||
// treat NULL surface ptr as a non primary
|
||||
if(!ps) return FALSE;
|
||||
for (i=0;i<DDSQLEN;i++) {
|
||||
if (SurfaceDB[i].lpdds==0) return FALSE;
|
||||
if (SurfaceDB[i].lpdds==ps) return (SurfaceDB[i].uRole == SURFACE_ROLE_PRIMARY);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL dxwSStack::IsABackBufferSurface(LPDIRECTDRAWSURFACE ps)
|
||||
{
|
||||
int i;
|
||||
// treat NULL surface ptr as a non primary
|
||||
if(!ps) return FALSE;
|
||||
for (i=0;i<DDSQLEN;i++) {
|
||||
if (SurfaceDB[i].lpdds==0) return FALSE;
|
||||
if (SurfaceDB[i].lpdds==ps) return (SurfaceDB[i].uRole == SURFACE_ROLE_BACKBUFFER);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LPDIRECTDRAWSURFACE dxwSStack::GetSurfaceByRole(USHORT role)
|
||||
{
|
||||
// Get a surface marked for the desired role (either PRIMARY or BACKBUFFER) and
|
||||
// whith a not null reference counter. In case of multiple choices, it has to
|
||||
// return the most recent reference!!!
|
||||
// tested with "101 the Airborne Invasion of Normandy" and "Armored Fist 3"
|
||||
int i;
|
||||
LPDIRECTDRAWSURFACE ret = NULL;
|
||||
#ifdef DXW_SURFACE_STACK_TRACING
|
||||
if (IsAssertEnabled) CheckSurfaceList(SurfaceDB);
|
||||
#endif
|
||||
for (i=0;i<DDSQLEN;i++) {
|
||||
if ((SurfaceDB[i].uRole == role) && (SurfaceDB[i].uRef)) ret = SurfaceDB[i].lpdds;
|
||||
if (SurfaceDB[i].lpdds==NULL) break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
LPDIRECTDRAWSURFACE dxwSStack::GetPrimarySurface(void)
|
||||
{
|
||||
//return GetSurfaceByRole(SURFACE_ROLE_PRIMARY);
|
||||
return lpDDSPrimary;
|
||||
}
|
||||
|
||||
LPDIRECTDRAWSURFACE dxwSStack::GetBackBufferSurface(void)
|
||||
{
|
||||
//return GetSurfaceByRole(SURFACE_ROLE_BACKBUFFER);
|
||||
return lpDDSBackBuffer;
|
||||
}
|
@ -1,37 +1,28 @@
|
||||
#define _WIN32_WINNT 0x0600
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
/* ------------------------------------------------------------------ */
|
||||
// DirectDraw Surface Stack implementation
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <ddraw.h>
|
||||
#include "dxwnd.h"
|
||||
#include "dxwcore.hpp"
|
||||
#include "dxhook.h"
|
||||
#include "syslibs.h"
|
||||
#include "dxhelper.h"
|
||||
|
||||
typedef struct {
|
||||
HWND hwnd;
|
||||
WNDPROC wndproc;
|
||||
int w;
|
||||
int h;
|
||||
} wndstack_entry;
|
||||
|
||||
//#define DXW_WINPROC_STACK_TRACING
|
||||
#define MAXWNDHSTACK 256
|
||||
|
||||
wndstack_entry *WhndStack;
|
||||
static int WhndTOS = 0;
|
||||
static int WhndSize = 0;
|
||||
|
||||
void WinDBInit()
|
||||
dxwWStack::dxwWStack()
|
||||
{
|
||||
WhndTOS = 0;
|
||||
WhndSize = MAXWNDHSTACK;
|
||||
WhndStack = (wndstack_entry *)malloc(WhndSize * sizeof(wndstack_entry));
|
||||
}
|
||||
|
||||
void WinDBPut(HWND hwnd, WNDPROC wndproc, int w, int h)
|
||||
dxwWStack::~dxwWStack()
|
||||
{
|
||||
}
|
||||
|
||||
void dxwWStack::Put(HWND hwnd, WNDPROC wndproc, int w, int h)
|
||||
{
|
||||
int StackIdx;
|
||||
|
||||
@ -66,7 +57,7 @@ void WinDBPut(HWND hwnd, WNDPROC wndproc, int w, int h)
|
||||
WhndTOS++;
|
||||
}
|
||||
|
||||
void WinDBPutProc(HWND hwnd, WNDPROC wndproc)
|
||||
void dxwWStack::PutProc(HWND hwnd, WNDPROC wndproc)
|
||||
{
|
||||
int StackIdx;
|
||||
|
||||
@ -94,7 +85,7 @@ void WinDBPutProc(HWND hwnd, WNDPROC wndproc)
|
||||
WhndTOS++;
|
||||
}
|
||||
|
||||
void WinDBPutSize(HWND hwnd, int w, int h)
|
||||
void dxwWStack::PutSize(HWND hwnd, int w, int h)
|
||||
{
|
||||
int StackIdx;
|
||||
|
||||
@ -119,7 +110,7 @@ void WinDBPutSize(HWND hwnd, int w, int h)
|
||||
WhndTOS++;
|
||||
}
|
||||
|
||||
BOOL WinDBGetSize(HWND hwnd, int *w, int *h)
|
||||
BOOL dxwWStack::GetSize(HWND hwnd, int *w, int *h)
|
||||
{
|
||||
int StackIdx;
|
||||
for(StackIdx=0; StackIdx<WhndTOS; StackIdx++) if (WhndStack[StackIdx].hwnd==hwnd) {
|
||||
@ -133,15 +124,16 @@ BOOL WinDBGetSize(HWND hwnd, int *w, int *h)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WNDPROC WinDBGetProc(HWND hwnd)
|
||||
WNDPROC dxwWStack::GetProc(HWND hwnd)
|
||||
{
|
||||
int StackIdx;
|
||||
//if(dxw.dwFlags6 & USEDEFWINDOWPROC) return pDefWindowProcA;
|
||||
//OutTraceDW("DEBUG: WNDPROC STACK pop hwnd=%x TOS=%d\n", hwnd, WhndTOS);
|
||||
for(StackIdx=0; StackIdx<WhndTOS; StackIdx++) {
|
||||
if (WhndStack[StackIdx].hwnd==hwnd) {
|
||||
//OutTraceDW("DEBUG: WNDPROC STACK pop hwnd=%x, wndproc=%x\n", hwnd, WhndStack[StackIdx].wndproc);
|
||||
return WhndStack[StackIdx].wndproc; // either a good value, or NULL
|
||||
}
|
||||
//OutTraceDW("DEBUG: WNDPROC STACK pop hwnd=%x, wndproc=%x\n", hwnd, WhndStack[StackIdx].wndproc);
|
||||
return WhndStack[StackIdx].wndproc; // either a good value, or NULL
|
||||
}
|
||||
}
|
||||
//OutTraceDW("DEBUG: WNDPROC STACK pop hwnd=%x, wndproc=NULL\n", hwnd);
|
||||
return NULL;
|
362
dll/gdi32.cpp
362
dll/gdi32.cpp
@ -23,13 +23,6 @@ static void Stopper(char *s, int line)
|
||||
#define STOPPER(s)
|
||||
#endif
|
||||
|
||||
/*
|
||||
dlg->m_DCEmulationMode = 0;
|
||||
if(t->flags2 & GDISTRETCHED) dlg->m_DCEmulationMode = 1;
|
||||
if(t->flags3 & GDIEMULATEDC) dlg->m_DCEmulationMode = 2;
|
||||
if(t->flags & MAPGDITOPRIMARY) dlg->m_DCEmulationMode = 3;
|
||||
*/
|
||||
|
||||
typedef BOOL (WINAPI *ExtTextOutW_Type)(HDC, int, int, UINT, const RECT *, LPCWSTR, UINT, const INT *);
|
||||
typedef BOOL (WINAPI *ExtTextOutA_Type)(HDC, int, int, UINT, const RECT *, LPCSTR, UINT, const INT *);
|
||||
BOOL WINAPI extExtTextOutW(HDC, int, int, UINT, const RECT *, LPCWSTR, UINT, const INT *);
|
||||
@ -155,19 +148,6 @@ static HookEntry_Type EmulateHooks[]={
|
||||
{HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator
|
||||
};
|
||||
|
||||
static HookEntry_Type DDHooks[]={
|
||||
{HOOK_IAT_CANDIDATE, "CreateCompatibleDC", (FARPROC)CreateCompatibleDC, (FARPROC *)&pGDICreateCompatibleDC, (FARPROC)extDDCreateCompatibleDC},
|
||||
{HOOK_IAT_CANDIDATE, "DeleteDC", (FARPROC)DeleteDC, (FARPROC *)&pGDIDeleteDC, (FARPROC)extDDDeleteDC},
|
||||
{HOOK_IAT_CANDIDATE, "CreateDCA", (FARPROC)CreateDCA, (FARPROC *)&pGDICreateDC, (FARPROC)extDDCreateDC},
|
||||
{HOOK_IAT_CANDIDATE, "BitBlt", (FARPROC)BitBlt, (FARPROC *)&pGDIBitBlt, (FARPROC)extDDBitBlt},
|
||||
{HOOK_IAT_CANDIDATE, "StretchBlt", (FARPROC)StretchBlt, (FARPROC *)&pGDIStretchBlt, (FARPROC)extDDStretchBlt},
|
||||
{HOOK_IAT_CANDIDATE, "GetClipBox", (FARPROC)NULL, (FARPROC *)&pGDIGetClipBox, (FARPROC)extGetClipBox},
|
||||
|
||||
// {HOOK_IAT_CANDIDATE, "PatBlt", (FARPROC)PatBlt, (FARPROC *)&pGDIPatBlt, (FARPROC)extDDPatBlt}, // missing one ...
|
||||
// {HOOK_IAT_CANDIDATE, "MaskBlt", (FARPROC)NULL, (FARPROC *)&pMaskBlt, (FARPROC)extDDMaskBlt}, // missing one ...
|
||||
{HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator
|
||||
};
|
||||
|
||||
static HookEntry_Type TextHooks[]={
|
||||
{HOOK_IAT_CANDIDATE, "CreateFontA", (FARPROC)CreateFont, (FARPROC *)&pGDICreateFont, (FARPROC)extCreateFont},
|
||||
{HOOK_IAT_CANDIDATE, "CreateFontIndirectA", (FARPROC)CreateFontIndirectA, (FARPROC *)&pGDICreateFontIndirect, (FARPROC)extCreateFontIndirect},
|
||||
@ -206,7 +186,7 @@ void HookGDI32Init()
|
||||
{
|
||||
HookLibInit(Hooks);
|
||||
HookLibInit(RemapHooks);
|
||||
HookLibInit(DDHooks);
|
||||
HookLibInit(ScaledHooks);
|
||||
HookLibInit(EmulateHooks);
|
||||
HookLibInit(TextHooks);
|
||||
HookLibInit(GammaHooks);
|
||||
@ -220,7 +200,6 @@ void HookGDI32(HMODULE module)
|
||||
if (dxw.dwFlags1 & CLIENTREMAPPING) HookLibrary(module, RemapHooks, libname);
|
||||
if (dxw.dwFlags2 & GDISTRETCHED) HookLibrary(module, ScaledHooks, libname);
|
||||
if (dxw.dwFlags3 & GDIEMULATEDC) HookLibrary(module, EmulateHooks, libname);
|
||||
if (dxw.dwFlags1 & MAPGDITOPRIMARY) HookLibrary(module, DDHooks, libname);
|
||||
if (dxw.dwFlags1 & FIXTEXTOUT) HookLibrary(module, TextHooks, libname);
|
||||
if (dxw.dwFlags2 & DISABLEGAMMARAMP) HookLibrary(module, GammaHooks, libname);
|
||||
// v2.02.33 - for "Stratego" compatibility option
|
||||
@ -237,7 +216,6 @@ FARPROC Remap_GDI32_ProcAddress(LPCSTR proc, HMODULE hModule)
|
||||
if (dxw.dwFlags1 & CLIENTREMAPPING) if(addr=RemapLibrary(proc, hModule, RemapHooks)) return addr;
|
||||
if (dxw.dwFlags2 & GDISTRETCHED) if (addr=RemapLibrary(proc, hModule, ScaledHooks)) return addr;
|
||||
if (dxw.dwFlags3 & GDIEMULATEDC) if (addr=RemapLibrary(proc, hModule, EmulateHooks)) return addr;
|
||||
if (dxw.dwFlags1 & MAPGDITOPRIMARY) if (addr=RemapLibrary(proc, hModule, DDHooks)) return addr;
|
||||
if (dxw.dwFlags1 & FIXTEXTOUT) if(addr=RemapLibrary(proc, hModule, TextHooks)) return addr;
|
||||
if (dxw.dwFlags2 & DISABLEGAMMARAMP) if(addr=RemapLibrary(proc, hModule, GammaHooks)) return addr;
|
||||
// v2.02.33 - for "Stratego" compatibility option
|
||||
@ -495,61 +473,6 @@ BOOL WINAPI extGDIRestoreDC(HDC hdc, int nSavedDC)
|
||||
// maps the GDI palette to the buffered DirectDraw one. This fixes the screen
|
||||
// output for "Dementia" (a.k.a. "Armed & Delirious").
|
||||
|
||||
HPALETTE WINAPI extGDICreatePalette(CONST LOGPALETTE *plpal)
|
||||
{
|
||||
HPALETTE ret;
|
||||
|
||||
OutTraceDW("GDI.CreatePalette: plpal=%x version=%x NumEntries=%d\n", plpal, plpal->palVersion, plpal->palNumEntries);
|
||||
if(IsDebug) dxw.DumpPalette(plpal->palNumEntries, (LPPALETTEENTRY)plpal->palPalEntry);
|
||||
ret=(*pGDICreatePalette)(plpal);
|
||||
OutTraceDW("GDI.CreatePalette: hPalette=%x\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HPALETTE hDesktopPalette=NULL;
|
||||
|
||||
HPALETTE WINAPI extSelectPalette(HDC hdc, HPALETTE hpal, BOOL bForceBackground)
|
||||
{
|
||||
HPALETTE ret;
|
||||
|
||||
if(hdc==dxw.RealHDC) hdc= dxw.VirtualHDC;
|
||||
|
||||
ret=(*pGDISelectPalette)(hdc, hpal, bForceBackground);
|
||||
OutTraceDW("GDI.SelectPalette: hdc=%x hpal=%x ForceBackground=%x ret=%x\n", hdc, hpal, bForceBackground, ret);
|
||||
if((OBJ_DC == GetObjectType(hdc)) && (dxw.dwFlags1 & EMULATESURFACE)){
|
||||
OutTraceDW("GDI.SelectPalette: register desktop palette hpal=%x\n", hpal);
|
||||
hDesktopPalette=hpal;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL WINAPI extAnimatePalette(HPALETTE hpal, UINT iStartIndex, UINT cEntries, const PALETTEENTRY *ppe)
|
||||
{
|
||||
// Invoked by "Pharaoh's Ascent 1.4"
|
||||
STOPPER("AnimatePalette");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
UINT WINAPI extRealizePalette(HDC hdc)
|
||||
{
|
||||
UINT ret;
|
||||
extern void mySetPalette(int, int, LPPALETTEENTRY);
|
||||
|
||||
OutTraceDW("GDI.RealizePalette: hdc=%x\n", hdc);
|
||||
if((OBJ_DC == GetObjectType(hdc)) && (dxw.dwFlags1 & EMULATESURFACE)){
|
||||
PALETTEENTRY PalEntries[256];
|
||||
UINT nEntries;
|
||||
nEntries=(*pGetPaletteEntries)(hDesktopPalette, 0, 256, PalEntries);
|
||||
mySetPalette(0, nEntries, PalEntries);
|
||||
if(IsDebug) dxw.DumpPalette(nEntries, PalEntries);
|
||||
ret=DD_OK;
|
||||
}
|
||||
else
|
||||
ret=(*pGDIRealizePalette)(hdc);
|
||||
OutTraceDW("GDI.RealizePalette: hdc=%x ret=%x\n", hdc, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// In emulated mode (when color depyth is 8BPP ?) it may happen that the game
|
||||
// expects to get the requested system palette entries, while the 32BPP screen
|
||||
// returns 0. "Mission Force Cyberstorm" is one of these. Returning the same
|
||||
@ -622,6 +545,61 @@ static PALETTEENTRY dp[256]={ // default palette, captured on my PC with video m
|
||||
{0x00,0x00,0xff,0x00},{0xff,0x00,0xff,0x00},{0x00,0xff,0xff,0x00},{0xff,0xff,0xff,0x00}
|
||||
};
|
||||
|
||||
HPALETTE WINAPI extGDICreatePalette(CONST LOGPALETTE *plpal)
|
||||
{
|
||||
HPALETTE ret;
|
||||
|
||||
OutTraceDW("GDI.CreatePalette: plpal=%x version=%x NumEntries=%d\n", plpal, plpal->palVersion, plpal->palNumEntries);
|
||||
if(IsDebug) dxw.DumpPalette(plpal->palNumEntries, (LPPALETTEENTRY)plpal->palPalEntry);
|
||||
ret=(*pGDICreatePalette)(plpal);
|
||||
OutTraceDW("GDI.CreatePalette: hPalette=%x\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HPALETTE hDesktopPalette=NULL;
|
||||
|
||||
HPALETTE WINAPI extSelectPalette(HDC hdc, HPALETTE hpal, BOOL bForceBackground)
|
||||
{
|
||||
HPALETTE ret;
|
||||
|
||||
if(hdc==dxw.RealHDC) hdc= dxw.VirtualHDC;
|
||||
|
||||
ret=(*pGDISelectPalette)(hdc, hpal, bForceBackground);
|
||||
OutTraceDW("GDI.SelectPalette: hdc=%x hpal=%x ForceBackground=%x ret=%x\n", hdc, hpal, bForceBackground, ret);
|
||||
if((OBJ_DC == GetObjectType(hdc)) && (dxw.dwFlags1 & EMULATESURFACE)){
|
||||
OutTraceDW("GDI.SelectPalette: register desktop palette hpal=%x\n", hpal);
|
||||
hDesktopPalette=hpal;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL WINAPI extAnimatePalette(HPALETTE hpal, UINT iStartIndex, UINT cEntries, const PALETTEENTRY *ppe)
|
||||
{
|
||||
// Invoked by "Pharaoh's Ascent 1.4"
|
||||
STOPPER("AnimatePalette");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
UINT WINAPI extRealizePalette(HDC hdc)
|
||||
{
|
||||
UINT ret;
|
||||
extern void mySetPalette(int, int, LPPALETTEENTRY);
|
||||
|
||||
OutTraceDW("GDI.RealizePalette: hdc=%x\n", hdc);
|
||||
if((OBJ_DC == GetObjectType(hdc)) && (dxw.dwFlags1 & EMULATESURFACE)){
|
||||
PALETTEENTRY PalEntries[256];
|
||||
UINT nEntries;
|
||||
nEntries=(*pGetPaletteEntries)(hDesktopPalette, 0, 256, PalEntries);
|
||||
mySetPalette(0, nEntries, PalEntries);
|
||||
if(IsDebug && nEntries) dxw.DumpPalette(nEntries, PalEntries);
|
||||
ret=nEntries;
|
||||
}
|
||||
else
|
||||
ret=(*pGDIRealizePalette)(hdc);
|
||||
OutTraceDW("GDI.RealizePalette: hdc=%x ret=%x\n", hdc, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
UINT WINAPI extGetSystemPaletteEntries(HDC hdc, UINT iStartIndex, UINT nEntries, LPPALETTEENTRY lppe)
|
||||
{
|
||||
int ret;
|
||||
@ -639,234 +617,6 @@ UINT WINAPI extGetSystemPaletteEntries(HDC hdc, UINT iStartIndex, UINT nEntries,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
// directdraw supported GDI calls
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
// PrimHDC: DC handle of the selected DirectDraw primary surface. NULL when invalid.
|
||||
extern HDC PrimHDC;
|
||||
|
||||
HDC WINAPI extDDCreateCompatibleDC(HDC hdc)
|
||||
{
|
||||
HDC RetHdc;
|
||||
extern GetDC_Type pGetDC;
|
||||
|
||||
OutTraceDW("GDI.CreateCompatibleDC: hdc=%x\n", hdc);
|
||||
|
||||
if(dxw.IsDesktop(WindowFromDC(hdc)) && dxw.IsFullScreen()) {
|
||||
dxw.SetPrimarySurface();
|
||||
if(!PrimHDC && dxw.lpDDSPrimary){
|
||||
HRESULT res;
|
||||
STOPPER("null PrimHDC");
|
||||
res=(*pGetDC)(dxw.lpDDSPrimary, &PrimHDC);
|
||||
if(res) OutTraceE("GDI.CreateCompatibleDC ERROR: GetDC lpdds=%x err=%d(%s) at %d\n", dxw.lpDDSPrimary, res, ExplainDDError(res), __LINE__);
|
||||
}
|
||||
OutTraceDW("GDI.CreateCompatibleDC: duplicating primary surface HDC lpDDSPrimary=%x SrcHdc=%x\n", dxw.lpDDSPrimary, PrimHDC);
|
||||
RetHdc=(*pGDICreateCompatibleDC)(PrimHDC);
|
||||
}
|
||||
else
|
||||
RetHdc=(*pGDICreateCompatibleDC)(hdc);
|
||||
|
||||
if(RetHdc)
|
||||
OutTraceDW("GDI.CreateCompatibleDC: returning HDC=%x\n", RetHdc);
|
||||
else
|
||||
OutTraceE("GDI.CreateCompatibleDC ERROR: err=%d at %d\n", GetLastError(), __LINE__);
|
||||
|
||||
return RetHdc;
|
||||
}
|
||||
|
||||
BOOL WINAPI extDDDeleteDC(HDC hdc)
|
||||
{
|
||||
BOOL res;
|
||||
|
||||
OutTraceDW("GDI.DeleteDC: hdc=%x\n", hdc);
|
||||
|
||||
res=(*pGDIDeleteDC)(hdc);
|
||||
if(!res) OutTraceE("GDI.DeleteDC: ERROR err=%d at %d\n", GetLastError(), __LINE__);
|
||||
return res;
|
||||
}
|
||||
|
||||
static HDC WINAPI winDDGetDC(HWND hwnd, char *api)
|
||||
{
|
||||
HDC hdc;
|
||||
HRESULT res;
|
||||
extern HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE, HDC FAR *);
|
||||
|
||||
OutTraceDW("%s: hwnd=%x\n", api, hwnd);
|
||||
|
||||
dxw.ResetPrimarySurface();
|
||||
dxw.SetPrimarySurface();
|
||||
if(dxw.IsRealDesktop(hwnd)) hwnd=dxw.GethWnd();
|
||||
|
||||
if(dxw.lpDDSPrimary){
|
||||
if (PrimHDC){
|
||||
OutTraceDW("%s: reusing primary hdc\n", api);
|
||||
(*pUnlockMethod(dxw.lpDDSPrimary))(dxw.lpDDSPrimary, NULL);
|
||||
hdc=PrimHDC;
|
||||
}
|
||||
else{
|
||||
OutTraceDW("%s: get hdc from PRIMARY surface lpdds=%x\n", api, dxw.lpDDSPrimary);
|
||||
res=extGetDC(dxw.lpDDSPrimary,&hdc);
|
||||
if(res) {
|
||||
OutTraceE("%s: GetDC(%x) ERROR %x(%s) at %d\n", api, dxw.lpDDSPrimary, res, ExplainDDError(res), __LINE__);
|
||||
if(res==DDERR_DCALREADYCREATED){
|
||||
// try recovery....
|
||||
(*pReleaseDC)(dxw.lpDDSPrimary,NULL);
|
||||
res=extGetDC(dxw.lpDDSPrimary,&hdc);
|
||||
}
|
||||
if(res)return 0;
|
||||
}
|
||||
PrimHDC=hdc;
|
||||
}
|
||||
}
|
||||
else {
|
||||
hdc=(*pGDIGetDC)(hwnd ? hwnd : dxw.GethWnd());
|
||||
OutTraceDW("%s: returning window DC handle hwnd=%x hdc=%x\n", api, hwnd, hdc);
|
||||
PrimHDC=NULL;
|
||||
}
|
||||
|
||||
if(hdc)
|
||||
OutTraceDW("%s: hwnd=%x hdc=%x\n", api, hwnd, hdc);
|
||||
else
|
||||
OutTraceE("%s: ERROR err=%d at %d\n", api, GetLastError, __LINE__);
|
||||
return(hdc);
|
||||
}
|
||||
|
||||
HDC WINAPI extDDCreateDC(LPSTR Driver, LPSTR Device, LPSTR Output, CONST DEVMODE *InitData)
|
||||
{
|
||||
HDC RetHDC;
|
||||
OutTraceDW("GDI.CreateDC: Driver=%s Device=%s Output=%s InitData=%x\n",
|
||||
Driver?Driver:"(NULL)", Device?Device:"(NULL)", Output?Output:"(NULL)", InitData);
|
||||
|
||||
if (!Driver || !strncmp(Driver,"DISPLAY",7)) {
|
||||
//HDC PrimHDC;
|
||||
LPDIRECTDRAWSURFACE lpdds;
|
||||
OutTraceDW("GDI.CreateDC: returning primary surface DC\n");
|
||||
lpdds=dxw.GetPrimarySurface();
|
||||
(*pGetDC)(lpdds, &PrimHDC);
|
||||
RetHDC=(*pGDICreateCompatibleDC)(PrimHDC);
|
||||
(*pReleaseDC)(lpdds, PrimHDC);
|
||||
}
|
||||
else{
|
||||
RetHDC=(*pGDICreateDC)(Driver, Device, Output, InitData);
|
||||
}
|
||||
if(RetHDC)
|
||||
OutTraceDW("GDI.CreateDC: returning HDC=%x\n", RetHDC);
|
||||
else
|
||||
OutTraceE("GDI.CreateDC ERROR: err=%d at %d\n", GetLastError(), __LINE__);
|
||||
return RetHDC;
|
||||
}
|
||||
|
||||
HDC WINAPI extDDGetDC(HWND hwnd)
|
||||
{
|
||||
HDC ret;
|
||||
ret=winDDGetDC(hwnd, "GDI.GetDC");
|
||||
return ret;
|
||||
}
|
||||
|
||||
HDC WINAPI extDDGetDCEx(HWND hwnd, HRGN hrgnClip, DWORD flags)
|
||||
{
|
||||
HDC ret;
|
||||
ret=winDDGetDC(hwnd, "GDI.GetDCEx");
|
||||
return ret;
|
||||
}
|
||||
|
||||
HDC WINAPI extDDGetWindowDC(HWND hwnd)
|
||||
{
|
||||
HDC ret;
|
||||
ret=winDDGetDC(hwnd, "GDI.GetWindowDC");
|
||||
return ret;
|
||||
}
|
||||
|
||||
int WINAPI extDDReleaseDC(HWND hwnd, HDC hDC)
|
||||
{
|
||||
int res;
|
||||
extern HRESULT WINAPI extReleaseDC(LPDIRECTDRAWSURFACE, HDC);
|
||||
|
||||
OutTraceDW("GDI.ReleaseDC(DD): hwnd=%x hdc=%x\n", hwnd, hDC);
|
||||
res=0;
|
||||
if ((hDC == PrimHDC) || (hwnd==0)){
|
||||
dxw.SetPrimarySurface();
|
||||
OutTraceDW("GDI.ReleaseDC(DD): refreshing primary surface lpdds=%x\n",dxw.lpDDSPrimary);
|
||||
if(!dxw.lpDDSPrimary) return 0;
|
||||
extReleaseDC(dxw.lpDDSPrimary, hDC);
|
||||
PrimHDC=NULL;
|
||||
res=1; // 1 = OK
|
||||
}
|
||||
else {
|
||||
res=(*pGDIReleaseDC)(hwnd, hDC);
|
||||
if (!res) OutTraceE("GDI.ReleaseDC: ERROR err=%d at %d\n", GetLastError(), __LINE__);
|
||||
}
|
||||
return(res);
|
||||
}
|
||||
|
||||
BOOL WINAPI extDDBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop)
|
||||
{
|
||||
BOOL ret;
|
||||
HRESULT res;
|
||||
extern HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE, HDC FAR *);
|
||||
|
||||
OutTraceDW("GDI.BitBlt(PRIMARY): HDC=%x nXDest=%d nYDest=%d nWidth=%d nHeight=%d hdcSrc=%x nXSrc=%d nYSrc=%d dwRop=%x(%s)\n",
|
||||
hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop, ExplainROP(dwRop));
|
||||
|
||||
ret=TRUE; // OK
|
||||
|
||||
if(dxw.IsDesktop(WindowFromDC(hdcDest))) {
|
||||
OutTrace("hdcDest=%x PrimHDC=%x\n", hdcDest, PrimHDC);
|
||||
hdcDest=PrimHDC;
|
||||
if(hdcDest==0) {
|
||||
dxw.ResetPrimarySurface();
|
||||
dxw.SetPrimarySurface();
|
||||
extGetDC(dxw.lpDDSPrimary, &PrimHDC);
|
||||
hdcDest=PrimHDC;
|
||||
}
|
||||
res=(*pGDIBitBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
|
||||
if(!res) OutTraceE("GDI.BitBlt: ERROR err=%d at %d\n", GetLastError(), __LINE__);
|
||||
dxw.ScreenRefresh();
|
||||
return ret;
|
||||
}
|
||||
|
||||
// proxy ...
|
||||
res=(*pGDIBitBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
|
||||
if(!res) OutTraceE("GDI.BitBlt: ERROR err=%d at %d\n", GetLastError(), __LINE__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL WINAPI extDDStretchBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,
|
||||
HDC hdcSrc, int nXSrc, int nYSrc, int nWSrc, int nHSrc, DWORD dwRop)
|
||||
{
|
||||
BOOL ret;
|
||||
RECT ClientRect;
|
||||
extern HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE, HDC FAR *);
|
||||
|
||||
OutTraceDW("GDI.StretchBlt: HDC=%x nXDest=%d nYDest=%d nWidth=%d nHeight=%d hdcSrc=%x nXSrc=%d nYSrc=%d nWSrc=%x nHSrc=%x dwRop=%x\n",
|
||||
hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, nWSrc, nHSrc, dwRop);
|
||||
|
||||
//if(dxw.IsDesktop(WindowFromDC(hdcDest))) {
|
||||
// hdcDest=PrimHDC;
|
||||
// if(hdcDest==0) {
|
||||
// dxw.ResetPrimarySurface();
|
||||
// dxw.SetPrimarySurface();
|
||||
// extGetDC(dxw.lpDDSPrimary, &PrimHDC);
|
||||
// hdcDest=PrimHDC;
|
||||
// }
|
||||
//}
|
||||
|
||||
if(hdcDest != hdcSrc){
|
||||
(*pGetClientRect)(dxw.GethWnd(),&ClientRect);
|
||||
ret=(*pGDIStretchBlt)(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, nWidth, nHeight, dwRop);
|
||||
if(!ret) {
|
||||
OutTraceE("GDI.StretchBlt: ERROR err=%d at %d\n", GetLastError(), __LINE__);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
//dxw.SetPrimarySurface();
|
||||
//OutTraceDW("GDI.StretchBlt: refreshing primary surface lpdds=%x\n",dxw.lpDDSPrimary);
|
||||
//sBlt("GDI.StretchBlt", dxw.lpDDSPrimary, NULL, dxw.lpDDSPrimary, NULL, 0, NULL, 0);
|
||||
//res=(*pUnlockMethod(dxw.lpDDSPrimary))(dxw.lpDDSPrimary, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HDC WINAPI extGDICreateDC(LPSTR Driver, LPSTR Device, LPSTR Output, CONST DEVMODE *InitData)
|
||||
{
|
||||
HDC WinHDC, RetHDC;
|
||||
|
@ -504,7 +504,7 @@ HRESULT WINAPI extDirect3DCreateDevice(GUID FAR *lpGUID, LPDIRECT3D lpd3ddevice,
|
||||
HRESULT res;
|
||||
|
||||
OutTraceD3D("Direct3DCreateDevice: guid=%x d3ddevice=%x dds=%x%s UnkOuter=%x\n",
|
||||
lpGUID, lpd3ddevice, surf, dxw.ExplainSurfaceRole(surf), pUnkOuter);
|
||||
lpGUID, lpd3ddevice, surf, dxwss.ExplainSurfaceRole(surf), pUnkOuter);
|
||||
res=(*pDirect3DCreateDevice)(lpGUID, lpd3ddevice, surf, lplpd3ddevice, pUnkOuter);
|
||||
if(res) OutTraceE("Direct3DCreateDevice ERROR: err=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
else OutTraceD3D("Direct3DCreateDevice: d3ddevice=%x\n", *lplpd3ddevice);
|
||||
@ -879,7 +879,7 @@ HRESULT WINAPI extCreateDevice2(void *lpd3d, REFCLSID Guid, LPDIRECTDRAWSURFACE
|
||||
HRESULT res;
|
||||
|
||||
OutTraceD3D("CreateDevice(D3D2): d3d=%x GUID=%x(%s) lpdds=%x%s\n",
|
||||
lpd3d, Guid.Data1, ExplainGUID((GUID *)&Guid), lpdds, dxw.ExplainSurfaceRole((LPDIRECTDRAWSURFACE)lpdds));
|
||||
lpd3d, Guid.Data1, ExplainGUID((GUID *)&Guid), lpdds, dxwss.ExplainSurfaceRole((LPDIRECTDRAWSURFACE)lpdds));
|
||||
res=(*pCreateDevice2)(lpd3d, Guid, lpdds, lplpd3dd);
|
||||
if(res) {
|
||||
OutTraceE("CreateDevice(D3D2) ERROR: err=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
@ -903,7 +903,7 @@ HRESULT WINAPI extCreateDevice3(void *lpd3d, REFCLSID Guid, LPDIRECTDRAWSURFACE4
|
||||
HRESULT res;
|
||||
|
||||
OutTraceD3D("CreateDevice(D3D3): d3d=%x GUID=%x(%s) lpdds=%x%s\n",
|
||||
lpd3d, Guid.Data1, ExplainGUID((GUID *)&Guid), lpdds, dxw.ExplainSurfaceRole((LPDIRECTDRAWSURFACE)lpdds));
|
||||
lpd3d, Guid.Data1, ExplainGUID((GUID *)&Guid), lpdds, dxwss.ExplainSurfaceRole((LPDIRECTDRAWSURFACE)lpdds));
|
||||
res=(*pCreateDevice3)(lpd3d, Guid, lpdds, lplpd3dd, unk);
|
||||
if(res) {
|
||||
OutTraceE("CreateDevice(D3D3) ERROR: err=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
@ -931,7 +931,7 @@ HRESULT WINAPI extCreateDevice7(void *lpd3d, REFCLSID Guid, LPDIRECTDRAWSURFACE7
|
||||
HRESULT res;
|
||||
|
||||
OutTraceD3D("CreateDevice(D3D7): d3d=%x GUID=%x(%s) lpdds=%x%s\n",
|
||||
lpd3d, Guid.Data1, ExplainGUID((GUID *)&Guid), lpdds, dxw.ExplainSurfaceRole((LPDIRECTDRAWSURFACE)lpdds));
|
||||
lpd3d, Guid.Data1, ExplainGUID((GUID *)&Guid), lpdds, dxwss.ExplainSurfaceRole((LPDIRECTDRAWSURFACE)lpdds));
|
||||
res=(*pCreateDevice7)(lpd3d, Guid, lpdds, lplpd3dd);
|
||||
if(res) {
|
||||
OutTraceE("CreateDevice(D3D7) ERROR: err=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
|
@ -27,6 +27,7 @@ void D3D8TextureHandling(void *arg, int Level)
|
||||
IDirect3DSurface8 *pSurfaceLevel;
|
||||
D3DSURFACE_DESC Desc;
|
||||
D3DLOCKED_RECT LockedRect;
|
||||
//OutTrace("D3D8TextureHandling: arg=%x level=%d\n", (DWORD)arg, Level);
|
||||
if(res=lpd3dtex->GetSurfaceLevel(Level, &pSurfaceLevel)){
|
||||
OutTraceE("Texture::GetSurfaceLevel ERROR: res=%d(%s)\n", res, ExplainDDError(res));
|
||||
return;
|
||||
|
@ -27,15 +27,16 @@ void D3D9TextureHandling(void *arg, int Level)
|
||||
IDirect3DSurface9 *pSurfaceLevel;
|
||||
D3DSURFACE_DESC Desc;
|
||||
D3DLOCKED_RECT LockedRect;
|
||||
//OutTrace("D3D9TextureHandling: arg=%x level=%d\n", (DWORD)arg, Level);
|
||||
if(res=lpd3dtex->GetSurfaceLevel(Level, &pSurfaceLevel)){
|
||||
OutTraceE("Texture::GetSurfaceLevel ERROR: res=%d(%s)\n", res, ExplainDDError(res));
|
||||
return;
|
||||
}
|
||||
pSurfaceLevel->Release();
|
||||
if(res=lpd3dtex->GetLevelDesc(Level, &Desc)){
|
||||
OutTraceE("Texture::GetLevelDesc ERROR: res=%d(%s)\n", res, ExplainDDError(res));
|
||||
return;
|
||||
}
|
||||
pSurfaceLevel->Release();
|
||||
switch(Desc.Type){
|
||||
case D3DRTYPE_SURFACE:
|
||||
case D3DRTYPE_TEXTURE:
|
||||
|
@ -355,7 +355,8 @@ DXWEXTERN CoUninitialize_Type pCoUninitialize DXWINITIALIZED;
|
||||
|
||||
// user32.dll:
|
||||
DXWEXTERN BeginPaint_Type pBeginPaint DXWINITIALIZED;
|
||||
DXWEXTERN CallWindowProc_Type pCallWindowProc DXWINITIALIZED;
|
||||
DXWEXTERN CallWindowProc_Type pCallWindowProcA DXWINITIALIZED;
|
||||
DXWEXTERN CallWindowProc_Type pCallWindowProcW DXWINITIALIZED;
|
||||
DXWEXTERN ChangeDisplaySettingsA_Type pChangeDisplaySettingsA DXWINITIALIZED;
|
||||
DXWEXTERN ChangeDisplaySettingsExA_Type pChangeDisplaySettingsExA DXWINITIALIZED;
|
||||
DXWEXTERN ChangeDisplaySettingsW_Type pChangeDisplaySettingsW DXWINITIALIZED;
|
||||
@ -466,15 +467,12 @@ extern BOOL WINAPI extImmGetOpenStatus(HIMC);
|
||||
extern BOOL WINAPI extGDIBitBlt(HDC, int, int, int, int, HDC, int, int, DWORD);
|
||||
extern HDC WINAPI extGDICreateCompatibleDC(HDC);
|
||||
extern HDC WINAPI extEMUCreateCompatibleDC(HDC);
|
||||
extern HDC WINAPI extDDCreateCompatibleDC(HDC);
|
||||
extern HDC WINAPI extGDICreateDC(LPSTR, LPSTR, LPSTR, CONST DEVMODE *);
|
||||
extern HDC WINAPI extDDCreateDC(LPSTR, LPSTR, LPSTR, CONST DEVMODE *);
|
||||
extern HFONT WINAPI extCreateFont(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCTSTR);
|
||||
extern HFONT WINAPI extCreateFontIndirect(const LOGFONT*);
|
||||
extern HPALETTE WINAPI extGDICreatePalette(CONST LOGPALETTE *);
|
||||
extern HDWP WINAPI extDeferWindowPos(HDWP, HWND, HWND, int, int, int, int, UINT);
|
||||
extern BOOL WINAPI extGDIDeleteDC(HDC);
|
||||
extern BOOL WINAPI extDDDeleteDC(HDC);
|
||||
extern int WINAPI extGetClipBox(HDC, LPRECT);
|
||||
extern int WINAPI extGetRgnBox(HRGN, LPRECT);
|
||||
extern DWORD WINAPI extGetRegionData(HRGN, DWORD, LPRGNDATA);
|
||||
@ -483,7 +481,6 @@ extern BOOL WINAPI extGetDeviceGammaRamp(HDC, LPVOID);
|
||||
extern UINT WINAPI extGetSystemPaletteEntries(HDC, UINT, UINT, LPPALETTEENTRY);
|
||||
extern BOOL WINAPI extGDIPatBlt(HDC, int, int, int, int, DWORD);
|
||||
extern BOOL WINAPI extPolyline(HDC, const POINT *, int);
|
||||
extern BOOL WINAPI extDDBitBlt(HDC, int, int, int, int, HDC, int, int, DWORD);
|
||||
extern UINT WINAPI extRealizePalette(HDC);
|
||||
extern BOOL WINAPI extRectangle(HDC, int, int, int, int);
|
||||
extern BOOL WINAPI extGDIRestoreDC(HDC, int);
|
||||
@ -493,7 +490,6 @@ extern HPALETTE WINAPI extSelectPalette(HDC, HPALETTE, BOOL);
|
||||
extern BOOL WINAPI extSetDeviceGammaRamp(HDC, LPVOID);
|
||||
extern BOOL WINAPI extGDIStretchBlt(HDC, int, int, int, int, HDC, int, int, int, int, DWORD);
|
||||
extern int WINAPI extStretchDIBits(HDC, int, int, int, int, int, int, int, int, const VOID *, const BITMAPINFO *, UINT, DWORD);
|
||||
extern BOOL WINAPI extDDStretchBlt(HDC, int, int, int, int, HDC, int, int, int, int, DWORD);
|
||||
extern BOOL WINAPI extTextOutA(HDC, int, int, LPCTSTR, int);
|
||||
extern BOOL WINAPI extPolyBezierTo(HDC, const POINT *, DWORD);
|
||||
extern BOOL WINAPI extPolylineTo(HDC, const POINT *, DWORD);
|
||||
@ -571,8 +567,8 @@ extern void STDAPICALLTYPE extCoUninitialize(void);
|
||||
|
||||
// user32.dll:
|
||||
extern HDC WINAPI extBeginPaint(HWND, LPPAINTSTRUCT);
|
||||
extern HDC WINAPI extDDBeginPaint(HWND, LPPAINTSTRUCT);
|
||||
extern LRESULT WINAPI extCallWindowProc(WNDPROC, HWND, UINT, WPARAM, LPARAM);
|
||||
extern LRESULT WINAPI extCallWindowProcA(WNDPROC, HWND, UINT, WPARAM, LPARAM);
|
||||
extern LRESULT WINAPI extCallWindowProcW(WNDPROC, HWND, UINT, WPARAM, LPARAM);
|
||||
extern LONG WINAPI extChangeDisplaySettingsA(DEVMODEA *, DWORD);
|
||||
extern LONG WINAPI extChangeDisplaySettingsExA(LPCTSTR, DEVMODEA *, HWND, DWORD, LPVOID);
|
||||
extern LONG WINAPI extChangeDisplaySettingsW(DEVMODEW *, DWORD);
|
||||
@ -588,7 +584,6 @@ extern LRESULT WINAPI extDefWindowProcW(HWND, UINT, WPARAM, LPARAM);
|
||||
extern int WINAPI extDrawTextA(HDC, LPCTSTR, int, LPRECT, UINT);
|
||||
extern int WINAPI extDrawTextExA(HDC, LPTSTR, int, LPRECT, UINT, LPDRAWTEXTPARAMS);
|
||||
extern BOOL WINAPI extEndPaint(HWND, const PAINTSTRUCT *);
|
||||
extern BOOL WINAPI extDDEndPaint(HWND, const PAINTSTRUCT *);
|
||||
extern LONG WINAPI extEnumDisplaySettings(LPCTSTR, DWORD, DEVMODE *);
|
||||
extern int WINAPI extFillRect(HDC, const RECT *, HBRUSH);
|
||||
extern int WINAPI extFrameRect(HDC, const RECT *, HBRUSH);
|
||||
@ -597,7 +592,6 @@ extern BOOL WINAPI extGetClipCursor(LPRECT);
|
||||
extern BOOL WINAPI extGetCursorPos(LPPOINT);
|
||||
extern HDC WINAPI extGDIGetDC(HWND);
|
||||
extern HDC WINAPI extEMUGetDC(HWND);
|
||||
extern HDC WINAPI extDDGetDC(HWND);
|
||||
extern HWND WINAPI extGetDesktopWindow(void);
|
||||
extern BOOL WINAPI extGetMonitorInfoA(HMONITOR, LPMONITORINFO);
|
||||
extern BOOL WINAPI extGetMonitorInfoW(HMONITOR, LPMONITORINFO);
|
||||
@ -605,12 +599,10 @@ extern int WINAPI extGetSystemMetrics(int);
|
||||
extern HWND WINAPI extGetTopWindow(HWND);
|
||||
extern int WINAPI extGetUpdateRgn(HWND, HRGN, BOOL);
|
||||
extern HDC WINAPI extGDIGetWindowDC(HWND);
|
||||
extern HDC WINAPI extDDGetWindowDC(HWND);
|
||||
extern LONG WINAPI extGetWindowLongA(HWND, int);
|
||||
extern LONG WINAPI extGetWindowLongW(HWND, int);
|
||||
extern BOOL WINAPI extGetWindowRect(HWND, LPRECT);
|
||||
extern BOOL WINAPI extInvalidateRect(HWND, RECT *, BOOL);
|
||||
//extern BOOL WINAPI extDDInvalidateRect(HWND, RECT *, BOOL);
|
||||
extern int WINAPI extMapWindowPoints(HWND, HWND, LPPOINT, UINT);
|
||||
extern BOOL WINAPI extMoveWindow(HWND, int, int, int, int, BOOL);
|
||||
extern BOOL WINAPI extPeekMessage(LPMSG, HWND, UINT, UINT, UINT);
|
||||
@ -618,7 +610,6 @@ extern BOOL WINAPI extRedrawWindow(HWND, const RECT *, HRGN, UINT);
|
||||
extern ATOM WINAPI extRegisterClassExA(WNDCLASSEXA *);
|
||||
extern ATOM WINAPI extRegisterClassA(WNDCLASSA *);
|
||||
extern int WINAPI extGDIReleaseDC(HWND, HDC);
|
||||
extern int WINAPI extDDReleaseDC(HWND, HDC);
|
||||
extern BOOL WINAPI extScreenToClient(HWND, LPPOINT);
|
||||
extern LRESULT WINAPI extSendMessageA(HWND, UINT, WPARAM, LPARAM);
|
||||
extern LRESULT WINAPI extSendMessageW(HWND, UINT, WPARAM, LPARAM);
|
||||
@ -635,7 +626,6 @@ extern BOOL WINAPI extDestroyWindow(HWND);
|
||||
extern BOOL WINAPI extCloseWindow(HWND);
|
||||
extern BOOL WINAPI extSetSysColors(int, const INT *, const COLORREF *);
|
||||
extern HDC WINAPI extGDIGetDCEx(HWND, HRGN, DWORD);
|
||||
extern HDC WINAPI extDDGetDCEx(HWND, HRGN, DWORD);
|
||||
extern BOOL WINAPI extUpdateWindow(HWND);
|
||||
extern BOOL WINAPI extGetWindowPlacement(HWND, WINDOWPLACEMENT *);
|
||||
extern BOOL WINAPI extSetWindowPlacement(HWND, WINDOWPLACEMENT *);
|
||||
|
189
dll/user32.cpp
189
dll/user32.cpp
@ -17,7 +17,6 @@
|
||||
BOOL IsChangeDisplaySettingsHotPatched = FALSE;
|
||||
#define GDIMODE_STRETCHED 0
|
||||
#define GDIMODE_EMULATED 1
|
||||
#define GDIMODE_DIRECTDRAW 2
|
||||
int GDIEmulationMode = 0;
|
||||
|
||||
//typedef BOOL (WINAPI *ValidateRect_Type)(HWND, const RECT *);
|
||||
@ -154,18 +153,6 @@ static HookEntry_Type ScaledHooks[]={
|
||||
{HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator
|
||||
};
|
||||
|
||||
static HookEntry_Type DDHooks[]={
|
||||
{HOOK_IAT_CANDIDATE, "BeginPaint", (FARPROC)BeginPaint, (FARPROC *)&pBeginPaint, (FARPROC)extDDBeginPaint},
|
||||
//{HOOK_IAT_CANDIDATE, "BeginPaint", (FARPROC)BeginPaint, (FARPROC *)&pBeginPaint, (FARPROC)extBeginPaint},
|
||||
{HOOK_IAT_CANDIDATE, "EndPaint", (FARPROC)EndPaint, (FARPROC *)&pEndPaint, (FARPROC)extDDEndPaint},
|
||||
{HOOK_IAT_CANDIDATE, "GetDC", (FARPROC)GetDC, (FARPROC *)&pGDIGetDC, (FARPROC)extDDGetDC},
|
||||
{HOOK_IAT_CANDIDATE, "GetDCEx", (FARPROC)GetDCEx, (FARPROC *)&pGDIGetDCEx, (FARPROC)extDDGetDCEx},
|
||||
{HOOK_IAT_CANDIDATE, "GetWindowDC", (FARPROC)GetWindowDC, (FARPROC *)&pGDIGetWindowDC, (FARPROC)extDDGetDC},
|
||||
{HOOK_IAT_CANDIDATE, "ReleaseDC", (FARPROC)ReleaseDC, (FARPROC *)&pGDIReleaseDC, (FARPROC)extDDReleaseDC},
|
||||
{HOOK_IAT_CANDIDATE, "InvalidateRect", (FARPROC)InvalidateRect, (FARPROC *)&pInvalidateRect, (FARPROC)extInvalidateRect},
|
||||
{HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator
|
||||
};
|
||||
|
||||
static HookEntry_Type RemapHooks[]={
|
||||
{HOOK_IAT_CANDIDATE, "ScreenToClient", (FARPROC)ScreenToClient, (FARPROC *)&pScreenToClient, (FARPROC)extScreenToClient},
|
||||
{HOOK_IAT_CANDIDATE, "ClientToScreen", (FARPROC)ClientToScreen, (FARPROC *)&pClientToScreen, (FARPROC)extClientToScreen},
|
||||
@ -198,7 +185,8 @@ static HookEntry_Type WinHooks[]={
|
||||
{HOOK_HOT_CANDIDATE, "ShowWindow", (FARPROC)ShowWindow, (FARPROC *)&pShowWindow, (FARPROC)extShowWindow},
|
||||
{HOOK_HOT_CANDIDATE, "SetWindowPos", (FARPROC)SetWindowPos, (FARPROC *)&pSetWindowPos, (FARPROC)extSetWindowPos},
|
||||
{HOOK_HOT_CANDIDATE, "DeferWindowPos", (FARPROC)DeferWindowPos, (FARPROC *)&pGDIDeferWindowPos, (FARPROC)extDeferWindowPos},
|
||||
{HOOK_HOT_CANDIDATE, "CallWindowProcA", (FARPROC)CallWindowProcA, (FARPROC *)&pCallWindowProc, (FARPROC)extCallWindowProc},
|
||||
{HOOK_HOT_CANDIDATE, "CallWindowProcA", (FARPROC)CallWindowProcA, (FARPROC *)&pCallWindowProcA, (FARPROC)extCallWindowProcA},
|
||||
{HOOK_HOT_CANDIDATE, "CallWindowProcW", (FARPROC)CallWindowProcW, (FARPROC *)&pCallWindowProcW, (FARPROC)extCallWindowProcW},
|
||||
{HOOK_IAT_CANDIDATE, 0, NULL, 0, 0} // terminator
|
||||
};
|
||||
|
||||
@ -221,8 +209,7 @@ FARPROC Remap_user32_ProcAddress(LPCSTR proc, HMODULE hModule)
|
||||
|
||||
if (dxw.dwFlags2 & GDISTRETCHED) if (addr=RemapLibrary(proc, hModule, ScaledHooks)) return addr;
|
||||
if (dxw.dwFlags3 & GDIEMULATEDC) if (addr=RemapLibrary(proc, hModule, EmulateHooks)) return addr;
|
||||
if (dxw.dwFlags1 & MAPGDITOPRIMARY) if (addr=RemapLibrary(proc, hModule, DDHooks)) return addr;
|
||||
if (!(dxw.dwFlags2 & GDISTRETCHED) && !(dxw.dwFlags3 & GDIEMULATEDC) && !(dxw.dwFlags1 & MAPGDITOPRIMARY))
|
||||
if (!(dxw.dwFlags2 & GDISTRETCHED) && !(dxw.dwFlags3 & GDIEMULATEDC))
|
||||
if (addr=RemapLibrary(proc, hModule, NoGDIHooks)) return addr;
|
||||
|
||||
if (dxw.dwFlags1 & MODIFYMOUSE) if (addr=RemapLibrary(proc, hModule, MouseHooks)) return addr;
|
||||
@ -245,14 +232,12 @@ void HookUser32(HMODULE hModule)
|
||||
GDIEmulationMode = GDIMODE_STRETCHED; // default
|
||||
if (dxw.dwFlags2 & GDISTRETCHED) GDIEmulationMode = GDIMODE_STRETCHED;
|
||||
if (dxw.dwFlags3 & GDIEMULATEDC) GDIEmulationMode = GDIMODE_EMULATED;
|
||||
if (dxw.dwFlags1 & MAPGDITOPRIMARY) GDIEmulationMode = GDIMODE_DIRECTDRAW;
|
||||
|
||||
HookLibrary(hModule, Hooks, libname);
|
||||
if (!(dxw.dwFlags2 & GDISTRETCHED) && !(dxw.dwFlags3 & GDIEMULATEDC) && !(dxw.dwFlags1 & MAPGDITOPRIMARY))
|
||||
if (!(dxw.dwFlags2 & GDISTRETCHED) && !(dxw.dwFlags3 & GDIEMULATEDC))
|
||||
HookLibrary(hModule, NoGDIHooks, libname);
|
||||
if (dxw.dwFlags3 & GDIEMULATEDC) HookLibrary(hModule, EmulateHooks, libname);
|
||||
if (dxw.dwFlags2 & GDISTRETCHED) HookLibrary(hModule, ScaledHooks, libname);
|
||||
if (dxw.dwFlags1 & MAPGDITOPRIMARY) HookLibrary(hModule, DDHooks, libname);
|
||||
|
||||
if (dxw.dwFlags1 & CLIENTREMAPPING) HookLibrary(hModule, RemapHooks, libname);
|
||||
if (dxw.dwFlags1 & MODIFYMOUSE) HookLibrary(hModule, MouseHooks, libname);
|
||||
@ -268,7 +253,8 @@ void HookUser32(HMODULE hModule)
|
||||
void HookUser32Init()
|
||||
{
|
||||
HookLibInit(Hooks);
|
||||
HookLibInit(DDHooks);
|
||||
HookLibInit(ScaledHooks);
|
||||
HookLibInit(EmulateHooks);
|
||||
HookLibInit(RemapHooks);
|
||||
HookLibInit(MouseHooks);
|
||||
HookLibInit(WinHooks);
|
||||
@ -631,7 +617,7 @@ LONG WINAPI extGetWindowLong(GetWindowLong_Type pGetWindowLong, char *ApiName, H
|
||||
|
||||
if((nIndex==GWL_WNDPROC)||(nIndex==DWL_DLGPROC)){
|
||||
WNDPROC wp;
|
||||
wp=WinDBGetProc(hwnd);
|
||||
wp=dxwws.GetProc(hwnd);
|
||||
OutTraceDW("%s: remapping WindowProc res=%x -> %x\n", ApiName, res, (LONG)wp);
|
||||
if(wp) res=(LONG)wp; // if not found, don't alter the value.
|
||||
}
|
||||
@ -709,8 +695,8 @@ LONG WINAPI extSetWindowLong(HWND hwnd, int nIndex, LONG dwNewLong, SetWindowLon
|
||||
if((OldProc==extWindowProc) ||
|
||||
(OldProc==extChildWindowProc)||
|
||||
(OldProc==extDialogWindowProc))
|
||||
OldProc=WinDBGetProc(hwnd);
|
||||
WinDBPutProc(hwnd, (WNDPROC)dwNewLong);
|
||||
OldProc=dxwws.GetProc(hwnd);
|
||||
dxwws.PutProc(hwnd, (WNDPROC)dwNewLong);
|
||||
res=(LONG)OldProc;
|
||||
SetLastError(0);
|
||||
lres=(WNDPROC)(*pSetWindowLongA)(hwnd, nIndex, (LONG)extWindowProc);
|
||||
@ -1089,7 +1075,7 @@ BOOL WINAPI extGetClientRect(HWND hwnd, LPRECT lpRect)
|
||||
if (dxw.IsFullScreen()){
|
||||
int w, h;
|
||||
if(FIXCHILDSIZE){
|
||||
if(WinDBGetSize(hwnd, &w, &h)){
|
||||
if(dxwws.GetSize(hwnd, &w, &h)){
|
||||
lpRect->top=lpRect->left=0;
|
||||
lpRect->right=w;
|
||||
lpRect->bottom=h;
|
||||
@ -1275,7 +1261,7 @@ static void HookChildWndProc(HWND hwnd, DWORD dwStyle, LPCTSTR ApiName)
|
||||
{
|
||||
// child window inherit the father's windproc, so if it's redirected to
|
||||
// a hooker (either extWindowProc or extChildWindowProc) you have to retrieve
|
||||
// the correct value (WinDBGetProc) before saving it (WinDBPutProc).
|
||||
// the correct value (dxwws.GetProc) before saving it (dxwws.PutProc).
|
||||
long res;
|
||||
WNDPROC pWindowProc;
|
||||
|
||||
@ -1286,13 +1272,13 @@ static void HookChildWndProc(HWND hwnd, DWORD dwStyle, LPCTSTR ApiName)
|
||||
HWND Father;
|
||||
WNDPROC pFatherProc;
|
||||
Father=GetParent(hwnd);
|
||||
pFatherProc=WinDBGetProc(Father);
|
||||
pFatherProc=dxwws.GetProc(Father);
|
||||
OutTraceDW("%s: WndProc=%s father=%x WndProc=%x\n", ApiName,
|
||||
(pWindowProc == extWindowProc) ? "extWindowProc" : ((pWindowProc == extChildWindowProc) ? "extChildWindowProc" : "extDialogWindowProc"),
|
||||
Father, pFatherProc);
|
||||
pWindowProc = pFatherProc;
|
||||
}
|
||||
WinDBPutProc(hwnd, pWindowProc);
|
||||
dxwws.PutProc(hwnd, pWindowProc);
|
||||
if(dwStyle & WS_CHILD){
|
||||
OutTraceDW("%s: Hooking CHILD hwnd=%x father WindowProc %x->%x\n", ApiName, hwnd, pWindowProc, extChildWindowProc);
|
||||
res=(*pSetWindowLongA)(hwnd, GWL_WNDPROC, (LONG)extChildWindowProc);
|
||||
@ -1502,7 +1488,7 @@ static HWND WINAPI extCreateWindowCommon(
|
||||
HookChildWndProc(hwnd, dwStyle, ApiName);
|
||||
|
||||
if ((FIXCHILDSIZE) && (dwStyle & (WS_CHILD|WS_DLGFRAME)))
|
||||
WinDBPutSize(hwnd, iOrigW, iOrigH);
|
||||
dxwws.PutSize(hwnd, iOrigW, iOrigH);
|
||||
|
||||
// "Hoyle Casino Empire" needs to be in a maximized state to continue after the intro movie.
|
||||
// Sending a SW_MAXIMIZE message intercepted by the PREVENTMAXIMIZE handling fixes the problem.
|
||||
@ -1606,16 +1592,30 @@ HWND WINAPI extCreateWindowExA(
|
||||
return extCreateWindowCommon("CreateWindowExA", FALSE, dwExStyle, (void *)lpClassName, (void *)lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
|
||||
}
|
||||
|
||||
LRESULT WINAPI extCallWindowProc(WNDPROC lpPrevWndFunc, HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT WINAPI extCallWindowProcA(WNDPROC lpPrevWndFunc, HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// v2.02.30: fix (Imperialism II): apply to main window only !!!
|
||||
HRESULT res;
|
||||
|
||||
res = -1;
|
||||
if(hwnd == dxw.GethWnd()) res=FixWindowProc("CallWindowProc", hwnd, Msg, wParam, &lParam);
|
||||
if(hwnd == dxw.GethWnd()) res=FixWindowProc("CallWindowProcA", hwnd, Msg, wParam, &lParam);
|
||||
|
||||
if (res==(HRESULT)-1)
|
||||
return (*pCallWindowProc)(lpPrevWndFunc, hwnd, Msg, wParam, lParam);
|
||||
return (*pCallWindowProcA)(lpPrevWndFunc, hwnd, Msg, wParam, lParam);
|
||||
else
|
||||
return res;
|
||||
}
|
||||
|
||||
LRESULT WINAPI extCallWindowProcW(WNDPROC lpPrevWndFunc, HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// v2.02.30: fix (Imperialism II): apply to main window only !!!
|
||||
HRESULT res;
|
||||
|
||||
res = -1;
|
||||
if(hwnd == dxw.GethWnd()) res=FixWindowProc("CallWindowProcW", hwnd, Msg, wParam, &lParam);
|
||||
|
||||
if (res==(HRESULT)-1)
|
||||
return (*pCallWindowProcW)(lpPrevWndFunc, hwnd, Msg, wParam, lParam);
|
||||
else
|
||||
return res;
|
||||
}
|
||||
@ -1910,16 +1910,9 @@ static HDC WINAPI sGetDC(HWND hwnd, char *ApiName)
|
||||
if(bFlippedDC) {
|
||||
extern HDC hFlippedDC;
|
||||
LPDIRECTDRAWSURFACE lpDDSPrim;
|
||||
lpDDSPrim = dxw.GetPrimarySurface();
|
||||
#if 0
|
||||
// v2.03.20: beware, from this release the output from dxw.GetPrimarySurface() could be a
|
||||
// zero reference counter released surface that could be used to feed a QueryInterface method,
|
||||
// but would crash if used otherwise.
|
||||
__try {(*pGetDC)(lpDDSPrim, &hFlippedDC);} __except(EXCEPTION_EXECUTE_HANDLER){hFlippedDC=NULL;};
|
||||
#else
|
||||
lpDDSPrim = dxwss.GetPrimarySurface();
|
||||
if (lpDDSPrim) (*pGetDC)(lpDDSPrim, &hFlippedDC);
|
||||
#endif
|
||||
OutTraceDW("%s: remapping flipped GDI hdc=%x\n", ApiName, hFlippedDC);
|
||||
OutTraceDW("%s: remapping flipped GDI lpDDSPrim=%x hdc=%x\n", ApiName, lpDDSPrim, hFlippedDC);
|
||||
if(hFlippedDC) return hFlippedDC;
|
||||
}
|
||||
#endif
|
||||
@ -1932,8 +1925,6 @@ static HDC WINAPI sGetDC(HWND hwnd, char *ApiName)
|
||||
ret=dxw.AcquireEmulatedDC(lochwnd);
|
||||
dxw.VirtualHDC=ret;
|
||||
break;
|
||||
case GDIMODE_DIRECTDRAW:
|
||||
break;
|
||||
}
|
||||
|
||||
if(ret){
|
||||
@ -1996,7 +1987,7 @@ int WINAPI extGDIReleaseDC(HWND hwnd, HDC hDC)
|
||||
if(bFlippedDC && (hDC == hFlippedDC)) {
|
||||
HRESULT ret;
|
||||
OutTraceDW("GDI.ReleaseDC: releasing flipped GDI hdc=%x\n", hDC);
|
||||
ret=(*pReleaseDC)(dxw.GetPrimarySurface(), hDC);
|
||||
ret=(*pReleaseDC)(dxwss.GetPrimarySurface(), hDC);
|
||||
if (ret) OutTraceE("GDI.ReleaseDC ERROR: err=%x(%s) at %d\n", ret, ExplainDDError(ret), __LINE__);
|
||||
else dxw.ScreenRefresh();
|
||||
return (ret == DD_OK);
|
||||
@ -2013,8 +2004,6 @@ int WINAPI extGDIReleaseDC(HWND hwnd, HDC hDC)
|
||||
res=dxw.ReleaseEmulatedDC(hwnd);
|
||||
res=(*pGDIReleaseDC)(hwnd, windc);
|
||||
break;
|
||||
case GDIMODE_DIRECTDRAW:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!res) OutTraceE("GDI.ReleaseDC ERROR: err=%d at %d\n", GetLastError(), __LINE__);
|
||||
@ -2047,15 +2036,6 @@ HDC WINAPI extBeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint)
|
||||
lpPaint->hdc=EmuHDC;
|
||||
hdc = EmuHDC;
|
||||
break;
|
||||
case GDIMODE_DIRECTDRAW:
|
||||
(*pGDIReleaseDC)(hwnd, lpPaint->hdc);
|
||||
(*pGetDC)(dxw.lpDDSPrimary,&PrimHDC);
|
||||
lpPaint->hdc=PrimHDC;
|
||||
// resize the paint area to virtual screen size (see CivIII clipped panels...)
|
||||
lpPaint->rcPaint=dxw.GetScreenRect();
|
||||
OutTraceDW("GDI.BeginPaint(MAPGDITOPRIMARY): hdc=%x -> %x\n", hdc, PrimHDC);
|
||||
hdc = PrimHDC;
|
||||
break;
|
||||
}
|
||||
|
||||
OutTraceDW("GDI.BeginPaint: hdc=%x rcPaint=(%d,%d)-(%d,%d)\n",
|
||||
@ -2063,53 +2043,6 @@ HDC WINAPI extBeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint)
|
||||
return hdc;
|
||||
}
|
||||
|
||||
HDC WINAPI extDDBeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint)
|
||||
{
|
||||
HDC hdc;
|
||||
extern HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE, HDC FAR *);
|
||||
|
||||
OutTraceDW("GDI.BeginPaint: hwnd=%x%s lpPaint=%x FullScreen=%x\n",
|
||||
hwnd, dxw.IsDesktop(hwnd)?"(DESKTOP)":"", lpPaint, dxw.IsFullScreen());
|
||||
|
||||
if(dxw.IsDesktop(hwnd)) hwnd=dxw.GethWnd();
|
||||
|
||||
hdc=(*pBeginPaint)(hwnd, lpPaint);
|
||||
|
||||
// if not in fullscreen mode, that's all!
|
||||
if(!dxw.IsFullScreen()) return hdc;
|
||||
|
||||
// on MAPGDITOPRIMARY, return the PrimHDC handle instead of the window DC
|
||||
// if a primary surface has not been created yet, do it
|
||||
if(!pGetDC || !dxw.lpDDSPrimary){
|
||||
extern HRESULT WINAPI extDirectDrawCreate(GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *);
|
||||
HRESULT res;
|
||||
LPDIRECTDRAW lpDD;
|
||||
LPDIRECTDRAWSURFACE lpDDS;
|
||||
DDSURFACEDESC ddsd;
|
||||
res=extDirectDrawCreate(0, &lpDD, NULL);
|
||||
//res=extDirectDrawCreate((GUID *)&IID_IDirectDraw, &lpDD, NULL);
|
||||
lpDD->SetCooperativeLevel(dxw.GethWnd(), DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
|
||||
//lpDD->SetCooperativeLevel(dxw.GethWnd(), DDSCL_NORMAL);
|
||||
memset((void *)&ddsd, 0, sizeof(DDSURFACEDESC));
|
||||
ddsd.dwSize = sizeof(DDSURFACEDESC);
|
||||
ddsd.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
||||
ddsd.dwHeight = dxw.GetScreenHeight();
|
||||
ddsd.dwWidth = dxw.GetScreenWidth();
|
||||
res=lpDD->CreateSurface(&ddsd, &lpDDS, NULL);
|
||||
dxw.lpDDSPrimary = lpDDS;
|
||||
OutTraceDW("GDI.BeginPaint(MAPGDITOPRIMARY): dd=%x ddsPrim=%x\n", lpDD, lpDDS);
|
||||
}
|
||||
|
||||
extGetDC(dxw.lpDDSPrimary,&PrimHDC);
|
||||
lpPaint->hdc=PrimHDC;
|
||||
// resize the paint area to virtual screen size (see CivIII clipped panels...)
|
||||
lpPaint->rcPaint=dxw.GetScreenRect();
|
||||
|
||||
OutTraceDW("GDI.BeginPaint(MAPGDITOPRIMARY): hdc=%x -> %x\n", hdc, PrimHDC);
|
||||
return PrimHDC;
|
||||
}
|
||||
|
||||
BOOL WINAPI extEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint)
|
||||
{
|
||||
BOOL ret;
|
||||
@ -2133,8 +2066,6 @@ BOOL WINAPI extEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint)
|
||||
case GDIMODE_EMULATED:
|
||||
ret=dxw.ReleaseEmulatedDC(hwnd);
|
||||
break;
|
||||
case GDIMODE_DIRECTDRAW:
|
||||
break;
|
||||
}
|
||||
|
||||
if(ret)
|
||||
@ -2145,54 +2076,6 @@ BOOL WINAPI extEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint)
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL WINAPI extDDEndPaint(HWND hwnd, const PAINTSTRUCT *lpPaint)
|
||||
{
|
||||
BOOL ret;
|
||||
extern HRESULT WINAPI extReleaseDC(LPDIRECTDRAWSURFACE lpdds, HDC FAR hdc);
|
||||
extern HRESULT WINAPI extGetDC(LPDIRECTDRAWSURFACE, HDC FAR *);
|
||||
extern HRESULT WINAPI extBlt(LPDIRECTDRAWSURFACE lpdds, LPRECT lpdestrect, LPDIRECTDRAWSURFACE lpddssrc, LPRECT lpsrcrect, DWORD dwflags, LPDDBLTFX lpddbltfx);
|
||||
|
||||
OutTraceDW("GDI.EndPaint(DD): hwnd=%x%s lpPaint=%x lpPaint.hdc=%x\n",
|
||||
hwnd, dxw.IsDesktop(hwnd)?"(DESKTOP)":"", lpPaint, lpPaint->hdc);
|
||||
|
||||
// v2.02.53 ...
|
||||
//if(dxw.IsFullScreen() && dxw.IsDesktop(hwnd)){
|
||||
if(dxw.IsFullScreen()){
|
||||
RECT Rect;
|
||||
LPRECT lpRect;
|
||||
ret=(*pEndPaint)(hwnd, lpPaint);
|
||||
dxw.lpDDSPrimary->Unlock(NULL);
|
||||
//dxw.ScreenRefresh();
|
||||
if(dxw.IsDesktop(hwnd))
|
||||
lpRect=NULL;
|
||||
else{
|
||||
#if 1
|
||||
POINT p={0,0};
|
||||
lpRect=&Rect;
|
||||
(*pGetClientRect)(hwnd, lpRect);
|
||||
p=dxw.ClientOffset(hwnd);
|
||||
lpRect->left += p.x;
|
||||
lpRect->right += p.x;
|
||||
lpRect->top += p.y;
|
||||
lpRect->bottom += p.y;
|
||||
//dxw.AddCoordinates(lpRect, p);
|
||||
dxw.UnmapClient(lpRect);
|
||||
#else
|
||||
lpRect=&Rect;
|
||||
Rect = dxw.MapClientRect(lpRect);
|
||||
#endif
|
||||
}
|
||||
extBlt(dxw.lpDDSPrimary, lpRect, dxw.lpDDSPrimary, NULL, 0, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// proxy part ...
|
||||
ret=(*pEndPaint)(hwnd, lpPaint);
|
||||
OutTraceDW("GDI.EndPaint: hwnd=%x ret=%x\n", hwnd, ret);
|
||||
if(!ret) OutTraceE("GDI.EndPaint ERROR: err=%d at %d\n", GetLastError(), __LINE__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HWND WINAPI extCreateDialogIndirectParam(HINSTANCE hInstance, LPCDLGTEMPLATE lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM lParamInit)
|
||||
{
|
||||
HWND RetHWND;
|
||||
@ -2204,7 +2087,7 @@ HWND WINAPI extCreateDialogIndirectParam(HINSTANCE hInstance, LPCDLGTEMPLATE lpT
|
||||
|
||||
// v2.02.73: redirect lpDialogFunc only when it is nor NULL
|
||||
if(lpDialogFunc) {
|
||||
WinDBPutProc(RetHWND, (WNDPROC)lpDialogFunc);
|
||||
dxwws.PutProc(RetHWND, (WNDPROC)lpDialogFunc);
|
||||
if(!(*pSetWindowLongA)(RetHWND, DWL_DLGPROC, (LONG)extDialogWindowProc))
|
||||
OutTraceE("SetWindowLong: ERROR err=%d at %d\n", GetLastError(), __LINE__);
|
||||
}
|
||||
@ -2226,7 +2109,7 @@ HWND WINAPI extCreateDialogParam(HINSTANCE hInstance, LPCTSTR lpTemplateName, HW
|
||||
|
||||
// v2.02.73: redirect lpDialogFunc only when it is nor NULL: fix for "LEGO Stunt Rally"
|
||||
if(lpDialogFunc) {
|
||||
WinDBPutProc(RetHWND, (WNDPROC)lpDialogFunc);
|
||||
dxwws.PutProc(RetHWND, (WNDPROC)lpDialogFunc);
|
||||
if(!(*pSetWindowLongA)(RetHWND, DWL_DLGPROC, (LONG)extDialogWindowProc))
|
||||
OutTraceE("SetWindowLong: ERROR err=%d at %d\n", GetLastError(), __LINE__);
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -204,7 +204,7 @@ static void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
|
||||
case 0: break;
|
||||
case 1: t->flags2 |= GDISTRETCHED; break;
|
||||
case 2: t->flags3 |= GDIEMULATEDC; break;
|
||||
case 3: t->flags |= MAPGDITOPRIMARY; break;
|
||||
//case 3: t->flags |= MAPGDITOPRIMARY; break;
|
||||
}
|
||||
|
||||
switch(dlg->m_ResTypes){
|
||||
@ -428,7 +428,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
|
||||
dlg->m_DCEmulationMode = 0;
|
||||
if(t->flags2 & GDISTRETCHED) dlg->m_DCEmulationMode = 1;
|
||||
if(t->flags3 & GDIEMULATEDC) dlg->m_DCEmulationMode = 2;
|
||||
if(t->flags & MAPGDITOPRIMARY) dlg->m_DCEmulationMode = 3;
|
||||
//if(t->flags & MAPGDITOPRIMARY) dlg->m_DCEmulationMode = 3;
|
||||
|
||||
dlg->m_ResTypes = 0;
|
||||
if(t->flags4 & SUPPORTSVGA) dlg->m_ResTypes = 0;
|
||||
|
BIN
host/resource
BIN
host/resource
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user