diff --git a/build/dxwnd.dll b/build/dxwnd.dll index 8850703..e037b01 100644 --- a/build/dxwnd.dll +++ b/build/dxwnd.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7f096da2bcb539a443b930cc06ca3814a98394da357dcc2817a7ffa431bb5faa -size 459776 +oid sha256:f6f6dffdd6c64dfb4fca9318b394132c66ec7a1070122c384b78e0a8a52c45e2 +size 461824 diff --git a/build/dxwnd.exe b/build/dxwnd.exe index 56379f4..9b2e702 100644 --- a/build/dxwnd.exe +++ b/build/dxwnd.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4ccfe97f2a4ee32296cfaae398fe767a22f26d620ba7065c0cbc7a078eb2d459 +oid sha256:84004748b9ed3c04e7d2d8101220a505a229bc299211e587a74ffd89cc85e154 size 535552 diff --git a/build/dxwnd.ini b/build/dxwnd.ini index 9af460b..0ee1d17 100644 --- a/build/dxwnd.ini +++ b/build/dxwnd.ini @@ -1181,9 +1181,9 @@ opengllib47= ver47=0 coord47=0 flag47=134234148 -flagg47=-939523840 +flagg47=1207959808 flagh47=20 -flagi47=16 +flagi47=384 tflag47=2 initx47=0 inity47=0 @@ -3459,7 +3459,7 @@ flag138=679493664 flagg138=1208025088 flagh138=65556 flagi138=4 -tflag138=6147 +tflag138=6403 initx138=0 inity138=0 minx138=0 @@ -3481,9 +3481,9 @@ opengllib139= ver139=8 coord139=0 flag139=687867937 -flagg139=1208025104 +flagg139=134283280 flagh139=65556 -flagi139=12 +flagi139=204 tflag139=4097 initx139=0 inity139=0 @@ -3504,12 +3504,12 @@ path140=D:\Games\Incoming and Incoming Forces\Incoming\incoming.exe module140= opengllib140= ver140=7 -coord140=2 +coord140=0 flag140=150994976 -flagg140=1207959568 -flagh140=20 -flagi140=4 -tflag140=1024 +flagg140=1208025104 +flagh140=-2147483628 +flagi140=67820 +tflag140=6163 initx140=0 inity140=0 minx140=0 @@ -3549,17 +3549,17 @@ maxfps141=0 initts141=0 winver141=0 maxres141=-1 -title142=CIsland.exe -path142=D:\Games\ChaosIsland\CIsland.exe +title142=Armored Fist 3 +path142=D:\Games\Armored Fist 3\Af3.exe module142= opengllib142= ver142=0 coord142=0 -flag142=134218272 -flagg142=1207959552 -flagh142=20 -flagi142=4 -tflag142=6147 +flag142=134217763 +flagg142=1208025088 +flagh142=6291476 +flagi142=14 +tflag142=64 initx142=0 inity142=0 minx142=0 @@ -3574,14 +3574,133 @@ maxfps142=0 initts142=0 winver142=0 maxres142=-1 -title143=Incoming (GOG) +title143=Earthworm Jim 3D module143= opengllib143= -title144=Incoming Forces (GOG) +title144=Echelon module144= opengllib144= +path143=D:\Games\Earthworm Jim 3D\EarthwormJim3D.exe +ver143=0 +coord143=0 +flag143=134217760 +flagg143=1212219392 +flagh143=65556 +flagi143=12 +tflag143=6211 +initx143=0 +inity143=0 +minx143=0 +miny143=0 +maxx143=0 +maxy143=0 +posx143=50 +posy143=50 +sizx143=800 +sizy143=600 +maxfps143=0 +initts143=2 +winver143=1 +maxres143=-1 +path144=D:\Games\echelon\Game.exe +ver144=0 +coord144=0 +flag144=151011328 +flagg144=-2013265920 +flagh144=20 +flagi144=132 +tflag144=0 +initx144=0 +inity144=0 +minx144=0 +miny144=0 +maxx144=0 +maxy144=0 +posx144=50 +posy144=50 +sizx144=800 +sizy144=600 +maxfps144=0 +initts144=0 +winver144=0 +maxres144=-1 +title145=Total Soccer 2000 (DirectX) +path145=D:\Games\Total Soccer 2000\SOCCERDX.EXE +module145= +opengllib145= +ver145=1 +coord145=0 +flag145=134234146 +flagg145=134283520 +flagh145=20 +flagi145=12 +tflag145=5249 +initx145=0 +inity145=0 +minx145=0 +miny145=0 +maxx145=0 +maxy145=0 +posx145=50 +posy145=50 +sizx145=800 +sizy145=600 +maxfps145=0 +initts145=2 +winver145=0 +maxres145=-1 +title146=Total Soccer 2000 (3DFX) +path146=D:\Games\Total Soccer 2000\soccer3dfx.exe +module146= +opengllib146= +ver146=9 +coord146=0 +flag146=134234657 +flagg146=1208025344 +flagh146=20 +flagi146=12 +tflag146=5121 +initx146=0 +inity146=0 +minx146=0 +miny146=0 +maxx146=0 +maxy146=0 +posx146=50 +posy146=50 +sizx146=800 +sizy146=600 +maxfps146=0 +initts146=2 +winver146=0 +maxres146=-1 +title147=Gruntz +path147=D:\Games\gruntz\GRUNTZ.EXE +module147= +opengllib147= +ver147=0 +coord147=0 +flag147=134235680 +flagg147=1207959560 +flagh147=67108884 +flagi147=4 +tflag147=6419 +initx147=0 +inity147=0 +minx147=0 +miny147=0 +maxx147=0 +maxy147=0 +posx147=0 +posy147=0 +sizx147=800 +sizy147=600 +maxfps147=0 +initts147=0 +winver147=0 +maxres147=-1 [window] -posx=1161 -posy=364 +posx=1010 +posy=145 sizx=638 sizy=618 diff --git a/build/exports/Armored Fist 3.dxw b/build/exports/Armored Fist 3.dxw new file mode 100644 index 0000000..b2238c9 --- /dev/null +++ b/build/exports/Armored Fist 3.dxw @@ -0,0 +1,26 @@ +[target] +title0=Armored Fist 3 +path0=D:\Games\Armored Fist 3\Af3.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134218272 +flagg0=1207959552 +flagh0=20 +flagi0=6 +tflag0=64 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 diff --git a/build/exports/Dune 2000 (not emulated).dxw b/build/exports/Dune 2000 (not emulated).dxw new file mode 100644 index 0000000..0435be3 --- /dev/null +++ b/build/exports/Dune 2000 (not emulated).dxw @@ -0,0 +1,26 @@ +[target] +title0=Dune 2000 +path0=D:\Games\Dune 2000\DUNE2000.DAT +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=671105312 +flagg0=1207959568 +flagh0=20 +flagi0=4 +tflag0=64 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 diff --git a/build/exports/Earthworm Jim 3D.dxw b/build/exports/Earthworm Jim 3D.dxw new file mode 100644 index 0000000..06a6bfc --- /dev/null +++ b/build/exports/Earthworm Jim 3D.dxw @@ -0,0 +1,26 @@ +[target] +title0=Earthworm Jim 3D +path0=D:\Games\Earthworm Jim 3D\EarthwormJim3D.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134217760 +flagg0=1212153856 +flagh0=65556 +flagi0=4 +tflag0=6211 +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=1 +maxres0=-1 diff --git a/build/exports/Echelon.dxw b/build/exports/Echelon.dxw new file mode 100644 index 0000000..956cf80 --- /dev/null +++ b/build/exports/Echelon.dxw @@ -0,0 +1,26 @@ +[target] +title0=Echelon +path0=D:\Games\echelon\Game.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=151011328 +flagg0=134217728 +flagh0=20 +flagi0=4 +tflag0=0 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 diff --git a/build/exports/Geneforge.dxw b/build/exports/Geneforge.dxw new file mode 100644 index 0000000..7953689 --- /dev/null +++ b/build/exports/Geneforge.dxw @@ -0,0 +1,26 @@ +[target] +title0=Geneforge +path0=d:\games\Geneforge\Geneforge.exe +module0= +opengllib0= +ver0=0 +coord0=0 +flag0=134234628 +flagg0=1207959808 +flagh0=20 +flagi0=4 +tflag0=64 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=0 +winver0=0 +maxres0=-1 diff --git a/build/exports/Total Soccer 2000 (3DFX).dxw b/build/exports/Total Soccer 2000 (3DFX).dxw new file mode 100644 index 0000000..a16ee5d --- /dev/null +++ b/build/exports/Total Soccer 2000 (3DFX).dxw @@ -0,0 +1,26 @@ +[target] +title0=Total Soccer 2000 (3DFX) +path0=D:\Games\Total Soccer 2000\soccer3dfx.exe +module0= +opengllib0= +ver0=9 +coord0=0 +flag0=134234657 +flagg0=1208025344 +flagh0=20 +flagi0=67596 +tflag0=5121 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=2 +winver0=0 +maxres0=-1 diff --git a/build/exports/Total Soccer 2000 (DirectX).dxw b/build/exports/Total Soccer 2000 (DirectX).dxw new file mode 100644 index 0000000..454c0eb --- /dev/null +++ b/build/exports/Total Soccer 2000 (DirectX).dxw @@ -0,0 +1,26 @@ +[target] +title0=Total Soccer 2000 (DirectX) +path0=D:\Games\Total Soccer 2000\SOCCERDX.EXE +module0= +opengllib0= +ver0=1 +coord0=0 +flag0=134234656 +flagg0=1208025344 +flagh0=20 +flagi0=12 +tflag0=5249 +initx0=0 +inity0=0 +minx0=0 +miny0=0 +maxx0=0 +maxy0=0 +posx0=50 +posy0=50 +sizx0=800 +sizy0=600 +maxfps0=0 +initts0=2 +winver0=0 +maxres0=-1 diff --git a/build/readme-relnotes.txt b/build/readme-relnotes.txt index 34966fe..4c8e459 100644 --- a/build/readme-relnotes.txt +++ b/build/readme-relnotes.txt @@ -398,7 +398,10 @@ minor fixes on logging v2.02.59 fixed IDIrectDraw reference counter for ddraw release 1 session: fixes "Warhammer 40K Rites Of War" first screen -fixed QueryPerformanceCounter handling: fixes "New Yourk Racer" time stretching problems - +fixed QueryPerformanceCounter handling: fixes "New York Racer" time stretching problems +v2.02.60 +fixed time stretching to handle Total Soccer 2000 +fixed ZBUFFER surface creation to handle GOG Incoming troubles on some cards +fixed handling of special effects (wireframe, no fogging, zbuffer always) to be valid on all d3d versions diff --git a/dll/ddraw.cpp b/dll/ddraw.cpp index 05180b0..18fdd56 100644 --- a/dll/ddraw.cpp +++ b/dll/ddraw.cpp @@ -1320,19 +1320,36 @@ static void MaskCapsD(LPDDCAPS c1, LPDDCAPS c2) OutTraceDW("MaskCaps\n"); capfile=fopen("dxwnd.cap", "r"); if(!capfile) return; - while(TRUE){ - if(fscanf(capfile, "%s=%x", token, &val)!=2) break; - if(!strcmp(token, "dwCaps")) c1->dwCaps &= val; - if(!strcmp(token, "dwCaps2")) c1->dwCaps2 &= val; - if(!strcmp(token, "dwCKeyCaps")) c1->dwCKeyCaps &= val; - if(!strcmp(token, "dwFXCaps")) c1->dwFXCaps &= val; + if(c1) { + while(TRUE){ + if(fscanf(capfile, "%s=%x", token, &val)!=2) break; + if(!strcmp(token, "dwCaps")) c1->dwCaps &= val; + if(!strcmp(token, "dwCaps2")) c1->dwCaps2 &= val; + if(!strcmp(token, "dwCKeyCaps")) c1->dwCKeyCaps &= val; + if(!strcmp(token, "dwFXCaps")) c1->dwFXCaps &= val; + } + OutTraceDW("MaskCaps(D-HW): caps=%x(%s) caps2=%x(%s) fxcaps=%x(%s) fxalphacaps=%x(%s) keycaps=%x(%s)\n", + c1->dwCaps, ExplainDDDCaps(c1->dwCaps), + c1->dwCaps2, ExplainDDDCaps2(c1->dwCaps2), + c1->dwFXCaps, ExplainDDFXCaps(c1->dwFXCaps), + c1->dwFXAlphaCaps, ExplainDDFXALPHACaps(c1->dwFXAlphaCaps), + c1->dwCKeyCaps, ExplainDDCKeyCaps(c1->dwCKeyCaps)); } - OutTraceDW("MaskCaps(D-HW): caps=%x(%s) caps2=%x(%s) fxcaps=%x(%s) fxalphacaps=%x(%s) keycaps=%x(%s)\n", - c1->dwCaps, ExplainDDDCaps(c1->dwCaps), - c1->dwCaps2, ExplainDDDCaps2(c1->dwCaps2), - c1->dwFXCaps, ExplainDDFXCaps(c1->dwFXCaps), - c1->dwFXAlphaCaps, ExplainDDFXALPHACaps(c1->dwFXAlphaCaps), - c1->dwCKeyCaps, ExplainDDCKeyCaps(c1->dwCKeyCaps)); + if(c2) { + while(TRUE){ + if(fscanf(capfile, "%s=%x", token, &val)!=2) break; + if(!strcmp(token, "dwCaps")) c2->dwCaps &= val; + if(!strcmp(token, "dwCaps2")) c2->dwCaps2 &= val; + if(!strcmp(token, "dwCKeyCaps")) c2->dwCKeyCaps &= val; + if(!strcmp(token, "dwFXCaps")) c2->dwFXCaps &= val; + } + OutTraceDW("MaskCaps(D-HW): caps=%x(%s) caps2=%x(%s) fxcaps=%x(%s) fxalphacaps=%x(%s) keycaps=%x(%s)\n", + c2->dwCaps, ExplainDDDCaps(c2->dwCaps), + c2->dwCaps2, ExplainDDDCaps2(c2->dwCaps2), + c2->dwFXCaps, ExplainDDFXCaps(c2->dwFXCaps), + c2->dwFXAlphaCaps, ExplainDDFXALPHACaps(c2->dwFXAlphaCaps), + c2->dwCKeyCaps, ExplainDDCKeyCaps(c2->dwCKeyCaps)); + } fclose(capfile); } @@ -1380,7 +1397,7 @@ HRESULT WINAPI extGetCapsD(LPDIRECTDRAW lpdd, LPDDCAPS c1, LPDDCAPS c2) //c1->dwFXAlphaCaps=AlphaCaps; } - if((dxw.dwFlags3 & CAPMASK) && c1 && c2) MaskCapsD(c1, c2); + if(dxw.dwFlags3 & CAPMASK) MaskCapsD(c1, c2); return res; } @@ -2551,7 +2568,8 @@ static HRESULT BuildGenericDir(LPDIRECTDRAW lpdd, CreateSurface_Type pCreateSurf res = (*pCreateSurface)(lpdd, lpddsd, lplpdds, 0); if(res){ - if ((dxw.dwFlags1 & SWITCHVIDEOMEMORY) && (res==DDERR_OUTOFVIDEOMEMORY)){ + // v2.02.60: Ref. game Incoming GOG release, post by Marek, error DDERR_UNSUPPORTED while trying to create ZBUFFER surface + if ((dxw.dwFlags1 & SWITCHVIDEOMEMORY) && ((res==DDERR_OUTOFVIDEOMEMORY)||(res==DDERR_UNSUPPORTED))){ OutTraceDW("CreateSurface ERROR: res=%x(%s) at %d, retry\n", res, ExplainDDError(res), __LINE__); lpddsd->ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY; lpddsd->ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; @@ -4564,9 +4582,17 @@ HRESULT WINAPI extDDGetGammaRamp(LPDIRECTDRAWSURFACE lpdds, DWORD dwFlags, LPDDG HRESULT WINAPI extGetAvailableVidMem(LPDIRECTDRAW lpdd, LPDDSCAPS lpDDSCaps, LPDWORD lpdwTotal, LPDWORD lpdwFree, GetAvailableVidMem_Type pGetAvailableVidMem) { HRESULT res; + const DWORD dwMaxMem = 0x7FFFF000; OutTraceDDRAW("GetAvailableVidMem(D): lpdd=%x\n", lpdd); res=(*pGetAvailableVidMem)(lpdd, lpDDSCaps, lpdwTotal, lpdwFree); if(res){ + if((dxw.dwFlags3 & FORCESHEL) && (res==DDERR_NODIRECTDRAWHW)){ + // fake some video memory.... + OutTraceDW("GetAvailableVidMem(D): FORCESHEL mode Total=Free=%x\n", dwMaxMem); + *lpdwTotal = dwMaxMem; + *lpdwFree = dwMaxMem; + return DD_OK; + } OutTraceE("GetAvailableVidMem(D): ERROR res=%x(%s)\n", res, ExplainDDError(res)); } else { @@ -4574,7 +4600,6 @@ HRESULT WINAPI extDDGetGammaRamp(LPDIRECTDRAWSURFACE lpdds, DWORD dwFlags, LPDDG *lpDDSCaps, ExplainDDSCaps(lpDDSCaps->dwCaps), lpdwTotal?*lpdwTotal:0, lpdwFree?*lpdwFree:0); if(dxw.dwFlags2 & LIMITRESOURCES){ // check for memory value overflow - see "Mageslayer" and "Take no Prisoners" DWORD dwLocalTotal; - const DWORD dwMaxMem = 0x7FFFF000; if(lpdwTotal == NULL) { lpdwTotal = &dwLocalTotal; // point to usable memory.... res=(*pGetAvailableVidMem)(lpdd, lpDDSCaps, lpdwTotal, lpdwFree); // do it again to get total memory diff --git a/dll/dxwcore.cpp b/dll/dxwcore.cpp index 9a1946c..f1742f3 100644 --- a/dll/dxwcore.cpp +++ b/dll/dxwcore.cpp @@ -884,7 +884,13 @@ DWORD dxwCore::GetTickCount(void) static DWORD dwLastRealTick=0; static DWORD dwLastFakeTick=0; DWORD dwNextRealTick; + BOOL FirstTime = TRUE; + if(FirstTime){ + dwLastRealTick=(*pGetTickCount)(); + dwLastFakeTick=dwLastRealTick; + FirstTime=FALSE; + } dwNextRealTick=(*pGetTickCount)(); dwTick=(dwNextRealTick-dwLastRealTick); TimeShift=GetHookInfo()->TimeShift; @@ -910,9 +916,13 @@ DWORD dxwCore::StretchCounter(DWORD dwTimer) LARGE_INTEGER dxwCore::StretchCounter(LARGE_INTEGER dwTimer) { + static int Reminder = 0; + LARGE_INTEGER ret; TimeShift=GetHookInfo()->TimeShift; - dwTimer = TimeShifter64(dwTimer, TimeShift); - return dwTimer; + dwTimer.QuadPart += Reminder; + ret = TimeShifter64(dwTimer, TimeShift); + Reminder = (ret.QuadPart==0) ? dwTimer.LowPart : 0; + return ret; } void dxwCore::GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) diff --git a/dll/dxwnd.cpp b/dll/dxwnd.cpp index f043e94..8f2c2ca 100644 --- a/dll/dxwnd.cpp +++ b/dll/dxwnd.cpp @@ -24,7 +24,7 @@ along with this program. If not, see . #include "dxwnd.h" #include "dxwcore.hpp" -#define VERSION "2.02.59" +#define VERSION "2.02.60" #define DDTHREADLOCK 1 diff --git a/dll/dxwnd.vs2008.suo b/dll/dxwnd.vs2008.suo index 68bd8e7..7cf4258 100644 Binary files a/dll/dxwnd.vs2008.suo and b/dll/dxwnd.vs2008.suo differ diff --git a/dll/hd3d.cpp b/dll/hd3d.cpp index 0ef3618..66b4e2a 100644 --- a/dll/hd3d.cpp +++ b/dll/hd3d.cpp @@ -40,6 +40,11 @@ typedef void (WINAPI *GetGammaRamp_Type)(void *, UINT, D3DGAMMARAMP *); typedef void (WINAPI *SetCursorPosition9_Type)(void *, int, int, DWORD); typedef void (WINAPI *SetCursorPosition8_Type)(void *, int, int, DWORD); +//typedef ULONG (WINAPI *CreateRenderTarget8_Type)(void *, UINT, UINT, D3DFORMAT, D3DMULTISAMPLE_TYPE, BOOL, IDirect3DSurface8**); +typedef ULONG (WINAPI *CreateRenderTarget8_Type)(void *, UINT, UINT, D3DFORMAT, D3DMULTISAMPLE_TYPE, BOOL, void**); +typedef ULONG (WINAPI *BeginScene_Type)(void *); +typedef ULONG (WINAPI *EndScene_Type)(void *); + typedef HRESULT (WINAPI *D3D10CreateDevice_Type)(IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT, UINT, ID3D10Device **); typedef HRESULT (WINAPI *D3D10CreateDeviceAndSwapChain_Type)(IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT, UINT, DXGI_SWAP_CHAIN_DESC *, IDXGISwapChain **, ID3D10Device **); typedef HRESULT (WINAPI *D3D10CreateDevice1_Type)(IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT, D3D10_FEATURE_LEVEL1, UINT, ID3D10Device **); @@ -88,6 +93,13 @@ ULONG WINAPI extAddRef9(void *); ULONG WINAPI extRelease9(void *); BOOL WINAPI voidDisableD3DSpy(void); +//ULONG WINAPI extCreateRenderTarget8(void *, UINT, UINT, D3DFORMAT, D3DMULTISAMPLE_TYPE, BOOL, IDirect3DSurface8**); +ULONG WINAPI extCreateRenderTarget8(void *, UINT, UINT, D3DFORMAT, D3DMULTISAMPLE_TYPE, BOOL, void**); +ULONG WINAPI extBeginScene8(void *); +ULONG WINAPI extEndScene8(void *); +ULONG WINAPI extBeginScene9(void *); +ULONG WINAPI extEndScene9(void *); + HRESULT WINAPI extD3D10CreateDevice(IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT, UINT, ID3D10Device **); @@ -135,6 +147,12 @@ GetGammaRamp_Type pGetGammaRamp = 0; SetCursorPosition9_Type pSetCursorPosition9 = 0; SetCursorPosition8_Type pSetCursorPosition8 = 0; +CreateRenderTarget8_Type pCreateRenderTarget8 = 0; +BeginScene_Type pBeginScene8 = 0; +EndScene_Type pEndScene8 = 0; +BeginScene_Type pBeginScene9 = 0; +EndScene_Type pEndScene9 = 0; + D3D10CreateDevice_Type pD3D10CreateDevice = 0; D3D10CreateDeviceAndSwapChain_Type pD3D10CreateDeviceAndSwapChain = 0; D3D10CreateDevice1_Type pD3D10CreateDevice1 = 0; @@ -468,11 +486,20 @@ void HookD3DDevice8(void** ppD3Ddev8) SetHook((void *)(**(DWORD **)ppD3Ddev8 + 72), extSetGammaRamp, (void **)&pSetGammaRamp, "SetGammaRamp(D8)"); SetHook((void *)(**(DWORD **)ppD3Ddev8 + 76), extGetGammaRamp, (void **)&pGetGammaRamp, "GetGammaRamp(D8)"); } - if(dxw.dwFlags2 & WIREFRAME){ + SetHook((void *)(**(DWORD **)ppD3Ddev8 + 100), extCreateRenderTarget8, (void **)&pCreateRenderTarget8, "CreateRenderTarget(D8)"); + SetHook((void *)(**(DWORD **)ppD3Ddev8 + 136), extBeginScene8, (void **)&pBeginScene8, "BeginScene(D8)"); + SetHook((void *)(**(DWORD **)ppD3Ddev8 + 140), extEndScene8, (void **)&pEndScene8, "EndScene(D8)"); + if((dxw.dwFlags2 & WIREFRAME) || (dxw.dwFlags4 & DISABLEFOGGING) || (dxw.dwFlags4 & ZBUFFERALWAYS)){ SetHook((void *)(**(DWORD **)ppD3Ddev8 + 200), extSetRenderState, (void **)&pSetRenderState, "SetRenderState(D8)"); SetHook((void *)(**(DWORD **)ppD3Ddev8 + 204), extGetRenderState, (void **)&pGetRenderState, "GetRenderState(D8)"); - (*pSetRenderState)((void *)*ppD3Ddev8, D3DRS_FILLMODE, D3DFILL_WIREFRAME); + if(dxw.dwFlags2 & WIREFRAME) (*pSetRenderState)((void *)*ppD3Ddev8, D3DRS_FILLMODE, D3DFILL_WIREFRAME); + if(dxw.dwFlags4 & DISABLEFOGGING) (*pSetRenderState)((void *)*ppD3Ddev8, D3DRS_FOGENABLE, FALSE); + if(dxw.dwFlags4 & ZBUFFERALWAYS) (*pSetRenderState)((void *)*ppD3Ddev8, D3DRS_ZFUNC, D3DCMP_ALWAYS); + //if(1) (*pSetRenderState)((void *)*ppD3Ddev8, D3DRS_SPECULARENABLE, TRUE); } + //if (!(dxw.dwTFlags & OUTPROXYTRACE)) return; + //SetHook((void *)(**(DWORD **)ppD3Ddev8 + 4), extAddRef8, (void **)&pAddRef8, "AddRef(D8)"); + //SetHook((void *)(**(DWORD **)ppD3Ddev8 + 8), extRelease8, (void **)&pRelease8, "Release(D8)"); } void HookD3DDevice9(void** ppD3Ddev9) @@ -491,14 +518,18 @@ void HookD3DDevice9(void** ppD3Ddev9) SetHook((void *)(**(DWORD **)ppD3Ddev9 + 84), extSetGammaRamp, (void **)&pSetGammaRamp, "SetGammaRamp(D9)"); SetHook((void *)(**(DWORD **)ppD3Ddev9 + 88), extGetGammaRamp, (void **)&pGetGammaRamp, "GetGammaRamp(D9)"); } + SetHook((void *)(**(DWORD **)ppD3Ddev9 + 164), extBeginScene9, (void **)&pBeginScene9, "BeginScene(D9)"); + SetHook((void *)(**(DWORD **)ppD3Ddev9 + 168), extEndScene9, (void **)&pEndScene9, "EndScene(D9)"); //SetHook((void *)(**(DWORD **)ppD3Ddev9 +188), extSetViewport, (void **)&pSetViewport, "SetViewport(D9)"); //SetHook((void *)(**(DWORD **)ppD3Ddev9 +192), extGetViewport, (void **)&pGetViewport, "GetViewport(D9)"); - if(dxw.dwFlags2 & WIREFRAME){ + if((dxw.dwFlags2 & WIREFRAME) || (dxw.dwFlags4 & DISABLEFOGGING) || (dxw.dwFlags4 & ZBUFFERALWAYS)){ SetHook((void *)(**(DWORD **)ppD3Ddev9 + 228), extSetRenderState, (void **)&pSetRenderState, "SetRenderState(D9)"); SetHook((void *)(**(DWORD **)ppD3Ddev9 + 232), extGetRenderState, (void **)&pGetRenderState, "GetRenderState(D9)"); - (*pSetRenderState)((void *)*ppD3Ddev9, D3DRS_FILLMODE, D3DFILL_WIREFRAME); + if(dxw.dwFlags2 & WIREFRAME) (*pSetRenderState)((void *)*ppD3Ddev9, D3DRS_FILLMODE, D3DFILL_WIREFRAME); + if(dxw.dwFlags4 & DISABLEFOGGING) (*pSetRenderState)((void *)*ppD3Ddev9, D3DRS_FOGENABLE, FALSE); + if(dxw.dwFlags4 & ZBUFFERALWAYS) (*pSetRenderState)((void *)*ppD3Ddev9, D3DRS_ZFUNC, D3DCMP_ALWAYS); + //if(1) (*pSetRenderState)((void *)*ppD3Ddev9, D3DRS_SPECULARENABLE, TRUE); } - if (!(dxw.dwTFlags & OUTPROXYTRACE)) return; SetHook((void *)(**(DWORD **)ppD3Ddev9 + 4), extAddRef9, (void **)&pAddRef9, "AddRef(D9)"); SetHook((void *)(**(DWORD **)ppD3Ddev9 + 8), extRelease9, (void **)&pRelease9, "Release(D9)"); @@ -925,9 +956,17 @@ HRESULT WINAPI extCreateDeviceEx(void *lpd3d, UINT adapter, D3DDEVTYPE devicetyp return 0; } +extern char *ExplainRenderstateValue(DWORD Value); + HRESULT WINAPI extSetRenderState(void *pd3dd, D3DRENDERSTATETYPE State, DWORD Value) { - if (State == D3DRS_FILLMODE) Value=D3DFILL_WIREFRAME; + if((dxw.dwFlags4 & ZBUFFERALWAYS) && (State == D3DRS_ZFUNC)) { + OutTraceD3D("SetRenderState: FIXED State=ZFUNC Value=%s->D3DCMP_ALWAYS\n", ExplainRenderstateValue(Value)); + Value = D3DCMP_ALWAYS; + } + if((dxw.dwFlags2 & WIREFRAME) && (State == D3DRS_FILLMODE)) Value=D3DFILL_WIREFRAME; + if((dxw.dwFlags4 & DISABLEFOGGING) && (State == D3DRS_FOGENABLE)) Value=FALSE; + //if(1 && (State == D3DRS_SPECULARENABLE)) Value=TRUE; return (*pSetRenderState)(pd3dd, State, Value); } @@ -1295,3 +1334,48 @@ ULONG WINAPI extRelease9(void *lpdd3dd) return res; } +//ULONG WINAPI extCreateRenderTarget8(void *lpdd3dd, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface) +ULONG WINAPI extCreateRenderTarget8(void *lpdd3dd, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, void** ppSurface) +{ + ULONG res; + + OutTraceD3D("Device::CreateRenderTarget(8): dd3dd=%x dim=(%dx%d) Format=%x Lockable=%x\n", + lpdd3dd, Width, Height, Format, Lockable); + res=(*pCreateRenderTarget8)(lpdd3dd, Width, Height, Format, MultiSample, Lockable, ppSurface); + OutTraceD3D("Device::CreateRenderTarget(8): res=%x\n", res); + return res; +} + +ULONG WINAPI extBeginScene8(void *lpdd3dd) +{ + ULONG res; + OutTraceD3D("Device::BeginScene(8): d3dd=%x\n", lpdd3dd); + res=(*pBeginScene8)(lpdd3dd); + if (res) OutTraceE("Device::BeginScene(8) ERROR: err=%x\n", res); + return res; +} + +ULONG WINAPI extBeginScene9(void *lpdd3dd) +{ + ULONG res; + OutTraceD3D("Device::BeginScene(9): d3dd=%x\n", lpdd3dd); + res=(*pBeginScene9)(lpdd3dd); + if (res) OutTraceE("Device::BeginScene(9) ERROR: err=%x\n", res); + return res; +} + +ULONG WINAPI extEndScene8(void *lpdd3dd) +{ + ULONG res; + res=(*pEndScene8)(lpdd3dd); + if (res) OutTraceE("Device::EndScene(8) ERROR: err=%x\n", res); + return res; +} + +ULONG WINAPI extEndScene9(void *lpdd3dd) +{ + ULONG res; + res=(*pEndScene9)(lpdd3dd); + if (res) OutTraceE("Device::EndScene(9) ERROR: err=%x\n", res); + return res; +} diff --git a/dll/hd3d7.cpp b/dll/hd3d7.cpp index 47be8e2..4223947 100644 --- a/dll/hd3d7.cpp +++ b/dll/hd3d7.cpp @@ -301,6 +301,7 @@ void HookDirect3DDevice(void **lpd3ddev, int d3dversion) if(pSetRenderState2){ if(dxw.dwFlags2 & WIREFRAME)(*pSetRenderState2)(*lpd3ddev, D3DRENDERSTATE_FILLMODE, D3DFILL_WIREFRAME); if(dxw.dwFlags4 & DISABLEFOGGING) (*pSetRenderState2)(*lpd3ddev, D3DRENDERSTATE_FOGENABLE, FALSE); + if(dxw.dwFlags4 & ZBUFFERALWAYS) (*pSetRenderState2)(*lpd3ddev, D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS); } break; case 3: @@ -315,6 +316,7 @@ void HookDirect3DDevice(void **lpd3ddev, int d3dversion) if(pSetRenderState3){ if(dxw.dwFlags2 & WIREFRAME)(*pSetRenderState3)(*lpd3ddev, D3DRENDERSTATE_FILLMODE, D3DFILL_WIREFRAME); if(dxw.dwFlags4 & DISABLEFOGGING) (*pSetRenderState3)(*lpd3ddev, D3DRENDERSTATE_FOGENABLE, FALSE); + if(dxw.dwFlags4 & ZBUFFERALWAYS) (*pSetRenderState3)(*lpd3ddev, D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS); } break; case 7: @@ -801,6 +803,10 @@ HRESULT WINAPI extSetRenderState2(void *d3dd, D3DRENDERSTATETYPE State, DWORD Va if((dxw.dwFlags2 & WIREFRAME) && (State == D3DRENDERSTATE_FILLMODE)){ Value = D3DFILL_WIREFRAME; OutTraceD3D("SetRenderState: FIXED State=FILLMODE Value=D3DFILL_WIREFRAME\n"); +} + if((dxw.dwFlags4 & DISABLEFOGGING) && (State == D3DRENDERSTATE_FOGENABLE)){ + OutTraceD3D("SetRenderState: FIXED State=FOGENABLE Value=FALSE\n"); + Value = FALSE; } res=(*pSetRenderState2)(d3dd, State, Value); if(res) OutTraceE("SetRenderState(2): res=%x(%s)\n", res, ExplainDDError(res)); diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index 8e37c87..ed30e24 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -41,8 +41,8 @@ static HookEntry_Type TimeHooks[]={ {"GetSystemTimeAsFileTime", (FARPROC)GetSystemTimeAsFileTime, (FARPROC *)&pGetSystemTimeAsFileTime, (FARPROC)extGetSystemTimeAsFileTime}, {"Sleep", (FARPROC)Sleep, (FARPROC *)&pSleep, (FARPROC)extSleep}, {"SleepEx", (FARPROC)SleepEx, (FARPROC *)&pSleepEx, (FARPROC)extSleepEx}, - {"QueryPerformanceCounter", (FARPROC)NULL, (FARPROC *)&pQueryPerformanceCounter, (FARPROC)extQueryPerformanceCounter}, - {"QueryPerformanceFrequency", (FARPROC)NULL, (FARPROC *)&pQueryPerformanceFrequency, (FARPROC)extQueryPerformanceFrequency}, + {"QueryPerformanceCounter", (FARPROC)QueryPerformanceCounter, (FARPROC *)&pQueryPerformanceCounter, (FARPROC)extQueryPerformanceCounter}, + {"QueryPerformanceFrequency", (FARPROC)QueryPerformanceFrequency, (FARPROC *)&pQueryPerformanceFrequency, (FARPROC)extQueryPerformanceFrequency}, {0, NULL, 0, 0} // terminator }; diff --git a/host/dxwndhost.vs2008.suo b/host/dxwndhost.vs2008.suo index cc73e27..f21bee9 100644 Binary files a/host/dxwndhost.vs2008.suo and b/host/dxwndhost.vs2008.suo differ