This commit is contained in:
Guus Waals 2025-06-06 02:50:20 +08:00
parent 599c2f746b
commit 919430c923
8 changed files with 38 additions and 36 deletions

View File

@ -50,6 +50,11 @@ function(setup_target TARGET DBG_MODE)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_definitions(${TARGET} PRIVATE MSVC=1)
# Disable SAFESEH on Windows
if(WIN32)
target_link_options(${TARGET} PRIVATE /SAFESEH:NO)
endif()
else()
target_compile_definitions(${TARGET} PRIVATE MSVC=0)
@ -58,6 +63,11 @@ function(setup_target TARGET DBG_MODE)
# Ignore -Wmicrosoft-cast
target_compile_options(${TARGET} PRIVATE -Wno-microsoft-cast)
# Disable SAFESEH on Windows with Clang
if(WIN32)
# target_link_options(${TARGET} PRIVATE -Wl,/SAFESEH:NO)
endif()
endif()
# Automatically re-run CMake if any gh_*.cxx files change

View File

@ -202,4 +202,5 @@
00408d30 // strcmp
0054c925 // _chdir
0054bce5 // strlwr
00402960 // sprintf
00402960 // sprintf
0059736c // Direct3DCreate8

View File

@ -5,7 +5,6 @@
extern "C" {
undefined FUN_00496ac0(void); // 00496ac0 // FUN_00496ac0 // cdecl
IDirect3D8 * Direct3DCreate8(UINT SDKVersion); // 0051e0a8 // Direct3DCreate8 // stdcall
undefined FUN_00470b00(void); // 00470b00 // FUN_00470b00 // cdecl
undefined FUN_00484ea0(undefined4 param_1); // 00484ea0 // FUN_00484ea0 // cdecl
@ -13,7 +12,7 @@ undefined FUN_00484ea0(undefined4 param_1); // 00484ea0 // FUN_00484ea0 // cdecl
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* WARNING: Enum "_D3DFORMAT": Some values do not have unique names */
undefined4 __stdcall gfx_init(HWND hwnd,int param_2,UINT param_3,UINT param_4,int param_5)
undefined4 gfx_init(HWND hwnd,int param_2,UINT param_3,UINT param_4,int param_5)
{
undefined4 *puVar1;
@ -42,8 +41,8 @@ undefined4 __stdcall gfx_init(HWND hwnd,int param_2,UINT param_3,UINT param_4,in
} while ((int)puVar1 < 0x7eb1a4);
DAT_005bf684 = param_2;
if (param_2 == 0) {
_DAT_005e6c20 = g_GLI_width0;
_DAT_005e6c24 = g_GLI_height0;
DWORD_005e6c20 = g_GLI_width0;
DWORD_005e6c24 = g_GLI_height0;
DAT_005e6c28 = g_GLI_bitdepth0;
if (param_3 == 0) {
param_3 = g_GLI_width0;
@ -56,8 +55,8 @@ undefined4 __stdcall gfx_init(HWND hwnd,int param_2,UINT param_3,UINT param_4,in
}
}
else {
_DAT_005e6c20 = param_3;
_DAT_005e6c24 = param_4;
DWORD_005e6c20 = param_3;
DWORD_005e6c24 = param_4;
DAT_005e6c28 = param_5;
}
gfx_d3d = Direct3DCreate8(0xdc);
@ -165,15 +164,15 @@ LAB_0046fa6f:
DAT_007eafc8 = 0x3f800000;
DAT_007eafc4 = 0x3f800000;
DAT_007eafc0 = 0x3f800000;
_DAT_007eafdc = 0x3f800000;
_DAT_007eafd8 = 0x3f800000;
_DAT_007eafd4 = 0x3f800000;
_DAT_007eafd0 = 0x3f800000;
_DAT_007eaff8 = 0;
_DAT_007eaff4 = 0;
_DAT_007eaff0 = 0;
_DAT_007eaffc = 0x3f800000;
_DAT_007eb000 = 0;
DAT_007eafdc = 0x3f800000;
DAT_007eafd8 = 0x3f800000;
DAT_007eafd4 = 0x3f800000;
DAT_007eafd0 = 0x3f800000;
DAT_007eaff8 = 0;
DAT_007eaff4 = 0;
DAT_007eaff0 = 0;
DAT_007eaffc = 0x3f800000;
DAT_007eb000 = 0;
(*gfx_device->lpVtbl->SetMaterial)(gfx_device,(D3DMATERIAL8 *)&DAT_007eafc0);
(*gfx_device->lpVtbl->SetRenderState)(gfx_device,D3DRS_FOGVERTEXMODE,3);
if ((g_startOfGfxStruct.d3dSurface != (IDirect3DSurface8 *)0x0) ||
@ -183,7 +182,7 @@ LAB_0046fa6f:
(*gfx_device->lpVtbl->GetDisplayMode)(gfx_device,&DStack_54);
DStack_54.Height = 0;
DStack_54.Width = DStack_54.RefreshRate;
_g_perfCounterRate = (float)DStack_54.RefreshRate;
g_perfCounterRate = (float)DStack_54.RefreshRate;
FUN_00496ac0();
}
return 0;

View File

@ -120,8 +120,8 @@ dword& g_soundOnHD= (dword&) GH_MEM(0x005d29bc);
dword& g_complete= (dword&) GH_MEM(0x005d29c0);
undefined1& DAT_005d2b18= (undefined1&) GH_MEM(0x005d2b18);
undefined4& DAT_005e693c= (undefined4&) GH_MEM(0x005e693c);
undefined4& DAT_005e6c20= (undefined4&) GH_MEM(0x005e6c20);
undefined4& DAT_005e6c24= (undefined4&) GH_MEM(0x005e6c24);
dword& DWORD_005e6c20= (dword&) GH_MEM(0x005e6c20);
dword& DWORD_005e6c24= (dword&) GH_MEM(0x005e6c24);
undefined4& DAT_005e6c28= (undefined4&) GH_MEM(0x005e6c28);
IDirect3D8*& gfx_d3d = (IDirect3D8*&)GH_MEM(0x005e6c30); // 005e6c30
r3_astruct_2& g_startOfGfxStruct= (r3_astruct_2&) GH_MEM(0x005f5e24);
@ -150,7 +150,7 @@ undefined1& DAT_007d98fc= (undefined1&) GH_MEM(0x007d98fc);
undefined4& DAT_007d9cc4= (undefined4&) GH_MEM(0x007d9cc4);
byte& g_config_unused0= (byte&) GH_MEM(0x007d9df0);
char(&g_driveLetter)[4] = reinterpret_cast<char(&)[4]>(GH_MEM(0x007d9e70));
undefined4& g_perfCounterRate= (undefined4&) GH_MEM(0x007e5ad8);
float& g_perfCounterRate= (float&) GH_MEM(0x007e5ad8);
undefined4& DAT_007eaf60= (undefined4&) GH_MEM(0x007eaf60);
undefined4& DAT_007eaf7c= (undefined4&) GH_MEM(0x007eaf7c);
undefined4& DAT_007eafa0= (undefined4&) GH_MEM(0x007eafa0);

View File

@ -125,8 +125,8 @@ extern dword& g_soundOnHD; // 005d29bc
extern dword& g_complete; // 005d29c0
extern undefined1& DAT_005d2b18; // 005d2b18
extern undefined4& DAT_005e693c; // 005e693c
extern undefined4& DAT_005e6c20; // 005e6c20
extern undefined4& DAT_005e6c24; // 005e6c24
extern dword& DWORD_005e6c20; // 005e6c20
extern dword& DWORD_005e6c24; // 005e6c24
extern undefined4& DAT_005e6c28; // 005e6c28
extern IDirect3D8*& gfx_d3d; // 005e6c30
extern r3_astruct_2& g_startOfGfxStruct; // 005f5e24
@ -155,7 +155,7 @@ extern undefined1& DAT_007d98fc; // 007d98fc
extern undefined4& DAT_007d9cc4; // 007d9cc4
extern byte& g_config_unused0; // 007d9df0
extern char(&g_driveLetter)[4]; // 007d9e70
extern undefined4& g_perfCounterRate; // 007e5ad8
extern float& g_perfCounterRate; // 007e5ad8
extern undefined4& DAT_007eaf60; // 007eaf60
extern undefined4& DAT_007eaf7c; // 007eaf7c
extern undefined4& DAT_007eafa0; // 007eafa0

View File

@ -1,13 +0,0 @@
// AUTO-GENERATED FILE!!!!
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <r3/binders/auto.h>
#include <r3/binders/stub.h>
#include <gh_global.h>
// 0051e0a8
// Direct3DCreate8
extern "C" IDirect3D8 * Direct3DCreate8(UINT SDKVersion) {
return gh_stub_impl_stdcall<(stub_t)0x0051e0a8, IDirect3D8 *>(SDKVersion);
}

View File

@ -4,6 +4,8 @@
#define A523F6DB_0645_4DEB_8AEB_3792CB732B49
#if _WIN32
// Use the C interface for COM
#define CINTERFACE
#include <Windows.h>
#include <d3d8.h>
#include <dinput.h>

View File

@ -16,6 +16,7 @@ extern "C" {
#define HOOK_S2(addr, name) void __stdcall name(int, int);
#define HOOK_S3(addr, name) void __stdcall name(int, int, int);
#define HOOK_S4(addr, name) void __stdcall name(int, int, int, int);
#define HOOK_S5(addr, name) void __stdcall name(int, int, int, int, int);
#include "hooks.def"
#undef HOOK
#undef HOOK_S0
@ -23,6 +24,7 @@ extern "C" {
#undef HOOK_S2
#undef HOOK_S3
#undef HOOK_S4
#undef HOOK_S5
}
struct R3Bin {
@ -199,6 +201,7 @@ struct R3Bin {
#define HOOK_S2(addr, name) HOOK(addr, name)
#define HOOK_S3(addr, name) HOOK(addr, name)
#define HOOK_S4(addr, name) HOOK(addr, name)
#define HOOK_S5(addr, name) HOOK(addr, name)
#include "hooks.def"
}