diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 5cb4fc38..d7202436 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -17704,12 +17704,12 @@ alloc__12mAllocator_cFUl = .text:0x802EE1E0; // type:function size:0x4 free__12mAllocator_cFPv = .text:0x802EE1F0; // type:function size:0x4 __ct__16mHeapAllocator_cFv = .text:0x802EE200; // type:function size:0x3C __dt__16mHeapAllocator_cFv = .text:0x802EE240; // type:function size:0x6C -replaceWithNewFrmHeap__16mHeapAllocator_cFlPQ23EGG4HeapPclUl = .text:0x802EE2B0; // type:function size:0x84 -replaceWithNewExpHeap__16mHeapAllocator_cFlPQ23EGG4HeapPclUl = .text:0x802EE340; // type:function size:0x84 +createFrmHeap__16mHeapAllocator_cFUlPQ23EGG4HeapPCcUlQ25mHeap13AllocOptBit_t = .text:0x802EE2B0; // type:function size:0x84 +createExpHeap__16mHeapAllocator_cFUlPQ23EGG4HeapPCcUlQ25mHeap13AllocOptBit_t = .text:0x802EE340; // type:function size:0x84 destroyHeap__16mHeapAllocator_cFv = .text:0x802EE3D0; // type:function size:0x54 adjustFrmHeap__16mHeapAllocator_cFv = .text:0x802EE430; // type:function size:0x70 adjustExpHeap__16mHeapAllocator_cFv = .text:0x802EE4A0; // type:function size:0x70 -createNewTempFrmHeap__16mHeapAllocator_cFlPQ23EGG4HeapPclUl = .text:0x802EE510; // type:function size:0x4C +createFrmHeapToCurrent__16mHeapAllocator_cFUlPQ23EGG4HeapPCcUlQ25mHeap13AllocOptBit_t = .text:0x802EE510; // type:function size:0x4C adjustFrmHeapRestoreCurrent__16mHeapAllocator_cFv = .text:0x802EE560; // type:function size:0x64 __nwa__FUlP12mAllocator_c = .text:0x802EE5D0; // type:function size:0x1C step__4mAngFslss = .text:0x802EE5F0; // type:function size:0xA4 @@ -17764,11 +17764,11 @@ createOrDie__15mDvd_callback_cFPFPv_PvPv = .text:0x802EF650; // type:function si execute__15mDvd_callback_cFv = .text:0x802EF680; // type:function size:0x54 __dt__22mDvd_mountMemArchive_cFv = .text:0x802EF6E0; // type:function size:0x58 __ct__22mDvd_mountMemArchive_cFi = .text:0x802EF740; // type:function size:0x74 -findPathWithCompressedExtension__FPCcPUc = .text:0x802EF7C0; // type:function size:0x16C -setAutoStreamDecomp__Fb = .text:0x802EF930; // type:function size:0x8 -getAutoStreamDecomp__Fv = .text:0x802EF940; // type:function size:0x8 -ConvertPathToEntrynum__FPCcPUc = .text:0x802EF950; // type:function size:0x80 scope:local -ConvertPathToEntrynum_Thunk__FPCcPUc = .text:0x802EF9D0; // type:function size:0x4 scope:local +ConvertPathToEntrynumASD___4mDvdFPCcPUc = .text:0x802EF7C0; // type:function size:0x16C +setAutoStreamDecomp__4mDvdFb = .text:0x802EF930; // type:function size:0x8 +isAutoStreamDecomp__4mDvdFv = .text:0x802EF940; // type:function size:0x8 +ConvertPathToEntrynum__4mDvdFPCcPUc = .text:0x802EF950; // type:function size:0x80 scope:local +ConvertPathToEntrynumWithWarning__4mDvdFPCcPUc = .text:0x802EF9D0; // type:function size:0x4 scope:local create__22mDvd_mountMemArchive_cFPCcUcPQ23EGG4Heap = .text:0x802EF9E0; // type:function size:0xA0 execute__22mDvd_mountMemArchive_cFv = .text:0x802EFA80; // type:function size:0xF8 getArcBinary__22mDvd_mountMemArchive_cFv = .text:0x802EFB80; // type:function size:0x18 @@ -17815,12 +17815,12 @@ set__10mFrustum_cFffffffRC6mMtx_cb = .text:0x802F08E0; // type:function size:0x3 fn_802F0C50 = .text:0x802F0C50; // type:function size:0x160 fn_802F0DB0 = .text:0x802F0DB0; // type:function size:0x8 fn_802F0DC0 = .text:0x802F0DC0; // type:function size:0x13C -copyAttribute__5mHeapFUl = .text:0x802F0F00; // type:function size:0x34 +GetOptFlag__5mHeapFQ25mHeap13AllocOptBit_t = .text:0x802F0F00; // type:function size:0x34 setCurrentHeap__5mHeapFPQ23EGG4Heap = .text:0x802F0F40; // type:function size:0x4 -createExpHeap__5mHeapFUlPQ23EGG4HeapPCcUlUl = .text:0x802F0F50; // type:function size:0x10C +createExpHeap__5mHeapFUlPQ23EGG4HeapPCcUlQ25mHeap13AllocOptBit_t = .text:0x802F0F50; // type:function size:0x10C adjustExpHeap__5mHeapFPQ23EGG7ExpHeap = .text:0x802F1060; // type:function size:0x68 expHeapCost__5mHeapFUlUl = .text:0x802F10D0; // type:function size:0x18 -createFrmHeap__5mHeapFUlPQ23EGG4HeapPCcUlUl = .text:0x802F10F0; // type:function size:0x10C +createFrmHeap__5mHeapFUlPQ23EGG4HeapPCcUlQ25mHeap13AllocOptBit_t = .text:0x802F10F0; // type:function size:0x10C destroyFrmHeap__5mHeapFPQ23EGG7FrmHeap = .text:0x802F1200; // type:function size:0x1C adjustFrmHeap__5mHeapFPQ23EGG7FrmHeap = .text:0x802F1220; // type:function size:0x68 frmHeapCost__5mHeapFUlUl = .text:0x802F1290; // type:function size:0x18 @@ -17829,7 +17829,7 @@ __dt__5mHeapFv = .text:0x802F12F0; // type:function size:0x58 createHeap__5mHeapFUlPQ23EGG4HeapPCc = .text:0x802F1350; // type:function size:0x74 saveCurrentHeap__5mHeapFv = .text:0x802F13D0; // type:function size:0xC restoreCurrentHeap__5mHeapFv = .text:0x802F13E0; // type:function size:0x2C -makeFrmHeapAndUpdate__5mHeapFUlPQ23EGG4HeapPCcUlUl = .text:0x802F1410; // type:function size:0x40 +createFrmHeapToCurrent__5mHeapFUlPQ23EGG4HeapPCcUlQ25mHeap13AllocOptBit_t = .text:0x802F1410; // type:function size:0x40 getDefaultGameHeapId__5mHeapFv = .text:0x802F1450; // type:function size:0x8 createGameHeap__5mHeapFiUlPQ23EGG4Heap = .text:0x802F1460; // type:function size:0xAC createGameHeap1__5mHeapFUlPQ23EGG4Heap = .text:0x802F1510; // type:function size:0x44 @@ -17837,7 +17837,7 @@ createArchiveHeap__5mHeapFUlPQ23EGG4Heap = .text:0x802F1560; // type:function si createCommandHeap__5mHeapFUlPQ23EGG4Heap = .text:0x802F1590; // type:function size:0x2C createDylinkHeap__5mHeapFUlPQ23EGG4Heap = .text:0x802F15C0; // type:function size:0x2C createAssertHeap__5mHeapFPQ23EGG4Heap = .text:0x802F15F0; // type:function size:0x50 -makeHeapOnCurrentGameHeap__5mHeapFUlPCcUlUl = .text:0x802F1640; // type:function size:0x20 +makeHeapOnCurrentGameHeap__5mHeapFUlPCcUlQ25mHeap13AllocOptBit_t = .text:0x802F1640; // type:function size:0x20 mMtx__ctor = .text:0x802F1660; // type:function size:0x44 XrotS__6mMtx_cFRC4mAng = .text:0x802F16B0; // type:function size:0xBC XrotM__6mMtx_cFRC4mAng = .text:0x802F1770; // type:function size:0x4C diff --git a/include/m/m_allocator.h b/include/m/m_allocator.h index 4391ad0e..6d6f307b 100644 --- a/include/m/m_allocator.h +++ b/include/m/m_allocator.h @@ -2,6 +2,7 @@ #define M_ALLOCATOR_H #include "egg/core/eggAllocator.h" +#include "m/m_heap.h" class mAllocator_c : public EGG::Allocator { public: @@ -19,12 +20,12 @@ public: /* 0x08 */ virtual ~mHeapAllocator_c(); /* 0x0C */ // virtual void* alloc(u32 size); // see mAlloctor::alloc /* 0x10 */ // virtual void free(void* block); // see mAlloctor::free - bool replaceWithNewFrmHeap(s32 size, EGG::Heap *newHeap, char *heapName, s32 align, u32 unk); - bool replaceWithNewExpHeap(s32 size, EGG::Heap *newHeap, char *heapName, s32 align, u32 unk); + bool createFrmHeap(u32 size, EGG::Heap *newHeap, const char *heapName, u32 align, mHeap::AllocOptBit_t attr); + bool createExpHeap(u32 size, EGG::Heap *newHeap, const char *heapName, u32 align, mHeap::AllocOptBit_t attr); void destroyHeap(); s32 adjustFrmHeap(); s32 adjustExpHeap(); - bool createNewTempFrmHeap(s32 size, EGG::Heap *newHeap, char *heapName, s32 align, u32 unk); + bool createFrmHeapToCurrent(u32 size, EGG::Heap *newHeap, const char *heapName, u32 align, mHeap::AllocOptBit_t attr); void adjustFrmHeapRestoreCurrent(); }; diff --git a/include/m/m_heap.h b/include/m/m_heap.h index 05cc8308..e13b028b 100644 --- a/include/m/m_heap.h +++ b/include/m/m_heap.h @@ -16,14 +16,22 @@ class AssertHeap; // TODO: Doc symbols and func locations class mHeap { public: - /* 802f0f00 */ static u16 copyAttribute(u32); + // TODO - fix when importing RVL MEM + enum AllocOptBit_t { + OPT_NONE = 0x0, + OPT_1 = 0x1, + OPT_2 = 0x2, + OPT_4 = 0x4, + }; + + /* 802f0f00 */ static u16 GetOptFlag(AllocOptBit_t); /* 802f0f40 */ static EGG::Heap *setCurrentHeap(EGG::Heap *); /* 802f0f50 */ static EGG::Heap *createExpHeap(size_t size, EGG::Heap *parentHeap, const char *name, u32 align, - u32 attrs); + AllocOptBit_t attrs); /* 802f1060 */ static size_t adjustExpHeap(EGG::ExpHeap *heap); /* 802f10d0 */ static size_t expHeapCost(size_t start, u32 size); /* 802f10f0 */ static EGG::FrmHeap *createFrmHeap(size_t size, EGG::Heap *parentHeap, const char *name, - size_t align, size_t attrs); + size_t align, AllocOptBit_t attrs); /* 802f1200 */ static void destroyFrmHeap(EGG::FrmHeap *heap); /* 802f1220 */ static size_t adjustFrmHeap(EGG::FrmHeap *heap); /* 802f1290 */ static size_t frmHeapCost(size_t start, u32 size); @@ -35,8 +43,8 @@ public: /* 802f1350 */ static EGG::ExpHeap *createHeap(size_t size, EGG::Heap *, const char *name); /* 802f13d0 */ static void saveCurrentHeap(); /* 802f13e0 */ static void restoreCurrentHeap(); - /* 802f1410 */ static EGG::FrmHeap *makeFrmHeapAndUpdate(size_t size, EGG::Heap *parentHeap, const char *name, - u32 align, u32 attrs); + /* 802f1410 */ static EGG::FrmHeap *createFrmHeapToCurrent(size_t size, EGG::Heap *parentHeap, const char *name, + u32 align, AllocOptBit_t attrs); /* 802f1450 */ static int getGameHeapNum(); /* 802f1460 */ static EGG::Heap *createGameHeap(int heapNum, size_t size, EGG::Heap *parentHeap); /* 802f1510 */ static void createGameHeap1(size_t size, EGG::Heap *parentHeap); @@ -44,7 +52,7 @@ public: /* 802f1590 */ static void createCommandHeap(size_t size, EGG::Heap *parentHeap); /* 802f15c0 */ static void createDylinkHeap(size_t size, EGG::Heap *parentHeap); /* 802f15f0 */ static EGG::AssertHeap *createAssertHeap(EGG::Heap *parentHeap); - /* 802f1640 */ static EGG::FrmHeap *makeHeapOnCurrentGameHeap(size_t size, const char *name, u32 align, u32 flags); + /* 802f1640 */ static EGG::FrmHeap *makeHeapOnCurrentGameHeap(size_t size, const char *name, u32 align, AllocOptBit_t flags); static int getDefaultGameHeapId(); diff --git a/src/d/a/d_a_base.cpp b/src/d/a/d_a_base.cpp index 5ad96e3c..a60175f5 100644 --- a/src/d/a/d_a_base.cpp +++ b/src/d/a/d_a_base.cpp @@ -16,6 +16,7 @@ #include "f/f_base.h" #include "f/f_list_nd.h" #include "m/m_angle.h" +#include "m/m_heap.h" #include "m/m_vec.h" #include "toBeSorted/actor_info.h" #include "toBeSorted/event.h" @@ -129,7 +130,7 @@ int dAcBase_c::initAllocatorWork1Heap(int size, char *name, int align) { } int dAcBase_c::initAllocator(int size, char *name, EGG::Heap *heap, int align) { - if (!heap_allocator.createNewTempFrmHeap(size, heap, name, 0x20, 0)) { + if (!heap_allocator.createFrmHeapToCurrent(size, heap, name, 0x20, mHeap::OPT_NONE)) { return 0; } sound_source = createSoundSource(); diff --git a/src/d/d_dylink.cpp b/src/d/d_dylink.cpp index 55197434..2c17a470 100644 --- a/src/d/d_dylink.cpp +++ b/src/d/d_dylink.cpp @@ -46,7 +46,7 @@ char relsDir[] = "/rels"; int initDylinkHeap(int maxRelId, const RelNamePtr *dynNameTable, int dynNameTableNum, EGG::Heap *parentHeap) { cCc_frmHeap = mHeap::createFrmHeap( maxRelId * 0x10 + dynNameTableNum * 0x48, parentHeap, "ダイナミックリンク制御用ヒープ(dDyl::cCc_frmHeap)", 0x20, - 0 + mHeap::OPT_NONE ); mHeap _guard(cCc_frmHeap); diff --git a/src/d/d_player_mdl.cpp b/src/d/d_player_mdl.cpp index c5c45ba3..43a2bf28 100644 --- a/src/d/d_player_mdl.cpp +++ b/src/d/d_player_mdl.cpp @@ -15,6 +15,7 @@ #include "m/m3d/m_fanm.h" #include "m/m3d/m_mdl.h" #include "m/m_allocator.h" +#include "m/m_heap.h" #include "m/m_mtx.h" #include "m/m_vec.h" #include "nw4r/g3d/g3d_anmchr.h" @@ -702,8 +703,7 @@ void daPlayerModelBase_c::freeFrmHeap(mHeapAllocator_c *allocator) { } void daPlayerModelBase_c::allocFrmHeap(mHeapAllocator_c *allocator, u32 size, const char *name) { - // TODO fix char constness - allocator->createNewTempFrmHeap(size, dHeap::work1Heap.heap, (char *)name, 0x20, 0); + allocator->createFrmHeapToCurrent(size, dHeap::work1Heap.heap, name, 0x20, mHeap::OPT_NONE); new u8[size](); allocator->adjustFrmHeapRestoreCurrent(); } diff --git a/src/d/d_rawarchive.cpp b/src/d/d_rawarchive.cpp index 45b20758..d3854d37 100644 --- a/src/d/d_rawarchive.cpp +++ b/src/d/d_rawarchive.cpp @@ -1,4 +1,5 @@ #include "d/d_rawarchive.h" +#include "m/m_heap.h" #include "rvl/VI.h" // IWYU pragma: export @@ -186,7 +187,7 @@ int dRawArcEntry_c::ensureLoadedMaybe(void *callbackArg) { if (mpArc == nullptr) { return -1; } - mpFrmHeap = mHeap::makeHeapOnCurrentGameHeap(-1, name(), 0x20, 0); + mpFrmHeap = mHeap::makeHeapOnCurrentGameHeap(-1, name(), 0x20, mHeap::OPT_NONE); if (mpFrmHeap == nullptr) { return -1; } diff --git a/src/d/d_room.cpp b/src/d/d_room.cpp index e6b9720f..801762fb 100644 --- a/src/d/d_room.cpp +++ b/src/d/d_room.cpp @@ -22,6 +22,7 @@ #include "m/m3d/m_anmvis.h" #include "m/m3d/m_fanm.h" #include "m/m3d/m_smdl.h" +#include "m/m_heap.h" #include "m/m_mtx.h" #include "m/m_vec.h" #include "nw4r/g3d/g3d_scnmdl.h" @@ -56,8 +57,8 @@ int dRoom_c::create() { !(dScGame_c::isCurrentStage("D300") && (roomid == 0 || roomid == 1 || roomid == 4)) && // LMF crawlspace, spike maze !(dScGame_c::isCurrentStage("D300_1") && (roomid == 7 || roomid == 9)); - if (!mAllocator.createNewTempFrmHeap( - -1, CurrentStageArcManager::GetInstance()->getHeap(roomid), "dRoom_c::m_allocator", 0x20, 0 + if (!mAllocator.createFrmHeapToCurrent( + -1, CurrentStageArcManager::GetInstance()->getHeap(roomid), "dRoom_c::m_allocator", 0x20, mHeap::OPT_NONE )) { return FAILED; } diff --git a/src/f/f_base.cpp b/src/f/f_base.cpp index 3fddeae8..d1b7e34a 100644 --- a/src/f/f_base.cpp +++ b/src/f/f_base.cpp @@ -23,8 +23,11 @@ void (*fBase_c::sUnloadCallback)(); /* 802e12f0 */ fBase_c::fBase_c() - : unique_ID(m_rootUniqueID), params(m_tmpCtData.params), profile_name(m_tmpCtData.prof_name), - group_type(m_tmpCtData.group_type), manager(this) { + : unique_ID(m_rootUniqueID), + params(m_tmpCtData.params), + profile_name(m_tmpCtData.prof_name), + group_type(m_tmpCtData.group_type), + manager(this) { m_rootUniqueID = (fBaseID_e)(m_rootUniqueID + 1); if (m_rootUniqueID == INVALID) { for (;;) { @@ -59,10 +62,10 @@ fBase_c::~fBase_c() { // that causes a weak destructor to spawn that actually needs to be in f_manager. // And it's not like any of fLiMgBa_c's methods are accessed via actor_list, // so who can tell? Maybe there's yet another type? - fLiNdBa_c *node = static_cast(actor_list.getFirst()); + fLiNdBa_c *node = static_cast(actor_list.getFirst()); while (node != nullptr) { node->unlink(); - node = static_cast(actor_list.getFirst()); + node = static_cast(actor_list.getFirst()); } } @@ -443,8 +446,9 @@ bool fBase_c::entryFrmHeap(size_t size, EGG::Heap *parentHeap) { EGG::FrmHeap *new_heap = nullptr; if (size != 0) { - new_heap = - mHeap::makeFrmHeapAndUpdate(size, parentHeap, "各プロセスが個別で持てるヒープ(fBase_c::mHeap)", 0x20, 0); + new_heap = mHeap::createFrmHeapToCurrent( + size, parentHeap, "各プロセスが個別で持てるヒープ(fBase_c::mHeap)", 0x20, mHeap::OPT_NONE + ); if (new_heap != nullptr) { bool create_sucess = createHeap(); mHeap::restoreCurrentHeap(); @@ -461,8 +465,9 @@ bool fBase_c::entryFrmHeap(size_t size, EGG::Heap *parentHeap) { } } if (new_heap == nullptr) { - new_heap = - mHeap::makeFrmHeapAndUpdate(-1, parentHeap, "各プロセスが個別で持てるヒープ(fBase_c::mHeap)", 0x20, 0); + new_heap = mHeap::createFrmHeapToCurrent( + -1, parentHeap, "各プロセスが個別で持てるヒープ(fBase_c::mHeap)", 0x20, mHeap::OPT_NONE + ); if (new_heap != nullptr) { bool create_sucess = createHeap(); @@ -477,8 +482,8 @@ bool fBase_c::entryFrmHeap(size_t size, EGG::Heap *parentHeap) { } if (new_heap != nullptr) { - EGG::FrmHeap *larger_heap = mHeap::makeFrmHeapAndUpdate( - heap_size, parentHeap, "各プロセスが個別で持てるヒープ(fBase_c::mHeap)", 0x20, 0 + EGG::FrmHeap *larger_heap = mHeap::createFrmHeapToCurrent( + heap_size, parentHeap, "各プロセスが個別で持てるヒープ(fBase_c::mHeap)", 0x20, mHeap::OPT_NONE ); if (larger_heap != nullptr) { if (larger_heap < new_heap) { @@ -516,8 +521,9 @@ bool fBase_c::entryFrmHeapNonAdjust(size_t size, EGG::Heap *parentHeap) { return true; } - EGG::FrmHeap *new_heap = - mHeap::makeFrmHeapAndUpdate(size, parentHeap, "各プロセスが個別で持てるヒープ(fBase_c::mHeap)", 0x20, 0); + EGG::FrmHeap *new_heap = mHeap::createFrmHeapToCurrent( + size, parentHeap, "各プロセスが個別で持てるヒープ(fBase_c::mHeap)", 0x20, mHeap::OPT_NONE + ); if (new_heap != nullptr) { bool create_sucess = createHeap(); mHeap::restoreCurrentHeap(); diff --git a/src/m/m3d/m_banm.cpp b/src/m/m3d/m_banm.cpp index 047e5972..53a4a81b 100644 --- a/src/m/m3d/m_banm.cpp +++ b/src/m/m3d/m_banm.cpp @@ -29,7 +29,8 @@ bool banm_c::createAllocator(mAllocator_c *alloc, u32 *pStart) { i1 = mHeap::frmHeapCost(i2, 0x20); *pStart = ROUND_UP(i1, 0x20); mpFrameHeap = mHeap::createFrmHeap( - i2, (EGG::Heap *)alloc->mHeap, "アニメ切り替え用アロケータ(m3d::banm_c::m_heap)", internal::l_alignment, 0 + i2, (EGG::Heap *)alloc->mHeap, "アニメ切り替え用アロケータ(m3d::banm_c::m_heap)", internal::l_alignment, + mHeap::OPT_NONE ); mAllocator.attach(mpFrameHeap, 0x20); return true; diff --git a/src/m/m3d/m_shadow.cpp b/src/m/m3d/m_shadow.cpp index da0246ef..668a6669 100644 --- a/src/m/m3d/m_shadow.cpp +++ b/src/m/m3d/m_shadow.cpp @@ -56,7 +56,7 @@ void mShadow_c::create( // Maybe an Inline? EGG::FrmHeap **heap = mpFrmHeaps; for (int i = 0; i < 2; i++) { - heap[0] = mHeap::createFrmHeap(heapSize, mpHeap, "ShadowTmp", 0x4, 0); + heap[0] = mHeap::createFrmHeap(heapSize, mpHeap, "ShadowTmp", 0x4, mHeap::OPT_NONE); heap[0]->recordState(FRM_HEAP_STATE); heap++; } @@ -519,7 +519,7 @@ void mShadowChild_c::updateMtx() { mVec3_c a(mQuat.v.x, mQuat.v.y, mQuat.v.z); a += mPositionMaybe * GetOffset(); - + mVec3_c b(mQuat.v.x, mQuat.v.y, mQuat.v.z); b -= mPositionMaybe * field_0x13C; diff --git a/src/m/m_allocator.cpp b/src/m/m_allocator.cpp index 1c6a56f0..25334c5c 100644 --- a/src/m/m_allocator.cpp +++ b/src/m/m_allocator.cpp @@ -35,7 +35,7 @@ mHeapAllocator_c::~mHeapAllocator_c() { destroyHeap(); } -bool mHeapAllocator_c::replaceWithNewFrmHeap(s32 size, EGG::Heap *newHeap, char *heapName, s32 align, u32 attrs) { +bool mHeapAllocator_c::createFrmHeap(u32 size, EGG::Heap *newHeap, const char *heapName, u32 align, mHeap::AllocOptBit_t attrs) { destroyHeap(); EGG::Heap *heap = mHeap::createFrmHeap(size, newHeap, heapName, align, attrs); if (heap == nullptr) { @@ -45,7 +45,7 @@ bool mHeapAllocator_c::replaceWithNewFrmHeap(s32 size, EGG::Heap *newHeap, char return true; } -bool mHeapAllocator_c::replaceWithNewExpHeap(s32 size, EGG::Heap *newHeap, char *heapName, s32 align, u32 attrs) { +bool mHeapAllocator_c::createExpHeap(u32 size, EGG::Heap *newHeap, const char *heapName, u32 align, mHeap::AllocOptBit_t attrs) { destroyHeap(); EGG::Heap *heap = mHeap::createExpHeap(size, newHeap, heapName, align, attrs); if (heap == nullptr) { @@ -79,8 +79,8 @@ s32 mHeapAllocator_c::adjustExpHeap() { return mHeap::adjustExpHeap(EGG::Heap::toExpHeap(heap)); } -bool mHeapAllocator_c::createNewTempFrmHeap(s32 size, EGG::Heap *newHeap, char *heapName, s32 align, u32 attrs) { - if (!replaceWithNewFrmHeap(size, newHeap, heapName, align, attrs)) { +bool mHeapAllocator_c::createFrmHeapToCurrent(u32 size, EGG::Heap *newHeap, const char *heapName, u32 align, mHeap::AllocOptBit_t attrs) { + if (!createFrmHeap(size, newHeap, heapName, align, attrs)) { return false; } mHeap::saveCurrentHeap(); diff --git a/src/m/m_dvd.cpp b/src/m/m_dvd.cpp index cfee7660..49c2eba8 100644 --- a/src/m/m_dvd.cpp +++ b/src/m/m_dvd.cpp @@ -165,8 +165,10 @@ static void *loadToMainRAM( return result; } +static int ConvertPathToEntrynum(const char *path, u8 *); + int ConvertPathToEntrynum(const char *path) { - return ::ConvertPathToEntrynum(path, nullptr); + return mDvd::ConvertPathToEntrynum(path, nullptr); } u32 IsExistPath(const char *path) { @@ -374,8 +376,10 @@ mDvd_mountMemArchive_c::mDvd_mountMemArchive_c(int mountDirection) { mAmountRead = 0; } +namespace mDvd { + /** 802ef7c0 */ -int findPathWithCompressedExtension(const char *name, u8 *outType) { +static int ConvertPathToEntrynumASD_(const char *name, u8 *outType) { u8 type; char buf[256]; int num; @@ -434,10 +438,11 @@ void setAutoStreamDecomp(bool arg) { } /** 802ef940 */ -bool getAutoStreamDecomp() { +bool isAutoStreamDecomp() { return mDvd::l_IsAutoStreamDecomp; } + /** 802ef950 */ static int ConvertPathToEntrynum(const char *path, u8 *outType) { int num = DVDConvertPathToEntrynum(path); @@ -445,22 +450,24 @@ static int ConvertPathToEntrynum(const char *path, u8 *outType) { if (outType != nullptr) { *outType = 0; } - } else if (getAutoStreamDecomp()) { - num = findPathWithCompressedExtension(path, outType); + } else if (mDvd::isAutoStreamDecomp()) { + num = mDvd::ConvertPathToEntrynumASD_(path, outType); } return num; } /** 802ef9d0 */ -static int ConvertPathToEntrynum_Thunk(const char *path, u8 *outType) { +static int ConvertPathToEntrynumWithWarning(const char *path, u8 *outType) { return ConvertPathToEntrynum(path, outType); } +} + /** 802ef9e0 */ mDvd_mountMemArchive_c *mDvd_mountMemArchive_c::create(const char *path, u8 mountDirection, EGG::Heap *heap) { u8 type; mDvd_mountMemArchive_c *cmd = nullptr; - int entryNum = ConvertPathToEntrynum_Thunk(path, &type); + int entryNum = mDvd::ConvertPathToEntrynumWithWarning(path, &type); if (entryNum != -1) { cmd = new mDvd_mountMemArchive_c(mountDirection); if (cmd != nullptr) { @@ -596,7 +603,7 @@ mDvd_toMainRam_normal_c::mDvd_toMainRam_normal_c(int mountDirection) : mDvd_toMa /** 802eff90 */ mDvd_toMainRam_normal_c *mDvd_toMainRam_normal_c::create(const char *path, int mountDirection, EGG::Heap *heap) { u8 type; - int entryNum = ConvertPathToEntrynum_Thunk(path, &type); + int entryNum = mDvd::ConvertPathToEntrynumWithWarning(path, &type); mDvd_toMainRam_normal_c *cmd; if (entryNum == -1) { cmd = nullptr; diff --git a/src/m/m_heap.cpp b/src/m/m_heap.cpp index f2767ac0..eb6bc6da 100644 --- a/src/m/m_heap.cpp +++ b/src/m/m_heap.cpp @@ -22,7 +22,7 @@ const char *const mHeap::s_GameHeapNames[4] = { 0, }; -u16 mHeap::copyAttribute(u32 arg) { +u16 mHeap::GetOptFlag(AllocOptBit_t arg) { u16 result = 0; if ((arg & 1) != 0) { @@ -40,7 +40,7 @@ u16 mHeap::copyAttribute(u32 arg) { EGG::Heap *mHeap::setCurrentHeap(EGG::Heap *heap) { return heap->becomeCurrentHeap(); } -EGG::Heap *mHeap::createExpHeap(size_t size, EGG::Heap *parentHeap, const char *name, u32 align, u32 attrs) { +EGG::Heap *mHeap::createExpHeap(size_t size, EGG::Heap *parentHeap, const char *name, u32 align, AllocOptBit_t attrs) { if (parentHeap == nullptr) { parentHeap = EGG::Heap::sCurrentHeap; } @@ -58,7 +58,7 @@ EGG::Heap *mHeap::createExpHeap(size_t size, EGG::Heap *parentHeap, const char * void *mem = parentHeap->alloc(size, align); EGG::ExpHeap *heap = nullptr; if (mem != nullptr) { - heap = EGG::ExpHeap::create(mem, size, copyAttribute(attrs)); + heap = EGG::ExpHeap::create(mem, size, GetOptFlag(attrs)); if (heap == nullptr) { parentHeap->free(mem); } else if (name != nullptr) { @@ -86,7 +86,7 @@ size_t mHeap::expHeapCost(size_t size, u32 align) { return size + (~(a)&b); } -EGG::FrmHeap *mHeap::createFrmHeap(size_t size, EGG::Heap *parent, const char *name, size_t align, size_t attrs) { +EGG::FrmHeap *mHeap::createFrmHeap(size_t size, EGG::Heap *parent, const char *name, size_t align, AllocOptBit_t attrs) { if (parent == nullptr) { parent = EGG::Heap::sCurrentHeap; } @@ -104,7 +104,7 @@ EGG::FrmHeap *mHeap::createFrmHeap(size_t size, EGG::Heap *parent, const char *n void *mem = parent->alloc(size, align); EGG::FrmHeap *heap = nullptr; if (mem != nullptr) { - heap = EGG::FrmHeap::create(mem, size, copyAttribute(attrs)); + heap = EGG::FrmHeap::create(mem, size, GetOptFlag(attrs)); if (heap == nullptr) { parent->free(mem); } else if (name != nullptr) { @@ -167,8 +167,8 @@ void mHeap::restoreCurrentHeap() { s_SavedCurrentHeap = nullptr; } -EGG::FrmHeap *mHeap::makeFrmHeapAndUpdate(size_t size, EGG::Heap *parentHeap, const char *name, u32 align, u32 unk) { - EGG::FrmHeap *heap = createFrmHeap(size, parentHeap, name, align, unk); +EGG::FrmHeap *mHeap::createFrmHeapToCurrent(size_t size, EGG::Heap *parentHeap, const char *name, u32 align, AllocOptBit_t opt) { + EGG::FrmHeap *heap = createFrmHeap(size, parentHeap, name, align, opt); if (heap != nullptr) { s_SavedCurrentHeap = setCurrentHeap(heap); } @@ -209,6 +209,6 @@ EGG::AssertHeap *mHeap::createAssertHeap(EGG::Heap *parent) { return g_assertHeap; } -EGG::FrmHeap *mHeap::makeHeapOnCurrentGameHeap(size_t size, const char *name, u32 align, u32 flags) { - return makeFrmHeapAndUpdate(size, g_gameHeaps[0], name, align, flags); +EGG::FrmHeap *mHeap::makeHeapOnCurrentGameHeap(size_t size, const char *name, u32 align, AllocOptBit_t flags) { + return createFrmHeapToCurrent(size, g_gameHeaps[0], name, align, flags); } diff --git a/src/toBeSorted/attention.cpp b/src/toBeSorted/attention.cpp index 21dd1b4a..86257c93 100644 --- a/src/toBeSorted/attention.cpp +++ b/src/toBeSorted/attention.cpp @@ -5,6 +5,7 @@ #include "d/d_heap.h" #include "d/d_pad.h" #include "m/m_angle.h" +#include "m/m_heap.h" #include "nw4r/g3d/res/g3d_resfile.h" #include "toBeSorted/arc_managers/oarc_manager.h" #include "toBeSorted/event_manager.h" @@ -81,7 +82,7 @@ bool AttentionManager::create() { field_0xBD5 = 0; field_0xBD4 = 0; - if (!mAllocator.createNewTempFrmHeap(-1, dHeap::work1Heap.heap, "Attention", 0x20, 0)) { + if (!mAllocator.createFrmHeapToCurrent(-1, dHeap::work1Heap.heap, "Attention", 0x20, mHeap::OPT_NONE)) { return 0; } mModels.mMdls[0].field_0x79 = 0; diff --git a/src/toBeSorted/d_emitter.cpp b/src/toBeSorted/d_emitter.cpp index a8b0379f..5fab3069 100644 --- a/src/toBeSorted/d_emitter.cpp +++ b/src/toBeSorted/d_emitter.cpp @@ -2,6 +2,7 @@ // vtable order #include "JSystem/JParticle/JPAEmitter.h" #include "JSystem/JParticle/JPAParticle.h" +#include "m/m_heap.h" #include "rvl/GX/GXTypes.h" #include "toBeSorted/d_d3d.h" // clang-format on @@ -910,7 +911,7 @@ bool dJEffManager_c::createEffManagers() { } } - ms_allocator->createNewTempFrmHeap(-1, dHeap::work1Heap.heap, "dJEffManager_c::ms_allocator", 0x20, 0); + ms_allocator->createFrmHeapToCurrent(-1, dHeap::work1Heap.heap, "dJEffManager_c::ms_allocator", 0x20, mHeap::OPT_NONE); for (s32 idx = 0; idx < 2; idx++) { sFogProcs[idx].create(idx, sInts[idx], -1, ms_allocator); } diff --git a/src/toBeSorted/d_particle.cpp b/src/toBeSorted/d_particle.cpp index e05695af..fe35b08e 100644 --- a/src/toBeSorted/d_particle.cpp +++ b/src/toBeSorted/d_particle.cpp @@ -26,7 +26,7 @@ static u16 extractResUserIdx(u16 particleResId) { namespace dParticle { JPAResourceManager *res_c::init(const void *jpc, const void *jpn, EGG::Heap *heap) { - mpHeap = mHeap::createFrmHeap(-1, heap, "dParticle::res_c", 0x20, 0); + mpHeap = mHeap::createFrmHeap(-1, heap, "dParticle::res_c", 0x20, mHeap::OPT_NONE); if (mpHeap == nullptr) { return nullptr; } diff --git a/src/toBeSorted/time_area_mgr.cpp b/src/toBeSorted/time_area_mgr.cpp index 5e7de081..3a613b34 100644 --- a/src/toBeSorted/time_area_mgr.cpp +++ b/src/toBeSorted/time_area_mgr.cpp @@ -2,6 +2,7 @@ #include "d/d_heap.h" #include "d/d_sc_game.h" +#include "m/m_heap.h" #include "nw4r/g3d/g3d_obj.h" dTimeAreaMgr_c::dTimeAreaMgr_c() { @@ -13,7 +14,7 @@ dTimeAreaMgr_c::~dTimeAreaMgr_c() { } bool dTimeAreaMgr_c::init() { - mAllocator.replaceWithNewFrmHeap(-1, dHeap::work1Heap.heap, "dTimeAreaMgr_c::m_allocator", 0x20, 0); + mAllocator.createFrmHeap(-1, dHeap::work1Heap.heap, "dTimeAreaMgr_c::m_allocator", 0x20, mHeap::OPT_NONE); mProcA.create(&mAllocator); mProcB.create(&mAllocator); mAllocator.adjustFrmHeap();