From 77f8365ac5feb49236f8b5237eac91cdb1912b2c Mon Sep 17 00:00:00 2001 From: robojumper Date: Wed, 22 May 2024 19:46:13 +0200 Subject: [PATCH] Cleanups --- config/SOUE01/symbols.txt | 6 +++--- include/d/d_dvd.h | 11 ----------- include/m/m_dvd.h | 9 +++++---- include/rvl/OS/OSLink.h | 1 + src/DynamicLink.cpp | 10 +++++----- src/d/d_dvd.cpp | 2 +- src/m/m_dvd.cpp | 10 +++++----- 7 files changed, 20 insertions(+), 29 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 1ae97d22..5250ad05 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -17753,7 +17753,7 @@ removeCommand__12mDvd_param_cFP14mDvd_command_c = .text:0x802EF310; // type:func executeCB__12mDvd_param_cFPP14mDvd_command_c = .text:0x802EF3D0; // type:function size:0x34 mainLoop__12mDvd_param_cFv = .text:0x802EF410; // type:function size:0x4C __ct__14mDvd_command_cFv = .text:0x802EF460; // type:function size:0x1C -fn_802EF480 = .text:0x802EF480; // type:function size:0x20 +do_delete__14mDvd_command_cFv = .text:0x802EF480; // type:function size:0x20 destroy__14mDvd_command_cFPP14mDvd_command_c = .text:0x802EF4A0; // type:function size:0x54 __dt__15mDvd_callback_cFv = .text:0x802EF500; // type:function size:0x58 __ct__15mDvd_callback_cFPFPv_bPv = .text:0x802EF560; // type:function size:0x64 @@ -17777,11 +17777,11 @@ __dt__20mDvd_toMainRam_arc_cFv = .text:0x802EFCE0; // type:function size:0x58 __ct__20mDvd_toMainRam_arc_cFPQ23EGG7Archiveii = .text:0x802EFD40; // type:function size:0x60 makeRequest__20mDvd_toMainRam_arc_cFPQ23EGG7ArchiveiiPQ23EGG4Heap = .text:0x802EFDA0; // type:function size:0x80 create__20mDvd_toMainRam_arc_cFPQ23EGG7ArchivePCciPQ23EGG4Heap = .text:0x802EFE20; // type:function size:0x64 -fn_802EFE90 = .text:0x802EFE90; // type:function size:0x30 +createOrFail__20mDvd_toMainRam_arc_cFPQ23EGG7ArchivePCciPQ23EGG4Heap = .text:0x802EFE90; // type:function size:0x30 execute__20mDvd_toMainRam_arc_cFv = .text:0x802EFEC0; // type:function size:0x78 __ct__23mDvd_toMainRam_normal_cFi = .text:0x802EFF40; // type:function size:0x4C create__23mDvd_toMainRam_normal_cFPCciPQ23EGG4Heap = .text:0x802EFF90; // type:function size:0x9C -fn_802F0030 = .text:0x802F0030; // type:function size:0x30 +createOrFail__23mDvd_toMainRam_normal_cFPCciPQ23EGG4Heap = .text:0x802F0030; // type:function size:0x30 create2__23mDvd_toMainRam_normal_cFPP23mDvd_toMainRam_normal_cPCciPQ23EGG4Heap = .text:0x802F0060; // type:function size:0x48 __dt__23mDvd_toMainRam_normal_cFv = .text:0x802F00B0; // type:function size:0x58 execute__23mDvd_toMainRam_normal_cFv = .text:0x802F0110; // type:function size:0xA0 diff --git a/include/d/d_dvd.h b/include/d/d_dvd.h index 56fb848c..a7addacb 100644 --- a/include/d/d_dvd.h +++ b/include/d/d_dvd.h @@ -25,17 +25,6 @@ private: void* mpBuffer; }; -class unkstruct_c { -public: - static unkstruct_c *create(EGG::Heap *heap); - void init(); - char getUnk(); - -private: - UNKWORD field_0x0; - char field_0x4; -}; - } // dDvd #endif diff --git a/include/m/m_dvd.h b/include/m/m_dvd.h index 86be5449..11890653 100644 --- a/include/m/m_dvd.h +++ b/include/m/m_dvd.h @@ -7,6 +7,8 @@ #include #include +// Note: names are taken from NSMBW where available but a lot are made up + void unk_initDecompressors(); namespace mDvd { @@ -56,6 +58,7 @@ public: void waitDone(); void waitUntilDone(); static void destroy(mDvd_command_c **cmd); + void do_delete(); void *operator new(size_t size); void operator delete(void *ptr); @@ -117,6 +120,7 @@ public: static mDvd_toMainRam_arc_c *makeRequest(EGG::Archive *arc, int entryNum, int mountDirection, EGG::Heap *heap); static mDvd_toMainRam_arc_c *create(EGG::Archive *arc, const char *path, int mountDirection, EGG::Heap *heap); + static mDvd_toMainRam_arc_c *createOrFail(EGG::Archive *arc, const char *path, int mountDirection, EGG::Heap *heap); EGG::Archive *mArcPtr; int mEntryNum; @@ -130,6 +134,7 @@ public: virtual void doClear(); static mDvd_toMainRam_normal_c *create(const char *path, int mountDirection, EGG::Heap *heap); + static mDvd_toMainRam_normal_c *createOrFail(const char *path, int mountDirection, EGG::Heap *heap); static void create2(mDvd_toMainRam_normal_c **cmd, const char *path, int mountDirection, EGG::Heap *heap); u8 mCompressionType2; @@ -178,8 +183,4 @@ public: }; } // namespace mDvd -extern "C" void fn_802EF480(mDvd_command_c *cmd); -extern "C" mDvd_toMainRam_normal_c *fn_802F0030(const char *path, int mountDirection, EGG::Heap *heap); -extern "C" mDvd_toMainRam_arc_c *fn_802EFE90(EGG::Archive *arc, const char *path, int mountDirection, EGG::Heap *heap); - #endif diff --git a/include/rvl/OS/OSLink.h b/include/rvl/OS/OSLink.h index aa2a86cf..8f6df8b0 100644 --- a/include/rvl/OS/OSLink.h +++ b/include/rvl/OS/OSLink.h @@ -1,6 +1,7 @@ #ifndef OSLINK_H #define OSLINK_H +#include #ifdef __cplusplus extern "C" { diff --git a/src/DynamicLink.cpp b/src/DynamicLink.cpp index f1d048a6..2c7947c0 100644 --- a/src/DynamicLink.cpp +++ b/src/DynamicLink.cpp @@ -159,9 +159,9 @@ bool DynamicModuleControl::do_load() { snprintf(buf, sizeof(buf), "%s/%sNP.rel", sRelsDir, mName); if (mModule == nullptr) { if (sArchive != nullptr) { - sDvdFile = fn_802EFE90(sArchive, buf, 1, mHeap); + sDvdFile = mDvd_toMainRam_arc_c::createOrFail(sArchive, buf, 1, mHeap); } else { - sDvdFile = fn_802F0030(buf, 1, mHeap); + sDvdFile = mDvd_toMainRam_normal_c::createOrFail(buf, 1, mHeap); } if (sDvdFile != nullptr) { @@ -170,7 +170,7 @@ bool DynamicModuleControl::do_load() { void *ptr = sDvdFile->mDataPtr; sDvdFile->mDataPtr = nullptr; mModule = static_cast(ptr); - fn_802EF480(sDvdFile); + sDvdFile->do_delete(); sDvdFile = nullptr; if (mModule != nullptr) { unk_40 = 0; @@ -198,7 +198,7 @@ BOOL DynamicModuleControl::do_load_async() { } if (mDvdCallbackRequest != nullptr && mDvdCallbackRequest->mStatus != 0) { - fn_802EF480(mDvdCallbackRequest); + mDvdCallbackRequest->do_delete(); mDvdCallbackRequest = nullptr; return true; } else { @@ -351,6 +351,7 @@ void DbMapFile::Unregister() { unk_0 = 0; } } + extern "C" { void ModuleProlog() {} @@ -370,5 +371,4 @@ void ModuleDestructorsX(void (**ptrs)()) { (*ptrs)(); } } - } diff --git a/src/d/d_dvd.cpp b/src/d/d_dvd.cpp index afe8d10f..2f7b9cfa 100644 --- a/src/d/d_dvd.cpp +++ b/src/d/d_dvd.cpp @@ -43,7 +43,7 @@ void *loader_c::request(const char *path, u8 mountDirection, EGG::Heap *heap) { mpBuffer = mpCommand->mDataPtr; mSize = mpCommand->mAmountRead; mpCommand->mDataPtr = nullptr; - fn_802EF480(mpCommand); + mpCommand->do_delete(); mpCommand = nullptr; return mpBuffer; } else { diff --git a/src/m/m_dvd.cpp b/src/m/m_dvd.cpp index c503216b..82fce847 100644 --- a/src/m/m_dvd.cpp +++ b/src/m/m_dvd.cpp @@ -309,8 +309,8 @@ mDvd_command_c::mDvd_command_c() { } /** 802ef480 */ -extern "C" void fn_802EF480(mDvd_command_c *cmd) { - delete cmd; +void mDvd_command_c::do_delete() { + delete this; } /** 802ef4a0 */ @@ -318,7 +318,7 @@ void mDvd_command_c::destroy(mDvd_command_c **cmd) { // TODO fake match, this looks like an inlined dtor if (cmd != nullptr && cmd != nullptr && *cmd != nullptr) { (*cmd)->done(); - fn_802EF480(*cmd); + (*cmd)->do_delete(); *cmd = nullptr; } } @@ -568,7 +568,7 @@ mDvd_toMainRam_arc_c *mDvd_toMainRam_arc_c::create(EGG::Archive *arc, const char } /** 802efe90 */ -extern "C" mDvd_toMainRam_arc_c *fn_802EFE90(EGG::Archive *arc, const char *path, int mountDirection, EGG::Heap *heap) { +mDvd_toMainRam_arc_c *mDvd_toMainRam_arc_c::createOrFail(EGG::Archive *arc, const char *path, int mountDirection, EGG::Heap *heap) { mDvd_toMainRam_arc_c *cmd = mDvd_toMainRam_arc_c::create(arc, path, mountDirection, heap); while (!cmd) {} return cmd; @@ -608,7 +608,7 @@ mDvd_toMainRam_normal_c *mDvd_toMainRam_normal_c::create(const char *path, int m } /** 802f0030 */ -extern "C" mDvd_toMainRam_normal_c *fn_802F0030(const char *path, int mountDirection, EGG::Heap *heap) { +mDvd_toMainRam_normal_c *mDvd_toMainRam_normal_c::createOrFail(const char *path, int mountDirection, EGG::Heap *heap) { mDvd_toMainRam_normal_c *cmd = mDvd_toMainRam_normal_c::create(path, mountDirection, heap); while (!cmd) {} return cmd;