From 51bfda0e1b8f557552e0f7639ce7b1c2d547b503 Mon Sep 17 00:00:00 2001 From: Sean Miller Date: Sun, 15 Mar 2026 16:45:12 +0000 Subject: [PATCH 01/21] Initial work on d_main --- config/SOUE01/splits.txt | 1 + config/SOUE01/symbols.txt | 8 +++--- include/d/d_main.h | 13 +++++++++ include/d/d_sys.h | 8 ++++++ include/rvl/OS/OSThread.h | 3 +++ include/toBeSorted/d_lib.h | 6 +++++ include/toBeSorted/mpls.h | 7 +++++ src/d/d_main.cpp | 54 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 include/d/d_main.h create mode 100644 include/toBeSorted/d_lib.h create mode 100644 include/toBeSorted/mpls.h create mode 100644 src/d/d_main.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index be914da8..6fad7717 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -256,6 +256,7 @@ d/d_lang.cpp: d/d_main.cpp: .text start:0x80054F90 end:0x80055170 align:16 .sbss start:0x805751D0 end:0x805751E0 + .bss start:0x80597758 end:0x80597A70 d/d_pad.cpp: .text start:0x80055170 end:0x8005961C align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 19e43777..c9998e05 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -2239,9 +2239,9 @@ getCurrentLanguage__Fv = .text:0x80054F50; // type:function size:0x38 fn_80054F90 = .text:0x80054F90; // type:function size:0x18 fn_80054FB0 = .text:0x80054FB0; // type:function size:0x24 fn_80054FE0 = .text:0x80054FE0; // type:function size:0x20 -dMain__Create = .text:0x80055000; // type:function size:0x28 -dMain__Execute = .text:0x80055030; // type:function size:0x14 -dMain__main01 = .text:0x80055050; // type:function size:0x28 +Create__5dMainFv = .text:0x80055000; // type:function size:0x28 +Execute__5dMainFv = .text:0x80055030; // type:function size:0x14 +main01__5dMainFPv = .text:0x80055050; // type:function size:0x28 main = .text:0x80055080; // type:function size:0xE4 scope:global control_mpls_callback__4dPadFll = .text:0x80055170; // type:function size:0x38 isDeviceTypeMpls__4dPadFUl = .text:0x800551B0; // type:function size:0x24 @@ -42180,7 +42180,7 @@ layoutResHeap__5dHeap = .sbss:0x805751C0; // type:object size:0x4 data:4byte fontHeap__5dHeap = .sbss:0x805751C4; // type:object size:0x4 data:4byte HBMHeap__5dHeap = .sbss:0x805751C8; // type:object size:0x4 data:4byte lbl_805751D0 = .sbss:0x805751D0; // type:object size:0x8 data:4byte -dMain__g_InitialTime = .sbss:0x805751D8; // type:object size:0x8 data:4byte +g_InitialTime__5dMain = .sbss:0x805751D8; // type:object size:0x8 data:4byte m_connected__Q24dPad4ex_c = .sbss:0x805751E0; // type:object size:0x4 sInstance__13dPadManager_c = .sbss:0x805751E8; // type:object size:0x8 data:4byte LINK_ROT = .sbss:0x805751F0; // type:object size:0x2 data:2byte diff --git a/include/d/d_main.h b/include/d/d_main.h new file mode 100644 index 00000000..09537513 --- /dev/null +++ b/include/d/d_main.h @@ -0,0 +1,13 @@ +#ifndef D_MAIN_H +#define D_MAIN_H + +#include "rvl/OS.h" + +namespace dMain { + void Create(); + void Execute(); + void *main01(void *arg); + OSTime g_InitialTime; +}; + +#endif // D_MAIN_H diff --git a/include/d/d_sys.h b/include/d/d_sys.h index 7557307d..2bb13c1e 100644 --- a/include/d/d_sys.h +++ b/include/d/d_sys.h @@ -7,14 +7,22 @@ class dSys_c { public: + static void setBlack(bool); /* Frame rate values: 1 - 60fps, 2 - 30fps */ static void setFrameRate(u8); static u8 getFrameRate(); static void setClearColor(nw4r::ut::Color clr); + static void create(); + static void execute(); + static EGG::Heap *ms_RootHeapMem1; static EGG::Heap *ms_RootHeapMem2; }; +namespace dSystem { +void fixHeaps(); +}; + #endif diff --git a/include/rvl/OS/OSThread.h b/include/rvl/OS/OSThread.h index 871ce0a7..f315c558 100644 --- a/include/rvl/OS/OSThread.h +++ b/include/rvl/OS/OSThread.h @@ -12,6 +12,8 @@ extern "C" { #define OS_THREAD_STACK_MAGIC 0xDEADBABE +typedef s32 OSPriority; + typedef enum { OS_THREAD_STATE_EXITED = 0, OS_THREAD_STATE_READY = 1, @@ -97,6 +99,7 @@ s32 OSSuspendThread(OSThread *thread); void OSSleepThread(OSThreadQueue *queue); void OSWakeupThread(OSThreadQueue *queue); BOOL OSSetThreadPriority(OSThread *thread, s32 prio); +OSPriority OSGetThreadPriority(OSThread *thread); void OSClearStack(u8 val); void OSSleepTicks(s64 ticks); diff --git a/include/toBeSorted/d_lib.h b/include/toBeSorted/d_lib.h new file mode 100644 index 00000000..0a4787ca --- /dev/null +++ b/include/toBeSorted/d_lib.h @@ -0,0 +1,6 @@ +#ifndef D_LIB_H +#define D_LIB_H + +void fn_80006C20(); + +#endif // D_LIB_H diff --git a/include/toBeSorted/mpls.h b/include/toBeSorted/mpls.h new file mode 100644 index 00000000..561c5bff --- /dev/null +++ b/include/toBeSorted/mpls.h @@ -0,0 +1,7 @@ +#ifndef MPLS_H +#define MPLS_H + +void fn_80006CE0(int, char **); +void fn_80006D60(); + +#endif // MPLS_H diff --git a/src/d/d_main.cpp b/src/d/d_main.cpp new file mode 100644 index 00000000..9ad27e41 --- /dev/null +++ b/src/d/d_main.cpp @@ -0,0 +1,54 @@ +#include "d/d_main.h" + +#include "d/d_sys.h" +#include "rvl/OS.h" +#include "toBeSorted/d_lib.h" +#include "toBeSorted/mpls.h" + +OSThread MAIN_THREAD; + +#define STACK_SIZE 0xF000 + +void dMain::Create() { + dSys_c::create(); + dSys_c::setBlack(false); +} + +void dMain::Execute() { + while (true) { + dSys_c::execute(); + } +} + +void *dMain::main01(void *arg) { + Create(); + Execute(); + return nullptr; +} + +void main(int argc, char **argv) { + u8 pStackBase[STACK_SIZE] __attribute__((aligned(32))); + + fn_80006C20(); + dMain::g_InitialTime = OSGetTime(); + dSystem::fixHeaps(); + fn_80006CE0(argc, argv); + fn_80006D60(); + + OSThread *curThread = OSGetCurrentThread(); + OSPriority curPrio = OSGetThreadPriority(curThread); + + OSCreateThread( + &MAIN_THREAD, + dMain::main01, + nullptr, + &pStackBase[STACK_SIZE], + STACK_SIZE, + curPrio, + 0 + ); + + OSResumeThread(&MAIN_THREAD); + OSSetThreadPriority(curThread, 31); + OSSuspendThread(curThread); +} From adb84c1cd698cad09b89e97476088ebd624ccf1b Mon Sep 17 00:00:00 2001 From: Sean Miller Date: Sun, 15 Mar 2026 16:53:18 +0000 Subject: [PATCH 02/21] Format files --- include/d/d_main.h | 12 +++++++----- src/d/d_main.cpp | 15 ++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/include/d/d_main.h b/include/d/d_main.h index 09537513..12d3a150 100644 --- a/include/d/d_main.h +++ b/include/d/d_main.h @@ -4,10 +4,12 @@ #include "rvl/OS.h" namespace dMain { - void Create(); - void Execute(); - void *main01(void *arg); - OSTime g_InitialTime; -}; + +void Create(); +void Execute(); +void *main01(void *arg); +OSTime g_InitialTime; + +}; // namespace dMain #endif // D_MAIN_H diff --git a/src/d/d_main.cpp b/src/d/d_main.cpp index 9ad27e41..aac41dd6 100644 --- a/src/d/d_main.cpp +++ b/src/d/d_main.cpp @@ -1,10 +1,11 @@ #include "d/d_main.h" #include "d/d_sys.h" -#include "rvl/OS.h" #include "toBeSorted/d_lib.h" #include "toBeSorted/mpls.h" +#include "rvl/OS.h" + OSThread MAIN_THREAD; #define STACK_SIZE 0xF000 @@ -28,7 +29,7 @@ void *dMain::main01(void *arg) { void main(int argc, char **argv) { u8 pStackBase[STACK_SIZE] __attribute__((aligned(32))); - + fn_80006C20(); dMain::g_InitialTime = OSGetTime(); dSystem::fixHeaps(); @@ -38,15 +39,7 @@ void main(int argc, char **argv) { OSThread *curThread = OSGetCurrentThread(); OSPriority curPrio = OSGetThreadPriority(curThread); - OSCreateThread( - &MAIN_THREAD, - dMain::main01, - nullptr, - &pStackBase[STACK_SIZE], - STACK_SIZE, - curPrio, - 0 - ); + OSCreateThread(&MAIN_THREAD, dMain::main01, nullptr, &pStackBase[STACK_SIZE], STACK_SIZE, curPrio, 0); OSResumeThread(&MAIN_THREAD); OSSetThreadPriority(curThread, 31); From dd1c8ac8c2ff91e84272fc2187a5213fef481def Mon Sep 17 00:00:00 2001 From: Sean Miller Date: Sun, 15 Mar 2026 17:33:53 +0000 Subject: [PATCH 03/21] Minor formatting adjustments + symbol renaming --- config/SOUE01/symbols.txt | 8 ++++---- include/d/d_main.h | 3 ++- src/d/d_main.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index c9998e05..29d66005 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -2829,16 +2829,16 @@ dSys_c__beginFrame = .text:0x80064360; // type:function size:0x68 EGG__ConfigurationData__onBeginFrame = .text:0x800643D0; // type:function size:0x4 dSys_c__endFrame = .text:0x800643E0; // type:function size:0x48 EGG__ConfigurationData__onEndFrame = .text:0x80064430; // type:function size:0x4 -dSys_c__setBlack = .text:0x80064440; // type:function size:0x80 +setBlack__6dSys_cFb = .text:0x80064440; // type:function size:0x80 setFrameRate__6dSys_cFUc = .text:0x800644C0; // type:function size:0x10 getFrameRate__6dSys_cFv = .text:0x800644D0; // type:function size:0x10 setClearColor__6dSys_cFQ34nw4r2ut5Color = .text:0x800644E0; // type:function size:0x60 dSys_c__getClearColor = .text:0x80064540; // type:function size:0x14 -dSys_c__create = .text:0x80064560; // type:function size:0x3BC +create__6dSys_cFv = .text:0x80064560; // type:function size:0x3BC setPosParam__Q23EGG14CoreControllerFff = .text:0x80064920; // type:function size:0x8 EGG__TSystem__initialize = .text:0x80064930; // type:function size:0x1F4 -dSys_c__execute = .text:0x80064B30; // type:function size:0x268 -dSystem__fixHeaps = .text:0x80064DA0; // type:function size:0xB8 +execute__6dSys_cFv = .text:0x80064B30; // type:function size:0x268 +fixHeaps__7dSystemFv = .text:0x80064DA0; // type:function size:0xB8 dSystem__init = .text:0x80064E60; // type:function size:0x34 EGG__ConfigurationData__initRenderMode = .text:0x80064EA0; // type:function size:0x4 getVideo = .text:0x80064EB0; // type:function size:0x8 diff --git a/include/d/d_main.h b/include/d/d_main.h index 12d3a150..2eca2708 100644 --- a/include/d/d_main.h +++ b/include/d/d_main.h @@ -5,10 +5,11 @@ namespace dMain { +OSTime g_InitialTime; + void Create(); void Execute(); void *main01(void *arg); -OSTime g_InitialTime; }; // namespace dMain diff --git a/src/d/d_main.cpp b/src/d/d_main.cpp index aac41dd6..feb4ea6a 100644 --- a/src/d/d_main.cpp +++ b/src/d/d_main.cpp @@ -6,10 +6,6 @@ #include "rvl/OS.h" -OSThread MAIN_THREAD; - -#define STACK_SIZE 0xF000 - void dMain::Create() { dSys_c::create(); dSys_c::setBlack(false); @@ -27,7 +23,11 @@ void *dMain::main01(void *arg) { return nullptr; } +#define STACK_SIZE 0xF000 + void main(int argc, char **argv) { + static OSThread MAIN_THREAD; + u8 pStackBase[STACK_SIZE] __attribute__((aligned(32))); fn_80006C20(); From 2bcf403ea0c86dbdcb0ded8c81984741aadb08f7 Mon Sep 17 00:00:00 2001 From: Sean Miller Date: Sun, 22 Mar 2026 22:07:56 +0000 Subject: [PATCH 04/21] dSys: create() and execute() to 99% each --- config/SOUE01/symbols.txt | 28 +-- include/c/c_counter.h | 11 + include/d/d_hbm.h | 2 +- include/d/d_heap.h | 20 +- include/d/d_scene.h | 4 + include/d/d_state.h | 13 + include/d/d_sys.h | 13 + include/d/d_sys_init.h | 12 + include/d/lyt/d_lyt_system_window.h | 2 + include/egg/core/eggSystem.h | 148 ++++++++--- include/m/m_dvd.h | 5 +- include/toBeSorted/arc_callback_handler.h | 8 + include/toBeSorted/d_d3d.h | 4 + include/toBeSorted/unk_save_time.h | 2 + src/d/d_main.cpp | 2 +- src/d/d_sys.cpp | 294 ++++++++++++++++++++++ src/toBeSorted/arc_callback_handler.cpp | 6 +- 17 files changed, 511 insertions(+), 63 deletions(-) create mode 100644 include/d/d_state.h create mode 100644 include/d/d_sys_init.h create mode 100644 include/toBeSorted/arc_callback_handler.h diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 29d66005..20273ecd 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -2822,10 +2822,10 @@ parseStageBzs__FiPCv = .text:0x80064070; // type:function size:0x7C parseRoomBzs__FiPCv = .text:0x800640F0; // type:function size:0x70 parseRoomReactivateBzs__FiPCv = .text:0x80064160; // type:function size:0x70 parseRoomActivateBzs__FiPCv = .text:0x800641D0; // type:function size:0x7C -dSys_c__initAudioMgr = .text:0x80064250; // type:function size:0xB0 -dSys_c__beginRender = .text:0x80064300; // type:function size:0x38 -dSys_c__endRender = .text:0x80064340; // type:function size:0x18 -dSys_c__beginFrame = .text:0x80064360; // type:function size:0x68 +initAudioMgr__6dSys_cFPQ23EGG4Heap = .text:0x80064250; // type:function size:0xB0 +beginRender__6dSys_cFv = .text:0x80064300; // type:function size:0x38 +endRender__6dSys_cFv = .text:0x80064340; // type:function size:0x18 +beginFrame__6dSys_cFv = .text:0x80064360; // type:function size:0x68 EGG__ConfigurationData__onBeginFrame = .text:0x800643D0; // type:function size:0x4 dSys_c__endFrame = .text:0x800643E0; // type:function size:0x48 EGG__ConfigurationData__onEndFrame = .text:0x80064430; // type:function size:0x4 @@ -2839,15 +2839,15 @@ setPosParam__Q23EGG14CoreControllerFff = .text:0x80064920; // type:function size EGG__TSystem__initialize = .text:0x80064930; // type:function size:0x1F4 execute__6dSys_cFv = .text:0x80064B30; // type:function size:0x268 fixHeaps__7dSystemFv = .text:0x80064DA0; // type:function size:0xB8 -dSystem__init = .text:0x80064E60; // type:function size:0x34 +__sinit_\d_sys_cpp = .text:0x80064E60; // type:function size:0x34 EGG__ConfigurationData__initRenderMode = .text:0x80064EA0; // type:function size:0x4 -getVideo = .text:0x80064EB0; // type:function size:0x8 -getSystemHeap = .text:0x80064EC0; // type:function size:0x8 -getDisplay = .text:0x80064ED0; // type:function size:0x8 -getXfbManager = .text:0x80064EE0; // type:function size:0x8 -getPerfView = .text:0x80064EF0; // type:function size:0x14 -getSceneMgr = .text:0x80064F10; // type:function size:0x8 -getAudioMgr = .text:0x80064F20; // type:function size:0x8 +getVideo__Q23EGG123TSystemFv = .text:0x80064EB0; // type:function size:0x8 +getSysHeap__Q23EGG123TSystemFv = .text:0x80064EC0; // type:function size:0x8 +getDisplay__Q23EGG123TSystemFv = .text:0x80064ED0; // type:function size:0x8 +getXfbMgr__Q23EGG123TSystemFv = .text:0x80064EE0; // type:function size:0x8 +getPerfView__Q23EGG123TSystemFv = .text:0x80064EF0; // type:function size:0x14 +getSceneMgr__Q23EGG123TSystemFv = .text:0x80064F10; // type:function size:0x8 +getAudioMgr__Q23EGG123TSystemFv = .text:0x80064F20; // type:function size:0x8 fn_80064F30 = .text:0x80064F30; // type:function size:0x24 fn_80064F60 = .text:0x80064F60; // type:function size:0x2C fn_80064F90 = .text:0x80064F90; // type:function size:0x30 @@ -17224,7 +17224,7 @@ my_vprintf__4sLibFPCcP16__va_list_struct = .text:0x802DEF90; // type:function si printf__4sLibFPCce = .text:0x802DEFE0; // type:function size:0x80 OSReport = .text:0x802DF060; // type:function size:0x80 scope:global OSVReport = .text:0x802DF0E0; // type:function size:0x4 scope:global -cCounter_c__clear = .text:0x802DF0F0; // type:function size:0x10 +clear__10cCounter_cFv = .text:0x802DF0F0; // type:function size:0x10 __dt__24DynamicModuleControlBaseFv = .text:0x802DF100; // type:function size:0xA0 __ct__24DynamicModuleControlBaseFv = .text:0x802DF1A0; // type:function size:0x48 link__24DynamicModuleControlBaseFv = .text:0x802DF1F0; // type:function size:0x94 @@ -17283,7 +17283,7 @@ cM__rad2s = .text:0x802E0A50; // type:function size:0x5C cM__U_GetAtanTable = .text:0x802E0AB0; // type:function size:0x34 atan2s__2cMFff = .text:0x802E0AF0; // type:function size:0x1BC atan2f__2cMFff = .text:0x802E0CB0; // type:function size:0x48 -cM__initRnd = .text:0x802E0D00; // type:function size:0x8 +initRnd__2cMFl = .text:0x802E0D00; // type:function size:0x8 rnd__2cMFv = .text:0x802E0D10; // type:function size:0x8 rndInt__2cMFi = .text:0x802E0D20; // type:function size:0x58 rndF__2cMFf = .text:0x802E0D80; // type:function size:0x38 diff --git a/include/c/c_counter.h b/include/c/c_counter.h index 8efe5f26..cb19146d 100644 --- a/include/c/c_counter.h +++ b/include/c/c_counter.h @@ -9,8 +9,19 @@ public: return m_gameFrame; } + static void IncrementGameFrame() { + m_gameFrame++; + } + + static void IncrementUnkCounter() { + m_unkCounter++; + } + + static void clear(); + private: static s32 m_gameFrame; + static s32 m_unkCounter; }; #endif diff --git a/include/d/d_hbm.h b/include/d/d_hbm.h index f02387db..7f6ce607 100644 --- a/include/d/d_hbm.h +++ b/include/d/d_hbm.h @@ -12,7 +12,7 @@ public: typedef void (*MenuInitCallback)(); - static void CreateInstance(); + static void CreateInstance(EGG::Heap *); static Manage_c *GetInstance(); Manage_c(EGG::Heap *); diff --git a/include/d/d_heap.h b/include/d/d_heap.h index 8809144b..6a6bb1f0 100644 --- a/include/d/d_heap.h +++ b/include/d/d_heap.h @@ -3,20 +3,20 @@ #include "egg/core/eggExpHeap.h" -class dHeap { +class dHeap : public EGG::Heap { public: EGG::ExpHeap *heap; public: - static dHeap work1Heap; - static dHeap work2Heap; - static dHeap workExHeap; - static dHeap layoutHeap; - static dHeap layoutExHeap; - static dHeap layoutEx2Heap; - static dHeap layoutResHeap; - static dHeap fontHeap; - static dHeap HBMHeap; + static dHeap *work1Heap; + static dHeap *work2Heap; + static dHeap *workExHeap; + static dHeap *layoutHeap; + static dHeap *layoutExHeap; + static dHeap *layoutEx2Heap; + static dHeap *layoutResHeap; + static dHeap *fontHeap; + static dHeap *HBMHeap; public: EGG::ExpHeap *init(const char *name, size_t size, EGG::Heap *parent); diff --git a/include/d/d_scene.h b/include/d/d_scene.h index 8c2334a0..eee6ea91 100644 --- a/include/d/d_scene.h +++ b/include/d/d_scene.h @@ -19,6 +19,10 @@ public: static dBase_c *staticExecute(); static void setRootActor(fProfile::PROFILE_NAME_e rootActor, u32 params, s32 fadeInType, s32 fadeOutType); + static dFader_c *getFader() { + return &sFader; + } + protected: static dFader_c sFader; }; diff --git a/include/d/d_state.h b/include/d/d_state.h new file mode 100644 index 00000000..b6384b7d --- /dev/null +++ b/include/d/d_state.h @@ -0,0 +1,13 @@ +#ifndef D_STATE_H +#define D_STATE_H + +namespace dState { + +void fn_80062E40(); +void fn_80062E50(); +void fn_80062EB0(); +bool fn_80062EC0(); + +} + +#endif // D_STATE_H diff --git a/include/d/d_sys.h b/include/d/d_sys.h index 2bb13c1e..384c5779 100644 --- a/include/d/d_sys.h +++ b/include/d/d_sys.h @@ -3,10 +3,20 @@ #include "common.h" #include "egg/core/eggHeap.h" +#include "egg/core/eggSystem.h" #include "nw4r/ut/ut_Color.h" +class dSndMgr_c; + class dSys_c { public: + static dSndMgr_c *initAudioMgr(EGG::Heap *heap); + + static void beginRender(); + static void endRender(); + static void beginFrame(); + static void endFrame(); + static void setBlack(bool); /* Frame rate values: 1 - 60fps, 2 - 30fps */ static void setFrameRate(u8); @@ -17,12 +27,15 @@ public: static void create(); static void execute(); + static EGG::BaseSystem *ms_configuration_p; static EGG::Heap *ms_RootHeapMem1; static EGG::Heap *ms_RootHeapMem2; }; namespace dSystem { + void fixHeaps(); + }; #endif diff --git a/include/d/d_sys_init.h b/include/d/d_sys_init.h new file mode 100644 index 00000000..b87d3526 --- /dev/null +++ b/include/d/d_sys_init.h @@ -0,0 +1,12 @@ +#ifndef D_SYS_INIT_H +#define D_SYS_INIT_H + +#include "s/s_Phase.hpp" + +namespace dSystem { + +extern sPhase_c myDylinkInitPhase; + +} + +#endif // D_SYS_INIT_H diff --git a/include/d/lyt/d_lyt_system_window.h b/include/d/lyt/d_lyt_system_window.h index 838edc69..bba711d5 100644 --- a/include/d/lyt/d_lyt_system_window.h +++ b/include/d/lyt/d_lyt_system_window.h @@ -80,6 +80,8 @@ public: s32 getField_0xDE0() const; bool getField_0xDFC() const; + void fn_80125E20(); + void fn_80125EF0(); void fn_80152F10(); bool fn_80152F50() const; bool fn_80152F60() const; diff --git a/include/egg/core/eggSystem.h b/include/egg/core/eggSystem.h index 919c84da..97682fa3 100644 --- a/include/egg/core/eggSystem.h +++ b/include/egg/core/eggSystem.h @@ -2,64 +2,146 @@ #define EGG_SYSTEM_H #include "common.h" +#include "egg/core/eggGraphicsFifo.h" #include "egg/core/eggHeap.h" +#include "rvl/SC.h" + +// Ported from https://github.com/snailspeed3/mkw/blob/master/lib/egg/core/eggSystem.hpp namespace EGG { class Display; -class XfbManager; +class Heap; +class PerformanceView; +class SceneManager; +class SimpleAudioMgr; +class Thread; class Video; +class XfbManager; -class ConfigurationData { +class BaseSystem { public: - // vtable at 0x0 + static BaseSystem *sSystem; + +public: + inline BaseSystem() : mSysHeapSize(0x97000), mGraphicsFifoSize(0x80000), mRenderMode(nullptr) {} + /* vt 0x08 */ virtual Video *getVideo() = 0; - /* vt 0x0C */ virtual Heap *getSystemHeap() = 0; + /* vt 0x0C */ virtual Heap *getSysHeap() = 0; /* vt 0x10 */ virtual Display *getDisplay() = 0; /* vt 0x14 */ virtual XfbManager *getXfbMgr() = 0; - /* vt 0x18 */ virtual void getPerfView() = 0; - /* vt 0x1C */ virtual void getScnMgr() = 0; - /* vt 0x20 */ virtual void getAudioMgr() = 0; + /* vt 0x18 */ virtual PerformanceView *getPerfView() = 0; + /* vt 0x1C */ virtual SceneManager *getSceneMgr() = 0; + /* vt 0x20 */ virtual SimpleAudioMgr *getAudioMgr() = 0; /* vt 0x24 */ virtual void onBeginFrame(); /* vt 0x28 */ virtual void onEndFrame(); /* vt 0x2C */ virtual void initRenderMode(); /* vt 0x30 */ virtual void initMemory(); /* vt 0x34 */ virtual void run(); + /* vt 0x38 */ virtual void initialize() = 0; public: - /* 0x04 */ u32 mRoot1HeapStart; - /* 0x08 */ u32 mRoot1HeapEnd; - /* 0x0C */ u32 mRoot2HeapStart; - /* 0x10 */ u32 mRoot2HeapEnd; - /* 0x14 */ u32 mMemSize; + /* 0x04 */ void *mMEM1ArenaLo; + /* 0x08 */ void *mMEM1ArenaHi; + /* 0x0C */ void *mMEM2ArenaLo; + /* 0x10 */ void *mMEM2ArenaHi; + /* 0x14 */ u32 mMemorySize; /* 0x18 */ Heap *mRootHeapMem1; /* 0x1C */ Heap *mRootHeapMem2; /* 0x20 */ Heap *mRootHeapDebug; - /* 0x24 */ Heap *mSystemHeap; - /* 0x28 */ Thread *mSystemThread; - /* 0x2C */ u32 field_0x2C; - /* 0x30 */ u32 mSystemHeapStart; - /* 0x34 */ u32 mSystemHeapSize; + /* 0x24 */ Heap *mSysHeap; + /* 0x28 */ Thread *mThread; + /* 0x2C */ void *_2c; + /* 0x30 */ void *_30; + /* 0x34 */ u32 mSysHeapSize; /* 0x38 */ u32 mGraphicsFifoSize; - /* 0x3C */ u32 field_0x3C; -}; -class BaseSystem { -public: - static ConfigurationData *mConfigData; - static XfbManager *getXfbMgr() { - return mConfigData->getXfbMgr(); - } - static Display *getDisplay() { - return mConfigData->getDisplay(); - } - static Video *getVideo() { - return mConfigData->getVideo(); - } + /* 0x3C */ GXRenderModeObj *mRenderMode; }; -template -class TSystem : ConfigurationData {}; +template +class TSystem : public BaseSystem { +public: + inline TSystem() : BaseSystem() {} + + Video *getVideo() override { + return static_cast