diff --git a/CMakeLists.txt b/CMakeLists.txt index 481569be..b5f1fadd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ -cmake_minimum_required(VERSION 3.27.0) +cmake_minimum_required(VERSION 3.26.4) project(reman3) +set(GAME_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/game) + add_subdirectory(game_re) # Use highest possible C standard diff --git a/game_re/CMakeLists.txt b/game_re/CMakeLists.txt index 87dc901b..e25c01d4 100644 --- a/game_re/CMakeLists.txt +++ b/game_re/CMakeLists.txt @@ -5,15 +5,24 @@ add_link_options(-m32) add_subdirectory(third_party/spdlog) add_executable(game_re - main.cpp + r3/main.cpp + r3/binders/static_mem.cxx gh_global.cxx - binders/gh_static_mem.cxx) +) target_compile_features(game_re PUBLIC cxx_std_20) -target_include_directories(game_re PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/binders) +target_include_directories(game_re PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}) + +target_compile_definitions(game_re PRIVATE + R3_GAME_DATA_DIR=\"${GAME_DATA_DIR}\" +) + +get_filename_component(R3_DATA_SEGMENT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/gh_datasegment.bin" ABSOLUTE) +target_compile_definitions(game_re PRIVATE + R3_DATA_SEGMENT_FILE=\"${R3_DATA_SEGMENT_FILE}\" +) if(WIN32) target_link_directories(game_re PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/mssdk/lib) diff --git a/game_re/binders/gh_base.h b/game_re/binders/gh_base.h deleted file mode 100644 index 92bfd085..00000000 --- a/game_re/binders/gh_base.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef A523F6DB_0645_4DEB_8AEB_3792CB732B49 -#define A523F6DB_0645_4DEB_8AEB_3792CB732B49 - -#if _WIN32 -#include -#else -#include "../win32_shim.h" -#endif -#include -#include -#include - -typedef uint8_t undefined; -typedef uint32_t undefined4; -typedef uint16_t undefined2; -typedef uint16_t word; -typedef uint32_t dword; -struct undefined3 { - uint8_t _0; - uint8_t _1; - uint8_t _2; - - undefined3& operator=(const uint32_t& other) { - _0 = other & 0xff; - _1 = (other >> 8) & 0xff; - _2 = (other >> 16) & 0xff; - return *this; - } -}; -typedef unsigned char byte; -typedef byte undefined1; -// typedef uint64_t uint; -typedef void *pointer; -typedef char *TerminatedCString; -typedef char *string; - -enum R3ModuleId : uint8_t { - R3ModId_unk = 0x00, - R3ModId_not_initialized = 0xff, -}; - -typedef uint32_t cc_type_t; - - -template -inline constexpr undefined3 CONCAT12(T0 a, T1 b) { - return undefined3(cc_type_t(a) << 16 | cc_type_t(b)); -} -template -inline constexpr cc_type_t CONCAT11(T0 a, T1 b) { - return cc_type_t(a) << 8 | cc_type_t(b); -} -template -inline constexpr cc_type_t CONCAT21(T0 a, T1 b) { - return cc_type_t(a) << 8 | cc_type_t(b); -} - -template -inline constexpr cc_type_t CONCAT22(T0 a, T1 b) { - return cc_type_t(a) << 16 | cc_type_t(b); -} - -template -inline constexpr cc_type_t CONCAT23(T0 a, T1 b) { - return cc_type_t(a) << 24 | cc_type_t(b); -} - -template -inline constexpr char SUB21(T0 a, size_t b) { - return cc_type_t(a) >> (b * 8); -} - -template -inline constexpr char SUB41(T0 a, size_t b) { - return cc_type_t(a) >> (b * 8); -} - -template -inline constexpr uint16_t SUB42(T0 a, size_t b) { - return cc_type_t(a) >> (b * 8); -} - -// Can not export enums for some reason - -#endif /* A523F6DB_0645_4DEB_8AEB_3792CB732B49 */ diff --git a/game_re/gh_fix/FUN_0046f240.cxx b/game_re/gh_fix/FUN_0046f240.cxx index 5dd481c7..c9affc31 100644 --- a/game_re/gh_fix/FUN_0046f240.cxx +++ b/game_re/gh_fix/FUN_0046f240.cxx @@ -1,7 +1,7 @@ // AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! -#include -#include "../gh_global.h" +#include +#include extern "C" { undefined FUN_0046ecc0(undefined2 param_1, undefined2 param_2); // 0046ecc0 // FUN_0046ecc0 diff --git a/game_re/gh_fix/FUN_0047c150.cxx b/game_re/gh_fix/FUN_0047c150.cxx index 6abbfcc8..1f9e9281 100644 --- a/game_re/gh_fix/FUN_0047c150.cxx +++ b/game_re/gh_fix/FUN_0047c150.cxx @@ -1,7 +1,7 @@ // AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! -#include -#include "../gh_global.h" +#include +#include extern "C" { undefined FUN_0047c340(dword* param_1, dword* param_2, undefined4 param_3); // 0047c340 // FUN_0047c340 diff --git a/game_re/gh_fix/getHWND.cxx b/game_re/gh_fix/getHWND.cxx index ee6d1a3b..b66cccba 100644 --- a/game_re/gh_fix/getHWND.cxx +++ b/game_re/gh_fix/getHWND.cxx @@ -1,7 +1,7 @@ // AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! -#include -#include "../gh_global.h" +#include +#include // 00401410 diff --git a/game_re/gh_fix/r3_containsCmdLine.cxx b/game_re/gh_fix/r3_containsCmdLine.cxx index 23908345..8e00d75a 100644 --- a/game_re/gh_fix/r3_containsCmdLine.cxx +++ b/game_re/gh_fix/r3_containsCmdLine.cxx @@ -1,7 +1,7 @@ // AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! -#include -#include "../gh_global.h" +#include +#include extern "C" { diff --git a/game_re/gh_fix/r3_main.cxx b/game_re/gh_fix/r3_main.cxx index 5ff50d3d..d3644787 100644 --- a/game_re/gh_fix/r3_main.cxx +++ b/game_re/gh_fix/r3_main.cxx @@ -1,32 +1,38 @@ -// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! +// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! -#include -#include "../gh_global.h" +#include +#include +#include extern "C" { -undefined FUN_00470db0(void); // 00470db0 // FUN_00470db0 -undefined r3_checkDisc(void); // 004464f0 // r3_checkDisc -undefined FUN_00503710(void); // 00503710 // FUN_00503710 +undefined FUN_00470db0(void); // 00470db0 // FUN_00470db0 +undefined r3_checkDisc(void); // 004464f0 // r3_checkDisc +undefined FUN_00503710(void); // 00503710 // FUN_00503710 undefined r3_module0_init(void); // 00401000 // r3_module0_init -undefined FUN_00472150(void); // 00472150 // FUN_00472150 -undefined r3_wait_for_dvd(char * param_1, char * param_2, undefined4 param_3); // 0043e540 // r3_wait_for_dvd -undefined FUN_004725a0(void); // 004725a0 // FUN_004725a0 -uint32_t r3_containsCmdLine(uint * param_1, char * param_2); // 004028e0 // r3_containsCmdLine -int r3_get_gli_width1(void); // 0047baf0 // r3_get_gli_width1 -undefined gfx_init2(void); // 00470be0 // gfx_init2 -void g_setInitVar0(void); // 00401310 // g_setInitVar0 -int r3_get_gli_height1(void); // 0047bb00 // r3_get_gli_height1 -undefined FUN_004010b0(void); // 004010b0 // FUN_004010b0 -undefined FUN_00401320(void); // 00401320 // FUN_00401320 -void r3_noop(void * p_cTxt1, void * p_cTxt2); // 00401100 // r3_noop -undefined r3_initEngine(void); // 00401220 // r3_initEngine -undefined FUN_005038e0(void); // 005038e0 // FUN_005038e0 -undefined FUN_004fb300(void); // 004fb300 // FUN_004fb300 -undefined spawnThread(void); // 004477d0 // spawnThread -undefined r3_setupWindow(HINSTANCE hInstance, undefined4 param_2, undefined4 maximizeWindow); // 00402140 // r3_setupWindow +undefined FUN_00472150(void); // 00472150 // FUN_00472150 +undefined r3_wait_for_dvd(char *param_1, char *param_2, + undefined4 param_3); // 0043e540 // r3_wait_for_dvd +undefined FUN_004725a0(void); // 004725a0 // FUN_004725a0 +uint32_t r3_containsCmdLine(uint *param_1, + char *param_2); // 004028e0 // r3_containsCmdLine +int r3_get_gli_width1(void); // 0047baf0 // r3_get_gli_width1 +undefined gfx_init2(void); // 00470be0 // gfx_init2 +void g_setInitVar0(void); // 00401310 // g_setInitVar0 +int r3_get_gli_height1(void); // 0047bb00 // r3_get_gli_height1 +undefined FUN_004010b0(void); // 004010b0 // FUN_004010b0 +undefined FUN_00401320(void); // 00401320 // FUN_00401320 +void r3_noop(void *p_cTxt1, void *p_cTxt2); // 00401100 // r3_noop +undefined r3_initEngine(void); // 00401220 // r3_initEngine +undefined FUN_005038e0(void); // 005038e0 // FUN_005038e0 +undefined FUN_004fb300(void); // 004fb300 // FUN_004fb300 +undefined spawnThread(void); // 004477d0 // spawnThread +undefined +r3_setupWindow(HINSTANCE hInstance, undefined4 param_2, + undefined4 maximizeWindow); // 00402140 // r3_setupWindow // 00401630 -int r3_main(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR *cmdline,int showCmd) +int r3_main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR *cmdline, + int showCmd) { undefined4 uVar1; @@ -57,18 +63,18 @@ int r3_main(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR *cmdline,int showC HKEY pHStack_838; HANDLE pvStack_834; UINT UStack_830; - BYTE aBStack_82c [4]; + BYTE aBStack_82c[4]; DWORD DStack_828; DWORD DStack_824; tagRECT tStack_820; - char acStack_810 [260]; - CHAR languageStr [256]; - CHAR pathToUbi_ini [260]; - char acStack_508 [260]; - CHAR windowsDir [260]; - char acStack_300 [256]; - char acStack_200 [256]; - char acStack_100 [256]; + char acStack_810[260]; + CHAR languageStr[256]; + CHAR pathToUbi_ini[260]; + char acStack_508[260]; + CHAR windowsDir[260]; + char acStack_300[256]; + char acStack_200[256]; + char acStack_100[256]; BOOL BVar18; char cVar1; undefined4 chars; @@ -77,169 +83,28 @@ int r3_main(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR *cmdline,int showC HANDLE *lpTargetHandle; undefined2 uVar2; undefined4 uVar22; - - /* Append windows dir / ubi.ini */ - GetWindowsDirectoryA(pathToUbi_ini,0x104); - iVar13 = -1; - pcVar4 = pathToUbi_ini; - do { - pcVar17 = pcVar4; - if (iVar13 == 0) break; - iVar13 = iVar13 + -1; - pcVar17 = pcVar4 + 1; - cVar1 = *pcVar4; - pcVar4 = pcVar17; - } while (cVar1 != '\0'); - *(undefined4 *)(pcVar17 + -1) = s_UbiSoft_Ubi_ini + Field<0, 4>(); - *(undefined4 *)(pcVar17 + 3) = s_UbiSoft_Ubi_ini + Field<4, 4>(); - *(undefined4 *)(pcVar17 + 7) = s_UbiSoft_Ubi_ini + Field<8, 4>(); - *(undefined4 *)(pcVar17 + 0xb) = s_UbiSoft_Ubi_ini + Field<12, 4>(); - pcVar17[0xf] = s_UbiSoft_Ubi_ini[0x10]; + pCVar3 = GetCommandLineA(); - pcVar4 = pCVar3 + 1; - iVar13 = -(int)pcVar4; - do { - cVar1 = *pcVar4; - pcVar4[(int)(acStack_810 + iVar13)] = cVar1; - pcVar4 = pcVar4 + 1; - } while (cVar1 != '\0'); - pcVar4 = strrchr(acStack_810,0x5c); - if (pcVar4 == (char *)0x0) { - /* Read from ubi.ini */ - GetPrivateProfileStringA - (lpAppName_005b68f0,s_Directory_005b68f8,s_None,acStack_810,0xff,pathToUbi_ini); - iVar13 = strcmpi(acStack_810,s_None); - } - else { - pcVar4 = strrchr(acStack_810,0x5c); - *pcVar4 = '\0'; - iVar13 = chdir(acStack_810); - if (iVar13 != -1) goto LAB_00401765; - /* Read from ubi.ini */ - GetPrivateProfileStringA - (lpAppName_005b68f0,s_Directory_005b68f8,s_None,acStack_810,0xff,pathToUbi_ini); - iVar13 = strcmpi(acStack_810,s_None); - } - if (iVar13 != 0) { - chdir(acStack_810); - } -LAB_00401765: - /* strcpy */ - iVar13 = 0; - do { - cVar1 = acStack_810[iVar13]; - r3_main_data_005d28b6.gameDataDir[iVar13] = cVar1; - iVar13 = iVar13 + 1; - } while (cVar1 != '\0'); - strlwr(r3_main_data_005d28b6.gameDataDir); - iVar13 = -1; - pcVar4 = r3_main_data_005d28b6.gameDataDir; - do { - if (iVar13 == 0) break; - iVar13 = iVar13 + -1; - cVar1 = *pcVar4; - pcVar4 = pcVar4 + 1; - } while (cVar1 != '\0'); -joined_r0x00401792: - if (iVar13 != -2) { - uVar14 = 0xffffffff; - pcVar4 = r3_main_data_005d28b6.gameDataDir; - do { - if (uVar14 == 0) break; - uVar14 = uVar14 - 1; - cVar1 = *pcVar4; - pcVar4 = pcVar4 + 1; - } while (cVar1 != '\0'); - if (r3_main_data_005d28b6.gameDataDir[~uVar14 - 2] != '\\') goto LAB_004017ce; - uVar14 = 0xffffffff; - pcVar4 = r3_main_data_005d28b6.gameDataDir; - do { - if (uVar14 == 0) break; - uVar14 = uVar14 - 1; - cVar1 = *pcVar4; - pcVar4 = pcVar4 + 1; - } while (cVar1 != '\0'); - r3_main_data_005d28b6.gameDataDir[~uVar14 - 2] = '\0'; - iVar13 = -1; - pcVar4 = r3_main_data_005d28b6.gameDataDir; - do { - if (iVar13 == 0) break; - iVar13 = iVar13 + -1; - cVar1 = *pcVar4; - pcVar4 = pcVar4 + 1; - } while (cVar1 != '\0'); - goto joined_r0x00401792; - } -LAB_004017ce: - pFVar5 = fopen(pathToUbi_ini,fopen_mode_r_text); - GetPrivateProfileStringA - (lpAppName_005b68f0,s_Adapter_005b68e4,(LPCSTR)&lpDefault_005cf96c,acStack_300,0xff, - pathToUbi_ini); - if ((pFVar5 == (FILE *)0x0) || (acStack_300[0] == '\0')) { - /* Concat game data dir with r3 setup exe */ - iVar13 = 0; - do { - cVar1 = r3_main_data_005d28b6.gameDataDir[iVar13]; - acStack_508[iVar13] = cVar1; - iVar13 = iVar13 + 1; - } while (cVar1 != '\0'); - iVar13 = -1; - pcVar4 = acStack_508; - do { - pcVar17 = pcVar4; - if (iVar13 == 0) break; - iVar13 = iVar13 + -1; - pcVar17 = pcVar4 + 1; - cVar1 = *pcVar4; - pcVar4 = pcVar17; - } while (cVar1 != '\0'); - *(undefined4 *)(pcVar17 + -1) = s__R3_Setup_DX8_exe_005b68d0 + Field<0, 4>(); - *(undefined4 *)(pcVar17 + 3) = s__R3_Setup_DX8_exe_005b68d0 + Field<4, 4>(); - *(undefined4 *)(pcVar17 + 7) = s__R3_Setup_DX8_exe_005b68d0 + Field<8, 4>(); - *(undefined4 *)(pcVar17 + 0xb) = s__R3_Setup_DX8_exe_005b68d0 + Field<12, 4>(); - *(undefined2 *)(pcVar17 + 0xf) = s__R3_Setup_DX8_exe_005b68d0 + Field<16, 2>(); - pFVar5 = fopen(acStack_508,fopen_mode_r_binary); - if (pFVar5 == (FILE *)0x0) { - MessageBoxA((HWND)0x0,s_Unable_to_find_R3_Setup_DX8_exe__005b6880,s_Rayman_3_Error_005b68bc, - 0x10); - return -1; - } - fclose(pFVar5); - spawnl(0,acStack_508,acStack_508,0); - pFVar5 = fopen(pathToUbi_ini,fopen_mode_r_text); - if (pFVar5 == (FILE *)0x0) { - return -1; - } - } - fclose(pFVar5); - /* Open reg key - HKEY_LOCAL_MACHINE\\SOFTWARE\\UBI SOFT\\RAYMAN 3 */ - LVar6 = RegOpenKeyExA((HKEY)0x80000002,s_SOFTWARE_UBI_SOFT_RAYMAN_3_005b6864,0,0x20019, - &pHStack_838); - if (LVar6 == 0) { - LVar6 = RegQueryValueExA(pHStack_838,s_CompleteInstall_005b6854,(LPDWORD)0x0,&DStack_824, - aBStack_82c,&DStack_828); - DAT_007d9cc4 = (uint)(LVar6 == 0); - if (pHStack_838 != (HKEY)0x0) { - RegCloseKey(pHStack_838); - } - } - else { - DAT_007d9cc4 = 0; - } - GetPrivateProfileStringA - (lpAppName_005b68f0,s_Language_005b6840,s_English_005b684c,languageStr,0xff, - pathToUbi_ini); - sprintf(g_mutexName_Rayman3,s_percents,lpAppName_005b68f0); - sprintf(g_windowTitle,s_percents,s_windowTitle); - /* Setup localized quiting/restoring strings */ - iVar13 = strcmpi(languageStr,s_French_005b6828); + + R3Config &gameConfig = getDefaultConfig(); + + // Store and change to game directory + chdir(gameConfig.gameDataDir.c_str()); + strcpy(r3_main_data_005d28b6.gameDataDir, gameConfig.gameDataDir.c_str()); + + strcpy(languageStr, gameConfig.language.c_str()); + sprintf(g_mutexName_Rayman3, s_percents, lpAppName_005b68f0); + sprintf(g_windowTitle, s_percents, s_windowTitle); + + /* Setup localized quiting/restoring strings */ + iVar13 = strcmpi(languageStr, s_French_005b6828); if (iVar13 == 0) { - sprintf(s_windowTitleRestoring,s_Restauration_fmt,s_windowTitle); + sprintf(s_windowTitleRestoring, s_Restauration_fmt, s_windowTitle); chars = s_QUITTER + Field<4, 4>(); puVar15 = (undefined4 *)s_ou_appuyez_sur_Echap_pour_quitte_005b67d0; puVar16 = (undefined4 *)s_quitting1; - for (iVar13 = 0xb; uVar22 = s_QUITTER + Field<4, 4>(), iVar13 != 0; iVar13 = iVar13 + -1) { + for (iVar13 = 0xb; uVar22 = s_QUITTER + Field<4, 4>(), iVar13 != 0; + iVar13 = iVar13 + -1) { *puVar16 = *puVar15; puVar15 = puVar15 + 1; puVar16 = puVar16 + 1; @@ -248,17 +113,17 @@ LAB_004017ce: s_wndStrQuiting[1] = s_QUITTER[1]; s_wndStrQuiting[2] = s_QUITTER[2]; s_wndStrQuiting[3] = s_QUITTER[3]; - /* Wrong decompilation? */ + /* Wrong decompilation? */ s_QUITTER[4] = (char)chars; - s_QUITTER[5] = SUB41(chars,1); - s_QUITTER[6] = SUB41(chars,2); - s_QUITTER[7] = SUB41(chars,3); + s_QUITTER[5] = SUB41(chars, 1); + s_QUITTER[6] = SUB41(chars, 2); + s_QUITTER[7] = SUB41(chars, 3); s_wndStrQuiting[4] = s_QUITTER[4]; s_wndStrQuiting[5] = s_QUITTER[5]; s_wndStrQuiting[6] = s_QUITTER[6]; s_wndStrQuiting[7] = s_QUITTER[7]; s_QUITTER + Field<4, 4>() = uVar22; - sprintf(lpString_0077d2c0,s__s___Pause_005b67c4,s_windowTitle); + sprintf(lpString_0077d2c0, s__s___Pause_005b67c4, s_windowTitle); puVar15 = (undefined4 *)s_Restauration; puVar16 = (undefined4 *)s_wndStrRestoring; for (iVar13 = 7; iVar13 != 0; iVar13 = iVar13 + -1) { @@ -266,15 +131,16 @@ LAB_004017ce: puVar15 = puVar15 + 1; puVar16 = puVar16 + 1; } - } - else { - iVar13 = strcmpi(languageStr,s_Spanish_005b67a0); + } else { + iVar13 = strcmpi(languageStr, s_Spanish_005b67a0); if (iVar13 == 0) { - sprintf(s_windowTitleRestoring,s__s___Restablecer_datos____005b6784,s_windowTitle); + sprintf(s_windowTitleRestoring, s__s___Restablecer_datos____005b6784, + s_windowTitle); uVar2 = s_SALIR_005b675c + Field<4, 2>(); puVar15 = (undefined4 *)s_Pulsa_ESC_para_salir_Rayman_3__005b6764; puVar16 = (undefined4 *)s_quitting1; - for (iVar13 = 7; chars = s_SALIR_005b675c + Field<0, 4>(), iVar13 != 0; iVar13 = iVar13 + -1) { + for (iVar13 = 7; chars = s_SALIR_005b675c + Field<0, 4>(), iVar13 != 0; + iVar13 = iVar13 + -1) { *puVar16 = *puVar15; puVar15 = puVar15 + 1; puVar16 = puVar16 + 1; @@ -284,20 +150,20 @@ LAB_004017ce: uVar3 = s_SALIR_005b675c + Field<4, 2>(); uVar22 = s_SALIR_005b675c + Field<0, 4>(); s_SALIR_005b675c[0] = (char)chars; - s_SALIR_005b675c[1] = SUB41(chars,1); - s_SALIR_005b675c[2] = SUB41(chars,2); - s_SALIR_005b675c[3] = SUB41(chars,3); + s_SALIR_005b675c[1] = SUB41(chars, 1); + s_SALIR_005b675c[2] = SUB41(chars, 2); + s_SALIR_005b675c[3] = SUB41(chars, 3); s_wndStrQuiting[0] = s_SALIR_005b675c[0]; s_wndStrQuiting[1] = s_SALIR_005b675c[1]; s_wndStrQuiting[2] = s_SALIR_005b675c[2]; s_wndStrQuiting[3] = s_SALIR_005b675c[3]; s_SALIR_005b675c[4] = (char)uVar2; - s_SALIR_005b675c[5] = SUB21(uVar2,1); + s_SALIR_005b675c[5] = SUB21(uVar2, 1); s_wndStrQuiting[4] = s_SALIR_005b675c[4]; s_wndStrQuiting[5] = s_SALIR_005b675c[5]; s_SALIR_005b675c + Field<0, 4>() = uVar22; s_SALIR_005b675c + Field<4, 2>() = uVar3; - sprintf(lpString_0077d2c0,s__s___Rotura_005b6750,s_windowTitle); + sprintf(lpString_0077d2c0, s__s___Rotura_005b6750, s_windowTitle); puVar15 = (undefined4 *)s_Restablecer_datos____005b6738; puVar16 = (undefined4 *)s_wndStrRestoring; for (iVar13 = 5; iVar13 != 0; iVar13 = iVar13 + -1) { @@ -306,15 +172,16 @@ LAB_004017ce: puVar16 = puVar16 + 1; } *(undefined *)puVar16 = *(undefined *)puVar15; - } - else { - iVar13 = strcmpi(languageStr,s_Italian_005b6730); + } else { + iVar13 = strcmpi(languageStr, s_Italian_005b6730); if (iVar13 == 0) { - sprintf(s_windowTitleRestoring,s__s___Ripristino_dati____005b6718,s_windowTitle); + sprintf(s_windowTitleRestoring, s__s___Ripristino_dati____005b6718, + s_windowTitle); uVar2 = s_USCIRE_005b66ec + Field<4, 2>(); puVar15 = (undefined4 *)s_Premi_ESC_per_uscire_da_Rayman_3_005b66f4; puVar16 = (undefined4 *)s_quitting1; - for (iVar13 = 8; cVar1 = s_USCIRE_005b66ec[6], iVar13 != 0; iVar13 = iVar13 + -1) { + for (iVar13 = 8; cVar1 = s_USCIRE_005b66ec[6], iVar13 != 0; + iVar13 = iVar13 + -1) { *puVar16 = *puVar15; puVar15 = puVar15 + 1; puVar16 = puVar16 + 1; @@ -324,8 +191,8 @@ LAB_004017ce: s_wndStrQuiting[2] = s_USCIRE_005b66ec[2]; s_wndStrQuiting[3] = s_USCIRE_005b66ec[3]; *(undefined2 *)puVar16 = *(undefined2 *)puVar15; - s_wndStrQuiting + Field<4, 3>() = CONCAT12(cVar1,uVar2); - sprintf(lpString_0077d2c0,s__s___Pausa_005b66e0,s_windowTitle); + s_wndStrQuiting + Field<4, 3>() = CONCAT12(cVar1, uVar2); + sprintf(lpString_0077d2c0, s__s___Pausa_005b66e0, s_windowTitle); s_wndStrRestoring[0] = s_Ripristino_dati____005b66cc[0]; s_wndStrRestoring[1] = s_Ripristino_dati____005b66cc[1]; s_wndStrRestoring[2] = s_Ripristino_dati____005b66cc[2]; @@ -338,19 +205,22 @@ LAB_004017ce: s_wndStrRestoring[9] = s_Ripristino_dati____005b66cc[9]; s_wndStrRestoring[10] = s_Ripristino_dati____005b66cc[10]; s_wndStrRestoring[0xb] = s_Ripristino_dati____005b66cc[0xb]; - s_wndStrRestoring + Field<12, 4>() = s_Ripristino_dati____005b66cc + Field<12, 4>(); - s_wndStrRestoring + Field<16, 2>() = s_Ripristino_dati____005b66cc + Field<16, 2>(); + s_wndStrRestoring + Field<12, 4>() = + s_Ripristino_dati____005b66cc + Field<12, 4>(); + s_wndStrRestoring + Field<16, 2>() = + s_Ripristino_dati____005b66cc + Field<16, 2>(); s_wndStrRestoring[0x12] = s_Ripristino_dati____005b66cc[0x12]; - } - else { - iVar13 = strcmpi(languageStr,s_German_005b66c4); + } else { + iVar13 = strcmpi(languageStr, s_German_005b66c4); if (iVar13 == 0) { - sprintf(s_windowTitleRestoring,s__s___Daten_Reparatur____005b66ac,s_windowTitle); + sprintf(s_windowTitleRestoring, s__s___Daten_Reparatur____005b66ac, + s_windowTitle); chars = s_BEENDIGEN_005b6678 + Field<0, 4>(); puVar15 = (undefined4 *)&CHAR_E_005b6684; puVar16 = (undefined4 *)s_quitting1; - for (iVar13 = 9; uVar2 = s_BEENDIGEN_005b6678 + Field<8, 2>(), uVar22 = s_BEENDIGEN_005b6678 + Field<4, 4>(), - iVar13 != 0; iVar13 = iVar13 + -1) { + for (iVar13 = 9; uVar2 = s_BEENDIGEN_005b6678 + Field<8, 2>(), + uVar22 = s_BEENDIGEN_005b6678 + Field<4, 4>(), iVar13 != 0; + iVar13 = iVar13 + -1) { *puVar16 = *puVar15; puVar15 = puVar15 + 1; puVar16 = puVar16 + 1; @@ -358,9 +228,9 @@ LAB_004017ce: *(undefined2 *)puVar16 = *(undefined2 *)puVar15; uVar1 = s_BEENDIGEN_005b6678 + Field<0, 4>(); s_BEENDIGEN_005b6678[0] = (char)chars; - s_BEENDIGEN_005b6678[1] = SUB41(chars,1); - s_BEENDIGEN_005b6678[2] = SUB41(chars,2); - s_BEENDIGEN_005b6678[3] = SUB41(chars,3); + s_BEENDIGEN_005b6678[1] = SUB41(chars, 1); + s_BEENDIGEN_005b6678[2] = SUB41(chars, 2); + s_BEENDIGEN_005b6678[3] = SUB41(chars, 3); s_wndStrQuiting[0] = s_BEENDIGEN_005b6678[0]; s_wndStrQuiting[1] = s_BEENDIGEN_005b6678[1]; s_wndStrQuiting[2] = s_BEENDIGEN_005b6678[2]; @@ -370,20 +240,20 @@ LAB_004017ce: uVar3 = s_BEENDIGEN_005b6678 + Field<8, 2>(); chars = s_BEENDIGEN_005b6678 + Field<4, 4>(); s_BEENDIGEN_005b6678[4] = (char)uVar22; - s_BEENDIGEN_005b6678[5] = SUB41(uVar22,1); - s_BEENDIGEN_005b6678[6] = SUB41(uVar22,2); - s_BEENDIGEN_005b6678[7] = SUB41(uVar22,3); + s_BEENDIGEN_005b6678[5] = SUB41(uVar22, 1); + s_BEENDIGEN_005b6678[6] = SUB41(uVar22, 2); + s_BEENDIGEN_005b6678[7] = SUB41(uVar22, 3); s_wndStrQuiting[4] = s_BEENDIGEN_005b6678[4]; s_wndStrQuiting[5] = s_BEENDIGEN_005b6678[5]; s_wndStrQuiting[6] = s_BEENDIGEN_005b6678[6]; s_wndStrQuiting[7] = s_BEENDIGEN_005b6678[7]; s_BEENDIGEN_005b6678[8] = (char)uVar2; - s_BEENDIGEN_005b6678[9] = SUB21(uVar2,1); + s_BEENDIGEN_005b6678[9] = SUB21(uVar2, 1); s_wndStrQuiting[8] = s_BEENDIGEN_005b6678[8]; s_wndStrQuiting[9] = s_BEENDIGEN_005b6678[9]; s_BEENDIGEN_005b6678 + Field<4, 4>() = chars; s_BEENDIGEN_005b6678 + Field<8, 2>() = uVar3; - sprintf(lpString_0077d2c0,s__s___Pause_005b67c4,s_windowTitle); + sprintf(lpString_0077d2c0, s__s___Pause_005b67c4, s_windowTitle); s_wndStrRestoring[0] = s_Daten_Reparatur____005b6664[0]; s_wndStrRestoring[1] = s_Daten_Reparatur____005b6664[1]; s_wndStrRestoring[2] = s_Daten_Reparatur____005b6664[2]; @@ -403,13 +273,14 @@ LAB_004017ce: s_wndStrRestoring[0x10] = s_Daten_Reparatur____005b6664[0x10]; s_wndStrRestoring[0x11] = s_Daten_Reparatur____005b6664[0x11]; s_wndStrRestoring[0x12] = s_Daten_Reparatur____005b6664[0x12]; - } - else { - sprintf(s_windowTitleRestoring,s__s___Restoring_data____005b664c,s_windowTitle); + } else { + sprintf(s_windowTitleRestoring, s__s___Restoring_data____005b664c, + s_windowTitle); chars = s_QUIT + Field<0, 4>(); puVar15 = (undefined4 *)s_or_press_ESC_to_quit_Rayman_3__005b662c; puVar16 = (undefined4 *)s_quitting1; - for (iVar13 = 7; cVar1 = s_QUIT[4], iVar13 != 0; iVar13 = iVar13 + -1) { + for (iVar13 = 7; cVar1 = s_QUIT[4], iVar13 != 0; + iVar13 = iVar13 + -1) { *puVar16 = *puVar15; puVar15 = puVar15 + 1; puVar16 = puVar16 + 1; @@ -418,16 +289,16 @@ LAB_004017ce: *(undefined *)((int)puVar16 + 2) = *(undefined *)((int)puVar15 + 2); uVar22 = s_QUIT + Field<0, 4>(); s_QUIT[0] = (char)chars; - s_QUIT[1] = SUB41(chars,1); - s_QUIT[2] = SUB41(chars,2); - s_QUIT[3] = SUB41(chars,3); + s_QUIT[1] = SUB41(chars, 1); + s_QUIT[2] = SUB41(chars, 2); + s_QUIT[3] = SUB41(chars, 3); s_wndStrQuiting[0] = s_QUIT[0]; s_wndStrQuiting[1] = s_QUIT[1]; s_wndStrQuiting[2] = s_QUIT[2]; s_wndStrQuiting[3] = s_QUIT[3]; s_wndStrQuiting[4] = cVar1; s_QUIT + Field<0, 4>() = uVar22; - sprintf(lpString_0077d2c0,s__s___Pause_005b67c4,s_windowTitle); + sprintf(lpString_0077d2c0, s__s___Pause_005b67c4, s_windowTitle); s_wndStrRestoring[0] = s_Restoring_data_____005b6610[0]; s_wndStrRestoring[1] = s_Restoring_data_____005b6610[1]; s_wndStrRestoring[2] = s_Restoring_data_____005b6610[2]; @@ -440,86 +311,73 @@ LAB_004017ce: s_wndStrRestoring[9] = s_Restoring_data_____005b6610[9]; s_wndStrRestoring[10] = s_Restoring_data_____005b6610[10]; s_wndStrRestoring[0xb] = s_Restoring_data_____005b6610[0xb]; - s_wndStrRestoring + Field<12, 4>() = s_Restoring_data_____005b6610 + Field<12, 4>(); - s_wndStrRestoring + Field<16, 2>() = s_Restoring_data_____005b6610 + Field<16, 2>(); + s_wndStrRestoring + Field<12, 4>() = + s_Restoring_data_____005b6610 + Field<12, 4>(); + s_wndStrRestoring + Field<16, 2>() = + s_Restoring_data_____005b6610 + Field<16, 2>(); s_wndStrRestoring[0x12] = s_Restoring_data_____005b6610[0x12]; } } } } - /* Create draw semaphore - Initial count = 1 - Maximum count = 1 */ - g_drawSemaphore = CreateSemaphoreA((LPSECURITY_ATTRIBUTES)0x0,1,1,s_DRAWSEM_005b6608); + + /* Create draw semaphore + Initial count = 1 + Maximum count = 1 */ + g_drawSemaphore = + CreateSemaphoreA((LPSECURITY_ATTRIBUTES)0x0, 1, 1, s_DRAWSEM_005b6608); if (hPrevInstance != (HINSTANCE)0x0) { return -1; } - /* Load DirectPlay probably unused */ - hLibModule = LoadLibraryA(s_dpnhpast_dll_005b65f8); - if (hLibModule == (HMODULE)0x0) { - iVar13 = strcmpi(languageStr,s_French_005b6828); - if (iVar13 == 0) { - MessageBoxA((HWND)0x0,lpText_005b6598,s_Erreur_Rayman_3_005b65e4,0x10); - return -1; - } - iVar13 = strcmpi(languageStr,s_Spanish_005b67a0); - if (iVar13 == 0) { - MessageBoxA((HWND)0x0,lpText_005b6540,s_Rayman_3_005b6588,0x10); - return -1; - } - iVar13 = strcmpi(languageStr,s_Italian_005b6730); - if (iVar13 == 0) { - MessageBoxA((HWND)0x0,lpText_005b64f0,s_Rayman_3_005b6588,0x10); - return -1; - } - iVar13 = strcmpi(languageStr,s_German_005b66c4); - if (iVar13 != 0) { - MessageBoxA((HWND)0x0,s_Check_your_version_of_DirectX__V_005b6430,s_Rayman_3_Error_005b68bc, - 0x10); - return -1; - } - MessageBoxA((HWND)0x0,lpText_005b6478,s_Rayman_3_005b6588,0x10); - return -1; - } - FreeLibrary(hLibModule); - CreateMutexA((LPSECURITY_ATTRIBUTES)0x0,1,g_mutexName_Rayman3); - DVar7 = GetLastError(); - if (DVar7 == 0xb7) { - /* Mutex already exists */ - return -1; - } - GetWindowsDirectoryA(windowsDir,0x104); - iVar13 = -1; - /* Append ubi.ini */ - pcVar4 = windowsDir; - do { - pcVar17 = pcVar4; - if (iVar13 == 0) break; - iVar13 = iVar13 + -1; - pcVar17 = pcVar4 + 1; - cVar1 = *pcVar4; - pcVar4 = pcVar17; - } while (cVar1 != '\0'); - *(undefined4 *)(pcVar17 + -1) = s_UbiSoft_Ubi_ini + Field<0, 4>(); - *(undefined4 *)(pcVar17 + 3) = s_UbiSoft_Ubi_ini + Field<4, 4>(); - *(undefined4 *)(pcVar17 + 7) = s_UbiSoft_Ubi_ini + Field<8, 4>(); - *(undefined4 *)(pcVar17 + 0xb) = s_UbiSoft_Ubi_ini + Field<12, 4>(); - pcVar17[0xf] = s_UbiSoft_Ubi_ini[0x10]; - /* Read graphics settings */ - GetPrivateProfileStringA - (lpAppName_005b68f0,s_Adapter_005b68e4,(LPCSTR)&lpDefault_005cf96c,acStack_300,0xff, - windowsDir); - GetPrivateProfileStringA - (lpAppName_005b68f0,s_Identifier_005b6420,(LPCSTR)&lpDefault_005cf96c,acStack_100,0xff, - windowsDir); - GetPrivateProfileStringA - (lpAppName_005b68f0,s_Gli_Mode_005b6414,(LPCSTR)&lpDefault_005cf96c,acStack_200,0xff, - windowsDir); - /* If they're all set */ - if (((acStack_300[0] != '\0') && (acStack_100[0] != '\0')) && (acStack_200[0] != '\0')) { - /* For GLIMode - 1 = maximize - 0 = windowed */ + + /* Load DirectPlay probably unused */ + // hLibModule = LoadLibraryA(s_dpnhpast_dll_005b65f8); + // if (hLibModule == (HMODULE)0x0) { + // iVar13 = strcmpi(languageStr, s_French_005b6828); + // if (iVar13 == 0) { + // MessageBoxA((HWND)0x0, lpText_005b6598, s_Erreur_Rayman_3_005b65e4, + // 0x10); return -1; + // } + // iVar13 = strcmpi(languageStr, s_Spanish_005b67a0); + // if (iVar13 == 0) { + // MessageBoxA((HWND)0x0, lpText_005b6540, s_Rayman_3_005b6588, 0x10); + // return -1; + // } + // iVar13 = strcmpi(languageStr, s_Italian_005b6730); + // if (iVar13 == 0) { + // MessageBoxA((HWND)0x0, lpText_005b64f0, s_Rayman_3_005b6588, 0x10); + // return -1; + // } + // iVar13 = strcmpi(languageStr, s_German_005b66c4); + // if (iVar13 != 0) { + // MessageBoxA((HWND)0x0, s_Check_your_version_of_DirectX__V_005b6430, + // s_Rayman_3_Error_005b68bc, 0x10); + // return -1; + // } + // MessageBoxA((HWND)0x0, lpText_005b6478, s_Rayman_3_005b6588, 0x10); + // return -1; + // } + // FreeLibrary(hLibModule); + + // Run only once + // CreateMutexA((LPSECURITY_ATTRIBUTES)0x0, 1, g_mutexName_Rayman3); + // DVar7 = GetLastError(); + // if (DVar7 == 0xb7) { + // /* Mutex already exists */ + // return -1; + // } + + /* Read graphics settings */ + strcpy(acStack_300, getDefaultConfig().gfxAdapter.c_str()); + strcpy(acStack_100, getDefaultConfig().gfxIdentifier.c_str()); + strcpy(acStack_200, getDefaultConfig().gfxGliMode.c_str()); + + /* If they're all set */ + if (((acStack_300[0] != '\0') && (acStack_100[0] != '\0')) && + (acStack_200[0] != '\0')) { + /* For GLIMode + 1 = maximize + 0 = windowed */ g_runMaximized = (int)(acStack_200[0] != '0'); r3_checkDisc(); dwOptions = 0; @@ -530,10 +388,10 @@ LAB_004017ce: hTargetProcessHandle = GetCurrentProcess(); hSourceHandle = GetCurrentThread(); hSourceProcessHandle = GetCurrentProcess(); - DuplicateHandle(hSourceProcessHandle,hSourceHandle,hTargetProcessHandle,lpTargetHandle,DVar7, - BVar18,dwOptions); + DuplicateHandle(hSourceProcessHandle, hSourceHandle, hTargetProcessHandle, + lpTargetHandle, DVar7, BVar18, dwOptions); g_mainThreadHandle = pvStack_834; - /* Copy cmdline */ + /* Copy cmdline */ ppCVar8 = cmdline; do { cVar1 = *(char *)ppCVar8; @@ -541,10 +399,10 @@ LAB_004017ce: ppCVar8 = (LPSTR *)((int)ppCVar8 + 1); } while (cVar1 != '\0'); SetErrorMode(1); - uVar9 = r3_containsCmdLine((uint *)cmdline,s_dashCC); + uVar9 = r3_containsCmdLine((uint *)cmdline, s_dashCC); if (uVar9 == 0) { r3_module0_init(); - iVar13 = r3_setupWindow(hInstance,showCmd,g_runMaximized); + iVar13 = r3_setupWindow(hInstance, showCmd, g_runMaximized); if (iVar13 == 0) { return -1; } @@ -554,7 +412,7 @@ LAB_004017ce: gfx_init2(); lpRect = &tStack_820; hWnd = GetDesktopWindow(); - GetWindowRect(hWnd,lpRect); + GetWindowRect(hWnd, lpRect); BVar18 = 1; iVar13 = r3_get_gli_height1(); iVar13 = iVar13 + 0x20; @@ -563,13 +421,14 @@ LAB_004017ce: iVar11 = r3_get_gli_height1(); iVar11 = (tStack_820.bottom - iVar11) / 2; iVar12 = r3_get_gli_width1(); - MoveWindow(g_gameHWND,(tStack_820.right - iVar12) / 2,iVar11,iVar10,iVar13,BVar18); + MoveWindow(g_gameHWND, (tStack_820.right - iVar12) / 2, iVar11, iVar10, + iVar13, BVar18); FUN_004010b0(); - SystemParametersInfoA(0x10,0,&UStack_830,0); - SystemParametersInfoA(0x11,0,(PVOID)0x0,0); + SystemParametersInfoA(0x10, 0, &UStack_830, 0); + SystemParametersInfoA(0x11, 0, (PVOID)0x0, 0); ShowCursor(0); uStack_83c = 0; - SystemParametersInfoA(0x61,1,&uStack_83c,0); + SystemParametersInfoA(0x61, 1, &uStack_83c, 0); g_engineRunning = 1; r3_initEngine(); FUN_004725a0(); @@ -579,19 +438,17 @@ LAB_004017ce: FUN_00472150(); FUN_00470db0(); uStack_83c = 0; - SystemParametersInfoA(0x61,0,&uStack_83c,0); + SystemParametersInfoA(0x61, 0, &uStack_83c, 0); ShowCursor(1); - SystemParametersInfoA(0x11,UStack_830,(PVOID)0x0,0); + SystemParametersInfoA(0x11, UStack_830, (PVOID)0x0, 0); CloseHandle(pvStack_834); } return 0; } - sprintf(acStack_810,s_Please_run_the__s_setup__005b63f4,s_windowTitle); - sprintf(acStack_508,s__s_not_initialized__005b63e0,s_windowTitle); - r3_wait_for_dvd(acStack_810,acStack_508,0); - /* WARNING: Subroutine does not return */ + sprintf(acStack_810, s_Please_run_the__s_setup__005b63f4, s_windowTitle); + sprintf(acStack_508, s__s_not_initialized__005b63e0, s_windowTitle); + r3_wait_for_dvd(acStack_810, acStack_508, 0); + /* WARNING: Subroutine does not return */ exit(-1); } - } - diff --git a/game_re/gh_fix/r3_module0_init.cxx b/game_re/gh_fix/r3_module0_init.cxx index c19416bc..27a33837 100644 --- a/game_re/gh_fix/r3_module0_init.cxx +++ b/game_re/gh_fix/r3_module0_init.cxx @@ -1,7 +1,7 @@ // AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! -#include -#include "../gh_global.h" +#include +#include extern "C" { undefined r3_module_big_init(void); // 00443f10 // r3_module_big_init diff --git a/game_re/gh_fix/r3_noop.cxx b/game_re/gh_fix/r3_noop.cxx index 44d26cd3..1c30c49c 100644 --- a/game_re/gh_fix/r3_noop.cxx +++ b/game_re/gh_fix/r3_noop.cxx @@ -1,7 +1,7 @@ // AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! -#include -#include "../gh_global.h" +#include +#include // 00401100 diff --git a/game_re/gh_fix/r3_setupWindow.cxx b/game_re/gh_fix/r3_setupWindow.cxx index 37b9bf69..1bce3b2c 100644 --- a/game_re/gh_fix/r3_setupWindow.cxx +++ b/game_re/gh_fix/r3_setupWindow.cxx @@ -1,7 +1,7 @@ // AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! -#include -#include "../gh_global.h" +#include +#include extern "C" { undefined4 get_one(void); // 00485bd0 // get_one diff --git a/game_re/gh_fix/r3_windowProc.cxx b/game_re/gh_fix/r3_windowProc.cxx index 25a6b338..ffb4140e 100644 --- a/game_re/gh_fix/r3_windowProc.cxx +++ b/game_re/gh_fix/r3_windowProc.cxx @@ -1,7 +1,7 @@ // AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! -#include -#include "../gh_global.h" +#include +#include extern "C" { undefined FUN_004013a0(void); // 004013a0 // FUN_004013a0 diff --git a/game_re/gh_global.cxx b/game_re/gh_global.cxx index 2d988975..b5d7220b 100644 --- a/game_re/gh_global.cxx +++ b/game_re/gh_global.cxx @@ -1,5 +1,5 @@ // AUTO-GENERATED FILE -#include +#include char(&s__s_not_initialized__005b63e0)[20] = *reinterpret_cast(GH_MEM(0x005b63e0)); char(&s_Please_run_the__s_setup__005b63f4)[28] = *reinterpret_cast(GH_MEM(0x005b63f4)); char(&s_dashCC)[4] = *reinterpret_cast(GH_MEM(0x005b6410)); diff --git a/game_re/gh_global.h b/game_re/gh_global.h index daf50b2d..49f2801f 100644 --- a/game_re/gh_global.h +++ b/game_re/gh_global.h @@ -2,8 +2,7 @@ #ifndef GH_GENERATED_GLOBALS_H #define GH_GENERATED_GLOBALS_H -#include - +#include extern char(&s__s_not_initialized__005b63e0)[20]; // 005b63e0 extern char(&s_Please_run_the__s_setup__005b63f4)[28]; // 005b63f4 diff --git a/game_re/gh_stub/Erm_fn_ucInitErrMsg.cxx b/game_re/gh_stub/Erm_fn_ucInitErrMsg.cxx index 3f0f431e..61055723 100644 --- a/game_re/gh_stub/Erm_fn_ucInitErrMsg.cxx +++ b/game_re/gh_stub/Erm_fn_ucInitErrMsg.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 0043e1d0 diff --git a/game_re/gh_stub/FUN_004010b0.cxx b/game_re/gh_stub/FUN_004010b0.cxx index 4230cf16..40cbaa1c 100644 --- a/game_re/gh_stub/FUN_004010b0.cxx +++ b/game_re/gh_stub/FUN_004010b0.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 004010b0 diff --git a/game_re/gh_stub/FUN_00401320.cxx b/game_re/gh_stub/FUN_00401320.cxx index 6b3c5d53..d21c60f6 100644 --- a/game_re/gh_stub/FUN_00401320.cxx +++ b/game_re/gh_stub/FUN_00401320.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 00401320 diff --git a/game_re/gh_stub/FUN_004013a0.cxx b/game_re/gh_stub/FUN_004013a0.cxx index e5559ebb..fb42562c 100644 --- a/game_re/gh_stub/FUN_004013a0.cxx +++ b/game_re/gh_stub/FUN_004013a0.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 004013a0 diff --git a/game_re/gh_stub/FUN_0043f830.cxx b/game_re/gh_stub/FUN_0043f830.cxx index 7efb4d99..e2402019 100644 --- a/game_re/gh_stub/FUN_0043f830.cxx +++ b/game_re/gh_stub/FUN_0043f830.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 0043f830 diff --git a/game_re/gh_stub/FUN_0046ecc0.cxx b/game_re/gh_stub/FUN_0046ecc0.cxx index a9a8e8cd..e3f0d81e 100644 --- a/game_re/gh_stub/FUN_0046ecc0.cxx +++ b/game_re/gh_stub/FUN_0046ecc0.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 0046ecc0 diff --git a/game_re/gh_stub/FUN_0046ed70.cxx b/game_re/gh_stub/FUN_0046ed70.cxx index c23613ef..50718d85 100644 --- a/game_re/gh_stub/FUN_0046ed70.cxx +++ b/game_re/gh_stub/FUN_0046ed70.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 0046ed70 diff --git a/game_re/gh_stub/FUN_0046f060.cxx b/game_re/gh_stub/FUN_0046f060.cxx index af4a621f..dec99ef1 100644 --- a/game_re/gh_stub/FUN_0046f060.cxx +++ b/game_re/gh_stub/FUN_0046f060.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 0046f060 diff --git a/game_re/gh_stub/FUN_0046f0b0.cxx b/game_re/gh_stub/FUN_0046f0b0.cxx index 5a6a485c..b8bfbb39 100644 --- a/game_re/gh_stub/FUN_0046f0b0.cxx +++ b/game_re/gh_stub/FUN_0046f0b0.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 0046f0b0 diff --git a/game_re/gh_stub/FUN_0046f640.cxx b/game_re/gh_stub/FUN_0046f640.cxx index fb992699..6a14d41b 100644 --- a/game_re/gh_stub/FUN_0046f640.cxx +++ b/game_re/gh_stub/FUN_0046f640.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 0046f640 diff --git a/game_re/gh_stub/FUN_00470db0.cxx b/game_re/gh_stub/FUN_00470db0.cxx index 8f6f0478..c0924b82 100644 --- a/game_re/gh_stub/FUN_00470db0.cxx +++ b/game_re/gh_stub/FUN_00470db0.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 00470db0 diff --git a/game_re/gh_stub/FUN_00472150.cxx b/game_re/gh_stub/FUN_00472150.cxx index e91e2ef9..a23c1230 100644 --- a/game_re/gh_stub/FUN_00472150.cxx +++ b/game_re/gh_stub/FUN_00472150.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 00472150 diff --git a/game_re/gh_stub/FUN_004725a0.cxx b/game_re/gh_stub/FUN_004725a0.cxx index fdf23678..ee25ebcc 100644 --- a/game_re/gh_stub/FUN_004725a0.cxx +++ b/game_re/gh_stub/FUN_004725a0.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 004725a0 diff --git a/game_re/gh_stub/FUN_0047c340.cxx b/game_re/gh_stub/FUN_0047c340.cxx index af8f861b..5136be72 100644 --- a/game_re/gh_stub/FUN_0047c340.cxx +++ b/game_re/gh_stub/FUN_0047c340.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 0047c340 diff --git a/game_re/gh_stub/FUN_004fb300.cxx b/game_re/gh_stub/FUN_004fb300.cxx index 1775221e..0db380a6 100644 --- a/game_re/gh_stub/FUN_004fb300.cxx +++ b/game_re/gh_stub/FUN_004fb300.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 004fb300 diff --git a/game_re/gh_stub/FUN_00503710.cxx b/game_re/gh_stub/FUN_00503710.cxx index 6636fe29..1615d54b 100644 --- a/game_re/gh_stub/FUN_00503710.cxx +++ b/game_re/gh_stub/FUN_00503710.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 00503710 diff --git a/game_re/gh_stub/FUN_005038e0.cxx b/game_re/gh_stub/FUN_005038e0.cxx index c67b8772..7de1c2bf 100644 --- a/game_re/gh_stub/FUN_005038e0.cxx +++ b/game_re/gh_stub/FUN_005038e0.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 005038e0 diff --git a/game_re/gh_stub/g_setInitVar0.cxx b/game_re/gh_stub/g_setInitVar0.cxx index 1bae4bde..191ddbf5 100644 --- a/game_re/gh_stub/g_setInitVar0.cxx +++ b/game_re/gh_stub/g_setInitVar0.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 00401310 diff --git a/game_re/gh_stub/get_one.cxx b/game_re/gh_stub/get_one.cxx index 63a74072..bd1862ee 100644 --- a/game_re/gh_stub/get_one.cxx +++ b/game_re/gh_stub/get_one.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 00485bd0 diff --git a/game_re/gh_stub/gfx_init2.cxx b/game_re/gh_stub/gfx_init2.cxx index 48f1579b..24062683 100644 --- a/game_re/gh_stub/gfx_init2.cxx +++ b/game_re/gh_stub/gfx_init2.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 00470be0 diff --git a/game_re/gh_stub/r3_checkDisc.cxx b/game_re/gh_stub/r3_checkDisc.cxx index d0542664..d37ade3b 100644 --- a/game_re/gh_stub/r3_checkDisc.cxx +++ b/game_re/gh_stub/r3_checkDisc.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 004464f0 diff --git a/game_re/gh_stub/r3_get_gli_height0.cxx b/game_re/gh_stub/r3_get_gli_height0.cxx index bb3dad62..8cfc9346 100644 --- a/game_re/gh_stub/r3_get_gli_height0.cxx +++ b/game_re/gh_stub/r3_get_gli_height0.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 004012d0 diff --git a/game_re/gh_stub/r3_get_gli_height1.cxx b/game_re/gh_stub/r3_get_gli_height1.cxx index 21a33e50..848faeb9 100644 --- a/game_re/gh_stub/r3_get_gli_height1.cxx +++ b/game_re/gh_stub/r3_get_gli_height1.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 0047bb00 diff --git a/game_re/gh_stub/r3_get_gli_width0.cxx b/game_re/gh_stub/r3_get_gli_width0.cxx index 16a0046a..1d89cd18 100644 --- a/game_re/gh_stub/r3_get_gli_width0.cxx +++ b/game_re/gh_stub/r3_get_gli_width0.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 004012c0 diff --git a/game_re/gh_stub/r3_get_gli_width1.cxx b/game_re/gh_stub/r3_get_gli_width1.cxx index 10464d0f..d3dd2b39 100644 --- a/game_re/gh_stub/r3_get_gli_width1.cxx +++ b/game_re/gh_stub/r3_get_gli_width1.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 0047baf0 diff --git a/game_re/gh_stub/r3_initEngine.cxx b/game_re/gh_stub/r3_initEngine.cxx index 20aa98b8..0d9939bd 100644 --- a/game_re/gh_stub/r3_initEngine.cxx +++ b/game_re/gh_stub/r3_initEngine.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 00401220 diff --git a/game_re/gh_stub/r3_load_splash_bitmap.cxx b/game_re/gh_stub/r3_load_splash_bitmap.cxx index dc647912..cea66eaa 100644 --- a/game_re/gh_stub/r3_load_splash_bitmap.cxx +++ b/game_re/gh_stub/r3_load_splash_bitmap.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 00402450 diff --git a/game_re/gh_stub/r3_module1_init.cxx b/game_re/gh_stub/r3_module1_init.cxx index 4bc6f737..b6169047 100644 --- a/game_re/gh_stub/r3_module1_init.cxx +++ b/game_re/gh_stub/r3_module1_init.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 0043e630 diff --git a/game_re/gh_stub/r3_module_big_init.cxx b/game_re/gh_stub/r3_module_big_init.cxx index ac633ff4..8306b4f0 100644 --- a/game_re/gh_stub/r3_module_big_init.cxx +++ b/game_re/gh_stub/r3_module_big_init.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 00443f10 diff --git a/game_re/gh_stub/r3_set_window_wh.cxx b/game_re/gh_stub/r3_set_window_wh.cxx index ce384804..3f6e96fb 100644 --- a/game_re/gh_stub/r3_set_window_wh.cxx +++ b/game_re/gh_stub/r3_set_window_wh.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 004012a0 diff --git a/game_re/gh_stub/r3_wait_for_dvd.cxx b/game_re/gh_stub/r3_wait_for_dvd.cxx index b9c9f800..64295449 100644 --- a/game_re/gh_stub/r3_wait_for_dvd.cxx +++ b/game_re/gh_stub/r3_wait_for_dvd.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 0043e540 diff --git a/game_re/gh_stub/set_unk.cxx b/game_re/gh_stub/set_unk.cxx index f70b7e3c..09949ad8 100644 --- a/game_re/gh_stub/set_unk.cxx +++ b/game_re/gh_stub/set_unk.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 0043e620 diff --git a/game_re/gh_stub/spawnThread.cxx b/game_re/gh_stub/spawnThread.cxx index 3349eb47..5e463a41 100644 --- a/game_re/gh_stub/spawnThread.cxx +++ b/game_re/gh_stub/spawnThread.cxx @@ -2,8 +2,8 @@ // This function has yet to be decompiled using 'Dump Current Function' in ghidra // with possible manualy fixes -#include -#include "../gh_global.h" +#include +#include #include // 004477d0 diff --git a/game_re/gh_types.h b/game_re/gh_types.h index 180a22bb..fe30c6b6 100644 --- a/game_re/gh_types.h +++ b/game_re/gh_types.h @@ -2,7 +2,7 @@ #define GH_GENERATED_STRUCTS_H // AUTO-GENERATED FILE -#include +#include typedef struct _ExtraSoundParam _ExtraSoundParam, *P_ExtraSoundParam; typedef struct _RollOffParam _RollOffParam, *P_RollOffParam; diff --git a/game_re/r3/README.md b/game_re/r3/README.md new file mode 100644 index 00000000..efffb700 --- /dev/null +++ b/game_re/r3/README.md @@ -0,0 +1,4 @@ +# r3 folder + +Custom sources for the game + diff --git a/game_re/binders/gh_auto_binder.h b/game_re/r3/binders/auto.h similarity index 53% rename from game_re/binders/gh_auto_binder.h rename to game_re/r3/binders/auto.h index 0e5a32f3..f06927db 100644 --- a/game_re/binders/gh_auto_binder.h +++ b/game_re/r3/binders/auto.h @@ -1,10 +1,13 @@ +// This is included by any decompiled source file + #ifndef B8D59B54_1674_4C0F_AA2C_611385FF5D03 #define B8D59B54_1674_4C0F_AA2C_611385FF5D03 -#include "gh_base.h" -#include "gh_static_mem.h" -#include "gh_types.h" -#include "gh_global.h" +#include "static_mem.h" +#include "base.h" + +#include +#include #ifdef _WIN32 #include @@ -55,4 +58,44 @@ inline FieldBinder operator+(const void *str, return FieldBinder{.dst = (uint8_t *)str + Offset}; } +typedef uint32_t cc_type_t; + +template +inline constexpr undefined3 CONCAT12(T0 a, T1 b) { + return undefined3(cc_type_t(a) << 16 | cc_type_t(b)); +} +template +inline constexpr cc_type_t CONCAT11(T0 a, T1 b) { + return cc_type_t(a) << 8 | cc_type_t(b); +} +template +inline constexpr cc_type_t CONCAT21(T0 a, T1 b) { + return cc_type_t(a) << 8 | cc_type_t(b); +} + +template +inline constexpr cc_type_t CONCAT22(T0 a, T1 b) { + return cc_type_t(a) << 16 | cc_type_t(b); +} + +template +inline constexpr cc_type_t CONCAT23(T0 a, T1 b) { + return cc_type_t(a) << 24 | cc_type_t(b); +} + +template +inline constexpr char SUB21(T0 a, size_t b) { + return cc_type_t(a) >> (b * 8); +} + +template +inline constexpr char SUB41(T0 a, size_t b) { + return cc_type_t(a) >> (b * 8); +} + +template +inline constexpr uint16_t SUB42(T0 a, size_t b) { + return cc_type_t(a) >> (b * 8); +} + #endif /* B8D59B54_1674_4C0F_AA2C_611385FF5D03 */ diff --git a/game_re/r3/binders/base.h b/game_re/r3/binders/base.h new file mode 100644 index 00000000..70289e0d --- /dev/null +++ b/game_re/r3/binders/base.h @@ -0,0 +1,47 @@ +// Common definition required for all generated files + +#ifndef A523F6DB_0645_4DEB_8AEB_3792CB732B49 +#define A523F6DB_0645_4DEB_8AEB_3792CB732B49 + +#if _WIN32 +#include +#else +#include "win32_shim.h" +#endif +#include +#include +#include + +typedef uint8_t undefined; +typedef uint32_t undefined4; +typedef uint16_t undefined2; +typedef uint16_t word; +typedef uint32_t dword; +struct undefined3 { + uint8_t _0; + uint8_t _1; + uint8_t _2; + + undefined3& operator=(const uint32_t& other) { + _0 = other & 0xff; + _1 = (other >> 8) & 0xff; + _2 = (other >> 16) & 0xff; + return *this; + } +}; +typedef unsigned char byte; +typedef byte undefined1; +// typedef uint64_t uint; +typedef void *pointer; +typedef char *TerminatedCString; +typedef char *string; + +// Can not export enums for some reason +enum R3ModuleId : uint8_t { + R3ModId_unk = 0x00, + R3ModId_not_initialized = 0xff, +}; + + + +#endif /* A523F6DB_0645_4DEB_8AEB_3792CB732B49 */ diff --git a/game_re/binders/gh_global_binder.h b/game_re/r3/binders/global.h similarity index 58% rename from game_re/binders/gh_global_binder.h rename to game_re/r3/binders/global.h index 3332c038..ebd1da98 100644 --- a/game_re/binders/gh_global_binder.h +++ b/game_re/r3/binders/global.h @@ -1,8 +1,10 @@ +// This is included by gh_global.h + #ifndef EDBE48FC_B879_4985_9274_B7ACF24AD024 #define EDBE48FC_B879_4985_9274_B7ACF24AD024 -#include "gh_base.h" -#include "gh_types.h" -#include "gh_static_mem.h" +#include "base.h" +#include "static_mem.h" +#include #endif /* EDBE48FC_B879_4985_9274_B7ACF24AD024 */ diff --git a/game_re/binders/gh_auto_shared.h b/game_re/r3/binders/shared.h similarity index 73% rename from game_re/binders/gh_auto_shared.h rename to game_re/r3/binders/shared.h index 39642acb..6c266571 100644 --- a/game_re/binders/gh_auto_shared.h +++ b/game_re/r3/binders/shared.h @@ -3,9 +3,9 @@ // Header file that is automatically included in all generated code -#include "gh_types.h" -#include "gh_static_mem.h" -#include "../gh_global.h" +#include "static_mem.h" +#include +#include #endif /* DF40ED2B_5659_43AA_8A22_499A89C4BD62 */ diff --git a/game_re/binders/gh_static_mem.cxx b/game_re/r3/binders/static_mem.cxx similarity index 50% rename from game_re/binders/gh_static_mem.cxx rename to game_re/r3/binders/static_mem.cxx index bd88a34a..ea937fee 100644 --- a/game_re/binders/gh_static_mem.cxx +++ b/game_re/r3/binders/static_mem.cxx @@ -1,13 +1,16 @@ -#include "gh_static_mem.h" +#include "static_mem.h" #include unsigned char gh_static_mem[GH_DATA_SIZE]; void gh_init_data_segment() { SPDLOG_INFO("Initializing data segment"); - FILE *f = fopen("gh_datasegment.bin", "r"); + FILE *f = fopen(R3_DATA_SEGMENT_FILE, "rb"); if (!f) { throw std::runtime_error("Failed to open gh_datasegment.bin"); } - fread(gh_static_mem, 1, gh_data_size, f); + size_t actual = fread(gh_static_mem, 1, gh_data_size, f); + if (actual != gh_data_size) { + throw std::runtime_error("Failed to read gh_datasegment.bin"); + } fclose(f); } \ No newline at end of file diff --git a/game_re/binders/gh_static_mem.h b/game_re/r3/binders/static_mem.h similarity index 95% rename from game_re/binders/gh_static_mem.h rename to game_re/r3/binders/static_mem.h index 10b1bf5d..8f37ec2d 100644 --- a/game_re/binders/gh_static_mem.h +++ b/game_re/r3/binders/static_mem.h @@ -1,7 +1,7 @@ #ifndef A18E3E17_2A80_4DBD_96CD_1CE0120A164E #define A18E3E17_2A80_4DBD_96CD_1CE0120A164E -#include "../gh_datasegment.h" +#include #include extern unsigned char gh_static_mem[GH_DATA_SIZE]; diff --git a/game_re/binders/gh_struct_binder.h b/game_re/r3/binders/type.h similarity index 72% rename from game_re/binders/gh_struct_binder.h rename to game_re/r3/binders/type.h index fe457582..7940c8cb 100644 --- a/game_re/binders/gh_struct_binder.h +++ b/game_re/r3/binders/type.h @@ -1,6 +1,8 @@ +// This is included by gh_types.h + #ifndef F3E71404_380C_4417_8642_0AA89E12BE28 #define F3E71404_380C_4417_8642_0AA89E12BE28 -#include "gh_base.h" +#include "base.h" #endif /* F3E71404_380C_4417_8642_0AA89E12BE28 */ diff --git a/game_re/win32_shim.h b/game_re/r3/binders/win32_shim.h similarity index 100% rename from game_re/win32_shim.h rename to game_re/r3/binders/win32_shim.h diff --git a/game_re/r3/config/static.hpp b/game_re/r3/config/static.hpp new file mode 100644 index 00000000..898919c3 --- /dev/null +++ b/game_re/r3/config/static.hpp @@ -0,0 +1,34 @@ +#ifndef D9171C14_8ED0_407B_A289_4C75D30D9DCC +#define D9171C14_8ED0_407B_A289_4C75D30D9DCC + +#include +#include + +struct R3Config { + std::string gameDataDir; + std::string gfxAdapter; + std::string gfxIdentifier; + std::string gfxGliMode; + std::string language; +}; + +inline R3Config createDefaultConfig() { + R3Config config{}; +#ifdef R3_GAME_DATA_DIR + config.gameDataDir = R3_GAME_DATA_DIR; +#endif + + // Windowed 720p + config.gfxGliMode = "0 - 1200 x 720 - 16"; + config.gfxAdapter = "D3D"; + config.gfxIdentifier = "00000000-0000-0000-0000-000000000000"; + config.language = s_English_005b684c; + return config; +} + +inline R3Config &getDefaultConfig() { + static R3Config config = createDefaultConfig(); + return config; +} + +#endif /* D9171C14_8ED0_407B_A289_4C75D30D9DCC */ diff --git a/game_re/main.cpp b/game_re/r3/main.cpp similarity index 100% rename from game_re/main.cpp rename to game_re/r3/main.cpp diff --git a/game_re/readme.md b/game_re/readme.md index 98e9bd8d..36be2b98 100644 --- a/game_re/readme.md +++ b/game_re/readme.md @@ -5,8 +5,21 @@ For each required function in the program the file will be either in gh_auto or ## gh_auto -Contains the decompiled ghidra source files +Contains the unchanged automatically decompiled ghidra source files. ## gh_fix -Contains decompiled source functions, manually fixed up \ No newline at end of file +Contains decompiled source functions, manually fixed up. Move files here from gh_auto to prevent them from being overwritten. + +## gh_stub + +Contains the stubs for the functions that are not decompiled yet. Allows early testing of parts of the game code, as long as the stub functions are never called. + +## gh_ref + +Whenever a function is moved to gh_fix, it can still be decompiled, but instead of overwriting the file, the decompiled source is moved here for reference. +Files in this folder are not used for compilation. + +## r3 + +This folder contains custom written sources that are mean to patch the game up, simplify some of the decompiled code or add new functionality. diff --git a/scripts/Decompile.java b/scripts/Decompile.java index 2d801122..62218730 100644 --- a/scripts/Decompile.java +++ b/scripts/Decompile.java @@ -63,13 +63,13 @@ public class Decompile extends GhidraScript { // PrintWriter hwriter = new PrintWriter(globalSymbolsListH, "UTF-8"); // hwriter.println("// AUTO-GENERATED FILE "); // headerGuardPre(hwriter, "GLOBALS"); - // hwriter.println("#include "); + // hwriter.println("#include "); // hwriter.println(); // File globalSymbolsListC = new File(RecompileConfig.INSTANCE.outputDir, "gh_global.cxx"); // PrintWriter cwriter = new PrintWriter(globalSymbolsListC, "UTF-8"); // cwriter.println("// AUTO-GENERATED FILE "); - // cwriter.println("#include "); + // cwriter.println("#include "); // hwriter.println(); // for (GlobalRec sym : globalSymbols.values()) { diff --git a/scripts/re3lib/FunctionDumper.java b/scripts/re3lib/FunctionDumper.java index b3bc0170..ea109d68 100644 --- a/scripts/re3lib/FunctionDumper.java +++ b/scripts/re3lib/FunctionDumper.java @@ -134,8 +134,8 @@ public class FunctionDumper { try (PrintWriter writer2 = new PrintWriter(f0, "UTF-8")) { writer2.println("// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! "); writer2.println(); - writer2.println("#include "); - writer2.println("#include \"../gh_global.h\""); + writer2.println("#include "); + writer2.println("#include "); writer2.println(); writer2.println("extern \"C\" {"); @@ -287,8 +287,8 @@ public class FunctionDumper { writer2.println("// This function has yet to be decompiled using 'Dump Current Function' in ghidra"); writer2.println("// with possible manualy fixes"); writer2.println(); - writer2.println("#include "); - writer2.println("#include \"../gh_global.h\""); + writer2.println("#include "); + writer2.println("#include "); writer2.println("#include "); writer2.println(); writer2.println("// " + externalFunction.getEntryPoint()); diff --git a/scripts/re3lib/GlobalDumper.java b/scripts/re3lib/GlobalDumper.java index eb68b50c..5855ef0c 100644 --- a/scripts/re3lib/GlobalDumper.java +++ b/scripts/re3lib/GlobalDumper.java @@ -155,13 +155,13 @@ public class GlobalDumper { PrintWriter hwriter = new PrintWriter(globalSymbolsListH, "UTF-8"); hwriter.println("// AUTO-GENERATED FILE "); Utils.headerGuardPre(hwriter, "GLOBALS"); - hwriter.println("#include "); + hwriter.println("#include "); hwriter.println(); File globalSymbolsListC = new File(RecompileConfig.INSTANCE.outputDir, "gh_global.cxx"); PrintWriter cwriter = new PrintWriter(globalSymbolsListC, "UTF-8"); cwriter.println("// AUTO-GENERATED FILE "); - cwriter.println("#include "); + cwriter.println("#include "); hwriter.println(); List globals = new ArrayList<>(globalAddrs.values()); diff --git a/scripts/re3lib/TypeDumper.java b/scripts/re3lib/TypeDumper.java index 35a10c41..f9d27d3a 100644 --- a/scripts/re3lib/TypeDumper.java +++ b/scripts/re3lib/TypeDumper.java @@ -60,7 +60,7 @@ public class TypeDumper { "UTF-8")) { Utils.headerGuardPre(writer, "STRUCTS"); writer.println("// AUTO-GENERATED FILE "); - writer.println("#include "); + writer.println("#include "); DataTypeWriter dtw = new DataTypeWriter(dtm, writer); dtw.blacklistedTypes = typeBlacklist;