1
0
mirror of synced 2025-01-20 01:32:51 +01:00

Fix DX8 window wrapper and TroubleWitches (TTX)

- Fix DX8 window wrapper
- Change up DX9 window wrapper to work in non-windowed mode for Trouble Witches (TTX) and force BackBufferFormat for that game so that it works fullscreen
- Fix TroubleWitches (TTX) saving stuff to D:\
This commit is contained in:
Nezarn 2020-06-07 14:25:08 +02:00
parent f25e1574bc
commit 838684d886
3 changed files with 34 additions and 7 deletions

View File

@ -1332,6 +1332,13 @@ static InitFunction initFunction([]()
// skip dinput devices (TODO: maybe make original Dinput.dll wrapper?)
injector::WriteMemory<BYTE>(imageBase + 0xBD1D7, 0xEB, true);
}
if (GameDetect::currentGame == GameID::TroubleWitches)
{
injector::WriteMemoryRaw(imageBase + 0xB2E6C, ".\\Save", 7, true);
injector::WriteMemoryRaw(imageBase + 0xC28B0, ".\\Save\\Config%d.bin", 20, true);
injector::WriteMemoryRaw(imageBase + 0xC28C8, ".\\Save\\Config%04d.bin", 22, true);
}
});
#endif
#pragma optimize("", on)

View File

@ -6,7 +6,7 @@
#include "Utility/GameDetect.h"
static bool swShaderHack = false;
static bool windowed = false;
//static bool windowed = false;
IDirect3D8*(WINAPI* g_origDirect3DCreate8)(UINT SDKVersion);
@ -28,12 +28,13 @@ static HRESULT(WINAPI* g_oldReset)(IDirect3DDevice8* self, D3DPRESENT_PARAMETERS
HRESULT WINAPI ResetWrap(IDirect3DDevice8* self, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
if (windowed)
if (ToBool(config["General"]["Windowed"]))
{
pPresentationParameters->Windowed = TRUE;
pPresentationParameters->FullScreen_RefreshRateInHz = 0;
pPresentationParameters->BackBufferWidth = 0;
pPresentationParameters->BackBufferHeight = 0;
pPresentationParameters->BackBufferFormat = D3DFMT_A8R8G8B8; // TODO: query current desktop format and use it
pPresentationParameters->Flags = 0;
pPresentationParameters->FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
}
@ -45,12 +46,13 @@ static HRESULT(WINAPI* g_oldCreateDevice)(IDirect3D8* self, UINT Adapter, D3DDEV
HRESULT WINAPI CreateDeviceWrap(IDirect3D8* self, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice8** ppReturnedDeviceInterface)
{
if (windowed)
if (ToBool(config["General"]["Windowed"]))
{
pPresentationParameters->Windowed = TRUE;
pPresentationParameters->FullScreen_RefreshRateInHz = 0;
pPresentationParameters->BackBufferWidth = 0;
pPresentationParameters->BackBufferHeight = 0;
pPresentationParameters->BackBufferFormat = D3DFMT_A8R8G8B8; // TODO: query current desktop format and use it
pPresentationParameters->Flags = 0;
pPresentationParameters->FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
}

View File

@ -25,8 +25,15 @@ static HRESULT(WINAPI* g_oldReset)(IDirect3DDevice9* self, D3DPRESENT_PARAMETERS
HRESULT WINAPI ResetWrap(IDirect3DDevice9* self, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
pPresentationParameters->Windowed = TRUE;
pPresentationParameters->FullScreen_RefreshRateInHz = 0;
if (ToBool(config["General"]["Windowed"]))
{
pPresentationParameters->Windowed = TRUE;
pPresentationParameters->FullScreen_RefreshRateInHz = 0;
}
if (GameDetect::currentGame == GameID::TroubleWitches)
{
pPresentationParameters->BackBufferFormat = D3DFMT_A8R8G8B8; // TODO: query current desktop format and use it
}
return g_oldReset(self, pPresentationParameters);
}
@ -35,8 +42,15 @@ static HRESULT(WINAPI* g_oldCreateDevice)(IDirect3D9* self, UINT Adapter, D3DDEV
HRESULT WINAPI CreateDeviceWrap(IDirect3D9* self, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface)
{
pPresentationParameters->Windowed = TRUE;
pPresentationParameters->FullScreen_RefreshRateInHz = 0;
if (ToBool(config["General"]["Windowed"]))
{
pPresentationParameters->Windowed = TRUE;
pPresentationParameters->FullScreen_RefreshRateInHz = 0;
}
if (GameDetect::currentGame == GameID::TroubleWitches)
{
pPresentationParameters->BackBufferFormat = D3DFMT_A8R8G8B8; // TODO: query current desktop format and use it
}
HRESULT hr = g_oldCreateDevice(self, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface);
@ -72,6 +86,10 @@ static InitFunction initFunc([]()
{
if (GameDetect::currentGame == GameID::BG4 || GameDetect::currentGame == GameID::BG4_Eng || GameDetect::currentGame == GameID::JLeague || GameDetect::currentGame == GameID::TER)
return;
if (GameDetect::currentGame == GameID::TroubleWitches && !ToBool(config["General"]["Windowed"]))
{
InitD3D9WindowHook();
}
if (ToBool(config["General"]["Windowed"]))
{
InitD3D9WindowHook();