From 51bfda0e1b8f557552e0f7639ce7b1c2d547b503 Mon Sep 17 00:00:00 2001 From: Sean Miller Date: Sun, 15 Mar 2026 16:45:12 +0000 Subject: Initial work on d_main --- 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 +++++++ 5 files changed, 37 insertions(+) create mode 100644 include/d/d_main.h create mode 100644 include/toBeSorted/d_lib.h create mode 100644 include/toBeSorted/mpls.h (limited to 'include') 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 -- cgit v1.2.3 From adb84c1cd698cad09b89e97476088ebd624ccf1b Mon Sep 17 00:00:00 2001 From: Sean Miller Date: Sun, 15 Mar 2026 16:53:18 +0000 Subject: Format files --- include/d/d_main.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'include') 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 -- cgit v1.2.3 From dd1c8ac8c2ff91e84272fc2187a5213fef481def Mon Sep 17 00:00:00 2001 From: Sean Miller Date: Sun, 15 Mar 2026 17:33:53 +0000 Subject: Minor formatting adjustments + symbol renaming --- include/d/d_main.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') 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 -- cgit v1.2.3 From 2bcf403ea0c86dbdcb0ded8c81984741aadb08f7 Mon Sep 17 00:00:00 2001 From: Sean Miller Date: Sun, 22 Mar 2026 22:07:56 +0000 Subject: dSys: create() and execute() to 99% each --- 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 | 140 +++++++++++++++++++++++------- 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 + 13 files changed, 194 insertions(+), 42 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 (limited to 'include') 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 BaseSystem { +public: + static BaseSystem *sSystem; -class ConfigurationData { public: - // vtable at 0x0 + 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; + /* 0x3C */ GXRenderModeObj *mRenderMode; }; -class BaseSystem { + +template +class TSystem : public BaseSystem { public: - static ConfigurationData *mConfigData; - static XfbManager *getXfbMgr() { - return mConfigData->getXfbMgr(); + inline TSystem() : BaseSystem() {} + + Video *getVideo() override { + return static_cast