mirror of
https://github.com/DxWnd/DxWnd.reloaded
synced 2024-12-30 09:25:35 +01:00
v2_04_03_src_fx1
Former-commit-id: 129196aa26a1556b838eec59754175d69b7e2dcf
This commit is contained in:
parent
bb49a3ab13
commit
e2b83b2dda
@ -264,6 +264,7 @@
|
||||
#define DDSFORMAT 0x00001000 // texture dump / hack are performed in MS DDS format
|
||||
#define HOOKWING32 0x00002000 // Hook WinG32.dll
|
||||
#define SEQUENCEDIAT 0x00004000 // IFT has sequential format, DLL entries before and API next
|
||||
#define D3D8BACK16 0x00008000 // D3D8 emulate 16 bpp backbuffer on a 32 bpp desktop (Win8-10 needed feature)
|
||||
|
||||
// logging Tflags DWORD:
|
||||
#define OUTTRACE 0x00000001 // enables tracing to dxwnd.log in general
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c1ff3a6f4bd35e8240757938f69a200d952634e134b6543dea433fc90ef1a35b
|
||||
size 770560
|
||||
oid sha256:1db64cc2ff8db11e460be5c81efc1a0da01f7393b14471b0d3fb158105ed4523
|
||||
size 774656
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:490cb948680c5a66c5697716453ebc008d2a3614cda1924c369ccfd9d5f925a1
|
||||
size 669184
|
||||
oid sha256:cac62feee622d3aecce7d6529ebd4f0460d97e9eb20edf79b3a03d935610cc1f
|
||||
size 669696
|
||||
|
36
build/exports/Dangerous Waters.dxw
Normal file
36
build/exports/Dangerous Waters.dxw
Normal file
@ -0,0 +1,36 @@
|
||||
[target]
|
||||
title0=Dangerous Waters
|
||||
path0=F:\Games\Dangerous Waters\dangerouswaters.noshims.exe
|
||||
startfolder0=
|
||||
launchpath0=
|
||||
module0=
|
||||
opengllib0=
|
||||
notes0=
|
||||
registry0=
|
||||
ver0=0
|
||||
monitorid0=-1
|
||||
coord0=0
|
||||
flag0=673185832
|
||||
flagg0=1207959680
|
||||
flagh0=20
|
||||
flagi0=138412036
|
||||
flagj0=4224
|
||||
flagk0=65537
|
||||
flagl0=32768
|
||||
flagm0=32768
|
||||
tflag0=0
|
||||
dflag0=0
|
||||
posx0=50
|
||||
posy0=50
|
||||
sizx0=800
|
||||
sizy0=600
|
||||
maxfps0=0
|
||||
initts0=0
|
||||
winver0=0
|
||||
maxres0=0
|
||||
swapeffect0=0
|
||||
maxddinterface0=7
|
||||
slowratio0=2
|
||||
scanline0=0
|
||||
initresw0=640
|
||||
initresh0=480
|
36
build/exports/Dirt Track Racing 2 Demo.dxw
Normal file
36
build/exports/Dirt Track Racing 2 Demo.dxw
Normal file
@ -0,0 +1,36 @@
|
||||
[target]
|
||||
title0=Dirt Track Racing 2 Demo
|
||||
path0=F:\Games\Dirt Track Racing 2 Demo\DTR2Demo.exe
|
||||
startfolder0=
|
||||
launchpath0=
|
||||
module0=
|
||||
opengllib0=
|
||||
notes0=
|
||||
registry0=
|
||||
ver0=0
|
||||
monitorid0=-1
|
||||
coord0=0
|
||||
flag0=673185826
|
||||
flagg0=1207959552
|
||||
flagh0=20
|
||||
flagi0=138412036
|
||||
flagj0=4226
|
||||
flagk0=65536
|
||||
flagl0=0
|
||||
flagm0=0
|
||||
tflag0=0
|
||||
dflag0=0
|
||||
posx0=50
|
||||
posy0=50
|
||||
sizx0=800
|
||||
sizy0=600
|
||||
maxfps0=0
|
||||
initts0=0
|
||||
winver0=0
|
||||
maxres0=0
|
||||
swapeffect0=0
|
||||
maxddinterface0=7
|
||||
slowratio0=2
|
||||
scanline0=0
|
||||
initresw0=800
|
||||
initresh0=600
|
36
build/exports/Dirt Track Racing 2.dxw
Normal file
36
build/exports/Dirt Track Racing 2.dxw
Normal file
@ -0,0 +1,36 @@
|
||||
[target]
|
||||
title0=Dirt Track Racing 2
|
||||
path0=F:\Games\Dirt Track Racing 2\DTR2.exe
|
||||
startfolder0=
|
||||
launchpath0=
|
||||
module0=
|
||||
opengllib0=
|
||||
notes0=
|
||||
registry0=
|
||||
ver0=0
|
||||
monitorid0=-1
|
||||
coord0=0
|
||||
flag0=673185826
|
||||
flagg0=1207959560
|
||||
flagh0=20
|
||||
flagi0=138412036
|
||||
flagj0=4224
|
||||
flagk0=65536
|
||||
flagl0=0
|
||||
flagm0=0
|
||||
tflag0=0
|
||||
dflag0=0
|
||||
posx0=50
|
||||
posy0=50
|
||||
sizx0=800
|
||||
sizy0=600
|
||||
maxfps0=0
|
||||
initts0=0
|
||||
winver0=0
|
||||
maxres0=0
|
||||
swapeffect0=0
|
||||
maxddinterface0=7
|
||||
slowratio0=2
|
||||
scanline0=0
|
||||
initresw0=800
|
||||
initresh0=600
|
36
build/exports/Dirt Track Racing.dxw
Normal file
36
build/exports/Dirt Track Racing.dxw
Normal file
@ -0,0 +1,36 @@
|
||||
[target]
|
||||
title0=Dirt Track Racing
|
||||
path0=F:\Games\Dirt Track Racing\DTR.exe
|
||||
startfolder0=
|
||||
launchpath0=
|
||||
module0=
|
||||
opengllib0=
|
||||
notes0=
|
||||
registry0=
|
||||
ver0=0
|
||||
monitorid0=-1
|
||||
coord0=0
|
||||
flag0=673185826
|
||||
flagg0=1207959552
|
||||
flagh0=20
|
||||
flagi0=138412036
|
||||
flagj0=4224
|
||||
flagk0=65536
|
||||
flagl0=0
|
||||
flagm0=0
|
||||
tflag0=0
|
||||
dflag0=0
|
||||
posx0=50
|
||||
posy0=50
|
||||
sizx0=800
|
||||
sizy0=600
|
||||
maxfps0=0
|
||||
initts0=0
|
||||
winver0=0
|
||||
maxres0=0
|
||||
swapeffect0=0
|
||||
maxddinterface0=7
|
||||
slowratio0=2
|
||||
scanline0=0
|
||||
initresw0=800
|
||||
initresh0=600
|
36
build/exports/TOCA Touring Car Championship.dxw
Normal file
36
build/exports/TOCA Touring Car Championship.dxw
Normal file
@ -0,0 +1,36 @@
|
||||
[target]
|
||||
title0=TOCA Touring Car Championship
|
||||
path0=F:\Games\tourcar\tourcars.exe
|
||||
startfolder0=
|
||||
launchpath0=F:\Games\tourcar\setup.exe
|
||||
module0=
|
||||
opengllib0=
|
||||
notes0=
|
||||
registry0=\n[HKEY_LOCAL_MACHINE\SOFTWARE\Codemasters]\n\n[HKEY_LOCAL_MACHINE\SOFTWARE\Codemasters\Touring Car]\n"GameDirectory"="F:\\Games\\tourcar\\"\n"CD_Drive"="."\n"Install_Drive"="F:"\n"CardHintIndex"=dword:00000000\n"ShowRunInfo"=dword:00000000\n"S3RunInfo"=dword:00000000\n\n
|
||||
ver0=0
|
||||
monitorid0=-1
|
||||
coord0=0
|
||||
flag0=673185834
|
||||
flagg0=1207959552
|
||||
flagh0=528
|
||||
flagi0=138412032
|
||||
flagj0=4224
|
||||
flagk0=65536
|
||||
flagl0=0
|
||||
flagm0=0
|
||||
tflag0=0
|
||||
dflag0=0
|
||||
posx0=50
|
||||
posy0=50
|
||||
sizx0=800
|
||||
sizy0=600
|
||||
maxfps0=0
|
||||
initts0=0
|
||||
winver0=0
|
||||
maxres0=0
|
||||
swapeffect0=0
|
||||
maxddinterface0=7
|
||||
slowratio0=2
|
||||
scanline0=0
|
||||
initresw0=800
|
||||
initresh0=600
|
@ -1416,4 +1416,10 @@ fix: bilinear 2X crash
|
||||
fix: handling of 16 to 32 bpp color conversion in D3D8 IDirect3DDevice8 Copyrects and GetFrontBuffer methods. Fixes "Dirt track Racing 2" missing panels.
|
||||
fix: more / better logging
|
||||
fix: in USER32/CreateWindow* calls, handles the case where a to-be main window is moved/resized before being declared as main window. Fixes uncontrolled position changes in "Civil Wars 2 Generals".
|
||||
add: preliminary hooks for message loop APIs USER32/PeekMessage, GetMessage, PostMessage. Now PeekMessage includes SLOWDOW flag processing, reduces CPU time in "Civil Wars 2 Generals".
|
||||
add: preliminary hooks for message loop APIs USER32/PeekMessage, GetMessage, PostMessage. Now PeekMessage includes SLOWDOW flag processing, reduces CPU time in "Civil Wars 2 Generals".
|
||||
|
||||
v2.04.03-fx1
|
||||
add: D3D8 16bpp backbuffer emulation on 32bpp color depth. Fixes "Dangerous Waters" on 32bpp Win8-10
|
||||
add: more OpenGL wgl* hooks, used by "StarSiege 2014".
|
||||
fix: using correct version method pointers in bilinear blit, avoids crash in "Daytona USA" using bilinear filtering
|
||||
fix: do not try to CloseHandle the handle returned by GetMenu, avoids debugger exceptions.
|
||||
|
@ -2996,7 +2996,7 @@ HRESULT WINAPI PrimaryBilinearBlt(int dxversion, Blt_Type pBlt, LPDIRECTDRAWSURF
|
||||
BltFast_Type pBltFast;
|
||||
int dwSize;
|
||||
|
||||
switch(dxversion){
|
||||
switch(iBakBufferVersion){ // v2.04.03.fx1 fix: must use iBakBufferVersion, not dxversion!
|
||||
default:
|
||||
case 1: pBltFast=pBltFast1; pCreateSurface=pCreateSurface1; dwSize = sizeof(DDSURFACEDESC); break;
|
||||
case 2: pBltFast=pBltFast2; pCreateSurface=(CreateSurface1_Type)pCreateSurface2; dwSize = sizeof(DDSURFACEDESC); break;
|
||||
@ -3004,6 +3004,7 @@ HRESULT WINAPI PrimaryBilinearBlt(int dxversion, Blt_Type pBlt, LPDIRECTDRAWSURF
|
||||
case 4: pBltFast=pBltFast4; pCreateSurface=(CreateSurface1_Type)pCreateSurface4; dwSize = sizeof(DDSURFACEDESC2); break;
|
||||
case 7: pBltFast=pBltFast7; pCreateSurface=(CreateSurface1_Type)pCreateSurface7; dwSize = sizeof(DDSURFACEDESC2); break;
|
||||
}
|
||||
|
||||
caps.dwCaps = DDSCAPS_BACKBUFFER;
|
||||
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
|
||||
ddsd.dwSize = dwSize;
|
||||
|
@ -26,7 +26,7 @@ void dxwCore::UpdateDesktopCoordinates()
|
||||
RECT Client;
|
||||
POINT UpLeft = {0, 0};
|
||||
|
||||
OutTraceB("dxwCore::UpdateDesktopCoordinates: OLD pos=(%d,%d) size=(%dx%d)\n", iPosX, iPosY, iSizX, iSizY);
|
||||
//OutTraceB("dxwCore::UpdateDesktopCoordinates: OLD pos=(%d,%d) size=(%dx%d)\n", iPosX, iPosY, iSizX, iSizY);
|
||||
if(!(*pGetClientRect)(hWnd, &Client)) return;
|
||||
if((Client.right == 0) || (Client.bottom == 0)) return;
|
||||
if(!(*pClientToScreen)(hWnd, &UpLeft)) return;
|
||||
@ -35,7 +35,7 @@ void dxwCore::UpdateDesktopCoordinates()
|
||||
iPosY = UpLeft.y;
|
||||
iSizX = Client.right - Client.left;
|
||||
iSizY = Client.bottom - Client.top;
|
||||
OutTraceB("dxwCore::UpdateDesktopCoordinates: NEW pos=(%d,%d) size=(%dx%d)\n", iPosX, iPosY, iSizX, iSizY);
|
||||
//OutTraceB("dxwCore::UpdateDesktopCoordinates: NEW pos=(%d,%d) size=(%dx%d)\n", iPosX, iPosY, iSizX, iSizY);
|
||||
}
|
||||
|
||||
// GetScreenRect: returns a RECT sized as the virtual desktop
|
||||
@ -460,7 +460,7 @@ void dxwCore::CalculateWindowPos(HWND hwnd, DWORD width, DWORD height, LPWINDOWP
|
||||
// BEWARE: from MSDN - If the window is a child window, the return value is undefined.
|
||||
hMenu = (dwStyle & WS_CHILD) ? NULL : GetMenu(hwnd);
|
||||
AdjustWindowRectEx(&rect, dwStyle, (hMenu!=NULL), dwExStyle);
|
||||
if (hMenu) __try {CloseHandle(hMenu);} __except(EXCEPTION_EXECUTE_HANDLER){};
|
||||
// if (hMenu) __try {CloseHandle(hMenu);} __except(EXCEPTION_EXECUTE_HANDLER){};
|
||||
switch(dxw.Coordinates){
|
||||
case DXW_DESKTOP_WORKAREA:
|
||||
case DXW_DESKTOP_FULL:
|
||||
|
@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "TlHelp32.h"
|
||||
|
||||
#define VERSION "2.04.02"
|
||||
#define VERSION "2.04.03.fx1"
|
||||
|
||||
#define DDTHREADLOCK 1
|
||||
|
||||
|
BIN
dll/dxwnd.vs2008.suo
Normal file
BIN
dll/dxwnd.vs2008.suo
Normal file
Binary file not shown.
@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioUserFile
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
ShowAllFiles="false"
|
||||
>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command=""
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="DESKTOP-Q3RE27J"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command=""
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="DESKTOP-Q3RE27J"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</VisualStudioUserFile>
|
276
dll/hd3d.cpp
276
dll/hd3d.cpp
@ -20,6 +20,16 @@
|
||||
|
||||
extern void D3D9TextureHandling(void *, int);
|
||||
extern void D3D8TextureHandling(void *, int);
|
||||
extern HRESULT exCreateImageSurface8(void *, UINT, UINT, D3DFORMAT, LPDIRECTDRAWSURFACE *);
|
||||
extern HRESULT dxCopyRects(void *, LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE);
|
||||
extern HRESULT dwD3D8InitEmulation(void *);
|
||||
extern LPDIRECTDRAWSURFACE dwGetVirtualBackBuffer();
|
||||
extern void dwD3D8ShutdownEmulation(void *);
|
||||
extern HRESULT dwD3D8Present(void *, CONST RECT *, CONST RECT*, HWND, CONST RGNDATA *);
|
||||
extern void HookWindowProc(HWND);
|
||||
extern char *ExplainDDError(DWORD);
|
||||
extern char *ExplainRenderstateValue(DWORD Value);
|
||||
extern HRESULT dxGetFrontBuffer(void *, LPDIRECTDRAWSURFACE);
|
||||
|
||||
void *lpD3DActiveDevice = NULL;
|
||||
typedef HRESULT (WINAPI *QueryInterface_Type)(void *, REFIID riid, void** ppvObj);
|
||||
@ -67,6 +77,7 @@ typedef HMONITOR (WINAPI *GetAdapterMonitor_Type)(void *, UINT);
|
||||
typedef HRESULT (WINAPI *CreateDevice_Type)(void *, UINT, D3DDEVTYPE, HWND, DWORD, void *, void **);
|
||||
typedef HRESULT (WINAPI *CreateDeviceEx_Type)(void *, UINT, D3DDEVTYPE, HWND, DWORD, void *, D3DDISPLAYMODEEX *, void **);
|
||||
typedef BOOL (WINAPI *DisableD3DSpy_Type)(void);
|
||||
typedef HRESULT (WINAPI *GetBackBuffer8_Type)(void *, UINT, D3DBACKBUFFER_TYPE, LPDIRECTDRAWSURFACE *);
|
||||
|
||||
UINT WINAPI extGetAdapterCount8(void *);
|
||||
UINT WINAPI extGetAdapterCount9(void *);
|
||||
@ -83,6 +94,7 @@ HMONITOR WINAPI extGetAdapterMonitor9(void *, UINT);
|
||||
HRESULT WINAPI extCreateDevice8(void *, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS *, void **);
|
||||
HRESULT WINAPI extCreateDevice9(void *, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS *, void **);
|
||||
HRESULT WINAPI extCreateDeviceEx(void *, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS *, D3DDISPLAYMODEEX *, void **);
|
||||
HRESULT WINAPI extGetBackBuffer8(void *, UINT, D3DBACKBUFFER_TYPE, LPDIRECTDRAWSURFACE *);
|
||||
|
||||
GetAdapterCount_Type pGetAdapterCount8, pGetAdapterCount9;
|
||||
GetAdapterModeCount8_Type pGetAdapterModeCount8;
|
||||
@ -94,6 +106,7 @@ D3DGetDeviceCaps9_Type pD3DGetDeviceCaps9 = 0;
|
||||
GetAdapterMonitor_Type pGetAdapterMonitor8, pGetAdapterMonitor9;
|
||||
CreateDevice_Type pCreateDevice8, pCreateDevice9;
|
||||
CreateDeviceEx_Type pCreateDeviceEx = 0;
|
||||
GetBackBuffer8_Type pGetBackBuffer8 = 0;
|
||||
|
||||
// IDirect3DDevice8/9 methods
|
||||
|
||||
@ -117,6 +130,7 @@ typedef HRESULT (WINAPI *CreateTexture8_Type)(void *, UINT, UINT, UINT, DWORD, D
|
||||
typedef HRESULT (WINAPI *CreateTexture9_Type)(void *, UINT, UINT, UINT, DWORD, D3DFORMAT, D3DPOOL, void **, HANDLE *);
|
||||
typedef HRESULT (WINAPI *CopyRects_Type)(void *, LPDIRECTDRAWSURFACE, CONST RECT *, UINT, LPDIRECTDRAWSURFACE, CONST POINT *);
|
||||
typedef HRESULT (WINAPI *GetFrontBuffer_Type)(void *, LPDIRECTDRAWSURFACE);
|
||||
typedef ULONG (WINAPI *ReleaseDev_Type)(void *);
|
||||
|
||||
UINT WINAPI extGetAvailableTextureMem8(void *);
|
||||
UINT WINAPI extGetAvailableTextureMem9(void *);
|
||||
@ -143,6 +157,8 @@ HRESULT WINAPI extCreateTexture9(void *, UINT, UINT, UINT, DWORD, D3DFORMAT, D3D
|
||||
// CopyRects prototype uses IDirect3DSurface8 *, but to avoid including d3d8.h better use a generic ptr as LPDIRECTDRAWSURFACE
|
||||
HRESULT WINAPI extCopyRects(void *, LPDIRECTDRAWSURFACE, CONST RECT *, UINT, LPDIRECTDRAWSURFACE, CONST POINT *);
|
||||
HRESULT WINAPI extGetFrontBuffer(void *, LPDIRECTDRAWSURFACE);
|
||||
ULONG WINAPI extReleaseDev8(void *);
|
||||
ULONG WINAPI extReleaseDev9(void *);
|
||||
|
||||
GetAvailableTextureMem_Type pGetAvailableTextureMem8, pGetAvailableTextureMem9;
|
||||
TestCooperativeLevel_Type pTestCooperativeLevel8, pTestCooperativeLevel9;
|
||||
@ -166,6 +182,7 @@ CreateTexture8_Type pCreateTexture8 = 0;
|
||||
CreateTexture9_Type pCreateTexture9 = 0;
|
||||
CopyRects_Type pCopyRects = 0;
|
||||
GetFrontBuffer_Type pGetFrontBuffer = 0;
|
||||
ReleaseDev_Type pReleaseDev8, pReleaseDev9;
|
||||
|
||||
// IDirect3DTexture8/9 methods
|
||||
|
||||
@ -233,8 +250,6 @@ void WINAPI extSetGammaRamp8(void *, UINT, DWORD, D3DGAMMARAMP *);
|
||||
void WINAPI extSetGammaRamp9(void *, UINT, DWORD, D3DGAMMARAMP *);
|
||||
void WINAPI extGetGammaRamp8(void *, UINT, D3DGAMMARAMP *);
|
||||
void WINAPI extGetGammaRamp9(void *, UINT, D3DGAMMARAMP *);
|
||||
ULONG WINAPI extAddRef9(void *);
|
||||
ULONG WINAPI extRelease9(void *);
|
||||
BOOL WINAPI voidDisableD3DSpy(void);
|
||||
|
||||
ULONG WINAPI extCreateRenderTarget8(void *, UINT, UINT, D3DFORMAT, D3DMULTISAMPLE_TYPE, BOOL, void**);
|
||||
@ -255,8 +270,6 @@ HRESULT WINAPI extD3D11CreateDeviceAndSwapChain(IDXGIAdapter *, D3D_DRIVER_TYPE,
|
||||
void WINAPI extRSSetViewports10(void *, UINT, D3D10_VIEWPORT *);
|
||||
void WINAPI extRSSetViewports11(ID3D11DeviceContext *, UINT, D3D11_VIEWPORT *);
|
||||
|
||||
extern char *ExplainDDError(DWORD);
|
||||
|
||||
QueryInterface_Type pQueryInterfaceD3D8 = 0;
|
||||
QueryInterface_Type pQueryInterfaceDev8 = 0;
|
||||
QueryInterface_Type pQueryInterfaceD3D9 = 0;
|
||||
@ -460,6 +473,7 @@ void HookD3DDevice8(void** ppD3Ddev8)
|
||||
{
|
||||
OutTraceD3D("Device hook for IID_IDirect3DDevice8 interface\n");
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev8 + 0), extQueryInterfaceDev8, (void **)&pQueryInterfaceDev8, "QueryInterface(D8)");
|
||||
//SetHook((void *)(**(DWORD **)ppD3Ddev8 + 8), extReleaseDev8, (void **)&pReleaseDev8, "Release(D8)");
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev8 + 12), extTestCooperativeLevel8, (void **)&pTestCooperativeLevel8, "TestCooperativeLevel(D8)");
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev8 + 16), extGetAvailableTextureMem8, (void **)&pGetAvailableTextureMem8, "GetAvailableTextureMem(D8)");
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev8 + 24), extGetDirect3D8, (void **)&pGetDirect3D8, "GetDirect3D(D8)");
|
||||
@ -469,6 +483,7 @@ void HookD3DDevice8(void** ppD3Ddev8)
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev8 + 52), extCreateAdditionalSwapChain8, (void **)&pCreateAdditionalSwapChain8, "CreateAdditionalSwapChain(D8)");
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev8 + 56), extReset8, (void **)&pReset8, "Reset(D8)");
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev8 + 60), extPresent8, (void **)&pPresent8, "Present(D8)");
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev8 + 64), extGetBackBuffer8, (void **)&pGetBackBuffer8, "GetBackBuffer(D8)");
|
||||
if(dxw.dwFlags2 & DISABLEGAMMARAMP){
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev8 + 72), extSetGammaRamp8, (void **)&pSetGammaRamp8, "SetGammaRamp(D8)");
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev8 + 76), extGetGammaRamp8, (void **)&pGetGammaRamp8, "GetGammaRamp(D8)");
|
||||
@ -503,6 +518,7 @@ void HookD3DDevice9(void** ppD3Ddev9)
|
||||
{
|
||||
OutTraceD3D("Device hook for IID_IDirect3DDevice9 interface\n");
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev9 + 0), extQueryInterfaceDev9, (void **)&pQueryInterfaceDev9, "QueryInterface(D9)");
|
||||
//SetHook((void *)(**(DWORD **)ppD3Ddev9 + 8), extReleaseDev9, (void **)&pReleaseDev9, "Release(D9)");
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev9 + 12), extTestCooperativeLevel9, (void **)&pTestCooperativeLevel9, "TestCooperativeLevel(D9)");
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev9 + 16), extGetAvailableTextureMem9, (void **)&pGetAvailableTextureMem9, "GetAvailableTextureMem(D9)");
|
||||
SetHook((void *)(**(DWORD **)ppD3Ddev9 + 24), extGetDirect3D9, (void **)&pGetDirect3D9, "GetDirect3D(D9)");
|
||||
@ -613,6 +629,26 @@ void HookDirect3D9(void *lpd3d, BOOL ex)
|
||||
if(ex) SetHook((void *)(*(DWORD *)lpd3d + 80), extCreateDeviceEx, (void **)&pCreateDeviceEx, "CreateDeviceEx(D9)");
|
||||
}
|
||||
|
||||
static char *ExplainD3DBehaviourFlags(DWORD c)
|
||||
{
|
||||
static char eb[256];
|
||||
unsigned int l;
|
||||
strcpy(eb,"D3DCREATE_");
|
||||
if (c & D3DCREATE_FPU_PRESERVE) strcat(eb, "FPU_PRESERVE+");
|
||||
if (c & D3DCREATE_MULTITHREADED) strcat(eb, "MULTITHREADED+");
|
||||
if (c & D3DCREATE_PUREDEVICE) strcat(eb, "PUREDEVICE+");
|
||||
if (c & D3DCREATE_SOFTWARE_VERTEXPROCESSING) strcat(eb, "SOFTWARE_VERTEXPROCESSING+");
|
||||
if (c & D3DCREATE_HARDWARE_VERTEXPROCESSING) strcat(eb, "HARDWARE_VERTEXPROCESSING+");
|
||||
if (c & D3DCREATE_MIXED_VERTEXPROCESSING) strcat(eb, "MIXED_VERTEXPROCESSING+");
|
||||
if (c & D3DCREATE_DISABLE_DRIVER_MANAGEMENT) strcat(eb, "DISABLE_DRIVER_MANAGEMENT+");
|
||||
if (c & D3DCREATE_ADAPTERGROUP_DEVICE) strcat(eb, "ADAPTERGROUP_DEVICE+");
|
||||
if (c & D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX) strcat(eb, "DISABLE_DRIVER_MANAGEMENT_EX+");
|
||||
l=strlen(eb);
|
||||
if (l>strlen("D3DCREATE_")) eb[l-1]=0; // delete last '+' if any
|
||||
else eb[0]=0;
|
||||
return(eb);
|
||||
}
|
||||
|
||||
void* WINAPI extDirect3DCreate9(UINT sdkversion)
|
||||
{
|
||||
void *lpd3d;
|
||||
@ -739,7 +775,7 @@ static HRESULT WINAPI extReset(int dwD3DVersion, void *pd3dd, D3DPRESENT_PARAMET
|
||||
OutTrace("D3D%d::Reset\n", dwD3DVersion);
|
||||
OutTrace(" BackBufferWidth = %i\n", *(tmp ++));
|
||||
OutTrace(" BackBufferHeight = %i\n", *(tmp ++));
|
||||
OutTrace(" BackBufferFormat = %i\n", *(tmp ++));
|
||||
OutTrace(" BackBufferFormat = %i(%s)\n", *(tmp ++), ExplainD3DSurfaceFormat(param[2]));
|
||||
OutTrace(" BackBufferCount = %i\n", *(tmp ++));
|
||||
OutTrace(" MultiSampleType = %i\n", *(tmp ++));
|
||||
if(dwD3DVersion == 9) OutTrace(" MultiSampleQuality = %i\n", *(tmp ++));
|
||||
@ -808,10 +844,19 @@ static HRESULT WINAPI extReset(int dwD3DVersion, void *pd3dd, D3DPRESENT_PARAMET
|
||||
}
|
||||
}
|
||||
|
||||
if((dxw.dwFlags8 & D3D8BACK16) && (dwD3DVersion == 8)){
|
||||
D3DPRESENT_PARAMETERS *params = (D3DPRESENT_PARAMETERS *)¶m[0];
|
||||
dwD3D8ShutdownEmulation(pd3dd);
|
||||
// Change the presentation effect from D3DSWAPEFFECT_COPY to D3DSWAPEFFECT_DISCARD to fix blank screen on W10.
|
||||
params->SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
// Drop the lockable backbuffer flag to be safe. We do not need it.
|
||||
params->Flags &= ~D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
|
||||
}
|
||||
|
||||
if(!(dxw.dwFlags4 & NOD3DRESET)){
|
||||
res = (*pReset)(pd3dd, (D3DPRESENT_PARAMETERS *)param);
|
||||
if(res){
|
||||
OutTraceD3D("switching to mode=%x\n", mode.Format);
|
||||
OutTraceD3D("err=%x(%s) switching to mode=%d(%s)\n", res, ExplainDDError(res), mode.Format, ExplainD3DSurfaceFormat(mode.Format));
|
||||
param[2] = mode.Format; // first attempt: current screen mode
|
||||
res = (*pReset)(pd3dd, (D3DPRESENT_PARAMETERS *)param);
|
||||
}
|
||||
@ -825,7 +870,7 @@ static HRESULT WINAPI extReset(int dwD3DVersion, void *pd3dd, D3DPRESENT_PARAMET
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
if(res){
|
||||
OutTraceD3D("FAILED! %x\n", res);
|
||||
OutTraceD3D("FAILED! %x(%s)\n", res, ExplainDDError(res));
|
||||
return res;
|
||||
}
|
||||
OutTraceD3D("SUCCESS!\n");
|
||||
@ -836,6 +881,11 @@ static HRESULT WINAPI extReset(int dwD3DVersion, void *pd3dd, D3DPRESENT_PARAMET
|
||||
res=D3D_OK;
|
||||
}
|
||||
|
||||
if((dxw.dwFlags8 & D3D8BACK16) && (dwD3DVersion == 8)){
|
||||
dwD3D8InitEmulation(pd3dd);
|
||||
if(res) OutTraceE("Reset: dwD3D8InitEmulation ERROR: err=%x(%s)\n", res, ExplainDDError(res));
|
||||
}
|
||||
|
||||
dxw.SetScreenSize(pPresParam->BackBufferWidth, pPresParam->BackBufferHeight);
|
||||
dxw.SetVSyncDelays(mode.RefreshRate);
|
||||
|
||||
@ -853,7 +903,7 @@ HRESULT WINAPI extReset8(void *pd3dd, D3DPRESENT_PARAMETERS* pPresParam)
|
||||
HRESULT WINAPI extReset9(void *pd3dd, D3DPRESENT_PARAMETERS* pPresParam)
|
||||
{ return extReset(9, pd3dd, pPresParam); }
|
||||
|
||||
static HRESULT WINAPI extPresent(Present_Type pPresent, void *pd3dd, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion)
|
||||
static HRESULT WINAPI extPresent(int d3dversion, Present_Type pPresent, void *pd3dd, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion)
|
||||
{
|
||||
HRESULT res;
|
||||
RECT RemappedSrcRect, RemappedDstRect;
|
||||
@ -864,13 +914,19 @@ static HRESULT WINAPI extPresent(Present_Type pPresent, void *pd3dd, CONST RECT
|
||||
else strcpy(sSourceRect, "(NULL)");
|
||||
if (pDestRect) sprintf_s(sDestRect, 80, "(%d,%d)-(%d,%d)", pDestRect->left, pDestRect->top, pDestRect->right, pDestRect->bottom);
|
||||
else strcpy(sDestRect, "(NULL)");
|
||||
OutTraceB("Present: SourceRect=%s DestRect=%s hDestWndOverride=%x\n", sSourceRect, sDestRect, hDestWindowOverride);
|
||||
OutTraceB("Present(%d): d3dd=%x SourceRect=%s DestRect=%s hDestWndOverride=%x dirtyregion=%x\n",
|
||||
d3dversion, pd3dd, sSourceRect, sDestRect, hDestWindowOverride, pDirtyRegion);
|
||||
}
|
||||
|
||||
// frame counter handling....
|
||||
if (dxw.HandleFPS()) return D3D_OK;
|
||||
if (dxw.dwFlags1 & SAVELOAD) dxw.VSyncWait();
|
||||
|
||||
if((dxw.dwFlags8 & D3D8BACK16) && (d3dversion == 8)){
|
||||
res = dwD3D8Present(pd3dd, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
|
||||
OutTraceD3D("Present: EMULATION res=%x\n", res);
|
||||
}
|
||||
|
||||
if(dxw.dwFlags2 & FULLRECTBLT) pSourceRect = pDestRect = NULL;
|
||||
if(dxw.Windowize){
|
||||
// v2.03.15 - fix target RECT region
|
||||
@ -888,15 +944,29 @@ static HRESULT WINAPI extPresent(Present_Type pPresent, void *pd3dd, CONST RECT
|
||||
}
|
||||
|
||||
res=(*pPresent)(pd3dd, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
|
||||
if(res) OutTraceE("Present: err=%x(%s)\n", res, ExplainDDError(res));
|
||||
if(res) {
|
||||
OutTraceE("Present: err=%x(%s)\n", res, ExplainDDError(res));
|
||||
}
|
||||
else {
|
||||
if(IsDebug){
|
||||
if(pDirtyRegion) {
|
||||
OutTrace("Present: D3D_OK dirtyreg={buf=%x type=%d count=%d rgnsize=%x bound=(%d,%d)-(%d,%d)}\n",
|
||||
pDirtyRegion->Buffer, pDirtyRegion->rdh.iType, pDirtyRegion->rdh.nCount, pDirtyRegion->rdh.nRgnSize,
|
||||
pDirtyRegion->rdh.rcBound.left, pDirtyRegion->rdh.rcBound.top, pDirtyRegion->rdh.rcBound.right, pDirtyRegion->rdh.rcBound.bottom);
|
||||
}
|
||||
else {
|
||||
OutTrace("Present: D3D_OK\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
dxw.ShowOverlay();
|
||||
return res;
|
||||
}
|
||||
|
||||
HRESULT WINAPI extPresent8(void *pd3dd, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion)
|
||||
{ return extPresent(pPresent8, pd3dd, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); }
|
||||
{ return extPresent(8, pPresent8, pd3dd, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); }
|
||||
HRESULT WINAPI extPresent9(void *pd3dd, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion)
|
||||
{ return extPresent(pPresent9, pd3dd, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); }
|
||||
{ return extPresent(9, pPresent9, pd3dd, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); }
|
||||
|
||||
HRESULT WINAPI extGetDisplayMode8(void *lpd3d, D3DDISPLAYMODE *pMode)
|
||||
{
|
||||
@ -980,12 +1050,12 @@ HRESULT WINAPI extEnumAdapterModes9(void *lpd3d, UINT Adapter, D3DFORMAT Format,
|
||||
return res;
|
||||
}
|
||||
|
||||
HRESULT WINAPI extGetAdapterDisplayMode8(void *lpd3d, UINT Adapter, D3DDISPLAYMODE *pMode)
|
||||
HRESULT WINAPI extGetAdapterDisplayMode(int d3dversion, GetAdapterDisplayMode_Type pGetAdapterDisplayMode, void *lpd3d, UINT Adapter, D3DDISPLAYMODE *pMode)
|
||||
{
|
||||
HRESULT res;
|
||||
res=(*pGetAdapterDisplayMode8)(lpd3d, Adapter, pMode);
|
||||
OutTraceD3D("GetAdapterDisplayMode(8): size=(%dx%d) RefreshRate=%d Format=%d\n",
|
||||
pMode->Width, pMode->Height, pMode->RefreshRate, pMode->Format);
|
||||
res=(*pGetAdapterDisplayMode)(lpd3d, Adapter, pMode);
|
||||
OutTraceD3D("GetAdapterDisplayMode(%d): size=(%dx%d) RefreshRate=%d Format=%d(%s)\n",
|
||||
d3dversion, pMode->Width, pMode->Height, pMode->RefreshRate, pMode->Format, ExplainD3DSurfaceFormat(pMode->Format));
|
||||
if(dxw.dwFlags2 & KEEPASPECTRATIO){
|
||||
pMode->Width=dxw.iSizX;
|
||||
pMode->Height=dxw.iSizY;
|
||||
@ -994,33 +1064,19 @@ HRESULT WINAPI extGetAdapterDisplayMode8(void *lpd3d, UINT Adapter, D3DDISPLAYMO
|
||||
pMode->Width = dxw.GetScreenWidth();
|
||||
pMode->Height = dxw.GetScreenHeight();
|
||||
}
|
||||
OutTraceD3D("GetAdapterDisplayMode(8): fixed size=(%dx%d)\n", pMode->Width, pMode->Height);
|
||||
OutTraceD3D("GetAdapterDisplayMode: fixed size=(%dx%d)\n", pMode->Width, pMode->Height);
|
||||
dxw.SetVSyncDelays(pMode->RefreshRate);
|
||||
return res;
|
||||
}
|
||||
|
||||
HRESULT WINAPI extGetAdapterDisplayMode8(void *lpd3d, UINT Adapter, D3DDISPLAYMODE *pMode)
|
||||
{ return extGetAdapterDisplayMode(8, pGetAdapterDisplayMode8, lpd3d, Adapter, pMode); }
|
||||
HRESULT WINAPI extGetAdapterDisplayMode9(void *lpd3d, UINT Adapter, D3DDISPLAYMODE *pMode)
|
||||
{
|
||||
HRESULT res;
|
||||
res=(*pGetAdapterDisplayMode9)(lpd3d, Adapter, pMode);
|
||||
OutTraceD3D("GetAdapterDisplayMode(9): size=(%dx%d) RefreshRate=%d Format=%d\n",
|
||||
pMode->Width, pMode->Height, pMode->RefreshRate, pMode->Format);
|
||||
if(dxw.dwFlags2 & KEEPASPECTRATIO){
|
||||
pMode->Width=dxw.iSizX;
|
||||
pMode->Height=dxw.iSizY;
|
||||
}
|
||||
else{
|
||||
pMode->Width = dxw.GetScreenWidth();
|
||||
pMode->Height = dxw.GetScreenHeight();
|
||||
}
|
||||
OutTraceD3D("GetAdapterDisplayMode(9): fixed size=(%dx%d)\n", pMode->Width, pMode->Height);
|
||||
dxw.SetVSyncDelays(pMode->RefreshRate);
|
||||
return res;
|
||||
}
|
||||
{ return extGetAdapterDisplayMode(9, pGetAdapterDisplayMode9, lpd3d, Adapter, pMode); }
|
||||
|
||||
|
||||
HWND FixD3DWindowFrame(HWND hFocusWin)
|
||||
{
|
||||
extern void HookWindowProc(HWND);
|
||||
HWND hRetWnd = hFocusWin;
|
||||
|
||||
if(!(dxw.dwFlags3 & NOWINDOWMOVE))
|
||||
@ -1068,7 +1124,7 @@ static HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devi
|
||||
dxw.SetScreenSize(param[0], param[1]);
|
||||
|
||||
if(dxw.Windowize) hfocuswindow=FixD3DWindowFrame(hfocuswindow);
|
||||
|
||||
|
||||
if(IsTraceD3D){
|
||||
tmp = param;
|
||||
DWORD SwapEffect;
|
||||
@ -1076,10 +1132,10 @@ static HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devi
|
||||
OutTrace(" Adapter = %i\n", adapter);
|
||||
OutTrace(" DeviceType = %i\n", devicetype);
|
||||
OutTrace(" hFocusWindow = 0x%x\n", hfocuswindow);
|
||||
OutTrace(" BehaviorFlags = 0x%x\n", behaviorflags);
|
||||
OutTrace(" BehaviorFlags = 0x%x(%s)\n", behaviorflags, ExplainD3DBehaviourFlags(behaviorflags));
|
||||
OutTrace(" BackBufferWidth = %i\n", *(tmp ++));
|
||||
OutTrace(" BackBufferHeight = %i\n", *(tmp ++));
|
||||
OutTrace(" BackBufferFormat = %i\n", *(tmp ++));
|
||||
OutTrace(" BackBufferFormat = %i(%s)\n", *(tmp ++), ExplainD3DSurfaceFormat(param[2]));
|
||||
OutTrace(" BackBufferCount = %i\n", *(tmp ++));
|
||||
OutTrace(" MultiSampleType = %i\n", *(tmp ++));
|
||||
if(dwD3DVersion == 9) OutTrace(" MultiSampleQuality = %i\n", *(tmp ++));
|
||||
@ -1098,7 +1154,7 @@ static HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devi
|
||||
(*pGetAdapterDisplayMode9)(lpd3d, 0, &mode);
|
||||
else
|
||||
(*pGetAdapterDisplayMode8)(lpd3d, 0, &mode);
|
||||
OutTraceD3D(" Current Format = 0x%x\n", mode.Format);
|
||||
OutTraceD3D(" Current Format = %d(%s)\n", mode.Format, ExplainD3DSurfaceFormat(mode.Format));
|
||||
OutTraceD3D(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height);
|
||||
OutTraceD3D(" Current Refresh Rate = %d\n", mode.RefreshRate);
|
||||
|
||||
@ -1128,12 +1184,12 @@ static HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devi
|
||||
}
|
||||
res = (*pCreateDevice9)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, ppd3dd);
|
||||
if(res){
|
||||
OutTraceD3D("err=%x switching to mode=%x\n", res, mode.Format);
|
||||
OutTraceD3D("err=%x(%s) switching to mode=%d(%s)\n", res, ExplainDDError(res), mode.Format, ExplainD3DSurfaceFormat(mode.Format));
|
||||
param[2] = mode.Format; // first attempt: current screen mode
|
||||
res = (*pCreateDevice9)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, ppd3dd);
|
||||
}
|
||||
if(res){
|
||||
OutTraceD3D("err=%x switching to mode=D3DFMT_UNKNOWN\n", res);
|
||||
OutTraceD3D("err=%x(%s) switching to mode=D3DFMT_UNKNOWN\n", res, ExplainDDError(res));
|
||||
param[2] = D3DFMT_UNKNOWN; // second attempt: unknown, good for windowed mode
|
||||
res = (*pCreateDevice9)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, ppd3dd);
|
||||
}
|
||||
@ -1151,24 +1207,28 @@ static HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devi
|
||||
}
|
||||
res = (*pCreateDevice8)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, ppd3dd);
|
||||
if(res){
|
||||
OutTraceD3D("err=%x switching to mode=%x\n", res, mode.Format);
|
||||
OutTraceD3D("err=%x(%s) switching to mode=%d(%s)\n", res, ExplainDDError(res), mode.Format, ExplainD3DSurfaceFormat(mode.Format));
|
||||
param[2] = mode.Format; // first attempt: current screen mode
|
||||
res = (*pCreateDevice8)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, ppd3dd);
|
||||
}
|
||||
if(res){
|
||||
OutTraceD3D("err=%x switching to mode=D3DFMT_UNKNOWN\n", res);
|
||||
OutTraceD3D("err=%x(%s) switching to mode=D3DFMT_UNKNOWN\n", res, ExplainDDError(res));
|
||||
param[2] = D3DFMT_UNKNOWN; // second attempt: unknown, good for windowed mode
|
||||
res = (*pCreateDevice8)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, ppd3dd);
|
||||
}
|
||||
}
|
||||
|
||||
if(res){
|
||||
OutTraceD3D("FAILED! err=%x\n", res);
|
||||
OutTraceD3D("FAILED! err=%x(%s)\n", res, ExplainDDError(res));
|
||||
return res;
|
||||
}
|
||||
OutTraceD3D("SUCCESS! device=%x\n", *ppd3dd);
|
||||
lpD3DActiveDevice = *ppd3dd;
|
||||
|
||||
if((dxw.dwFlags8 & D3D8BACK16) && (dwD3DVersion == 8)){
|
||||
dwD3D8InitEmulation(*ppd3dd);
|
||||
}
|
||||
|
||||
if(dwD3DVersion == 8){
|
||||
HookD3DDevice8(ppd3dd);
|
||||
}
|
||||
@ -1218,7 +1278,7 @@ HRESULT WINAPI extCreateDeviceEx(void *lpd3d, UINT adapter, D3DDEVTYPE devicetyp
|
||||
OutTrace(" BehaviorFlags = 0x%x\n", behaviorflags);
|
||||
OutTrace(" BackBufferWidth = %i\n", *(tmp ++));
|
||||
OutTrace(" BackBufferHeight = %i\n", *(tmp ++));
|
||||
OutTrace(" BackBufferFormat = %i\n", *(tmp ++));
|
||||
OutTrace(" BackBufferFormat = %i(%s)\n", *(tmp ++), ExplainD3DSurfaceFormat(param[2]));
|
||||
OutTrace(" BackBufferCount = %i\n", *(tmp ++));
|
||||
OutTrace(" MultiSampleType = %i\n", *(tmp ++));
|
||||
OutTrace(" MultiSampleQuality = %i\n", *(tmp ++));
|
||||
@ -1235,7 +1295,7 @@ HRESULT WINAPI extCreateDeviceEx(void *lpd3d, UINT adapter, D3DDEVTYPE devicetyp
|
||||
|
||||
//((LPDIRECT3D9)lpd3d)->GetAdapterDisplayMode(0, &mode);
|
||||
(*pGetAdapterDisplayMode9)(lpd3d, 0, &mode);
|
||||
OutTraceD3D(" Current Format = 0x%x\n", mode.Format);
|
||||
OutTraceD3D(" Current Format = %d(%s)\n", mode.Format, ExplainD3DSurfaceFormat(mode.Format));
|
||||
OutTraceD3D(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height);
|
||||
OutTraceD3D(" Current Refresh Rate = %d\n", mode.RefreshRate);
|
||||
|
||||
@ -1270,17 +1330,17 @@ HRESULT WINAPI extCreateDeviceEx(void *lpd3d, UINT adapter, D3DDEVTYPE devicetyp
|
||||
|
||||
res = (*pCreateDeviceEx)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, pFullscreenDisplayMode, ppd3dd);
|
||||
if(res){
|
||||
OutTraceD3D("err=%x switching to mode=%x\n", res, mode.Format);
|
||||
OutTraceD3D("err=%x(%s) switching to mode=%d(%s)\n", res, ExplainDDError(res), mode.Format, ExplainD3DSurfaceFormat(mode.Format));
|
||||
param[2] = mode.Format; // first attempt: current screen mode
|
||||
res = (*pCreateDeviceEx)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, pFullscreenDisplayMode, ppd3dd);
|
||||
}
|
||||
if(res){
|
||||
OutTraceD3D("err=%x switching to mode=D3DFMT_UNKNOWN\n", res);
|
||||
OutTraceD3D("err=%x(%s) switching to mode=D3DFMT_UNKNOWN\n", res, ExplainDDError(res));
|
||||
param[2] = D3DFMT_UNKNOWN; // second attempt: unknown, good for windowed mode
|
||||
res = (*pCreateDeviceEx)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, pFullscreenDisplayMode, ppd3dd);
|
||||
}
|
||||
if(res){
|
||||
OutTraceD3D("FAILED! err=%x\n", res);
|
||||
OutTraceD3D("FAILED! err=%x(%s)\n", res, ExplainDDError(res));
|
||||
return res;
|
||||
}
|
||||
OutTraceD3D("SUCCESS!\n");
|
||||
@ -1299,8 +1359,6 @@ HRESULT WINAPI extCreateDeviceEx(void *lpd3d, UINT adapter, D3DDEVTYPE devicetyp
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
extern char *ExplainRenderstateValue(DWORD Value);
|
||||
|
||||
static HRESULT WINAPI extSetRenderState(SetRenderState_Type pSetRenderState, void *pd3dd, D3DRENDERSTATETYPE State, DWORD Value)
|
||||
{
|
||||
HRESULT res;
|
||||
@ -1387,7 +1445,7 @@ static HRESULT WINAPI extCreateAdditionalSwapChain(int dwD3DVersion, void *lpd3d
|
||||
OutTrace("D3D%d::CreateAdditionalSwapChain\n", dwD3DVersion);
|
||||
OutTrace(" BackBufferWidth = %i\n", *(tmp ++));
|
||||
OutTrace(" BackBufferHeight = %i\n", *(tmp ++));
|
||||
OutTrace(" BackBufferFormat = %i\n", *(tmp ++));
|
||||
OutTrace(" BackBufferFormat = %i(%s)\n", *(tmp ++), ExplainD3DSurfaceFormat(param[2]));
|
||||
OutTrace(" BackBufferCount = %i\n", *(tmp ++));
|
||||
OutTrace(" MultiSampleType = %i\n", *(tmp ++));
|
||||
if(dwD3DVersion == 9) OutTrace(" MultiSampleQuality = %i\n", *(tmp ++));
|
||||
@ -1405,7 +1463,7 @@ static HRESULT WINAPI extCreateAdditionalSwapChain(int dwD3DVersion, void *lpd3d
|
||||
res2=(*pGetAdapterDisplayMode)(lpd3dd, D3DADAPTER_DEFAULT, &mode);
|
||||
|
||||
if(res2==DD_OK){
|
||||
OutTraceD3D(" Current Format = 0x%x\n", mode.Format);
|
||||
OutTraceD3D(" Current Format = %d(%s)\n", mode.Format, ExplainD3DSurfaceFormat(mode.Format));
|
||||
OutTraceD3D(" Current ScreenSize = (%dx%d)\n", mode.Width, mode.Height);
|
||||
OutTraceD3D(" Current Refresh Rate = %d\n", mode.RefreshRate);
|
||||
}
|
||||
@ -1440,7 +1498,7 @@ static HRESULT WINAPI extCreateAdditionalSwapChain(int dwD3DVersion, void *lpd3d
|
||||
|
||||
res=(*pCreateAdditionalSwapChain)(lpd3dd, (D3DPRESENT_PARAMETERS *)param, ppSwapChain);
|
||||
if(res && (res2==DD_OK)){
|
||||
OutTraceD3D("switching to mode=%x\n", mode.Format);
|
||||
OutTraceD3D("err=%x(%s) switching to mode=%d(%s)\n", res, ExplainDDError(res), mode.Format, ExplainD3DSurfaceFormat(mode.Format));
|
||||
param[2] = mode.Format; // first attempt: current screen mode
|
||||
res=(*pCreateAdditionalSwapChain)(lpd3dd, (D3DPRESENT_PARAMETERS *)param, ppSwapChain);
|
||||
}
|
||||
@ -1712,6 +1770,19 @@ HRESULT WINAPI extQueryInterfaceDev9(void *obj, REFIID riid, void** ppvObj)
|
||||
return res;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ReleaseDev(int d3dversion, ReleaseDev_Type pReleaseDev, void *lpdd)
|
||||
{
|
||||
ULONG ActualRef;
|
||||
ActualRef=(*pReleaseDev)(lpdd);
|
||||
OutTraceD3D("Release(D%d): lpdd=%x ret=%d\n", d3dversion, lpdd, ActualRef);
|
||||
return ActualRef;
|
||||
}
|
||||
|
||||
ULONG WINAPI extReleaseDev8(void *lpdd)
|
||||
{ return ReleaseDev(8, pReleaseDev8, lpdd); }
|
||||
ULONG WINAPI extReleaseDev9(void *lpdd)
|
||||
{ return ReleaseDev(9, pReleaseDev9, lpdd); }
|
||||
|
||||
HRESULT WINAPI extGetDirect3D8(void *lpdd3dd, void **ppD3D8)
|
||||
{
|
||||
HRESULT res;
|
||||
@ -1794,22 +1865,6 @@ void WINAPI extSetCursorPosition8(void *lpdd3dd, int X, int Y, DWORD Flags)
|
||||
//(*pSetCursorPosition8)(lpdd3dd, X, Y, Flags);
|
||||
}
|
||||
|
||||
ULONG WINAPI extAddRef9(void *lpdd3dd)
|
||||
{
|
||||
ULONG res;
|
||||
res=(*pAddRef9)(lpdd3dd);
|
||||
OutTraceD3D("Device::AddRef(9): dd3dd=%x res=%x\n", lpdd3dd, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
ULONG WINAPI extRelease9(void *lpdd3dd)
|
||||
{
|
||||
ULONG res;
|
||||
res=(*pRelease9)(lpdd3dd);
|
||||
OutTraceD3D("Device::Release(9): dd3dd=%x res=%x\n", lpdd3dd, res);
|
||||
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)
|
||||
{
|
||||
@ -1936,22 +1991,7 @@ HRESULT WINAPI voidDirect3DShaderValidatorCreate9(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI extCheckDeviceType(CheckDeviceType_Type pCheckDeviceType, void *lpd3d, UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed)
|
||||
{
|
||||
HRESULT res;
|
||||
OutTraceD3D("CheckDeviceType: d3d=%x adapter=%d windowed=%x\n", lpd3d, Adapter, bWindowed);
|
||||
if(dxw.Windowize) bWindowed = TRUE;
|
||||
res = (*pCheckDeviceType)(lpd3d, Adapter, DevType, AdapterFormat, BackBufferFormat, bWindowed);
|
||||
OutTraceD3D("CheckDeviceType: res=%x\n", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
HRESULT WINAPI extCheckDeviceType8(void *lpd3d, UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed)
|
||||
{ return extCheckDeviceType(pCheckDeviceType8, lpd3d, Adapter, DevType, AdapterFormat, BackBufferFormat, bWindowed); }
|
||||
HRESULT WINAPI extCheckDeviceType9(void *lpd3d, UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed)
|
||||
{ return extCheckDeviceType(pCheckDeviceType9, lpd3d, Adapter, DevType, AdapterFormat, BackBufferFormat, bWindowed); }
|
||||
|
||||
static char *ExplainD3D9DeviceType(D3DDEVTYPE DeviceType)
|
||||
static char *ExplainD3DDeviceType(D3DDEVTYPE DeviceType)
|
||||
{
|
||||
char *s;
|
||||
switch(DeviceType){
|
||||
@ -1964,10 +2004,26 @@ static char *ExplainD3D9DeviceType(D3DDEVTYPE DeviceType)
|
||||
return s;
|
||||
}
|
||||
|
||||
HRESULT WINAPI extD3DGetDeviceCaps(void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps, int version)
|
||||
static HRESULT WINAPI extCheckDeviceType(int d3dversion, CheckDeviceType_Type pCheckDeviceType, void *lpd3d, UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed)
|
||||
{
|
||||
HRESULT res;
|
||||
OutTraceD3D("GetDeviceCaps(%d): d3d=%x adapter=%d devtype=%x(%s)\n", version, lpd3d, Adapter, DeviceType, ExplainD3D9DeviceType(DeviceType));
|
||||
OutTraceD3D("CheckDeviceType(%d): d3d=%x adapter=%d devtype=%x(%s) backbufferformat=%d(%s) windowed=%x\n",
|
||||
d3dversion, lpd3d, Adapter, DevType, ExplainD3DDeviceType(DevType), AdapterFormat, ExplainD3DSurfaceFormat(AdapterFormat), bWindowed);
|
||||
if(dxw.Windowize) bWindowed = TRUE;
|
||||
res = (*pCheckDeviceType)(lpd3d, Adapter, DevType, AdapterFormat, BackBufferFormat, bWindowed);
|
||||
OutTraceD3D("CheckDeviceType: res=%x(%s)\n", res, ExplainDDError(res));
|
||||
return res;
|
||||
}
|
||||
|
||||
HRESULT WINAPI extCheckDeviceType8(void *lpd3d, UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed)
|
||||
{ return extCheckDeviceType(8, pCheckDeviceType8, lpd3d, Adapter, DevType, AdapterFormat, BackBufferFormat, bWindowed); }
|
||||
HRESULT WINAPI extCheckDeviceType9(void *lpd3d, UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed)
|
||||
{ return extCheckDeviceType(9, pCheckDeviceType9, lpd3d, Adapter, DevType, AdapterFormat, BackBufferFormat, bWindowed); }
|
||||
|
||||
HRESULT WINAPI extD3DGetDeviceCaps(int version, void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps)
|
||||
{
|
||||
HRESULT res;
|
||||
OutTraceD3D("GetDeviceCaps(%d): d3d=%x adapter=%d devtype=%x(%s)\n", version, lpd3d, Adapter, DeviceType, ExplainD3DDeviceType(DeviceType));
|
||||
|
||||
if(version == 8)
|
||||
res=(*pD3DGetDeviceCaps8)(lpd3d, Adapter, DeviceType, (D3DCAPS8 *)pCaps);
|
||||
@ -1992,7 +2048,7 @@ HRESULT WINAPI extD3DGetDeviceCaps(void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceT
|
||||
"AlphaCmpCaps=%x\n\t"
|
||||
"ShadeCaps=%x\n\t"
|
||||
"TextureCaps=%x\n\t",
|
||||
pCaps->DeviceType, ExplainD3D9DeviceType(pCaps->DeviceType),
|
||||
pCaps->DeviceType, ExplainD3DDeviceType(pCaps->DeviceType),
|
||||
pCaps->Caps, pCaps->Caps2, pCaps->Caps3,
|
||||
pCaps->PresentationIntervals,
|
||||
pCaps->CursorCaps, pCaps->DevCaps,
|
||||
@ -2052,7 +2108,7 @@ HRESULT WINAPI extD3DGetDeviceCaps(void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceT
|
||||
"VertexShaderVersion=%x\n\t"
|
||||
"MaxVertexShaderConst=%d\n\t"
|
||||
"PixelShaderVersion=%x\n\t"
|
||||
"PixelShader1xMaxValue=%f\n\t",
|
||||
"PixelShader1xMaxValue=%f\n",
|
||||
pCaps->MaxTextureWidth, pCaps->MaxTextureHeight,
|
||||
pCaps->MaxVolumeExtent,
|
||||
pCaps->MaxTextureRepeat,
|
||||
@ -2081,7 +2137,7 @@ HRESULT WINAPI extD3DGetDeviceCaps(void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceT
|
||||
pCaps->PixelShaderVersion,
|
||||
pCaps->PixelShader1xMaxValue);
|
||||
if(version == 9) OutTrace(
|
||||
"DevCaps2=%x Reserved5=%x\n\t"
|
||||
"\tDevCaps2=%x Reserved5=%x\n\t"
|
||||
"MaxNpatchTessellationLevel=%f\n\t"
|
||||
"MasterAdapterOrdinal=%i\n\t"
|
||||
"AdapterOrdinalInGroup=%i\n\t"
|
||||
@ -2111,7 +2167,7 @@ HRESULT WINAPI extD3DGetDeviceCaps(void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceT
|
||||
}
|
||||
|
||||
if(dxw.dwFlags7 & SUPPRESSOVERLAY){
|
||||
if(pCaps->Caps & D3DCAPS_OVERLAY) OutTraceDW("GetDeviceCaps(%d): SUPPRESS OVERLAY CAP\n");
|
||||
if(pCaps->Caps & D3DCAPS_OVERLAY) OutTraceDW("GetDeviceCaps(%d): SUPPRESS OVERLAY CAP\n", version);
|
||||
pCaps->Caps &= ~D3DCAPS_OVERLAY;
|
||||
}
|
||||
|
||||
@ -2119,9 +2175,9 @@ HRESULT WINAPI extD3DGetDeviceCaps(void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceT
|
||||
}
|
||||
|
||||
HRESULT WINAPI extD3DGetDeviceCaps8(void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8 *pCaps)
|
||||
{ return extD3DGetDeviceCaps(lpd3d, Adapter, DeviceType, (D3DCAPS9 *)pCaps, 8); }
|
||||
{ return extD3DGetDeviceCaps(8, lpd3d, Adapter, DeviceType, (D3DCAPS9 *)pCaps); }
|
||||
HRESULT WINAPI extD3DGetDeviceCaps9(void *lpd3d, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps)
|
||||
{ return extD3DGetDeviceCaps(lpd3d, Adapter, DeviceType, pCaps, 9); }
|
||||
{ return extD3DGetDeviceCaps(9, lpd3d, Adapter, DeviceType, pCaps); }
|
||||
|
||||
static HMONITOR WINAPI extGetAdapterMonitor(GetAdapterMonitor_Type pGetAdapterMonitor, void *lpd3d, UINT Adapter)
|
||||
{
|
||||
@ -2274,6 +2330,7 @@ static HRESULT WINAPI extLockRect(LockRect_Type pLockRect, void *lpd3dtex, UINT
|
||||
strcpy_s(sRect, 80, "NULL");
|
||||
OutTrace("Texture::LockRect: lpd3dtex=%x level=%d rect=%s flags=%x\n", lpd3dtex, Level, sRect, Flags);
|
||||
}
|
||||
|
||||
res=(*pLockRect)(lpd3dtex, Level, pLockedRect, pRect, Flags);
|
||||
if (res) OutTraceE("Device::LockRect ERROR: err=%x\n", res);
|
||||
else {
|
||||
@ -2293,7 +2350,12 @@ static HRESULT WINAPI extUnlockRect(UnlockRect_Type pUnlockRect, void *lpd3dtex,
|
||||
{
|
||||
HRESULT res;
|
||||
OutTraceD3D("Texture::UnlockRect: lpd3dtex=%x level=%d\n", lpd3dtex, Level);
|
||||
|
||||
res=(*pUnlockRect)(lpd3dtex, Level);
|
||||
if (res) OutTraceE("Device::UnlockRect ERROR: err=%x\n", res);
|
||||
else {
|
||||
OutTraceD3D("Device::UnlockRect: D3D_OK\n");
|
||||
}
|
||||
|
||||
if(TextureHandling) TextureHandling(lpd3dtex, Level);
|
||||
return res;
|
||||
@ -2372,7 +2434,6 @@ HRESULT WINAPI extGetFrontBuffer(void *lpd3dd, LPDIRECTDRAWSURFACE pDestSurface)
|
||||
// fake D3D_OK condition.
|
||||
|
||||
if(res == D3DERR_INVALIDCALL) {
|
||||
extern HRESULT dxGetFrontBuffer(void *, LPDIRECTDRAWSURFACE);
|
||||
res = dxGetFrontBuffer(lpd3dd, pDestSurface);
|
||||
if(res) OutTraceDW("GetFrontBuffer(8): ret=%x return FAKE D3D_OK\n", res);
|
||||
res = D3D_OK;
|
||||
@ -2395,7 +2456,6 @@ HRESULT WINAPI extCopyRects(void *lpd3dd, LPDIRECTDRAWSURFACE pSourceSurface, CO
|
||||
|
||||
res = (*pCopyRects)(lpd3dd, pSourceSurface, pSourceRectsArray, cRects, pDestinationSurface, pDestPointsArray);
|
||||
if((res == D3DERR_INVALIDCALL) && (cRects==0)) {
|
||||
extern HRESULT dxCopyRects(void *, LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE);
|
||||
res = dxCopyRects(lpd3dd, pSourceSurface, pDestinationSurface);
|
||||
if(res) OutTraceDW("CopyRects(8): res=%x FAKE D3D_OK on 0 rects\n", res);
|
||||
res = D3D_OK;
|
||||
@ -2403,3 +2463,27 @@ HRESULT WINAPI extCopyRects(void *lpd3dd, LPDIRECTDRAWSURFACE pSourceSurface, CO
|
||||
OutTraceD3D("CopyRects(8): ret=%x\n", res);
|
||||
return res;
|
||||
}
|
||||
|
||||
// STDMETHOD(GetBackBuffer)(THIS_ UINT iSwapChain,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer) PURE;
|
||||
|
||||
HRESULT WINAPI extGetBackBuffer8(void *lpd3dd, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, LPDIRECTDRAWSURFACE *ppBackBuffer)
|
||||
{
|
||||
HRESULT res;
|
||||
OutTraceD3D("GetBackBuffer(8): d3d=%x backbuffer=%x type=%x\n", lpd3dd, BackBuffer, Type);
|
||||
|
||||
if((dxw.dwFlags8 & D3D8BACK16) && (dwD3DVersion == 8)){
|
||||
if ((BackBuffer != 0) || (Type != D3DBACKBUFFER_TYPE_MONO)) {
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
*ppBackBuffer = dwGetVirtualBackBuffer();
|
||||
(*ppBackBuffer)->AddRef();
|
||||
OutTraceD3D("GetBackBuffer(8): EMULATION OK\n");
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
res = (*pGetBackBuffer8)(lpd3dd, BackBuffer, Type, ppBackBuffer);
|
||||
if(res) OutTraceE("GetBackBuffer(8): ret=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
|
||||
|
||||
if(res) OutTraceE("GetBackBuffer(8): ret=%x(%s)\n", res, ExplainDDError(res));
|
||||
return res;
|
||||
}
|
179
dll/hd3d8.cpp
179
dll/hd3d8.cpp
@ -205,6 +205,11 @@ HRESULT dxGetFrontBuffer(void *lpd3dd, LPDIRECTDRAWSURFACE xdest)
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
HRESULT exCreateImageSurface8(void *lpd3dd, UINT w, UINT h, D3DFORMAT Format, LPDIRECTDRAWSURFACE *ppBackBuffer)
|
||||
{
|
||||
return ((IDirect3DDevice8 *)lpd3dd)->CreateImageSurface(w, h, Format, (IDirect3DSurface8 **)ppBackBuffer);
|
||||
}
|
||||
|
||||
HRESULT dxCopyRects(void *lpd3dd, LPDIRECTDRAWSURFACE psrc, LPDIRECTDRAWSURFACE pdst)
|
||||
{
|
||||
HRESULT res;
|
||||
@ -319,4 +324,178 @@ HRESULT dxCopyRects(void *lpd3dd, LPDIRECTDRAWSURFACE psrc, LPDIRECTDRAWSURFACE
|
||||
return res;
|
||||
}
|
||||
|
||||
LPDIRECT3DSURFACE8 D3D8EmulatedBackBuffer;
|
||||
LPDIRECT3DSURFACE8 D3D8RealBackBuffer;
|
||||
LPDIRECT3DSURFACE8 RealDepthBuffer;
|
||||
LPDIRECT3DTEXTURE8 D3D8EmulatedBackBufferTexture;
|
||||
IDirect3DSurface8* EmulatedBackBufferTextureLevel0;
|
||||
|
||||
LPDIRECTDRAWSURFACE dwGetVirtualBackBuffer()
|
||||
{
|
||||
return (LPDIRECTDRAWSURFACE)D3D8EmulatedBackBuffer;
|
||||
}
|
||||
|
||||
HRESULT dwD3D8InitEmulation(void *lpd3ddx)
|
||||
{
|
||||
HRESULT res;
|
||||
LPDIRECT3DDEVICE8 lpd3dd = (LPDIRECT3DDEVICE8)lpd3ddx;
|
||||
|
||||
// Create the render target which will be used as the real back buffer.
|
||||
res = lpd3dd->CreateRenderTarget(dxw.GetScreenWidth(), dxw.GetScreenHeight(), D3DFMT_R5G6B5, D3DMULTISAMPLE_NONE, TRUE, &D3D8EmulatedBackBuffer);
|
||||
if(res) OutTraceE("dwD3D8InitEmulation: CreateRenderTarget ERROR res=%x at %d\n", res, __LINE__);
|
||||
|
||||
res = lpd3dd->CreateTexture(dxw.GetScreenWidth(), dxw.GetScreenHeight(), 1, 0, D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &D3D8EmulatedBackBufferTexture);
|
||||
if(res) OutTraceE("dwD3D8InitEmulation: CreateTexture ERROR res=%x at %d\n", res, __LINE__);
|
||||
|
||||
res = D3D8EmulatedBackBufferTexture->GetSurfaceLevel(0, &EmulatedBackBufferTextureLevel0);
|
||||
if(res) OutTraceE("dwD3D8InitEmulation: GetSurfaceLevel ERROR res=%x at %d\n", res, __LINE__);
|
||||
|
||||
// Locate the real buffers.
|
||||
res = lpd3dd->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &D3D8RealBackBuffer);
|
||||
if(res) OutTraceE("dwD3D8InitEmulation: GetBackBuffer ERROR res=%x at %d\n", res, __LINE__);
|
||||
|
||||
res = lpd3dd->GetDepthStencilSurface(&RealDepthBuffer);
|
||||
if(res) OutTraceE("dwD3D8InitEmulation: GetDepthStencilSurface ERROR res=%x at %d\n", res, __LINE__);
|
||||
|
||||
// Switch the render target to the emulated one by default.
|
||||
|
||||
res = lpd3dd->SetRenderTarget(D3D8EmulatedBackBuffer, RealDepthBuffer);
|
||||
if(res) OutTraceE("dwD3D8InitEmulation: SetRenderTarget ERROR res=%x at %d\n", res, __LINE__);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
void dwD3D8ShutdownEmulation(void *lpd3ddx)
|
||||
{
|
||||
HRESULT res;
|
||||
LPDIRECT3DDEVICE8 lpd3dd = (LPDIRECT3DDEVICE8)lpd3ddx;
|
||||
|
||||
// Restore targets.
|
||||
|
||||
res=lpd3dd->SetRenderTarget(D3D8RealBackBuffer, RealDepthBuffer);
|
||||
if(res) OutTraceE("dwD3D8ShutdownEmulation: SetRenderTarget ERROR res=%x at %d\n", res, __LINE__);
|
||||
res=D3D8RealBackBuffer->Release();
|
||||
res=RealDepthBuffer->Release();
|
||||
|
||||
// Destroy emulation objects.
|
||||
|
||||
res=EmulatedBackBufferTextureLevel0->Release();
|
||||
res=D3D8EmulatedBackBufferTexture->Release();
|
||||
res=D3D8EmulatedBackBuffer->Release();
|
||||
}
|
||||
|
||||
static DWORD set_rs(LPDIRECT3DDEVICE8 lpd3dd, const D3DRENDERSTATETYPE type, const DWORD value)
|
||||
{
|
||||
DWORD old_value;
|
||||
lpd3dd->GetRenderState(type, &old_value);
|
||||
lpd3dd->SetRenderState(type, value);
|
||||
return old_value;
|
||||
}
|
||||
|
||||
static DWORD set_tss(LPDIRECT3DDEVICE8 lpd3dd, const DWORD stage, const D3DTEXTURESTAGESTATETYPE type, const DWORD value)
|
||||
{
|
||||
DWORD old_value;
|
||||
lpd3dd->GetTextureStageState(stage, type, &old_value);
|
||||
lpd3dd->SetTextureStageState(stage, type, value);
|
||||
return old_value;
|
||||
}
|
||||
|
||||
HRESULT dwD3D8Present(void *lpd3ddx, CONST RECT *pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion)
|
||||
{
|
||||
HRESULT res;
|
||||
LPDIRECT3DDEVICE8 lpd3dd = (LPDIRECT3DDEVICE8)lpd3ddx;
|
||||
|
||||
if (pSourceRect || pDestRect || hDestWindowOverride || pDirtyRegion) {
|
||||
OutTraceE("dwD3D8Present: ERROR only parameter-less Present is supported\n");
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
// Blit the render target to the texture.
|
||||
|
||||
res = lpd3dd->CopyRects(D3D8EmulatedBackBuffer, NULL, 0, EmulatedBackBufferTextureLevel0, NULL);
|
||||
if(res) OutTraceE("dwD3D8Present: CopyRects ERROR res=%x at %d\n", res, __LINE__);
|
||||
|
||||
// Render the texture to the real back buffer.
|
||||
|
||||
res = lpd3dd->BeginScene();
|
||||
if(res) {
|
||||
OutTraceE("dwD3D8Present: CopyRects ERROR res=%x at %d\n", res, __LINE__);
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
LPDIRECT3DSURFACE8 old_back_buffer;
|
||||
LPDIRECT3DSURFACE8 old_depth_buffer;
|
||||
lpd3dd->GetRenderTarget(&old_back_buffer);
|
||||
lpd3dd->GetDepthStencilSurface(&old_depth_buffer);
|
||||
|
||||
lpd3dd->SetRenderTarget(D3D8RealBackBuffer, RealDepthBuffer);
|
||||
|
||||
LPDIRECT3DBASETEXTURE8 old_txt;
|
||||
lpd3dd->GetTexture(0, &old_txt);
|
||||
lpd3dd->SetTexture(0, D3D8EmulatedBackBufferTexture);
|
||||
|
||||
DWORD old_vs;
|
||||
lpd3dd->GetVertexShader(&old_vs);
|
||||
lpd3dd->SetVertexShader(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||
|
||||
IDirect3DVertexBuffer8 *old_stream_0;
|
||||
UINT old_stream_0_stride;
|
||||
lpd3dd->GetStreamSource(0, &old_stream_0, &old_stream_0_stride);
|
||||
|
||||
const DWORD old_cull = set_rs(lpd3dd, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
const DWORD old_atest = set_rs(lpd3dd, D3DRS_ALPHATESTENABLE, FALSE);
|
||||
const DWORD old_blend = set_rs(lpd3dd, D3DRS_ALPHABLENDENABLE, FALSE);
|
||||
const DWORD old_z_enable = set_rs(lpd3dd, D3DRS_ZENABLE, FALSE);
|
||||
const DWORD old_z_write = set_rs(lpd3dd, D3DRS_ZWRITEENABLE, FALSE);
|
||||
const DWORD old_stencil = set_rs(lpd3dd, D3DRS_STENCILENABLE, FALSE);
|
||||
const DWORD old_fog = set_rs(lpd3dd, D3DRS_FOGENABLE, FALSE);
|
||||
const DWORD old_specular = set_rs(lpd3dd, D3DRS_SPECULARENABLE, FALSE);
|
||||
const DWORD old_zbias = set_rs(lpd3dd, D3DRS_ZBIAS, 0);
|
||||
|
||||
const DWORD old_colorop_0 = set_tss(lpd3dd, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
const DWORD old_colorarg_0 = set_tss(lpd3dd, 0, D3DTSS_COLORARG0, D3DTA_TEXTURE);
|
||||
const DWORD old_colorop_1 = set_tss(lpd3dd, 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
const DWORD old_mag_filter_0 = set_tss(lpd3dd, 0, D3DTSS_MAGFILTER, D3DTEXF_POINT);
|
||||
const DWORD old_min_filter_0 = set_tss(lpd3dd, 0, D3DTSS_MINFILTER, D3DTEXF_POINT);
|
||||
|
||||
const float right = static_cast<float>(dxw.GetScreenWidth());
|
||||
const float bottom = static_cast<float>(dxw.GetScreenHeight());
|
||||
|
||||
const struct QuadVertex {
|
||||
float x, y, z, w;
|
||||
float u, v;
|
||||
} quad[] = {
|
||||
{-0.5f + 0.0f, -0.5f + 0.0f, 0.5f, 1.0f, 0.0f, 0.0f},
|
||||
{-0.5f + right, -0.5f + 0.0f, 0.5f, 1.0f, 1.0f, 0.0f},
|
||||
{-0.5f + right, -0.5f + bottom, 0.5f, 1.0f, 1.0f, 1.0f},
|
||||
{-0.5f + 0.0f, -0.5f + bottom, 0.5f, 1.0f, 0.0f, 1.0f},
|
||||
};
|
||||
lpd3dd->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, quad, sizeof(QuadVertex));
|
||||
|
||||
// Restore whatever parts of the state are necessary.
|
||||
// Currently we do not restore viewport.
|
||||
|
||||
lpd3dd->SetRenderTarget(old_back_buffer, old_depth_buffer);
|
||||
lpd3dd->SetTexture(0, old_txt);
|
||||
lpd3dd->SetVertexShader(old_vs);
|
||||
|
||||
lpd3dd->SetRenderState(D3DRS_CULLMODE, old_cull);
|
||||
lpd3dd->SetRenderState(D3DRS_ALPHATESTENABLE, old_atest);
|
||||
lpd3dd->SetRenderState(D3DRS_ALPHABLENDENABLE, old_blend);
|
||||
lpd3dd->SetRenderState(D3DRS_ZENABLE, old_z_enable);
|
||||
lpd3dd->SetRenderState(D3DRS_ZWRITEENABLE, old_z_write);
|
||||
lpd3dd->SetRenderState(D3DRS_STENCILENABLE, old_stencil);
|
||||
lpd3dd->SetRenderState(D3DRS_FOGENABLE, old_fog);
|
||||
lpd3dd->SetRenderState(D3DRS_SPECULARENABLE, old_specular);
|
||||
lpd3dd->SetRenderState(D3DRS_ZBIAS, old_zbias);
|
||||
|
||||
lpd3dd->SetTextureStageState(0, D3DTSS_COLOROP, old_colorop_0);
|
||||
lpd3dd->SetTextureStageState(0, D3DTSS_COLORARG0, old_colorarg_0);
|
||||
lpd3dd->SetTextureStageState(1, D3DTSS_COLOROP, old_colorop_1);
|
||||
lpd3dd->SetTextureStageState(0, D3DTSS_MAGFILTER, old_mag_filter_0);
|
||||
lpd3dd->SetTextureStageState(0, D3DTSS_MINFILTER, old_min_filter_0);
|
||||
|
||||
lpd3dd->SetStreamSource(0, old_stream_0, old_stream_0_stride);
|
||||
lpd3dd->EndScene();
|
||||
return D3D_OK;
|
||||
}
|
||||
|
@ -53,6 +53,9 @@ void CTabDirect3D::DoDataExchange(CDataExchange* pDX)
|
||||
// Swap Effect
|
||||
DDX_Check(pDX, IDC_FORCESWAPEFFECT, cTarget->m_ForcesSwapEffect);
|
||||
DDX_Radio(pDX, IDC_SWAP_DISCARD, cTarget->m_SwapEffect);
|
||||
|
||||
// Emulations ....
|
||||
DDX_Check(pDX, IDC_D3D8BACK16, cTarget->m_D3D8Back16);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CTabDirect3D, CDialog)
|
||||
|
@ -60,6 +60,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
|
||||
m_SuppressD3DExt = FALSE;
|
||||
m_Enum16bitModes = FALSE;
|
||||
m_TrimTextureFormats = FALSE;
|
||||
m_D3D8Back16 = FALSE;
|
||||
m_NoHALDevice = FALSE;
|
||||
//m_RawFormat = FALSE;
|
||||
m_TextureFileFormat = 0;
|
||||
@ -114,6 +115,7 @@ CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
|
||||
m_StressResources = FALSE;
|
||||
m_DisableFogging = FALSE;
|
||||
m_Power2Width = FALSE;
|
||||
m_ClearTarget = FALSE;
|
||||
m_FixPitch = FALSE,
|
||||
m_NoPower2Fix = FALSE;
|
||||
m_NoPerfCounter = FALSE;
|
||||
|
@ -267,6 +267,7 @@ public:
|
||||
BOOL m_SuppressD3DExt;
|
||||
BOOL m_Enum16bitModes;
|
||||
BOOL m_TrimTextureFormats;
|
||||
BOOL m_D3D8Back16;
|
||||
//BOOL m_RawFormat;
|
||||
BOOL m_LimitScreenRes;
|
||||
BOOL m_InitialRes;
|
||||
|
BIN
host/dxwndhost.aps
Normal file
BIN
host/dxwndhost.aps
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioUserFile
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
ShowAllFiles="false"
|
||||
>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="DESKTOP-Q3RE27J"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="DESKTOP-Q3RE27J"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</VisualStudioUserFile>
|
@ -391,6 +391,7 @@ void SetTargetFromDlg(TARGETMAP *t, CTargetDlg *dlg)
|
||||
if(dlg->m_SuppressD3DExt) t->flags3 |= SUPPRESSD3DEXT;
|
||||
if(dlg->m_Enum16bitModes) t->flags7 |= ENUM16BITMODES;
|
||||
if(dlg->m_TrimTextureFormats) t->flags8 |= TRIMTEXTUREFORMATS;
|
||||
if(dlg->m_D3D8Back16) t->flags8 |= D3D8BACK16;
|
||||
if(dlg->m_SetCompatibility) t->flags2 |= SETCOMPATIBILITY;
|
||||
if(dlg->m_AEROBoost) t->flags5 |= AEROBOOST;
|
||||
if(dlg->m_DiabloTweak) t->flags5 |= DIABLOTWEAK;
|
||||
@ -687,6 +688,7 @@ static void SetDlgFromTarget(TARGETMAP *t, CTargetDlg *dlg)
|
||||
dlg->m_SuppressD3DExt = t->flags3 & SUPPRESSD3DEXT ? 1 : 0;
|
||||
dlg->m_Enum16bitModes = t->flags7 & ENUM16BITMODES ? 1 : 0;
|
||||
dlg->m_TrimTextureFormats = t->flags8 & TRIMTEXTUREFORMATS ? 1 : 0;
|
||||
dlg->m_D3D8Back16 = t->flags8 & D3D8BACK16 ? 1 : 0;
|
||||
dlg->m_SetCompatibility = t->flags2 & SETCOMPATIBILITY ? 1 : 0;
|
||||
dlg->m_AEROBoost = t->flags5 & AEROBOOST ? 1 : 0;
|
||||
dlg->m_DiabloTweak = t->flags5 & DIABLOTWEAK ? 1 : 0;
|
||||
|
BIN
host/resource
BIN
host/resource
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user