From 9a8f5253b90a733da698eb61145e68c5ded20945 Mon Sep 17 00:00:00 2001 From: Guus Waals <_@guusw.nl> Date: Mon, 30 Sep 2024 22:47:09 +0800 Subject: [PATCH] Add script to rebuild and regenerate function database --- game_re/gh_global.cxx | 42 +- game_re/gh_global.h | 42 +- .../{FUN_00445440.cxx => FUN_004011e0.cxx} | 8 +- ...le4_init.cxx => fn_vChooseTheGoodInit.cxx} | 8 +- ...nfig.cxx => r3_checkEngineTermination.cxx} | 8 +- .../r3_engine_init_phase_adv2_is_2_6_8.cxx | 14 + ...UN_0049b5a0.cxx => thunk_FUN_00444a80.cxx} | 8 +- game_re/gh_types.h | 1329 ++++++++++++++++- game_re/globals.txt | 44 +- scripts/DumpCurrentFunctionRecursive.java | 9 +- scripts/RebuildFunctionDatabase.java | 114 ++ scripts/re3lib/FunctionDatabase.java | 223 +++ scripts/re3lib/FunctionDumper.java | 7 +- scripts/re3lib/GlobalDumper.java | 6 +- 14 files changed, 1745 insertions(+), 117 deletions(-) rename game_re/gh_stub/{FUN_00445440.cxx => FUN_004011e0.cxx} (65%) rename game_re/gh_stub/{r3_module4_init.cxx => fn_vChooseTheGoodInit.cxx} (60%) rename game_re/gh_stub/{r3_readBinkVideoConfig.cxx => r3_checkEngineTermination.cxx} (59%) create mode 100644 game_re/gh_stub/r3_engine_init_phase_adv2_is_2_6_8.cxx rename game_re/gh_stub/{FUN_0049b5a0.cxx => thunk_FUN_00444a80.cxx} (62%) create mode 100644 scripts/RebuildFunctionDatabase.java create mode 100644 scripts/re3lib/FunctionDatabase.java diff --git a/game_re/gh_global.cxx b/game_re/gh_global.cxx index 5cf177cf..676f9c85 100644 --- a/game_re/gh_global.cxx +++ b/game_re/gh_global.cxx @@ -59,6 +59,9 @@ char(&lpAppName_005b68f0)[8] = reinterpret_cast(GH_MEM(0x005b68f0)); const char* s_Directory_005b68f8 = "Directory"; // 005b68f8 const char* s_None = "None"; // 005b6904 const char* s_UbiSoft_Ubi_ini = "/UbiSoft/Ubi.ini"; // 005b690c +undefined& DAT_005b6d10= (undefined&) GH_MEM(0x005b6d10); +undefined *& PTR_fassign= (undefined *&) GH_MEM(0x005b6de8); +char& DAT_005b93b0= (char&) GH_MEM(0x005b93b0); undefined& s_percent_d= (undefined&) GH_MEM(0x005bad58); byte& g_errMod0= (byte&) GH_MEM(0x005bd29c); const char* s_Warning_error__005bd318 = "Warning error: "; // 005bd318 @@ -88,6 +91,8 @@ undefined& DAT_005bda3c= (undefined&) GH_MEM(0x005bda3c); char& DAT_005bda3e= (char&) GH_MEM(0x005bda3e); undefined& s_DLL= (undefined&) GH_MEM(0x005bda40); const char* s_UbiSoft_bmp_005bda4c = "UbiSoft.bmp"; // 005bda4c +UINT& g_modemQuality= (UINT&) GH_MEM(0x005bdca0); +UINT& g_UDPPort= (UINT&) GH_MEM(0x005bdca4); const char* s_R3_DVD_005bdfd8 = "R3_DVD"; // 005bdfd8 const char* s_R3_DVD_005be0ec = "R3_DVD"; // 005be0ec const char* s__s_DVD_missing_005be0f4 = "%s DVD missing "; // 005be0f4 @@ -95,6 +100,8 @@ const char* s_Die__s_DVDROM_kann_nicht_gelesen_005be130 = "Die %s DVDROM kann ni const char* s_Impossibile_trovare_il_DVD____s_005be198 = "Impossibile trovare il DVD : %s"; // 005be198 undefined& DAT_005be1ec= (undefined&) GH_MEM(0x005be1ec); const char* s_Impossible_de_trouver_le_DVD_____005be238 = "Impossible de trouver le DVD : %s"; // 005be238 +const char* s_ModemQuality_005be2ec = "ModemQuality"; // 005be2ec +const char* s_UDPPort_005be2fc = "UDPPort"; // 005be2fc pointer& s_Yes= (pointer&) GH_MEM(0x005be304); const char* s_SingleProcessor_005be308 = "SingleProcessor"; // 005be308 undefined& lpDefault_005be318= (undefined&) GH_MEM(0x005be318); @@ -125,6 +132,7 @@ const char* s_fmt_c_colon_s = "%c:%s"; // 005be540 const char* s_r3_program_files = "\\program files\\Ubi Soft\\Rayman3"; // 005be548 undefined *& PTR_DAT_005be568= (undefined *&) GH_MEM(0x005be568); byte& g_errModFirst= (byte&) GH_MEM(0x005be6f0); +dword& g_modId4= (dword&) GH_MEM(0x005be8ac); byte& g_errMod5= (byte&) GH_MEM(0x005befbc); char(&s_M_005bf004)[2] = reinterpret_cast(GH_MEM(0x005bf004)); char(&s_S_005bf008)[2] = reinterpret_cast(GH_MEM(0x005bf008)); @@ -142,20 +150,25 @@ char& DAT_005c0f22= (char&) GH_MEM(0x005c0f22); byte& g_errMod17= (byte&) GH_MEM(0x005c1400); byte& g_errMod8= (byte&) GH_MEM(0x005c4b0c); byte& g_errMod9= (byte&) GH_MEM(0x005c4dcc); -byte& g_errMod7= (byte&) GH_MEM(0x005c506c); +byte& g_errMod3= (byte&) GH_MEM(0x005c506c); byte& g_errMod10= (byte&) GH_MEM(0x005c51f4); UINT& g_config_camera_hor_axis= (UINT&) GH_MEM(0x005c67c8); UINT& g_config_camera_ver_axis= (UINT&) GH_MEM(0x005c67cc); +const char* s_____005ca864 = " \t-\r]"; // 005ca864 +undefined1& DAT_005ca86c= (undefined1&) GH_MEM(0x005ca86c); byte& g_errMod11= (byte&) GH_MEM(0x005caf2c); -byte& g_errMod12= (byte&) GH_MEM(0x005cb16c); +char& g_errMod12= (char&) GH_MEM(0x005cb16c); byte& g_errMod14= (byte&) GH_MEM(0x005cf5d4); byte& g_errMod15= (byte&) GH_MEM(0x005cf814); byte& g_errMod16= (byte&) GH_MEM(0x005cf874); HWND& g_gameHWND1= (HWND&) GH_MEM(0x005cf964); long& lpDefault_005cf96c= (long&) GH_MEM(0x005cf96c); +dword& DWORD_005cfa20= (dword&) GH_MEM(0x005cfa20); +int& DAT_005cfb64= (int&) GH_MEM(0x005cfb64); +UINT& CodePage_005cfb74= (UINT&) GH_MEM(0x005cfb74); byte& g_ucErmNbOfModule= (byte&) GH_MEM(0x005d2638); mod1_ptrs& g_mod1_ptrs= (mod1_ptrs&) GH_MEM(0x005d2644); -undefined4& DAT_005d2660= (undefined4&) GH_MEM(0x005d2660); +windowCreationParams& g_currentBinkMovie= (windowCreationParams&) GH_MEM(0x005d2660); undefined& DAT_005d266c= (undefined&) GH_MEM(0x005d266c); undefined1& DAT_005d266d= (undefined1&) GH_MEM(0x005d266d); undefined1& DAT_005d26a8= (undefined1&) GH_MEM(0x005d26a8); @@ -163,6 +176,7 @@ undefined& lpVolumeNameBuffer_005d27b0= (undefined&) GH_MEM(0x005d27b0); r3_main_data& r3_main_data_005d28b6= (r3_main_data&) GH_MEM(0x005d28b6); undefined& g_soundOnHD= (undefined&) GH_MEM(0x005d29bc); undefined& g_complete= (undefined&) GH_MEM(0x005d29c0); +undefined4& DAT_005d29c8= (undefined4&) GH_MEM(0x005d29c8); int& DAT_005e6b00= (int&) GH_MEM(0x005e6b00); undefined& DAT_005e6b04= (undefined&) GH_MEM(0x005e6b04); int& DAT_005f5e24= (int&) GH_MEM(0x005f5e24); @@ -186,7 +200,11 @@ word& WORD_0077d4d6= (word&) GH_MEM(0x0077d4d6); dword& DWORD_0077d4d8= (dword&) GH_MEM(0x0077d4d8); char(&g_appCmdLine)[256] = reinterpret_cast(GH_MEM(0x0077d4e0)); char(&s_wndStrRestoring)[256] = reinterpret_cast(GH_MEM(0x0077d5e0)); -char(&g_gameDataBinPath)[64] = reinterpret_cast(GH_MEM(0x00781660)); +int& DAT_0077d704= (int&) GH_MEM(0x0077d704); +undefined& __unguarded_readlc_active= (undefined&) GH_MEM(0x0077d708); +undefined4& DAT_0077d960= (undefined4&) GH_MEM(0x0077d960); +FILE *& uNumber_0077da60= (FILE *&) GH_MEM(0x0077da60); +char(&g_gameDataPath)[64] = reinterpret_cast(GH_MEM(0x00781660)); undefined& DAT_00782086= (undefined&) GH_MEM(0x00782086); char(&lpBuffer_00782088)[260] = reinterpret_cast(GH_MEM(0x00782088)); char(&s_quitting1)[64] = reinterpret_cast(GH_MEM(0x007825c0)); @@ -203,13 +221,22 @@ undefined4& DAT_00794cec= (undefined4&) GH_MEM(0x00794cec); dword& DWORD_00794d00= (dword&) GH_MEM(0x00794d00); dword& DWORD_00794d04= (dword&) GH_MEM(0x00794d04); undefined1& DAT_007a0cd8= (undefined1&) GH_MEM(0x007a0cd8); -uint& DAT_007a2c14= (uint&) GH_MEM(0x007a2c14); +undefined4& g_windowClearColor= (undefined4&) GH_MEM(0x007a2c14); byte& g_bink_videoBpp= (byte&) GH_MEM(0x007a2e00); byte& g_bink_wantedVideoQuality= (byte&) GH_MEM(0x007a2e02); byte& g_bink_realVideoQuality= (byte&) GH_MEM(0x007a2e03); byte& g_bink_autoAdjustQuality= (byte&) GH_MEM(0x007a2e04); uint& DAT_007a2e0c= (uint&) GH_MEM(0x007a2e0c); int& g_bink_wantedVideoQualityPlus1= (int&) GH_MEM(0x007a2e10); +undefined& DAT_007d78b9= (undefined&) GH_MEM(0x007d78b9); +undefined& DAT_007d78ba= (undefined&) GH_MEM(0x007d78ba); +undefined& DAT_007d78bb= (undefined&) GH_MEM(0x007d78bb); +undefined& DAT_007d78bc= (undefined&) GH_MEM(0x007d78bc); +undefined& DAT_007d78bd= (undefined&) GH_MEM(0x007d78bd); +undefined& DAT_007d78be= (undefined&) GH_MEM(0x007d78be); +undefined4& DAT_007d79e8= (undefined4&) GH_MEM(0x007d79e8); +undefined4& DAT_007d79ec= (undefined4&) GH_MEM(0x007d79ec); +undefined4& DAT_007d79f0= (undefined4&) GH_MEM(0x007d79f0); undefined& DAT_007d7d84= (undefined&) GH_MEM(0x007d7d84); GAM_tdstEngineStructure& g_r3_engine= (GAM_tdstEngineStructure&) GH_MEM(0x007d7dc0); undefined2& DAT_007d7ea8= (undefined2&) GH_MEM(0x007d7ea8); @@ -229,7 +256,7 @@ word& WORD_007d9e6c= (word&) GH_MEM(0x007d9e6c); char(&sz_M)[2] = reinterpret_cast(GH_MEM(0x007d9e6e)); undefined& lpRootPathName_007d9e70= (undefined&) GH_MEM(0x007d9e70); undefined3& UNK_007d9e71= (undefined3&) GH_MEM(0x007d9e71); -dword& DWORD_007eb200= (dword&) GH_MEM(0x007eb200); +dword& g_unkModuleIdByte= (dword&) GH_MEM(0x007eb200); undefined& g_GLI_fullscreen= (undefined&) GH_MEM(0x007edd40); int& g_GLI_width0= (int&) GH_MEM(0x007edd44); int& g_GLI_height0= (int&) GH_MEM(0x007edd48); @@ -244,5 +271,6 @@ undefined1& g_config_tex_compressed= (undefined1&) GH_MEM(0x007edd65); undefined1& g_GLI_trilinear= (undefined1&) GH_MEM(0x007edd66); GUID& g_GLI_identifier= (GUID&) GH_MEM(0x007edd70); float& g_GLI_mode_float= (float&) GH_MEM(0x007edd80); -m7_init_struct& m7_init_struct_007edde0= (m7_init_struct&) GH_MEM(0x007edde0); +m7_init_struct& g_m7_init_struct= (m7_init_struct&) GH_MEM(0x007edde0); +undefined& m7_mmgBlockInitialized= (undefined&) GH_MEM(0x007eddf9); undefined& g_mod7CriticalSection= (undefined&) GH_MEM(0x007ede20); diff --git a/game_re/gh_global.h b/game_re/gh_global.h index b8f757ec..9fd70b65 100644 --- a/game_re/gh_global.h +++ b/game_re/gh_global.h @@ -64,6 +64,9 @@ extern char(&lpAppName_005b68f0)[8]; // 005b68f0 extern const char* s_Directory_005b68f8; // 005b68f8 extern const char* s_None; // 005b6904 extern const char* s_UbiSoft_Ubi_ini; // 005b690c +extern undefined& DAT_005b6d10; // 005b6d10 +extern undefined *& PTR_fassign; // 005b6de8 +extern char& DAT_005b93b0; // 005b93b0 extern undefined& s_percent_d; // 005bad58 extern byte& g_errMod0; // 005bd29c extern const char* s_Warning_error__005bd318; // 005bd318 @@ -93,6 +96,8 @@ extern undefined& DAT_005bda3c; // 005bda3c extern char& DAT_005bda3e; // 005bda3e extern undefined& s_DLL; // 005bda40 extern const char* s_UbiSoft_bmp_005bda4c; // 005bda4c +extern UINT& g_modemQuality; // 005bdca0 +extern UINT& g_UDPPort; // 005bdca4 extern const char* s_R3_DVD_005bdfd8; // 005bdfd8 extern const char* s_R3_DVD_005be0ec; // 005be0ec extern const char* s__s_DVD_missing_005be0f4; // 005be0f4 @@ -100,6 +105,8 @@ extern const char* s_Die__s_DVDROM_kann_nicht_gelesen_005be130; // 005be130 extern const char* s_Impossibile_trovare_il_DVD____s_005be198; // 005be198 extern undefined& DAT_005be1ec; // 005be1ec extern const char* s_Impossible_de_trouver_le_DVD_____005be238; // 005be238 +extern const char* s_ModemQuality_005be2ec; // 005be2ec +extern const char* s_UDPPort_005be2fc; // 005be2fc extern pointer& s_Yes; // 005be304 extern const char* s_SingleProcessor_005be308; // 005be308 extern undefined& lpDefault_005be318; // 005be318 @@ -130,6 +137,7 @@ extern const char* s_fmt_c_colon_s; // 005be540 extern const char* s_r3_program_files; // 005be548 extern undefined *& PTR_DAT_005be568; // 005be568 extern byte& g_errModFirst; // 005be6f0 +extern dword& g_modId4; // 005be8ac extern byte& g_errMod5; // 005befbc extern char(&s_M_005bf004)[2]; // 005bf004 extern char(&s_S_005bf008)[2]; // 005bf008 @@ -147,20 +155,25 @@ extern char& DAT_005c0f22; // 005c0f22 extern byte& g_errMod17; // 005c1400 extern byte& g_errMod8; // 005c4b0c extern byte& g_errMod9; // 005c4dcc -extern byte& g_errMod7; // 005c506c +extern byte& g_errMod3; // 005c506c extern byte& g_errMod10; // 005c51f4 extern UINT& g_config_camera_hor_axis; // 005c67c8 extern UINT& g_config_camera_ver_axis; // 005c67cc +extern const char* s_____005ca864; // 005ca864 +extern undefined1& DAT_005ca86c; // 005ca86c extern byte& g_errMod11; // 005caf2c -extern byte& g_errMod12; // 005cb16c +extern char& g_errMod12; // 005cb16c extern byte& g_errMod14; // 005cf5d4 extern byte& g_errMod15; // 005cf814 extern byte& g_errMod16; // 005cf874 extern HWND& g_gameHWND1; // 005cf964 extern long& lpDefault_005cf96c; // 005cf96c +extern dword& DWORD_005cfa20; // 005cfa20 +extern int& DAT_005cfb64; // 005cfb64 +extern UINT& CodePage_005cfb74; // 005cfb74 extern byte& g_ucErmNbOfModule; // 005d2638 extern mod1_ptrs& g_mod1_ptrs; // 005d2644 -extern undefined4& DAT_005d2660; // 005d2660 +extern windowCreationParams& g_currentBinkMovie; // 005d2660 extern undefined& DAT_005d266c; // 005d266c extern undefined1& DAT_005d266d; // 005d266d extern undefined1& DAT_005d26a8; // 005d26a8 @@ -168,6 +181,7 @@ extern undefined& lpVolumeNameBuffer_005d27b0; // 005d27b0 extern r3_main_data& r3_main_data_005d28b6; // 005d28b6 extern undefined& g_soundOnHD; // 005d29bc extern undefined& g_complete; // 005d29c0 +extern undefined4& DAT_005d29c8; // 005d29c8 extern int& DAT_005e6b00; // 005e6b00 extern undefined& DAT_005e6b04; // 005e6b04 extern int& DAT_005f5e24; // 005f5e24 @@ -191,7 +205,11 @@ extern word& WORD_0077d4d6; // 0077d4d6 extern dword& DWORD_0077d4d8; // 0077d4d8 extern char(&g_appCmdLine)[256]; // 0077d4e0 extern char(&s_wndStrRestoring)[256]; // 0077d5e0 -extern char(&g_gameDataBinPath)[64]; // 00781660 +extern int& DAT_0077d704; // 0077d704 +extern undefined& __unguarded_readlc_active; // 0077d708 +extern undefined4& DAT_0077d960; // 0077d960 +extern FILE *& uNumber_0077da60; // 0077da60 +extern char(&g_gameDataPath)[64]; // 00781660 extern undefined& DAT_00782086; // 00782086 extern char(&lpBuffer_00782088)[260]; // 00782088 extern char(&s_quitting1)[64]; // 007825c0 @@ -208,13 +226,22 @@ extern undefined4& DAT_00794cec; // 00794cec extern dword& DWORD_00794d00; // 00794d00 extern dword& DWORD_00794d04; // 00794d04 extern undefined1& DAT_007a0cd8; // 007a0cd8 -extern uint& DAT_007a2c14; // 007a2c14 +extern undefined4& g_windowClearColor; // 007a2c14 extern byte& g_bink_videoBpp; // 007a2e00 extern byte& g_bink_wantedVideoQuality; // 007a2e02 extern byte& g_bink_realVideoQuality; // 007a2e03 extern byte& g_bink_autoAdjustQuality; // 007a2e04 extern uint& DAT_007a2e0c; // 007a2e0c extern int& g_bink_wantedVideoQualityPlus1; // 007a2e10 +extern undefined& DAT_007d78b9; // 007d78b9 +extern undefined& DAT_007d78ba; // 007d78ba +extern undefined& DAT_007d78bb; // 007d78bb +extern undefined& DAT_007d78bc; // 007d78bc +extern undefined& DAT_007d78bd; // 007d78bd +extern undefined& DAT_007d78be; // 007d78be +extern undefined4& DAT_007d79e8; // 007d79e8 +extern undefined4& DAT_007d79ec; // 007d79ec +extern undefined4& DAT_007d79f0; // 007d79f0 extern undefined& DAT_007d7d84; // 007d7d84 extern GAM_tdstEngineStructure& g_r3_engine; // 007d7dc0 extern undefined2& DAT_007d7ea8; // 007d7ea8 @@ -234,7 +261,7 @@ extern word& WORD_007d9e6c; // 007d9e6c extern char(&sz_M)[2]; // 007d9e6e extern undefined& lpRootPathName_007d9e70; // 007d9e70 extern undefined3& UNK_007d9e71; // 007d9e71 -extern dword& DWORD_007eb200; // 007eb200 +extern dword& g_unkModuleIdByte; // 007eb200 extern undefined& g_GLI_fullscreen; // 007edd40 extern int& g_GLI_width0; // 007edd44 extern int& g_GLI_height0; // 007edd48 @@ -249,6 +276,7 @@ extern undefined1& g_config_tex_compressed; // 007edd65 extern undefined1& g_GLI_trilinear; // 007edd66 extern GUID& g_GLI_identifier; // 007edd70 extern float& g_GLI_mode_float; // 007edd80 -extern m7_init_struct& m7_init_struct_007edde0; // 007edde0 +extern m7_init_struct& g_m7_init_struct; // 007edde0 +extern undefined& m7_mmgBlockInitialized; // 007eddf9 extern undefined& g_mod7CriticalSection; // 007ede20 #endif // GH_GENERATED_GLOBALS_H diff --git a/game_re/gh_stub/FUN_00445440.cxx b/game_re/gh_stub/FUN_004011e0.cxx similarity index 65% rename from game_re/gh_stub/FUN_00445440.cxx rename to game_re/gh_stub/FUN_004011e0.cxx index 207464c8..b95995b6 100644 --- a/game_re/gh_stub/FUN_00445440.cxx +++ b/game_re/gh_stub/FUN_004011e0.cxx @@ -6,9 +6,9 @@ #include #include -// 00445440 -// FUN_00445440 -extern "C" undefined FUN_00445440(void) { +// 004011e0 +// FUN_004011e0 +extern "C" undefined FUN_004011e0(void) { // TODO: Implement this function - throw GHStubException("Function not implemented: FUN_00445440"); + throw GHStubException("Function not implemented: FUN_004011e0"); } diff --git a/game_re/gh_stub/r3_module4_init.cxx b/game_re/gh_stub/fn_vChooseTheGoodInit.cxx similarity index 60% rename from game_re/gh_stub/r3_module4_init.cxx rename to game_re/gh_stub/fn_vChooseTheGoodInit.cxx index 81804f03..30ef370c 100644 --- a/game_re/gh_stub/r3_module4_init.cxx +++ b/game_re/gh_stub/fn_vChooseTheGoodInit.cxx @@ -6,9 +6,9 @@ #include #include -// 00449660 -// r3_module4_init -extern "C" undefined r3_module4_init(void) { +// 00401110 +// fn_vChooseTheGoodInit +extern "C" undefined fn_vChooseTheGoodInit(void) { // TODO: Implement this function - throw GHStubException("Function not implemented: r3_module4_init"); + throw GHStubException("Function not implemented: fn_vChooseTheGoodInit"); } diff --git a/game_re/gh_stub/r3_readBinkVideoConfig.cxx b/game_re/gh_stub/r3_checkEngineTermination.cxx similarity index 59% rename from game_re/gh_stub/r3_readBinkVideoConfig.cxx rename to game_re/gh_stub/r3_checkEngineTermination.cxx index 020d75f6..c48e544f 100644 --- a/game_re/gh_stub/r3_readBinkVideoConfig.cxx +++ b/game_re/gh_stub/r3_checkEngineTermination.cxx @@ -6,9 +6,9 @@ #include #include -// 00441e70 -// r3_readBinkVideoConfig -extern "C" void r3_readBinkVideoConfig(void) { +// 00401130 +// r3_checkEngineTermination +extern "C" int r3_checkEngineTermination(void) { // TODO: Implement this function - throw GHStubException("Function not implemented: r3_readBinkVideoConfig"); + throw GHStubException("Function not implemented: r3_checkEngineTermination"); } diff --git a/game_re/gh_stub/r3_engine_init_phase_adv2_is_2_6_8.cxx b/game_re/gh_stub/r3_engine_init_phase_adv2_is_2_6_8.cxx new file mode 100644 index 00000000..8a887375 --- /dev/null +++ b/game_re/gh_stub/r3_engine_init_phase_adv2_is_2_6_8.cxx @@ -0,0 +1,14 @@ +// AUTO-GENERATED FILE!!!! +// This function has yet to be decompiled using 'Dump Current Function' in ghidra +// with possible manualy fixes + +#include +#include +#include + +// 00401150 +// r3_engine_init_phase_adv2_is_2_6_8 +extern "C" undefined r3_engine_init_phase_adv2_is_2_6_8(void) { + // TODO: Implement this function + throw GHStubException("Function not implemented: r3_engine_init_phase_adv2_is_2_6_8"); +} diff --git a/game_re/gh_stub/FUN_0049b5a0.cxx b/game_re/gh_stub/thunk_FUN_00444a80.cxx similarity index 62% rename from game_re/gh_stub/FUN_0049b5a0.cxx rename to game_re/gh_stub/thunk_FUN_00444a80.cxx index 484d3031..c324a2a0 100644 --- a/game_re/gh_stub/FUN_0049b5a0.cxx +++ b/game_re/gh_stub/thunk_FUN_00444a80.cxx @@ -6,9 +6,9 @@ #include #include -// 0049b5a0 -// FUN_0049b5a0 -extern "C" undefined FUN_0049b5a0(void) { +// 00401120 +// thunk_FUN_00444a80 +extern "C" undefined thunk_FUN_00444a80(void) { // TODO: Implement this function - throw GHStubException("Function not implemented: FUN_0049b5a0"); + throw GHStubException("Function not implemented: thunk_FUN_00444a80"); } diff --git a/game_re/gh_types.h b/game_re/gh_types.h index af5c509f..eae9b8ad 100644 --- a/game_re/gh_types.h +++ b/game_re/gh_types.h @@ -405,13 +405,13 @@ struct _tdstThemePartOutro { typedef struct _tdstTimer _tdstTimer, *P_tdstTimer; -typedef struct tdstTimerCount tdstTimerCount, *PtdstTimerCount; +typedef struct TMR_tdstTimerCount TMR_tdstTimerCount, *PTMR_tdstTimerCount; typedef void (td_fn_vTimerEventCallback)(void); typedef td_fn_vTimerEventCallback *td_p_fn_vTimerEventCallback; -struct tdstTimerCount { +struct TMR_tdstTimerCount { ulong ulLowPart; ulong ulHighPart; }; @@ -419,9 +419,9 @@ struct tdstTimerCount { struct _tdstTimer { short m_wTimerType; short m_wTimerState; - struct tdstTimerCount m_stTimerCount_InitValue; - struct tdstTimerCount m_stTimerCount_LastValue; - struct tdstTimerCount m_stTimerCount_TotalValue; + struct TMR_tdstTimerCount m_stTimerCount_InitValue; + struct TMR_tdstTimerCount m_stTimerCount_LastValue; + struct TMR_tdstTimerCount m_stTimerCount_TotalValue; ulong m_ulEventId; td_p_fn_vTimerEventCallback m_p_fn_vEventCallback; }; @@ -506,19 +506,923 @@ typedef struct AI_tdstMind_ AI_tdstMind_, *PAI_tdstMind_; struct AI_tdstMind_ { }; -typedef struct FIL_tdstConcatFile_ FIL_tdstConcatFile_, *PFIL_tdstConcatFile_; +typedef struct astruct_2 astruct_2, *Pastruct_2; -struct FIL_tdstConcatFile_ { +typedef unsigned int uint; +typedef unsigned int dword; +typedef dword color_rgba8_t; + +typedef unsigned char byte; +struct astruct_2 { + uint *field0_0x0; + uint *field1_0x4; + uint *field2_0x8; + undefined field3_0xc; + undefined field4_0xd; + undefined field5_0xe; + undefined field6_0xf; + undefined field7_0x10; + undefined field8_0x11; + undefined field9_0x12; + undefined field10_0x13; + color_rgba8_t unkColor; + byte field12_0x18; + undefined field13_0x19; + byte field14_0x1a; }; +typedef struct astruct_3 astruct_3, *Pastruct_3; + +struct astruct_3 { + undefined field0_0x0; + undefined field1_0x1; + undefined field2_0x2; + undefined field3_0x3; + undefined field4_0x4; + undefined field5_0x5; + undefined field6_0x6; + undefined field7_0x7; + undefined field8_0x8; + undefined field9_0x9; + undefined field10_0xa; + undefined field11_0xb; + undefined field12_0xc; + undefined field13_0xd; + undefined field14_0xe; + undefined field15_0xf; + int *binkFrameMemory; +}; + +typedef struct BINK BINK, *PBINK; + +typedef struct BINKRECT BINKRECT, *PBINKRECT; + +typedef struct BINKIO BINKIO, *PBINKIO; + +typedef struct BINKSND BINKSND, *PBINKSND; + +typedef struct BUNDLEPOINTERS BUNDLEPOINTERS, *PBUNDLEPOINTERS; + +typedef ulong (*BINKIOREADHEADER)(struct BINKIO *, long, void *, ulong); + +typedef ulong (*BINKIOREADFRAME)(struct BINKIO *, ulong, long, void *, ulong); + +typedef ulong (*BINKIOGETBUFFERSIZE)(struct BINKIO *, ulong); + +typedef void (*BINKIOSETINFO)(struct BINKIO *, void *, ulong, ulong, ulong); + +typedef ulong (*BINKIOIDLE)(struct BINKIO *); + +typedef void (*BINKIOCLOSE)(struct BINKIO *); + +typedef struct BINK *HBINK; + +typedef void (*BINKCBSUSPEND)(struct BINKIO *); + +typedef long (*BINKCBTRYSUSPEND)(struct BINKIO *); + +typedef void (*BINKCBRESUME)(struct BINKIO *); + +typedef void (*BINKCBIDLE)(struct BINKIO *); + +typedef long (*BINKSNDREADY)(struct BINKSND *); + +typedef long (*BINKSNDLOCK)(struct BINKSND *, uchar **, ulong *); + +typedef long (*BINKSNDUNLOCK)(struct BINKSND *, ulong); + +typedef void (*BINKSNDVOLUME)(struct BINKSND *, long); + +typedef void (*BINKSNDPAN)(struct BINKSND *, long); + +typedef long (*BINKSNDPAUSE)(struct BINKSND *, long); + +typedef long (*BINKSNDONOFF)(struct BINKSND *, long); + +typedef void (*BINKSNDCLOSE)(struct BINKSND *); + +typedef void (*BINKSNDMIXBINS)(struct BINKSND *, ulong *, ulong); + +typedef void (*BINKSNDMIXBINVOLS)(struct BINKSND *, ulong *, long *, ulong); + +struct BINKIO { + BINKIOREADHEADER ReadHeader; + BINKIOREADFRAME ReadFrame; + BINKIOGETBUFFERSIZE GetBufferSize; + BINKIOSETINFO SetInfo; + BINKIOIDLE Idle; + BINKIOCLOSE Close; + HBINK bink; + ulong ReadError; + ulong DoingARead; + ulong BytesRead; + ulong Working; + ulong TotalTime; + ulong ForegroundTime; + ulong IdleTime; + ulong ThreadTime; + ulong BufSize; + ulong BufHighUsed; + ulong CurBufSize; + ulong CurBufUsed; + uchar iodata[160]; + BINKCBSUSPEND suspend_callback; + BINKCBTRYSUSPEND try_suspend_callback; + BINKCBRESUME resume_callback; + BINKCBIDLE idle_on_callback; + ulong callback_control[16]; +}; + +struct BUNDLEPOINTERS { + void *typeptr; + void *type16ptr; + void *colorptr; + void *bits2ptr; + void *motionXptr; + void *motionYptr; + void *dctptr; + void *mdctptr; + void *patptr; +}; + +struct BINKRECT { + long Left; + long Top; + long Width; + long Height; +}; + +struct BINK { + ulong Width; + ulong Height; + ulong Frames; + ulong FrameNum; + ulong LastFrameNum; + ulong FrameRate; + ulong FrameRateDiv; + ulong ReadError; + ulong OpenFlags; + ulong BinkType; + ulong Size; + ulong FrameSize; + ulong SndSize; + struct BINKRECT FrameRects[8]; + long NumRects; + ulong PlaneNum; + void *YPlane[2]; + void *APlane[2]; + ulong YWidth; + ulong YHeight; + ulong UVWidth; + ulong UVHeight; + void *MaskPlane; + ulong MaskPitch; + ulong MaskLength; + ulong LargestFrameSize; + ulong InternalFrames; + long NumTracks; + ulong Highest1SecRate; + ulong Highest1SecFrame; + long Paused; + ulong BackgroundThread; + void *compframe; + void *preloadptr; + ulong *frameoffsets; + struct BINKIO bio; + uchar *ioptr; + ulong iosize; + ulong decompwidth; + ulong decompheight; + long *trackindexes; + ulong *tracksizes; + ulong *tracktypes; + long *trackIDs; + ulong numrects; + ulong playedframes; + ulong firstframetime; + ulong startframetime; + ulong startblittime; + ulong startsynctime; + ulong startsyncframe; + ulong twoframestime; + ulong entireframetime; + ulong slowestframetime; + ulong slowestframe; + ulong slowest2frametime; + ulong slowest2frame; + ulong soundon; + ulong videoon; + ulong totalmem; + ulong timevdecomp; + ulong timeadecomp; + ulong timeblit; + ulong timeopen; + ulong fileframerate; + ulong fileframeratediv; + ulong runtimeframes; + ulong runtimemoveamt; + ulong *rtframetimes; + ulong *rtadecomptimes; + ulong *rtvdecomptimes; + ulong *rtblittimes; + ulong *rtreadtimes; + ulong *rtidlereadtimes; + ulong *rtthreadreadtimes; + ulong lastblitflags; + ulong lastdecompframe; + ulong lastresynctime; + ulong doresync; + ulong playingtracks; + ulong soundskips; + struct BINKSND *bsnd; + ulong skippedlastblit; + ulong skipped_this_frame; + ulong skippedblits; + struct BUNDLEPOINTERS bunp; + ulong skipped_in_a_row; + ulong big_sound_skip_adj; + ulong big_sound_skip_reduce; + ulong last_time_almost_empty; + ulong last_read_count; + ulong last_sound_count; + ulong snd_callback_buffer[16]; +}; + +struct BINKSND { + BINKSNDREADY Ready; + BINKSNDLOCK Lock; + BINKSNDUNLOCK Unlock; + BINKSNDVOLUME Volume; + BINKSNDPAN Pan; + BINKSNDPAUSE Pause; + BINKSNDONOFF SetOnOff; + BINKSNDCLOSE Close; + BINKSNDMIXBINS MixBins; + BINKSNDMIXBINVOLS MixBinVols; + ulong sndbufsize; + uchar *sndbuf; + uchar *sndend; + uchar *sndwritepos; + uchar *sndreadpos; + ulong sndcomp; + ulong sndamt; + ulong sndconvert8; + ulong sndendframe; + ulong sndprime; + ulong sndpad; + ulong BestSizeIn16; + ulong BestSizeMask; + ulong SoundDroppedOut; + long NoThreadService; + long OnOff; + ulong Latency; + ulong VideoScale; + ulong freq; + long bits; + long chans; + uchar snddata[256]; +}; + +typedef struct Bink Bink, *PBink; + +typedef struct BinkInner0 BinkInner0, *PBinkInner0; + +typedef struct _iobuf FILE; + +struct Bink { + struct BinkInner0 *inner; + float field1_0x4; + float field2_0x8; + float field3_0xc; + float field4_0x10; + HANDLE drawSemaphore; + FILE *movieFile; + dword keySeqEsc; + undefined field8_0x20; + undefined field9_0x21; + undefined field10_0x22; + undefined field11_0x23; + undefined field12_0x24; + undefined field13_0x25; + undefined field14_0x26; + undefined field15_0x27; + undefined field16_0x28; + undefined field17_0x29; + undefined field18_0x2a; + undefined field19_0x2b; + undefined field20_0x2c; + undefined field21_0x2d; + undefined field22_0x2e; + undefined field23_0x2f; + undefined field24_0x30; + undefined field25_0x31; + undefined field26_0x32; + undefined field27_0x33; + undefined field28_0x34; + undefined field29_0x35; + undefined field30_0x36; + undefined field31_0x37; + undefined field32_0x38; + undefined field33_0x39; + undefined field34_0x3a; + undefined field35_0x3b; + undefined field36_0x3c; + undefined field37_0x3d; + undefined field38_0x3e; + undefined field39_0x3f; + undefined field40_0x40; + undefined field41_0x41; + undefined field42_0x42; + undefined field43_0x43; + undefined field44_0x44; + undefined field45_0x45; + undefined field46_0x46; + undefined field47_0x47; + char *movieName; + undefined field49_0x4c; + undefined field50_0x4d; + undefined field51_0x4e; + undefined field52_0x4f; + undefined field53_0x50; + undefined field54_0x51; + undefined field55_0x52; + undefined field56_0x53; + undefined field57_0x54; + undefined field58_0x55; + undefined field59_0x56; + undefined field60_0x57; + undefined field61_0x58; + undefined field62_0x59; + undefined field63_0x5a; + undefined field64_0x5b; + float field65_0x5c; +}; + +struct BinkInner0 { + undefined field0_0x0; + undefined field1_0x1; + undefined field2_0x2; + undefined field3_0x3; + undefined *field4_0x4; + float field5_0x8; + float field6_0xc; + undefined field7_0x10; + undefined field8_0x11; + undefined field9_0x12; + undefined field10_0x13; + float field11_0x14; + float field12_0x18; + float field13_0x1c; + undefined field14_0x20; + undefined field15_0x21; + undefined field16_0x22; + undefined field17_0x23; + undefined field18_0x24; + undefined field19_0x25; + undefined field20_0x26; + undefined field21_0x27; + undefined field22_0x28; + undefined field23_0x29; + undefined field24_0x2a; + undefined field25_0x2b; + undefined field26_0x2c; + undefined field27_0x2d; + undefined field28_0x2e; + undefined field29_0x2f; + undefined field30_0x30; + undefined field31_0x31; + undefined field32_0x32; + undefined field33_0x33; + undefined field34_0x34; + undefined field35_0x35; + undefined field36_0x36; + undefined field37_0x37; + undefined field38_0x38; + undefined field39_0x39; + undefined field40_0x3a; + undefined field41_0x3b; + undefined field42_0x3c; + undefined field43_0x3d; + undefined field44_0x3e; + undefined field45_0x3f; + undefined field46_0x40; + undefined field47_0x41; + undefined field48_0x42; + undefined field49_0x43; + undefined field50_0x44; + undefined field51_0x45; + undefined field52_0x46; + undefined field53_0x47; + undefined field54_0x48; + undefined field55_0x49; + undefined field56_0x4a; + undefined field57_0x4b; + undefined field58_0x4c; + undefined field59_0x4d; + undefined field60_0x4e; + undefined field61_0x4f; + undefined field62_0x50; + undefined field63_0x51; + undefined field64_0x52; + undefined field65_0x53; + undefined field66_0x54; + undefined field67_0x55; + undefined field68_0x56; + undefined field69_0x57; + undefined field70_0x58; + undefined field71_0x59; + undefined field72_0x5a; + undefined field73_0x5b; + undefined field74_0x5c; + undefined field75_0x5d; + undefined field76_0x5e; + undefined field77_0x5f; + undefined field78_0x60; + undefined field79_0x61; + undefined field80_0x62; + undefined field81_0x63; + undefined field82_0x64; + undefined field83_0x65; + undefined field84_0x66; + undefined field85_0x67; + undefined field86_0x68; + undefined field87_0x69; + undefined field88_0x6a; + undefined field89_0x6b; + undefined field90_0x6c; + undefined field91_0x6d; + undefined field92_0x6e; + undefined field93_0x6f; + undefined field94_0x70; + undefined field95_0x71; + undefined field96_0x72; + undefined field97_0x73; + undefined field98_0x74; + undefined field99_0x75; + undefined field100_0x76; + undefined field101_0x77; + undefined field102_0x78; + undefined field103_0x79; + undefined field104_0x7a; + undefined field105_0x7b; + undefined field106_0x7c; + undefined field107_0x7d; + undefined field108_0x7e; + undefined field109_0x7f; + undefined field110_0x80; + undefined field111_0x81; + undefined field112_0x82; + undefined field113_0x83; + undefined field114_0x84; + undefined field115_0x85; + undefined field116_0x86; + undefined field117_0x87; + undefined field118_0x88; + undefined field119_0x89; + undefined field120_0x8a; + undefined field121_0x8b; + undefined field122_0x8c; + undefined field123_0x8d; + undefined field124_0x8e; + undefined field125_0x8f; + undefined field126_0x90; + undefined field127_0x91; + undefined field128_0x92; + undefined field129_0x93; + undefined field130_0x94; + undefined field131_0x95; + undefined field132_0x96; + undefined field133_0x97; + undefined field134_0x98; + undefined field135_0x99; + undefined field136_0x9a; + undefined field137_0x9b; + undefined field138_0x9c; + undefined field139_0x9d; + undefined field140_0x9e; + undefined field141_0x9f; + undefined field142_0xa0; + undefined field143_0xa1; + undefined field144_0xa2; + undefined field145_0xa3; + undefined field146_0xa4; + undefined field147_0xa5; + undefined field148_0xa6; + undefined field149_0xa7; + undefined field150_0xa8; + undefined field151_0xa9; + undefined field152_0xaa; + undefined field153_0xab; + undefined field154_0xac; + undefined field155_0xad; + undefined field156_0xae; + undefined field157_0xaf; + undefined field158_0xb0; + undefined field159_0xb1; + undefined field160_0xb2; + undefined field161_0xb3; + undefined field162_0xb4; + undefined field163_0xb5; + undefined field164_0xb6; + undefined field165_0xb7; + undefined field166_0xb8; + undefined field167_0xb9; + undefined field168_0xba; + undefined field169_0xbb; + undefined field170_0xbc; + undefined field171_0xbd; + undefined field172_0xbe; + undefined field173_0xbf; + undefined field174_0xc0; + undefined field175_0xc1; + undefined field176_0xc2; + undefined field177_0xc3; + undefined field178_0xc4; + undefined field179_0xc5; + undefined field180_0xc6; + undefined field181_0xc7; + undefined field182_0xc8; + undefined field183_0xc9; + undefined field184_0xca; + undefined field185_0xcb; + undefined field186_0xcc; + undefined field187_0xcd; + undefined field188_0xce; + undefined field189_0xcf; + undefined field190_0xd0; + undefined field191_0xd1; + undefined field192_0xd2; + undefined field193_0xd3; + undefined field194_0xd4; + undefined field195_0xd5; + undefined field196_0xd6; + undefined field197_0xd7; + undefined field198_0xd8; + undefined field199_0xd9; + undefined field200_0xda; + undefined field201_0xdb; + undefined field202_0xdc; + undefined field203_0xdd; + undefined field204_0xde; + undefined field205_0xdf; + undefined field206_0xe0; + undefined field207_0xe1; + undefined field208_0xe2; + undefined field209_0xe3; + undefined field210_0xe4; + undefined field211_0xe5; + undefined field212_0xe6; + undefined field213_0xe7; + undefined field214_0xe8; + undefined field215_0xe9; + undefined field216_0xea; + undefined field217_0xeb; + undefined field218_0xec; + undefined field219_0xed; + undefined field220_0xee; + undefined field221_0xef; + undefined field222_0xf0; + undefined field223_0xf1; + undefined field224_0xf2; + undefined field225_0xf3; + undefined field226_0xf4; + undefined field227_0xf5; + undefined field228_0xf6; + undefined field229_0xf7; + undefined field230_0xf8; + undefined field231_0xf9; + undefined field232_0xfa; + undefined field233_0xfb; + undefined field234_0xfc; + undefined field235_0xfd; + undefined field236_0xfe; + undefined field237_0xff; + undefined field238_0x100; + undefined field239_0x101; + undefined field240_0x102; + undefined field241_0x103; + undefined field242_0x104; + undefined field243_0x105; + undefined field244_0x106; + undefined field245_0x107; + undefined field246_0x108; + undefined field247_0x109; + undefined field248_0x10a; + undefined field249_0x10b; + undefined field250_0x10c; + undefined field251_0x10d; + undefined field252_0x10e; + undefined field253_0x10f; + undefined field254_0x110; + undefined field255_0x111; + undefined field256_0x112; + undefined field257_0x113; + undefined field258_0x114; + undefined field259_0x115; + undefined field260_0x116; + undefined field261_0x117; + undefined field262_0x118; + undefined field263_0x119; + undefined field264_0x11a; + undefined field265_0x11b; + undefined field266_0x11c; + undefined field267_0x11d; + undefined field268_0x11e; + undefined field269_0x11f; + undefined field270_0x120; + undefined field271_0x121; + undefined field272_0x122; + undefined field273_0x123; + undefined field274_0x124; + undefined field275_0x125; + undefined field276_0x126; + undefined field277_0x127; + undefined field278_0x128; + undefined field279_0x129; + undefined field280_0x12a; + undefined field281_0x12b; + undefined field282_0x12c; + undefined field283_0x12d; + undefined field284_0x12e; + undefined field285_0x12f; + undefined field286_0x130; + undefined field287_0x131; + undefined field288_0x132; + undefined field289_0x133; + undefined field290_0x134; + undefined field291_0x135; + undefined field292_0x136; + undefined field293_0x137; + undefined field294_0x138; + undefined field295_0x139; + undefined field296_0x13a; + undefined field297_0x13b; + undefined field298_0x13c; + undefined field299_0x13d; + undefined field300_0x13e; + undefined field301_0x13f; + undefined field302_0x140; + undefined field303_0x141; + undefined field304_0x142; + undefined field305_0x143; + undefined field306_0x144; + undefined field307_0x145; + undefined field308_0x146; + undefined field309_0x147; + undefined field310_0x148; + undefined field311_0x149; + undefined field312_0x14a; + undefined field313_0x14b; + undefined field314_0x14c; + undefined field315_0x14d; + undefined field316_0x14e; + undefined field317_0x14f; + undefined field318_0x150; + undefined field319_0x151; + undefined field320_0x152; + undefined field321_0x153; + undefined field322_0x154; + undefined field323_0x155; + undefined field324_0x156; + undefined field325_0x157; + undefined field326_0x158; + undefined field327_0x159; + undefined field328_0x15a; + undefined field329_0x15b; + undefined field330_0x15c; + undefined field331_0x15d; + undefined field332_0x15e; + undefined field333_0x15f; + undefined field334_0x160; + undefined field335_0x161; + undefined field336_0x162; + undefined field337_0x163; + undefined field338_0x164; + undefined field339_0x165; + undefined field340_0x166; + undefined field341_0x167; + undefined field342_0x168; + undefined field343_0x169; + undefined field344_0x16a; + undefined field345_0x16b; + undefined field346_0x16c; + undefined field347_0x16d; + undefined field348_0x16e; + undefined field349_0x16f; + undefined field350_0x170; + undefined field351_0x171; + undefined field352_0x172; + undefined field353_0x173; + undefined field354_0x174; + undefined field355_0x175; + undefined field356_0x176; + undefined field357_0x177; + undefined field358_0x178; + undefined field359_0x179; + undefined field360_0x17a; + undefined field361_0x17b; + undefined field362_0x17c; + undefined field363_0x17d; + undefined field364_0x17e; + undefined field365_0x17f; + undefined field366_0x180; + undefined field367_0x181; + undefined field368_0x182; + undefined field369_0x183; + undefined field370_0x184; + undefined field371_0x185; + undefined field372_0x186; + undefined field373_0x187; +}; + +typedef struct BINKBUFFER BINKBUFFER, *PBINKBUFFER; + +struct BINKBUFFER { + ulong Width; + ulong Height; + ulong WindowWidth; + ulong WindowHeight; + ulong SurfaceType; + void *Buffer; + long BufferPitch; + long ClientOffsetX; + long ClientOffsetY; + ulong ScreenWidth; + ulong ScreenHeight; + ulong ScreenDepth; + ulong ExtraWindowWidth; + ulong ExtraWindowHeight; + ulong ScaleFlags; + ulong StretchWidth; + ulong StretchHeight; + long surface; + void *ddsurface; + void *ddclipper; + long destx; + long desty; + long wndx; + long wndy; + ulong wnd; + long minimized; + long ddoverlay; + long ddoffscreen; + long lastovershow; + long issoftcur; + ulong cursorcount; + void *buffertop; + ulong type; + long noclipping; + long loadeddd; + long loadedwin; + void *dibh; + void *dibbuffer; + long dibpitch; + void *dibinfo; + ulong dibdc; + ulong diboldbitmap; +}; + +typedef struct BINKHDR BINKHDR, *PBINKHDR; + +struct BINKHDR { + ulong Marker; + ulong Size; + ulong Frames; + ulong LargestFrameSize; + ulong InternalFrames; + ulong Width; + ulong Height; + ulong FrameRate; + ulong FrameRateDiv; + ulong Flags; + ulong NumTracks; +}; + +typedef struct BINKREALTIME BINKREALTIME, *PBINKREALTIME; + +struct BINKREALTIME { + ulong FrameNum; + ulong FrameRate; + ulong FrameRateDiv; + ulong Frames; + ulong FramesTime; + ulong FramesVideoDecompTime; + ulong FramesAudioDecompTime; + ulong FramesReadTime; + ulong FramesIdleReadTime; + ulong FramesThreadReadTime; + ulong FramesBlitTime; + ulong ReadBufferSize; + ulong ReadBufferUsed; + ulong FramesDataRate; +}; + +typedef struct BINKSUMMARY BINKSUMMARY, *PBINKSUMMARY; + +struct BINKSUMMARY { + ulong Width; + ulong Height; + ulong TotalTime; + ulong FileFrameRate; + ulong FileFrameRateDiv; + ulong FrameRate; + ulong FrameRateDiv; + ulong TotalOpenTime; + ulong TotalFrames; + ulong TotalPlayedFrames; + ulong SkippedFrames; + ulong SkippedBlits; + ulong SoundSkips; + ulong TotalBlitTime; + ulong TotalReadTime; + ulong TotalVideoDecompTime; + ulong TotalAudioDecompTime; + ulong TotalIdleReadTime; + ulong TotalBackReadTime; + ulong TotalReadSpeed; + ulong SlowestFrameTime; + ulong Slowest2FrameTime; + ulong SlowestFrameNum; + ulong Slowest2FrameNum; + ulong AverageDataRate; + ulong AverageFrameSize; + ulong HighestMemAmount; + ulong TotalIOMemory; + ulong HighestIOUsed; + ulong Highest1SecRate; + ulong Highest1SecFrame; +}; + +typedef struct BINKTRACK BINKTRACK, *PBINKTRACK; + +struct BINKTRACK { + ulong Frequency; + ulong Bits; + ulong Channels; + ulong MaxSize; + HBINK bink; + ulong sndcomp; + long trackindex; +}; + +typedef struct FIL_tdstConcatFile_ FIL_tdstConcatFile_, *PFIL_tdstConcatFile_; + typedef struct FIL_tdstConcatFileElement_ FIL_tdstConcatFileElement_, *PFIL_tdstConcatFileElement_; +typedef struct FIL_tdstConcatFileElement_ FIL_tdstConcatFileElement; + struct FIL_tdstConcatFileElement_ { + char *p_szFileName; + long lPathNumber; + long lOffset; + ulong ulFileLength; + ulong ulXorCode; + ulong ulCheckSum; +}; + +struct FIL_tdstConcatFile_ { + FILE *p_stFile; + ulong ulNumberOfPath; + ulong ulNumberOfFile; + uchar bUseXorCode; + uchar bUseCheckSum; + uchar ucPathXorCode; + uchar ucPathCheckSum; + char **d_szPathList; + FIL_tdstConcatFileElement *d_stConcatFileElement; +}; + +typedef struct FIL_tdstFileHeader_ FIL_tdstFileHeader_, *PFIL_tdstFileHeader_; + +struct FIL_tdstFileHeader_ { + ulong ulWidth; + ulong ulHeight; + ulong ulImageSize; + long lChromakeyIndex; + ushort uwNbColorInPalette; + uchar ucBpcInPalette; + uchar ucBpp; + uchar ucRLECode; + uchar ucRed; + uchar ucGreen; + uchar ucBlue; + uchar ucFormat; + uchar ucVersion; }; typedef struct FIL_tdstFileInConcatFile_ FIL_tdstFileInConcatFile_, *PFIL_tdstFileInConcatFile_; struct FIL_tdstFileInConcatFile_ { + uchar bUseConcatFile; + FILE *p_stFile; + ulong ulFileActualSeek; + ulong ulFileEndSeek; + ulong ulFileXorCode; + ulong ulFileCheckSum; + ulong ulCacheSeek; + ulong ulCacheSize; + ulong ulCacheCheckSum; + uchar *p_ucCache; }; typedef struct FIL_tdstFileNameList_ FIL_tdstFileNameList_, *PFIL_tdstFileNameList_; @@ -546,6 +1450,56 @@ struct FIL_tdstFileNameListElement_ { char *szFileName; }; + +/* WARNING! conflicting data type names: /file.h/FIL_tdstFileNameListElement_ - /engine.h/FIL_tdstFileNameListElement_ */ + +typedef struct FIL_tdstGF_ FIL_tdstGF_, *PFIL_tdstGF_; + +struct FIL_tdstGF_ { + struct FIL_tdstFileHeader_ stFileHeader; + uchar *p_ucBitMap; + uchar *p_ucPalette; +}; + +typedef struct FIL_tdstRealGFFileHeader_ FIL_tdstRealGFFileHeader_, *PFIL_tdstRealGFFileHeader_; + +struct FIL_tdstRealGFFileHeader_ { + ulong ulFormat; + ulong ulWidth; + ulong ulHeight; + uchar ucBpp; + uchar ucRLECode; +}; + +typedef struct FileInner1 FileInner1, *PFileInner1; + +struct FileInner1 { + undefined field0_0x0; + undefined field1_0x1; + undefined field2_0x2; + undefined field3_0x3; + undefined field4_0x4; + undefined field5_0x5; + undefined field6_0x6; + undefined field7_0x7; + undefined field8_0x8; + undefined field9_0x9; + undefined field10_0xa; + undefined field11_0xb; + undefined field12_0xc; + undefined field13_0xd; + undefined field14_0xe; + undefined field15_0xf; + undefined field16_0x10; + undefined field17_0x11; + undefined field18_0x12; + undefined field19_0x13; + undefined field20_0x14; + undefined field21_0x15; + undefined field22_0x16; + undefined field23_0x17; +}; + typedef struct Float2 Float2, *PFloat2; struct Float2 { /* Vector (r3) */ @@ -629,7 +1583,7 @@ typedef struct LST2_tdstAnchorToMC_tdxHandleToMainCharacterNodeDyn LST2_tdstAnch typedef struct LST2_tdstAnchorTotdxHandleToAlwaysActiveCharacterNodeDyn LST2_tdstAnchorTotdxHandleToAlwaysActiveCharacterNodeDyn, *PLST2_tdstAnchorTotdxHandleToAlwaysActiveCharacterNodeDyn; -typedef struct HIE_tdstSuperObject_ HIE_tdstSuperObject_, *PHIE_tdstSuperObject_; +typedef struct HIE_tdstSuperObject HIE_tdstSuperObject, *PHIE_tdstSuperObject; typedef struct GAM_tdstLanguageStructure GAM_tdstLanguageStructure, *PGAM_tdstLanguageStructure; @@ -639,8 +1593,6 @@ typedef struct POS_stCompletePosition POS_stCompletePosition, *PPOS_stCompletePo typedef struct POS_stCompletePosition POS_tdstCompletePosition; -typedef struct TMR_tdstTimerCount TMR_tdstTimerCount, *PTMR_tdstTimerCount; - typedef float GLI_tdxValue; typedef struct GLI_tdst2DVertex GLI_tdst2DVertex, *PGLI_tdst2DVertex; @@ -653,10 +1605,6 @@ typedef struct tdstFamilyList_ tdstFamilyList_, *PtdstFamilyList_; typedef struct tdstFamilyList_ *tdxHandleToFamilyList; -typedef union HIE_tduLinkedObject HIE_tduLinkedObject, *PHIE_tduLinkedObject; - -typedef struct POS_stCompletePosition *POS_tdxHandleToPosition; - typedef struct MTH3D_tdstMatrix_ MTH3D_tdstMatrix_, *PMTH3D_tdstMatrix_; typedef struct MTH3D_tdstMatrix_ MTH3D_tdstMatrix; @@ -666,6 +1614,9 @@ struct GLI_tdstSpecificAttributesFor3D { float xNear; }; +struct LST2_tdstAnchorToMC_tdxHandleToMainCharacterNodeDyn { +}; + struct LST2_tdstAnchorTotdxHandleToFamilyListDyn { tdxHandleToFamilyList hFirstElementDyn; tdxHandleToFamilyList hLastElementDyn; @@ -678,9 +1629,23 @@ struct LST2_tdstAnchorTotdxHandleToNodeCameraDyn { struct LST2_tdstAnchorTotdxHandleToAlwaysActiveCharacterNodeDyn { }; -struct TMR_tdstTimerCount { - ulong ulLowPart; - ulong ulHighPart; +struct MTH3D_tdstVector_ { + float xX; + float xY; + float xZ; +}; + +struct MTH3D_tdstMatrix_ { + MTH3D_tdstVector stCol_0; + MTH3D_tdstVector stCol_1; + MTH3D_tdstVector stCol_2; +}; + +struct POS_stCompletePosition { + ulong ulType; + MTH3D_tdstVector stTranslationVector; + MTH3D_tdstMatrix stRotationMatrix; + MTH3D_tdstMatrix stTransformMatrix; }; struct TMR_tdstEngineTimerStructure { @@ -729,28 +1694,6 @@ struct GLD_tdstViewportAttributes { GLD_tdhViewport hViewport; }; -struct MTH3D_tdstVector_ { - float xX; - float xY; - float xZ; -}; - -struct MTH3D_tdstMatrix_ { - MTH3D_tdstVector stCol_0; - MTH3D_tdstVector stCol_1; - MTH3D_tdstVector stCol_2; -}; - -struct POS_stCompletePosition { - ulong ulType; - MTH3D_tdstVector stTranslationVector; - MTH3D_tdstMatrix stRotationMatrix; - MTH3D_tdstMatrix stTransformMatrix; -}; - -struct LST2_tdstAnchorToMC_tdxHandleToMainCharacterNodeDyn { -}; - struct GAM_tdstEngineStructure { GAM_tdeEngineMode eEngineMode; char szLevelName[30]; @@ -774,9 +1717,9 @@ struct GAM_tdstEngineStructure { struct LST2_tdstAnchorTotdxHandleToFamilyListDyn hFamilyList; struct LST2_tdstAnchorToMC_tdxHandleToMainCharacterNodeDyn hMainCharacterList; struct LST2_tdstAnchorTotdxHandleToAlwaysActiveCharacterNodeDyn hAlwaysActiveCharactersList; - struct HIE_tdstSuperObject_ *g_hMainActor; - struct HIE_tdstSuperObject_ *g_hNextMainActor; - struct HIE_tdstSuperObject_ *g_hStdCamCharacter; + struct HIE_tdstSuperObject *g_hMainActor; + struct HIE_tdstSuperObject *g_hNextMainActor; + struct HIE_tdstSuperObject *g_hStdCamCharacter; struct GAM_tdstLanguageStructure *p_stLanguageTable; FIL_tdxHandleToFileNameList hLevelNameList; POS_tdstCompletePosition stMainCharacterPosition; @@ -784,6 +1727,18 @@ struct GAM_tdstEngineStructure { long lSubMapNumber; ACP_tdxBool bEngineIsInPaused; ACP_tdxBool bEngineHasInPaused; + char a_szLevelName[80][30]; + uchar ucNumberOfLevels; + uchar ucCurrentLevel; + uchar ucPreviousLevel; + uchar ucExitIdToQuitPrevLevel; + uchar ucLevelGlobalCounter; + ACP_tdxBool xDemoMode; + uchar ucCurrentLanguage; + uchar ucNbLanguages; + ACP_tdxBool bEngineFrozen; + ACP_tdxBool bResurrection; + char cCameraMode; }; struct GLI_tdst2DVertex { @@ -817,41 +1772,20 @@ struct GLI_tdstCamera_ { float xRatio; }; -union HIE_tduLinkedObject { - struct HIE_tdstSuperObject_ *p_stSuperObject; - void *p_Void; -}; - -struct HIE_tdstSuperObject_ { - ulong ulTypeOfLinkedObject; - union HIE_tduLinkedObject hLinkedObject; - struct HIE_tdstSuperObject_ *hFirstElementDyn; - struct HIE_tdstSuperObject_ *hLastElementDyn; - long lNumberOfElementsDyn; - struct HIE_tdstSuperObject_ *hNextBrotherDyn; - struct HIE_tdstSuperObject_ *hPrevBrotherDyn; - struct HIE_tdstSuperObject_ *hFatherDyn; - POS_tdxHandleToPosition hLocalMatrix; - POS_tdxHandleToPosition hGlobalMatrix; - long lLastComputeFrame; - long lDrawModeMask; - ulong ulFlags; - void *hBoundingVolume; - float fTransparenceLevel; - MTH3D_tdstVector stSemiLookAtVector; -}; - struct GAM_tdstLanguageStructure { char szLanguageCode[20]; char szLanguageText[20]; }; +struct HIE_tdstSuperObject { +}; + struct tdstFamilyList_ { }; struct GLI_tdstViewportManagement { - struct HIE_tdstSuperObject_ *hCamera; - struct HIE_tdstSuperObject_ *hTempCamera; + struct HIE_tdstSuperObject *hCamera; + struct HIE_tdstSuperObject *hTempCamera; GLI_tdstCamera *p_stCamera; ACP_tdxBool bValid; }; @@ -1016,9 +1950,38 @@ struct GMA_tdstEngineEndStructure { char cCameraMode; }; +typedef struct HIE_tdstSuperObject_ HIE_tdstSuperObject_, *PHIE_tdstSuperObject_; + +typedef union HIE_tduLinkedObject HIE_tduLinkedObject, *PHIE_tduLinkedObject; + +typedef struct POS_stCompletePosition *POS_tdxHandleToPosition; + +union HIE_tduLinkedObject { + struct HIE_tdstSuperObject *p_stSuperObject; + void *p_Void; +}; + +struct HIE_tdstSuperObject_ { + ulong ulTypeOfLinkedObject; + union HIE_tduLinkedObject hLinkedObject; + struct HIE_tdstSuperObject_ *hFirstElementDyn; + struct HIE_tdstSuperObject_ *hLastElementDyn; + long lNumberOfElementsDyn; + struct HIE_tdstSuperObject_ *hNextBrotherDyn; + struct HIE_tdstSuperObject_ *hPrevBrotherDyn; + struct HIE_tdstSuperObject_ *hFatherDyn; + POS_tdxHandleToPosition hLocalMatrix; + POS_tdxHandleToPosition hGlobalMatrix; + long lLastComputeFrame; + long lDrawModeMask; + ulong ulFlags; + void *hBoundingVolume; + float fTransparenceLevel; + MTH3D_tdstVector stSemiLookAtVector; +}; + typedef struct levelFixStruct levelFixStruct, *PlevelFixStruct; -typedef unsigned char byte; typedef unsigned int undefined4; struct levelFixStruct { byte field0_0x0; /* stripped of usually */ @@ -1159,6 +2122,13 @@ struct levelFixStructInner { undefined4 field64_0x43; }; +typedef struct LevelLoadState LevelLoadState, *PLevelLoadState; + +struct LevelLoadState { + undefined *ptrSized; /* len = size * 8 */ + dword ptrSize; +}; + typedef struct LST2_tdstAnchorToGLI_tdstNodeCameraDyn LST2_tdstAnchorToGLI_tdstNodeCameraDyn, *PLST2_tdstAnchorToGLI_tdstNodeCameraDyn; struct LST2_tdstAnchorToGLI_tdstNodeCameraDyn { @@ -1271,7 +2241,6 @@ struct tdstTransition_ { typedef struct m7_init_struct m7_init_struct, *Pm7_init_struct; -typedef unsigned int dword; typedef unsigned char undefined1; struct m7_init_struct { dword field0_0x0; @@ -1316,7 +2285,6 @@ struct r3_astruct_2 { typedef struct r3_graphics_data r3_graphics_data, *Pr3_graphics_data; -typedef unsigned int uint; struct r3_graphics_data { int field0_0x0; int field1_0x4; @@ -1620,6 +2588,28 @@ struct r3_TaggedFloatUnk { struct Float4 unk; }; +typedef struct tdst_inputAction tdst_inputAction, *Ptdst_inputAction; + +struct tdst_inputAction { + undefined field0_0x0; + undefined field1_0x1; + undefined field2_0x2; + undefined field3_0x3; + undefined field4_0x4; + undefined field5_0x5; + undefined field6_0x6; + undefined field7_0x7; + undefined field8_0x8; + undefined field9_0x9; + undefined field10_0xa; + undefined field11_0xb; + undefined field12_0xc; + undefined field13_0xd; + undefined field14_0xe; + undefined field15_0xf; + int validated; +}; + typedef struct tdstAChannel_ tdstAChannel_, *PtdstAChannel_; struct tdstAChannel_ { @@ -1715,6 +2705,14 @@ struct tdstEvent_ { ushort uwChannelNumber; }; +typedef struct tdstAviHeader_ tdstAviHeader_, *PtdstAviHeader_; + +struct tdstAviHeader_ { + uchar ucRIFFMark[4]; + long lLength; + uchar ucAVIMark[4]; +}; + typedef struct tdstBlockInfo_ tdstBlockInfo_, *PtdstBlockInfo_; struct tdstBlockInfo_ { @@ -1760,6 +2758,13 @@ struct tdstChannelInfo_ { uchar ucGroupId; }; +typedef struct tdstChunkHeader_ tdstChunkHeader_, *PtdstChunkHeader_; + +struct tdstChunkHeader_ { + uchar ucChunkMark[4]; + long lChunkLength; +}; + typedef struct tdstCsaList_ tdstCsaList_, *PtdstCsaList_; struct tdstCsaList_ { @@ -1891,6 +2896,13 @@ struct tdstSubAnim3d_ { struct tdstState_ *p_stCurrentState; }; +typedef struct tdstTimerCount tdstTimerCount, *PtdstTimerCount; + +struct tdstTimerCount { + ulong ulLowPart; + ulong ulHighPart; +}; + typedef struct tdstViewportManagement_ tdstViewportManagement_, *PtdstViewportManagement_; struct tdstViewportManagement_ { @@ -1911,4 +2923,179 @@ typedef struct tdstZoneSetList_ tdstZoneSetList_, *PtdstZoneSetList_; struct tdstZoneSetList_ { }; +typedef struct windowCreationParams windowCreationParams, *PwindowCreationParams; + +struct windowCreationParams { + undefined4 height1; + undefined4 width1; + undefined4 magic0; + undefined4 magic1; + undefined4 unk_0; + undefined4 unk_ffffffff; + undefined field6_0x18; + undefined field7_0x19; + undefined field8_0x1a; + undefined field9_0x1b; + undefined4 width; + undefined4 height; + undefined field12_0x24; + undefined field13_0x25; + undefined field14_0x26; + undefined field15_0x27; + HWND window0; + HWND window1; + int isPrimary; /* ? */ + undefined field19_0x34; + undefined field20_0x35; + uint unk16; /* bpp? */ + undefined field22_0x3a; + undefined field23_0x3b; + undefined field24_0x3c; + undefined field25_0x3d; + undefined field26_0x3e; + undefined field27_0x3f; + undefined field28_0x40; + undefined field29_0x41; + undefined field30_0x42; + undefined field31_0x43; + undefined field32_0x44; + undefined field33_0x45; + undefined field34_0x46; + undefined field35_0x47; + undefined field36_0x48; + undefined field37_0x49; + undefined field38_0x4a; + undefined field39_0x4b; + undefined field40_0x4c; + undefined field41_0x4d; + undefined field42_0x4e; + undefined field43_0x4f; + undefined field44_0x50; + undefined field45_0x51; + uint unk16_1; /* bpp? */ + undefined field47_0x56; + undefined field48_0x57; + undefined field49_0x58; + undefined field50_0x59; + undefined field51_0x5a; + undefined field52_0x5b; + undefined field53_0x5c; + undefined field54_0x5d; + undefined field55_0x5e; + undefined field56_0x5f; +}; + +typedef struct windowInnerParams windowInnerParams, *PwindowInnerParams; + +struct windowInnerParams { + undefined4 field0_0x0; + undefined field1_0x4; + undefined field2_0x5; + undefined field3_0x6; + undefined field4_0x7; + undefined field5_0x8; + undefined field6_0x9; + undefined field7_0xa; + undefined field8_0xb; + undefined field9_0xc; + undefined field10_0xd; + undefined field11_0xe; + undefined field12_0xf; + undefined field13_0x10; + undefined field14_0x11; + undefined field15_0x12; + undefined field16_0x13; + undefined field17_0x14; + undefined field18_0x15; + undefined field19_0x16; + undefined field20_0x17; + undefined field21_0x18; + undefined field22_0x19; + undefined field23_0x1a; + undefined field24_0x1b; + undefined field25_0x1c; +}; + +typedef struct windowInnerUnk windowInnerUnk, *PwindowInnerUnk; + +typedef struct windowInnerUnkParams windowInnerUnkParams, *PwindowInnerUnkParams; + +struct windowInnerUnkParams { + int field0_0x0; /* Init equal to field_0x8 */ + int field1_0x4; /* Init equal to field_0xc */ + int field2_0x8; + int field3_0xc; + undefined4 field4_0x10; + int field5_0x14; + undefined4 field6_0x18; + int field7_0x1c; + int field8_0x20; + uint field9_0x24; + int field10_0x28; + uint field11_0x2c; + int unk2_100; + int unk3_100; + int field14_0x38; + int field15_0x3c; + int field16_0x40; + int field17_0x44; + int unk5_0; + int unk1_1000; /* width? */ + int unk4_0; + int unk0_1000; /* height? */ + int unk6_0; + int unk7_0; + undefined4 unk1_0; + uint unk_ffffffff; + undefined *unk0_0; /* set from r3_wndUnk1 */ + undefined field27_0x6c; + undefined field28_0x6d; + undefined field29_0x6e; + undefined field30_0x6f; +}; + +struct windowInnerUnk { + struct windowInnerUnkParams params; + dword instanceUnk; +}; + +typedef struct windowInstance windowInstance, *PwindowInstance; + +struct windowInstance { + struct windowCreationParams params; + struct windowInnerUnk *unkTable[16]; + undefined field2_0xa0; + undefined field3_0xa1; + undefined field4_0xa2; + undefined field5_0xa3; + undefined field6_0xa4; + undefined field7_0xa5; + undefined field8_0xa6; + undefined field9_0xa7; + undefined field10_0xa8; + undefined field11_0xa9; + undefined field12_0xaa; + undefined field13_0xab; + undefined field14_0xac; + undefined field15_0xad; + undefined field16_0xae; + undefined field17_0xaf; + undefined field18_0xb0; + undefined field19_0xb1; + undefined field20_0xb2; + undefined field21_0xb3; + undefined field22_0xb4; + undefined field23_0xb5; + undefined field24_0xb6; + undefined field25_0xb7; + undefined field26_0xb8; + undefined field27_0xb9; + undefined field28_0xba; + undefined field29_0xbb; + undefined field30_0xbc; + undefined field31_0xbd; + undefined field32_0xbe; + undefined field33_0xbf; +}; + #endif // GH_GENERATED_STRUCTS_H diff --git a/game_re/globals.txt b/game_re/globals.txt index 82335ee9..e5f34f64 100644 --- a/game_re/globals.txt +++ b/game_re/globals.txt @@ -1,4 +1,4 @@ -0059733c || PTR__BinkOpenDirectSound@4_0059733c || / || undefined * +0059733c || PTR__BinkOpenDirectSound_4_0059733c || / || undefined * 005a9ed4 || DAT_005a9ed4 || / || undefined 005b63e0 || s__s_not_initialized__005b63e0 || / || char[20] 005b63f4 || s_Please_run_the__s_setup__005b63f4 || / || char[28] @@ -57,6 +57,9 @@ 005b68f8 || s_Directory_005b68f8 || / || string 005b6904 || s_None || / || TerminatedCString 005b690c || s_UbiSoft_Ubi_ini || / || TerminatedCString +005b6d10 || DAT_005b6d10 || / || undefined +005b6de8 || PTR_fassign || / || undefined * +005b93b0 || DAT_005b93b0 || / || char 005bad58 || s_percent_d || / || undefined 005bd29c || g_errMod0 || / || byte 005bd318 || s_Warning_error__005bd318 || / || string @@ -86,6 +89,8 @@ 005bda3e || DAT_005bda3e || / || char 005bda40 || s_DLL || / || undefined 005bda4c || s_UbiSoft_bmp_005bda4c || / || string +005bdca0 || g_modemQuality || /windef.h || UINT +005bdca4 || g_UDPPort || /windef.h || UINT 005bdfd8 || s_R3_DVD_005bdfd8 || / || string 005be0ec || s_R3_DVD_005be0ec || / || string 005be0f4 || s__s_DVD_missing_005be0f4 || / || string @@ -93,6 +98,8 @@ 005be198 || s_Impossibile_trovare_il_DVD____s_005be198 || / || string 005be1ec || DAT_005be1ec || / || undefined 005be238 || s_Impossible_de_trouver_le_DVD_____005be238 || / || string +005be2ec || s_ModemQuality_005be2ec || / || string +005be2fc || s_UDPPort_005be2fc || / || string 005be304 || s_Yes || / || pointer 005be308 || s_SingleProcessor_005be308 || / || string 005be318 || lpDefault_005be318 || / || undefined @@ -123,6 +130,7 @@ 005be548 || s_r3_program_files || / || string 005be568 || PTR_DAT_005be568 || / || undefined * 005be6f0 || g_errModFirst || / || byte +005be8ac || g_modId4 || / || dword 005befbc || g_errMod5 || / || byte 005bf004 || s_M_005bf004 || / || char[2] 005bf008 || s_S_005bf008 || / || char[2] @@ -140,20 +148,25 @@ 005c1400 || g_errMod17 || / || byte 005c4b0c || g_errMod8 || / || byte 005c4dcc || g_errMod9 || / || byte -005c506c || g_errMod7 || / || byte +005c506c || g_errMod3 || / || byte 005c51f4 || g_errMod10 || / || byte 005c67c8 || g_config_camera_hor_axis || /windef.h || UINT 005c67cc || g_config_camera_ver_axis || /windef.h || UINT +005ca864 || s_____005ca864 || / || string +005ca86c || DAT_005ca86c || / || undefined1 005caf2c || g_errMod11 || / || byte -005cb16c || g_errMod12 || / || byte +005cb16c || g_errMod12 || / || char 005cf5d4 || g_errMod14 || / || byte 005cf814 || g_errMod15 || / || byte 005cf874 || g_errMod16 || / || byte 005cf964 || g_gameHWND1 || /windef.h || HWND 005cf96c || lpDefault_005cf96c || / || long +005cfa20 || DWORD_005cfa20 || / || dword +005cfb64 || DAT_005cfb64 || / || int +005cfb74 || CodePage_005cfb74 || /windef.h || UINT 005d2638 || g_ucErmNbOfModule || / || byte 005d2644 || g_mod1_ptrs || / || mod1_ptrs -005d2660 || DAT_005d2660 || / || undefined4 +005d2660 || g_currentBinkMovie || /auto_structs || windowCreationParams 005d266c || DAT_005d266c || / || undefined 005d266d || DAT_005d266d || / || undefined1 005d26a8 || DAT_005d26a8 || / || undefined1 @@ -161,6 +174,7 @@ 005d28b6 || r3_main_data_005d28b6 || / || r3_main_data 005d29bc || g_soundOnHD || / || undefined 005d29c0 || g_complete || / || undefined +005d29c8 || DAT_005d29c8 || / || undefined4 005e6b00 || DAT_005e6b00 || / || int 005e6b04 || DAT_005e6b04 || / || undefined 005f5e24 || DAT_005f5e24 || / || int @@ -184,7 +198,11 @@ 0077d4d8 || DWORD_0077d4d8 || / || dword 0077d4e0 || g_appCmdLine || / || char[256] 0077d5e0 || s_wndStrRestoring || / || char[256] -00781660 || g_gameDataBinPath || / || char[64] +0077d704 || DAT_0077d704 || / || int +0077d708 || __unguarded_readlc_active || / || undefined +0077d960 || DAT_0077d960 || / || undefined4 +0077da60 || uNumber_0077da60 || /mbstring.h || FILE * +00781660 || g_gameDataPath || / || char[64] 00782086 || DAT_00782086 || / || undefined 00782088 || lpBuffer_00782088 || / || char[260] 007825c0 || s_quitting1 || / || char[64] @@ -201,13 +219,22 @@ 00794d00 || DWORD_00794d00 || / || dword 00794d04 || DWORD_00794d04 || / || dword 007a0cd8 || DAT_007a0cd8 || / || undefined1 -007a2c14 || DAT_007a2c14 || / || uint +007a2c14 || g_windowClearColor || / || undefined4 007a2e00 || g_bink_videoBpp || / || byte 007a2e02 || g_bink_wantedVideoQuality || / || byte 007a2e03 || g_bink_realVideoQuality || / || byte 007a2e04 || g_bink_autoAdjustQuality || / || byte 007a2e0c || DAT_007a2e0c || / || uint 007a2e10 || g_bink_wantedVideoQualityPlus1 || / || int +007d78b9 || DAT_007d78b9 || / || undefined +007d78ba || DAT_007d78ba || / || undefined +007d78bb || DAT_007d78bb || / || undefined +007d78bc || DAT_007d78bc || / || undefined +007d78bd || DAT_007d78bd || / || undefined +007d78be || DAT_007d78be || / || undefined +007d79e8 || DAT_007d79e8 || / || undefined4 +007d79ec || DAT_007d79ec || / || undefined4 +007d79f0 || DAT_007d79f0 || / || undefined4 007d7d84 || DAT_007d7d84 || / || undefined 007d7dc0 || g_r3_engine || /engine.h || GAM_tdstEngineStructure 007d7ea8 || DAT_007d7ea8 || / || undefined2 @@ -227,7 +254,7 @@ 007d9e6e || sz_M || / || char[2] 007d9e70 || lpRootPathName_007d9e70 || / || undefined 007d9e71 || UNK_007d9e71 || / || undefined3 -007eb200 || DWORD_007eb200 || / || dword +007eb200 || g_unkModuleIdByte || / || dword 007edd40 || g_GLI_fullscreen || / || undefined 007edd44 || g_GLI_width0 || / || int 007edd48 || g_GLI_height0 || / || int @@ -242,5 +269,6 @@ 007edd66 || g_GLI_trilinear || / || undefined1 007edd70 || g_GLI_identifier || /guiddef.h || GUID 007edd80 || g_GLI_mode_float || / || float -007edde0 || m7_init_struct_007edde0 || / || m7_init_struct +007edde0 || g_m7_init_struct || / || m7_init_struct +007eddf9 || m7_mmgBlockInitialized || / || undefined 007ede20 || g_mod7CriticalSection || / || undefined diff --git a/scripts/DumpCurrentFunctionRecursive.java b/scripts/DumpCurrentFunctionRecursive.java index 76f93c43..4de46f50 100644 --- a/scripts/DumpCurrentFunctionRecursive.java +++ b/scripts/DumpCurrentFunctionRecursive.java @@ -11,6 +11,7 @@ import re3lib.FunctionDumper; import re3lib.GlobalDumper; import re3lib.PCallTracer; import re3lib.RecompileConfig; +import re3lib.TypeDumper; public class DumpCurrentFunctionRecursive extends GhidraScript { @Override @@ -21,7 +22,10 @@ public class DumpCurrentFunctionRecursive extends GhidraScript { GlobalDumper globalDumper = new GlobalDumper(this); globalDumper.loadGlobalManifest(); + FunctionDumper functionDumper = new FunctionDumper(this, globalDumper); + PCallTracer tracer = new PCallTracer(); + tracer.setBlacklist(functionDumper.functionAddrBlackList); tracer.traceCalls(getFunctionContaining(currentAddress)); List functionsToDump = new ArrayList<>(); @@ -56,7 +60,6 @@ public class DumpCurrentFunctionRecursive extends GhidraScript { return; } - FunctionDumper functionDumper = new FunctionDumper(this, globalDumper); for (Function func : functionsToDump) { functionDumper.dump(func); } @@ -67,5 +70,9 @@ public class DumpCurrentFunctionRecursive extends GhidraScript { globalDumper.dumpGlobals(); globalDumper.saveGlobalManifest(); } + + // Dump types + TypeDumper dumper = new TypeDumper(this); + dumper.run(); } } diff --git a/scripts/RebuildFunctionDatabase.java b/scripts/RebuildFunctionDatabase.java new file mode 100644 index 00000000..b8f12798 --- /dev/null +++ b/scripts/RebuildFunctionDatabase.java @@ -0,0 +1,114 @@ +// @category _Reman3 +// @menupath Reman3.Rebuild Function Database + +import ghidra.app.script.GhidraScript; +import ghidra.program.model.address.Address; +import re3lib.FunctionDatabase; +import re3lib.RecompileConfig; + +import java.io.File; +import java.io.BufferedReader; +import java.io.FileReader; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RebuildFunctionDatabase extends GhidraScript { + FunctionDatabase functionDB; + + @Override + public void run() throws Exception { + RecompileConfig.INSTANCE = new RecompileConfig(this); + + functionDB = new FunctionDatabase(this); + + scanDirectory(RecompileConfig.INSTANCE.dirDecompAuto); + scanDirectory(RecompileConfig.INSTANCE.dirDecompFix); + scanDirectory(RecompileConfig.INSTANCE.dirDecompStub); + + println("Applying default filters..."); + functionDB.applyDefaultFilters(); + + println("Saving function database..."); + functionDB.save(); + + println("Function database rebuilt successfully."); + + // for (FunctionDatabase.Entry entry : functionDB.entries) { + // println(entry.address + " " + entry.name + " " + entry.file.getName()); + // for (FunctionDatabase.Dependency dependency : entry.dependencies) { + // println(" " + dependency.address + " " + dependency.name); + // } + // } + } + + private void scanDirectory(File directory) throws Exception { + File[] files = directory.listFiles((dir, name) -> name.endsWith(".cxx")); + if (files == null) + return; + + for (File file : files) { + scanFile(file); + } + } + + private void scanFile(File file) throws Exception { + println("Scanning " + file); + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + String line; + Pattern dependencyPattern = Pattern.compile("(\\w+)\\s+(\\w+)\\(.*\\);\\s*//\\s*([0-9A-Fa-f]{8})\\s*//\\s*(.*)"); + Pattern addressPattern = Pattern.compile("//\\s*([0-9A-Fa-f]{8})"); + Pattern functionNamePattern = Pattern.compile("(\\S+)\\s+(\\S+)\\s*\\("); + + List dependencies = new ArrayList<>(); + String address = null; + String functionName = null; + + while ((line = reader.readLine()) != null) { + Matcher dependencyMatcher = dependencyPattern.matcher(line); + if (dependencyMatcher.find()) { + // println("Found dependency: " + dependencyMatcher.group(3)); + Address depAddress = currentProgram.getAddressFactory().getAddress(dependencyMatcher.group(3)); + String name = dependencyMatcher.group(2); + FunctionDatabase.Dependency dependency = functionDB.new Dependency(depAddress, name); + dependencies.add(dependency); + continue; + } + + Matcher addressMatcher = addressPattern.matcher(line); + if (addressMatcher.find()) { + // println("Found address: " + addressMatcher.group(1)); + address = addressMatcher.group(1); + // Skip any comments or newlines between address and function definition + while ((line = reader.readLine()) != null) { + line = line.trim(); + // println("Line: " + line); + if (!line.isEmpty()) { + Matcher functionNameMatcher = functionNamePattern.matcher(line); + if (functionNameMatcher.find()) { + functionName = functionNameMatcher.group(2).trim(); + break; + } + } + } + if (functionName != null) { + break; + } + } + } + + if (address != null && functionName != null) { + Address functionAddress = currentProgram.getAddressFactory().getAddress(address); + FunctionDatabase.Entry entry = functionDB.new Entry(); + entry.address = functionAddress; + entry.name = functionName; + entry.file = file; + entry.dependencies = dependencies; + functionDB.entries.add(entry); + } else { + throw new Exception("Failed to parse function at " + file.getName()); + } + } + } +} diff --git a/scripts/re3lib/FunctionDatabase.java b/scripts/re3lib/FunctionDatabase.java new file mode 100644 index 00000000..9e8b002d --- /dev/null +++ b/scripts/re3lib/FunctionDatabase.java @@ -0,0 +1,223 @@ +package re3lib; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import ghidra.app.script.GhidraScript; +import ghidra.program.model.address.Address; +import ghidra.program.model.listing.Function; + +public class FunctionDatabase { + public class Dependency implements java.io.Serializable { + private static final long serialVersionUID = 1L; + public Address address; + public String name; + + public Dependency(Address address, String name) { + this.address = address; + this.name = name; + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + out.writeObject(address != null ? address.toString() : null); + out.writeObject(name); + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + String addressString = (String) in.readObject(); + if (addressString != null) { + address = RecompileConfig.INSTANCE.script.getCurrentProgram().getAddressFactory().getAddress(addressString); + } + name = (String) in.readObject(); + } + } + + public class Entry implements java.io.Serializable { + private static final long serialVersionUID = 1L; + public Address address; + public String name; + public File file; + public List dependencies = new ArrayList<>(); + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + out.writeObject(address != null ? address.toString() : null); + out.writeObject(name); + out.writeObject(file != null ? file.toString() : null); + out.writeObject(dependencies); + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + String addressString = (String) in.readObject(); + if (addressString != null) { + address = RecompileConfig.INSTANCE.script.getCurrentProgram().getAddressFactory().getAddress(addressString); + } + name = (String) in.readObject(); + String fileString = (String) in.readObject(); + if (fileString != null) { + file = new File(fileString); + } + dependencies = (List) in.readObject(); + } + } + + public List entries = new ArrayList<>(); + private File file; + private transient GhidraScript script; + + public FunctionDatabase(GhidraScript script) { + this.script = script; + file = new File(RecompileConfig.INSTANCE.outputDir, "functions.dat"); + } + + public void load() throws Exception { + if (!file.exists()) { + return; + } + + try (java.io.ObjectInputStream ois = new java.io.ObjectInputStream(new java.io.FileInputStream(file))) { + entries = (List) ois.readObject(); + script.println("Loaded " + entries.size() + " function entries from " + file); + } catch (java.io.IOException | ClassNotFoundException e) { + script.println("Error loading function database: " + e.getMessage()); + } + } + + public void save() throws Exception { + try (java.io.ObjectOutputStream oos = new java.io.ObjectOutputStream(new java.io.FileOutputStream(file))) { + oos.writeObject(entries); + script.println("Saved " + entries.size() + " function entries to " + file); + } catch (java.io.IOException e) { + script.println("Error saving function database: " + e.getMessage()); + } + } + + public void add(Entry entry) { + entries.add(entry); + } + + public void applyDefaultFilters() throws Exception { + GlobalDumper globalDumper = new GlobalDumper(script); + FunctionDumper dumper = new FunctionDumper(script, globalDumper); + + boolean madeAnyChanges = false; + + // Create a hash map to store symbol names + Map symbolNames = new HashMap<>(); + Map exportedFunctionNames = new HashMap<>(); + for (Entry entry : entries) { + Function function = script.getFunctionAt(entry.address); + if (function != null) { + String dirComponent = entry.file.getParent().toString(); + boolean isAuto = dirComponent.startsWith(RecompileConfig.INSTANCE.dirDecompAuto.toString()); + boolean isFix = dirComponent.startsWith(RecompileConfig.INSTANCE.dirDecompFix.toString()); + // Get the actual symbol name and store it in the hash map + String symbolName = function.getName(); + symbolNames.put(entry.address, symbolName); + + if (isAuto && !exportedFunctionNames.containsKey(entry.name)) { + exportedFunctionNames.put(entry.name, entry.file); + } else if (isFix) { + exportedFunctionNames.replace(entry.name, entry.file); + } + } + } + + // Print the number of symbol names collected + script.println("Collected " + symbolNames.size() + " symbol names"); + + boolean dryMode = true; + + HashSet functionsToRegenerate = new HashSet<>(); + + Iterator iterator = entries.iterator(); + while (iterator.hasNext()) { + Entry entry = iterator.next(); + Function function = script.getFunctionAt(entry.address); + + boolean pendingDelete = false; + boolean pendingRegenerate = false; + + // Remove CRT and other blacklisted functions + if (function == null || !dumper.isValidFunction(function)) { + // Remove the file + if (entry.file != null && entry.file.exists()) { + script.println("Removed file: " + entry.file.getAbsolutePath()); + pendingDelete = true; + } + + // Remove entry from the list + script.println("Removed invalid function entry: " + entry.name + " at " + entry.address); + function = null; + } + + // Check if symbol name matches the symbol name parsed from the file + if (function != null) { + String actualSymbolName = symbolNames.get(entry.address); + if (actualSymbolName == null) { + throw new Exception( + "Symbol name not found for function at " + entry.address + " in file " + entry.file.getAbsolutePath()); + } + + if (actualSymbolName != null && !actualSymbolName.equals(entry.name)) { + File fnExportedFile = exportedFunctionNames.get(entry.name); + if (fnExportedFile != null && fnExportedFile != entry.file) { + // Already exists elsewhere, so remove this file + script.println("Removing duplicate function: " + entry.name + " at " + entry.address + " overridden by " + + fnExportedFile); + pendingDelete = true; + } else { + // Regeneral this function + script.println("Symbol name mismatch for function at " + entry.address + ": " + + "File name: " + entry.name + ", Actual symbol: " + actualSymbolName); + entry.name = actualSymbolName; // Update the entry name to match the actual symbol + pendingRegenerate = true; + } + } + + // Check if dependencies are valid + for (Dependency dependency : entry.dependencies) { + Function depFunction = script.getFunctionAt(dependency.address); + if (depFunction == null) { + script.println("Dependency not found: " + dependency.name + " at " + dependency.address + " in " + entry.file); + pendingRegenerate = true; + } else if (!dumper.isValidFunction(depFunction) || !depFunction.getName().equals(dependency.name)) { + script + .println("Invalid dependency: " + dependency.name + " at " + dependency.address + " in " + entry.file + " should be " + dependency.name); + pendingRegenerate = true; + } + } + + entry.name = actualSymbolName; // Update the entry name to match the actual symbol + madeAnyChanges = true; + } + + if (pendingDelete) { + iterator.remove(); + if (!dryMode) { + entry.file.delete(); + madeAnyChanges = true; + } + } else if (pendingRegenerate) { + if (!dryMode) { + functionsToRegenerate.add(function); + madeAnyChanges = true; + } + } + } + + for (Function function : functionsToRegenerate) { + script.println("Regenerating function: " + function.getName() + " at " + function.getEntryPoint()); + dumper.dump(function); + } + + if (madeAnyChanges) { + // Update CMake timestamp + RecompileConfig.INSTANCE.touchCMakeTimestamp(); + } + } +} diff --git a/scripts/re3lib/FunctionDumper.java b/scripts/re3lib/FunctionDumper.java index 13a6b2df..59744508 100644 --- a/scripts/re3lib/FunctionDumper.java +++ b/scripts/re3lib/FunctionDumper.java @@ -28,7 +28,8 @@ import re3lib.GlobalDumper.GlobalRec; public class FunctionDumper { GhidraScript script; GlobalDumper globalDumper; - HashSet
functionAddrBlackList = new HashSet<>(); + + public HashSet
functionAddrBlackList = new HashSet<>(); public boolean createdFile = false; // Collects functions called by the current function @@ -188,7 +189,7 @@ public class FunctionDumper { ClangToken token = tokens.get(t); boolean thisDot = false; - // println("Token: " + token.toString()); + script.println("Token: " + token.toString()); if (token.toString().equals(".")) { // println("Found dot: " + token.toString() + " - " + token.getClass()); thisDot = true; @@ -232,10 +233,12 @@ public class FunctionDumper { // Check if it's a function pointer, otherwise add to globals if (address.isMemoryAddress()) { + // script.println("Address: " + address + " - " + sym.getName()); Function maybeFunction = script.getFunctionAt(address); if (maybeFunction != null) { externalFunctionCalls.add(maybeFunction); } else { + script.println("Add globals " + address + " - " + gsym.getName() + " - " + token.getText()); globalDumper.addGlobal(address, gsym); } } diff --git a/scripts/re3lib/GlobalDumper.java b/scripts/re3lib/GlobalDumper.java index b995e4d0..8c9942f5 100644 --- a/scripts/re3lib/GlobalDumper.java +++ b/scripts/re3lib/GlobalDumper.java @@ -113,15 +113,11 @@ public class GlobalDumper { // script.println("DATA: " + addr + " - " + dt.getDisplayName()); } } - // if(sym.getName().startsWith("s_SALIR")) { - // script.println("SALIR: " + addr + " - " + dt.getDisplayName() + " - " + - // dt.getClass().getName()); - // // script.println("SALIR: " + sym.getdata()); - // } if (dt == null) { script.println("WARNING: Missing type for global: " + sym.getName() + " at " + addr); return; } + // script.println("Global: " + addr + " - " + sym.getName() + " - " + dt.getDisplayName()); globalAddrs.put(addr, new GlobalRec(addr, sym.getName(), dt)); }