From 2bcf403ea0c86dbdcb0ded8c81984741aadb08f7 Mon Sep 17 00:00:00 2001 From: Sean Miller Date: Sun, 22 Mar 2026 22:07:56 +0000 Subject: [PATCH] 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