Upgrade folder structure

This commit is contained in:
Guus Waals 2024-09-24 19:45:20 +08:00
parent cdd0edd312
commit ee08c57515
64 changed files with 459 additions and 529 deletions

View File

@ -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

View File

@ -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)

View File

@ -1,85 +0,0 @@
#ifndef A523F6DB_0645_4DEB_8AEB_3792CB732B49
#define A523F6DB_0645_4DEB_8AEB_3792CB732B49
#if _WIN32
#include <Windows.h>
#else
#include "../win32_shim.h"
#endif
#include <stdint.h>
#include <stdio.h>
#include <string.h>
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 <typename T0, typename T1>
inline constexpr undefined3 CONCAT12(T0 a, T1 b) {
return undefined3(cc_type_t(a) << 16 | cc_type_t(b));
}
template <typename T0, typename T1>
inline constexpr cc_type_t CONCAT11(T0 a, T1 b) {
return cc_type_t(a) << 8 | cc_type_t(b);
}
template <typename T0, typename T1>
inline constexpr cc_type_t CONCAT21(T0 a, T1 b) {
return cc_type_t(a) << 8 | cc_type_t(b);
}
template <typename T0, typename T1>
inline constexpr cc_type_t CONCAT22(T0 a, T1 b) {
return cc_type_t(a) << 16 | cc_type_t(b);
}
template <typename T0, typename T1>
inline constexpr cc_type_t CONCAT23(T0 a, T1 b) {
return cc_type_t(a) << 24 | cc_type_t(b);
}
template <typename T0>
inline constexpr char SUB21(T0 a, size_t b) {
return cc_type_t(a) >> (b * 8);
}
template <typename T0>
inline constexpr char SUB41(T0 a, size_t b) {
return cc_type_t(a) >> (b * 8);
}
template <typename T0>
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 */

View File

@ -1,7 +1,7 @@
// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!!
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
extern "C" {
undefined FUN_0046ecc0(undefined2 param_1, undefined2 param_2); // 0046ecc0 // FUN_0046ecc0

View File

@ -1,7 +1,7 @@
// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!!
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
extern "C" {
undefined FUN_0047c340(dword* param_1, dword* param_2, undefined4 param_3); // 0047c340 // FUN_0047c340

View File

@ -1,7 +1,7 @@
// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!!
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
// 00401410

View File

@ -1,7 +1,7 @@
// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!!
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
extern "C" {

View File

@ -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 <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <r3/config/static.hpp>
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);
}
}

View File

@ -1,7 +1,7 @@
// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!!
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
extern "C" {
undefined r3_module_big_init(void); // 00443f10 // r3_module_big_init

View File

@ -1,7 +1,7 @@
// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!!
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
// 00401100

View File

@ -1,7 +1,7 @@
// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!!
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
extern "C" {
undefined4 get_one(void); // 00485bd0 // get_one

View File

@ -1,7 +1,7 @@
// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!!
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
extern "C" {
undefined FUN_004013a0(void); // 004013a0 // FUN_004013a0

View File

@ -1,5 +1,5 @@
// AUTO-GENERATED FILE
#include <gh_global_binder.h>
#include <r3/binders/global.h>
char(&s__s_not_initialized__005b63e0)[20] = *reinterpret_cast<char(*)[20]>(GH_MEM(0x005b63e0));
char(&s_Please_run_the__s_setup__005b63f4)[28] = *reinterpret_cast<char(*)[28]>(GH_MEM(0x005b63f4));
char(&s_dashCC)[4] = *reinterpret_cast<char(*)[4]>(GH_MEM(0x005b6410));

View File

@ -2,8 +2,7 @@
#ifndef GH_GENERATED_GLOBALS_H
#define GH_GENERATED_GLOBALS_H
#include <gh_global_binder.h>
#include <r3/binders/global.h>
extern char(&s__s_not_initialized__005b63e0)[20]; // 005b63e0
extern char(&s_Please_run_the__s_setup__005b63f4)[28]; // 005b63f4

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 0043e1d0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 004010b0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 00401320

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 004013a0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 0043f830

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 0046ecc0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 0046ed70

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 0046f060

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 0046f0b0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 0046f640

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 00470db0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 00472150

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 004725a0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 0047c340

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 004fb300

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 00503710

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 005038e0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 00401310

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 00485bd0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 00470be0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 004464f0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 004012d0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 0047bb00

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 004012c0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 0047baf0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 00401220

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 00402450

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 0043e630

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 00443f10

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 004012a0

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 0043e540

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 0043e620

View File

@ -2,8 +2,8 @@
// This function has yet to be decompiled using 'Dump Current Function' in ghidra
// with possible manualy fixes
#include <gh_auto_binder.h>
#include "../gh_global.h"
#include <r3/binders/auto.h>
#include <gh_global.h>
#include <stdexcept>
// 004477d0

View File

@ -2,7 +2,7 @@
#define GH_GENERATED_STRUCTS_H
// AUTO-GENERATED FILE
#include <gh_struct_binder.h>
#include <r3/binders/type.h>
typedef struct _ExtraSoundParam _ExtraSoundParam, *P_ExtraSoundParam;
typedef struct _RollOffParam _RollOffParam, *P_RollOffParam;

4
game_re/r3/README.md Normal file
View File

@ -0,0 +1,4 @@
# r3 folder
Custom sources for the game

View File

@ -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 <gh_types.h>
#include <gh_global.h>
#ifdef _WIN32
#include <direct.h>
@ -55,4 +58,44 @@ inline FieldBinder<Size> operator+(const void *str,
return FieldBinder<Size>{.dst = (uint8_t *)str + Offset};
}
typedef uint32_t cc_type_t;
template <typename T0, typename T1>
inline constexpr undefined3 CONCAT12(T0 a, T1 b) {
return undefined3(cc_type_t(a) << 16 | cc_type_t(b));
}
template <typename T0, typename T1>
inline constexpr cc_type_t CONCAT11(T0 a, T1 b) {
return cc_type_t(a) << 8 | cc_type_t(b);
}
template <typename T0, typename T1>
inline constexpr cc_type_t CONCAT21(T0 a, T1 b) {
return cc_type_t(a) << 8 | cc_type_t(b);
}
template <typename T0, typename T1>
inline constexpr cc_type_t CONCAT22(T0 a, T1 b) {
return cc_type_t(a) << 16 | cc_type_t(b);
}
template <typename T0, typename T1>
inline constexpr cc_type_t CONCAT23(T0 a, T1 b) {
return cc_type_t(a) << 24 | cc_type_t(b);
}
template <typename T0>
inline constexpr char SUB21(T0 a, size_t b) {
return cc_type_t(a) >> (b * 8);
}
template <typename T0>
inline constexpr char SUB41(T0 a, size_t b) {
return cc_type_t(a) >> (b * 8);
}
template <typename T0>
inline constexpr uint16_t SUB42(T0 a, size_t b) {
return cc_type_t(a) >> (b * 8);
}
#endif /* B8D59B54_1674_4C0F_AA2C_611385FF5D03 */

47
game_re/r3/binders/base.h Normal file
View File

@ -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 <Windows.h>
#else
#include "win32_shim.h"
#endif
#include <stdint.h>
#include <stdio.h>
#include <string.h>
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 */

View File

@ -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 <gh_types.h>
#endif /* EDBE48FC_B879_4985_9274_B7ACF24AD024 */

View File

@ -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 <gh_types.h>
#include <gh_global.h>
#endif /* DF40ED2B_5659_43AA_8A22_499A89C4BD62 */

View File

@ -1,13 +1,16 @@
#include "gh_static_mem.h"
#include "static_mem.h"
#include <spdlog/spdlog.h>
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);
}

View File

@ -1,7 +1,7 @@
#ifndef A18E3E17_2A80_4DBD_96CD_1CE0120A164E
#define A18E3E17_2A80_4DBD_96CD_1CE0120A164E
#include "../gh_datasegment.h"
#include <gh_datasegment.h>
#include <stdexcept>
extern unsigned char gh_static_mem[GH_DATA_SIZE];

View File

@ -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 */

View File

@ -0,0 +1,34 @@
#ifndef D9171C14_8ED0_407B_A289_4C75D30D9DCC
#define D9171C14_8ED0_407B_A289_4C75D30D9DCC
#include <string>
#include <gh_global.h>
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 */

View File

@ -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
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.

View File

@ -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 <gh_global_binder.h>");
// hwriter.println("#include <r3/binder/global.h>");
// 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 <gh_global_binder.h>");
// cwriter.println("#include <r3/binder/global.h>");
// hwriter.println();
// for (GlobalRec sym : globalSymbols.values()) {

View File

@ -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 <gh_auto_binder.h>");
writer2.println("#include \"../gh_global.h\"");
writer2.println("#include <r3/binders/auto.h>");
writer2.println("#include <gh_global.h>");
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 <gh_auto_binder.h>");
writer2.println("#include \"../gh_global.h\"");
writer2.println("#include <r3/binders/auto.h>");
writer2.println("#include <gh_global.h>");
writer2.println("#include <stdexcept>");
writer2.println();
writer2.println("// " + externalFunction.getEntryPoint());

View File

@ -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 <gh_global_binder.h>");
hwriter.println("#include <r3/binders/global.h>");
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 <gh_global_binder.h>");
cwriter.println("#include <r3/binders/global.h>");
hwriter.println();
List<GlobalRec> globals = new ArrayList<>(globalAddrs.values());

View File

@ -60,7 +60,7 @@ public class TypeDumper {
"UTF-8")) {
Utils.headerGuardPre(writer, "STRUCTS");
writer.println("// AUTO-GENERATED FILE ");
writer.println("#include <gh_struct_binder.h>");
writer.println("#include <r3/binders/type.h>");
DataTypeWriter dtw = new DataTypeWriter(dtm, writer);
dtw.blacklistedTypes = typeBlacklist;