diff --git a/include/d/actor/d_a_player.h b/include/d/actor/d_a_player.h index e81bce0a94..41a11ff662 100644 --- a/include/d/actor/d_a_player.h +++ b/include/d/actor/d_a_player.h @@ -73,6 +73,20 @@ private: /* 0x8 */ f32 m_offsetXZ; }; // Size: 0xC +#if TARGET_PC +#define PLAYER_CREATE_ANM_HEAP_F(heap, type, fmt, ...) \ + { \ + char pcah_name_buf[32]; \ + sprintf(pcah_name_buf, fmt, ##__VA_ARGS__); \ + (heap).createHeap(type, pcah_name_buf); \ + \ + } +#define PLAYER_CREATE_ANM_HEAP(heap, type, name) (heap).createHeap(type, name) +#else +#define PLAYER_CREATE_ANM_HEAP_F(heap, type, name, ...) (heap).createHeap(type) +#define PLAYER_CREATE_ANM_HEAP(heap, type, name) (heap).createHeap(type) +#endif + class daPy_anmHeap_c { public: enum daAlinkHEAP_TYPE { @@ -87,7 +101,11 @@ public: ~daPy_anmHeap_c(); void initData(); void* mallocBuffer(); +#if TARGET_PC + void createHeap(daAlinkHEAP_TYPE i_heapType, const char* name); +#else void createHeap(daAlinkHEAP_TYPE i_heapType); +#endif void* loadData(u16 i_resId); void* loadDataIdx(u16 i_resId); void* loadDataPriIdx(u16 i_resId); diff --git a/include/d/d_simple_model.h b/include/d/d_simple_model.h index 4952553208..25b9e6e2d1 100644 --- a/include/d/d_simple_model.h +++ b/include/d/d_simple_model.h @@ -32,6 +32,10 @@ public: J3DModel* getModel() { return mpModel; } +#if TARGET_PC + void setIdx(u8 idx) { this->idx = idx; } +#endif + private: /* 0x00 */ JKRSolidHeap* mpHeap; /* 0x04 */ J3DModel* mpModel; @@ -40,6 +44,9 @@ private: /* 0x10 */ u8 mDrawBG; /* 0x11 */ s8 mRoomNo; /* 0x12 */ u8 field_0x12; +#if TARGET_PC + u8 idx; +#endif }; // Size: 0x14 class dSmplMdl_draw_c { diff --git a/libs/JSystem/include/JSystem/JKernel/JKRHeap.h b/libs/JSystem/include/JSystem/JKernel/JKRHeap.h index 2ff883c393..419d49301d 100644 --- a/libs/JSystem/include/JSystem/JKernel/JKRHeap.h +++ b/libs/JSystem/include/JSystem/JKernel/JKRHeap.h @@ -222,9 +222,13 @@ public: #define JKRHEAP_NAME(heap, name) (heap)->setName(name) #define JKRHEAP_NAMEF(heap, name, ...) (heap)->setNamef(name, __VA_ARGS__) +#define JKRHEAP_CURRENT_NAME(heap, name) JKRHEAP_NAME(mDoExt_getCurrentHeap(), name) +#define JKRHEAP_CURRENT_NAMEF(heap, name, ...) JKRHEAP_NAMEF(mDoExt_getCurrentHeap(), name, __VA_ARGS__) #else #define JKRHEAP_NAME(heap, name) -#define JKRHEAP_NAMEF(heap, name) +#define JKRHEAP_NAMEF(heap, name, ...) +#define JKRHEAP_CURRENT_NAME(heap, name) +#define JKRHEAP_CURRENT_NAMEF(heap, name, ...) #endif }; diff --git a/src/d/actor/d_a_alink.cpp b/src/d/actor/d_a_alink.cpp index c05d595a3c..58e8935e7d 100644 --- a/src/d/actor/d_a_alink.cpp +++ b/src/d/actor/d_a_alink.cpp @@ -4453,7 +4453,7 @@ void daAlink_c::playerInit() { mAtSph.StartCAt(current.pos); mAnmHeap3.setBufferSize(0x20000); - mAnmHeap3.createHeap(daPy_anmHeap_c::HEAP_TYPE_4); + PLAYER_CREATE_ANM_HEAP(mAnmHeap3, daPy_anmHeap_c::HEAP_TYPE_4, "daAlink_c::mAnmHeap3"); if (checkWolf()) { changeWolf(); @@ -4462,7 +4462,7 @@ void daAlink_c::playerInit() { } mAnmHeap4.setBufferSize(0xB00); - mAnmHeap4.createHeap(daPy_anmHeap_c::HEAP_TYPE_4); + PLAYER_CREATE_ANM_HEAP(mAnmHeap4, daPy_anmHeap_c::HEAP_TYPE_4, "daAlink_c::mAnmHeap4"); setShieldModel(); #if DEBUG @@ -4507,24 +4507,24 @@ void daAlink_c::playerInit() { for (i = 0; i < 3; i++) { mUnderAnmHeap[i].setBuffer(mUnderAnmHeap[0].getBuffer() + (i * 0x2C00)); - mUnderAnmHeap[i].createHeap(daPy_anmHeap_c::HEAP_TYPE_3); + PLAYER_CREATE_ANM_HEAP_F(mUnderAnmHeap[i], daPy_anmHeap_c::HEAP_TYPE_3, "daAlink_c::mUnderAnmHeap[%d]", i); } mUpperAnmHeap[0].setBuffer(mUnderAnmHeap[0].getBuffer() + 0x8400); for (i = 0; i < 3; i++) { mUpperAnmHeap[i].setBuffer(mUpperAnmHeap[0].getBuffer() + (i * 0x2C00)); - mUpperAnmHeap[i].createHeap(daPy_anmHeap_c::HEAP_TYPE_3); + PLAYER_CREATE_ANM_HEAP_F(mUpperAnmHeap[i], daPy_anmHeap_c::HEAP_TYPE_3, "daAlink_c::mUpperAnmHeap[%d]", i); } - mFaceBtpHeap.createHeap(daPy_anmHeap_c::HEAP_TYPE_1); - mFaceBtkHeap.createHeap(daPy_anmHeap_c::HEAP_TYPE_2); - mFaceBckHeap.createHeap(daPy_anmHeap_c::HEAP_TYPE_3); + PLAYER_CREATE_ANM_HEAP(mFaceBtpHeap, daPy_anmHeap_c::HEAP_TYPE_1, "daAlink_c::mFaceBtpHeap"); + PLAYER_CREATE_ANM_HEAP(mFaceBtkHeap, daPy_anmHeap_c::HEAP_TYPE_2, "daAlink_c::mFaceBtkHeap"); + PLAYER_CREATE_ANM_HEAP(mFaceBckHeap, daPy_anmHeap_c::HEAP_TYPE_3, "daAlink_c::mFaceBckHeap"); for (i = 0; i < 2; i++) { mItemHeap[i].setBufferSize(0x13200); - mItemHeap[i].createHeap(daPy_anmHeap_c::HEAP_TYPE_4); + PLAYER_CREATE_ANM_HEAP_F(mItemHeap[i], daPy_anmHeap_c::HEAP_TYPE_4, "daAlink_c::mItemHeap[%d]", i); } - mAnmHeap9.createHeap(daPy_anmHeap_c::HEAP_TYPE_3); + PLAYER_CREATE_ANM_HEAP(mAnmHeap9, daPy_anmHeap_c::HEAP_TYPE_3, "daAlink_c::mAnmHeap9"); resetBasAnime(); mZ2Link.init(¤t.pos, &eyePos, &field_0x3720); diff --git a/src/d/actor/d_a_bg.cpp b/src/d/actor/d_a_bg.cpp index 2cc6f1f192..e73723d1f9 100644 --- a/src/d/actor/d_a_bg.cpp +++ b/src/d/actor/d_a_bg.cpp @@ -532,6 +532,7 @@ int daBg_c::create() { if (room_heap != NULL) { this->heap = JKRCreateSolidHeap(-1, room_heap, false); JUT_ASSERT(471, heap != NULL); + JKRHEAP_NAME(heap, "d_a_bg Anms"); JKRHeap* old = mDoExt_setCurrentHeap(this->heap); int rt = createHeap(); diff --git a/src/d/actor/d_a_midna.cpp b/src/d/actor/d_a_midna.cpp index dcdb2f43ff..cbbf1915e2 100644 --- a/src/d/actor/d_a_midna.cpp +++ b/src/d/actor/d_a_midna.cpp @@ -565,12 +565,12 @@ cPhs_Step daMidna_c::create() { mpFunc = &daMidna_c::checkMetamorphoseEnableBase; for (u16 i = 0; i < 3; i++) { - mBckHeap[i].createHeap(daPy_anmHeap_c::HEAP_TYPE_3); + PLAYER_CREATE_ANM_HEAP_F(mBckHeap[i], daPy_anmHeap_c::HEAP_TYPE_3, "daMidna_c::mBckHeap[%d]", i); } - mBtpHeap.createHeap(daPy_anmHeap_c::HEAP_TYPE_1); - mBtkHeap.createHeap(daPy_anmHeap_c::HEAP_TYPE_2); - + PLAYER_CREATE_ANM_HEAP_F(mBtpHeap, daPy_anmHeap_c::HEAP_TYPE_1, "daMidna_c::mBtpHeap"); + PLAYER_CREATE_ANM_HEAP_F(mBtkHeap, daPy_anmHeap_c::HEAP_TYPE_2, "daMidna_c::mBtkHeap"); + mSound.init(¤t.pos, &eyePos, 3, 1); mpShadowModel = mpMorf->getModel(); mpShadowModel->setUserArea((uintptr_t)this); diff --git a/src/d/actor/d_a_player.cpp b/src/d/actor/d_a_player.cpp index c091fae5dd..f38fe15a3b 100644 --- a/src/d/actor/d_a_player.cpp +++ b/src/d/actor/d_a_player.cpp @@ -237,7 +237,11 @@ void* daPy_anmHeap_c::mallocBuffer() { return mBuffer; } -void daPy_anmHeap_c::createHeap(daPy_anmHeap_c::daAlinkHEAP_TYPE i_heapType) { +#if TARGET_PC +void daPy_anmHeap_c::createHeap(daPy_anmHeap_c::daAlinkHEAP_TYPE i_heapType, const char* name) { +#else +void daPy_anmHeap_c::createHeap(daPy_anmHeap_c::daAlinkHEAP_TYPE i_heapType, const char* name) { +#endif u32 size; if (i_heapType == 4) { @@ -260,8 +264,8 @@ void daPy_anmHeap_c::createHeap(daPy_anmHeap_c::daAlinkHEAP_TYPE i_heapType) { JKRHeap* tmp; mAnimeHeap = mDoExt_createSolidHeapFromGameToCurrent(&tmp, size, 0x20); - JKRHEAP_NAMEF(mAnimeHeap, "Alink anime type %d", i_heapType); - + JKRHEAP_NAME(mAnimeHeap, name); + if (i_heapType == 4) { tmpWork = JKR_NEW_ARRAY(char, size); JUT_ASSERT(669, tmpWork != NULL); diff --git a/src/d/d_file_select.cpp b/src/d/d_file_select.cpp index 748d963de3..16aafb721f 100644 --- a/src/d/d_file_select.cpp +++ b/src/d/d_file_select.cpp @@ -5195,6 +5195,7 @@ void dFile_select3D_c::_create(u8 i_mirrorIdx, u8 i_maskIdx) { if (mpSolidHeap == NULL) { JUT_ASSERT(5189, mpSolidHeap != NULL); } + JKRHEAP_NAME(mpSolidHeap, "dFile_select3D_c::mpSolidHeap"); field_0x03c4 = 0.0f; field_0x03c8 = 0.0f; diff --git a/src/d/d_k_wmark.cpp b/src/d/d_k_wmark.cpp index 8021494be2..379b55f532 100644 --- a/src/d/d_k_wmark.cpp +++ b/src/d/d_k_wmark.cpp @@ -35,6 +35,7 @@ int dkWmark_c::create() { mpHeap = mDoExt_createSolidHeapFromGameToCurrent(0x880, 0x20); if (mpHeap != NULL) { + JKRHEAP_NAME(mpHeap, "dkWmark_c::mpHeap"); J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("Alink", 0x23); JUT_ASSERT(60, modelData != NULL); diff --git a/src/d/d_ky_thunder.cpp b/src/d/d_ky_thunder.cpp index 69c0d690ad..77c2a92769 100644 --- a/src/d/d_ky_thunder.cpp +++ b/src/d/d_ky_thunder.cpp @@ -26,6 +26,8 @@ int dThunder_c::createHeap() { if (mpHeap == NULL) { return 0; } + + JKRHEAP_NAME(mpHeap, "dThunder_c::mpHeap"); } return 1; diff --git a/src/d/d_menu_collect.cpp b/src/d/d_menu_collect.cpp index 4f18e74391..c1281a86c2 100644 --- a/src/d/d_menu_collect.cpp +++ b/src/d/d_menu_collect.cpp @@ -2222,6 +2222,7 @@ dMenu_Collect3D_c::~dMenu_Collect3D_c() { void dMenu_Collect3D_c::_create() { mpHeap->getTotalFreeSize(); mpSolidHeap = mDoExt_createSolidHeapToCurrent(0x25800, mpHeap, 0x20); + JKRHEAP_NAME(mpSolidHeap, "dMenu_Collect3D_c::mpSolidHeap"); mDoExt_setCurrentHeap((JKRHeap*)mpSolidHeap); daAlink_c* linkActor = daAlink_getAlinkActorClass(); if (linkActor != NULL) { diff --git a/src/d/d_menu_dmap.cpp b/src/d/d_menu_dmap.cpp index d78766b0e3..97721d9dd2 100644 --- a/src/d/d_menu_dmap.cpp +++ b/src/d/d_menu_dmap.cpp @@ -1649,6 +1649,7 @@ void dMenu_Dmap_c::_create() { mDmapHeap = JKRCreateExpHeap(field_0xe8->getFreeSize() - 0x10, field_0xe8, false); JUT_ASSERT(3732, mDmapHeap != NULL); + JKRHEAP_NAME(mDmapHeap, "dMenu_Dmap_c::mDmapHeap"); JKRHeap* heap = mDoExt_setCurrentHeap(mDmapHeap); u32 sp28 = mDmapHeap->getTotalFreeSize(); diff --git a/src/d/d_simple_model.cpp b/src/d/d_simple_model.cpp index 2bea7e950d..7106197644 100644 --- a/src/d/d_simple_model.cpp +++ b/src/d/d_simple_model.cpp @@ -18,6 +18,7 @@ static void dSmplMdl_modelUpdateDL(J3DModel* i_model) { dSmplMdl_draw_c::dSmplMdl_draw_c() { for (int i = 0; i < 8; i++) { mModel[i].init(); + mModel[i].setIdx(i); } for (int i = 0; i < 500; i++) { @@ -128,6 +129,7 @@ BOOL diff_model_c::create(J3DModelData* i_modelData, int roomNo, u8 drawBG) { JUT_ASSERT(397, i_modelData != NULL); if (mpHeap == NULL) { mpHeap = mDoExt_createSolidHeapFromGameToCurrent(0x2000, 0x20); + JKRHEAP_NAMEF(mpHeap, "Simple model (%d)", idx); if (mpHeap != NULL) { mpModel = mDoExt_J3DModel__create(i_modelData, 0x80000, 0x11000084); diff --git a/src/d/d_stage.cpp b/src/d/d_stage.cpp index b79bcc128c..f6c90b0f3d 100644 --- a/src/d/d_stage.cpp +++ b/src/d/d_stage.cpp @@ -384,6 +384,7 @@ static void dummy1(dStage_roomControl_c* roomControl) { JKRExpHeap* dStage_roomControl_c::createMemoryBlock(int i_blockIdx, u32 i_heapSize) { if (mMemoryBlock[i_blockIdx] == NULL) { mMemoryBlock[i_blockIdx] = JKRCreateExpHeap(i_heapSize, mDoExt_getArchiveHeap(), false); + JKRHEAP_NAMEF(mMemoryBlock[i_blockIdx], "Room control memory block %d", i_blockIdx); } return mMemoryBlock[i_blockIdx]; diff --git a/src/d/d_timer.cpp b/src/d/d_timer.cpp index 5299ebeb04..41826c3029 100644 --- a/src/d/d_timer.cpp +++ b/src/d/d_timer.cpp @@ -40,6 +40,7 @@ int dTimer_c::_create() { dComIfGp_setAllMapArchive(resInfo->getArchive()); mp_heap = fopMsgM_createExpHeap(0x11000, NULL); + JKRHEAP_NAME(mp_heap, "dTimer_c::mp_heap"); JKRHeap* prev_heap = mDoExt_setCurrentHeap(mp_heap); if (mp_heap != NULL) { mp_heap->getTotalFreeSize(); diff --git a/src/f_op/f_op_actor_mng.cpp b/src/f_op/f_op_actor_mng.cpp index 082c721418..79795d3bfe 100644 --- a/src/f_op/f_op_actor_mng.cpp +++ b/src/f_op/f_op_actor_mng.cpp @@ -524,6 +524,7 @@ bool fopAcM_entrySolidHeap_(fopAc_ac_c* i_actor, heapCallbackFunc i_heapCallback OSReport_Error("最大空きヒープサイズで確保失敗。[%s]\n", procNameString); return false; } + JKRHEAP_NAMEF(heap, "Actor mng (%s)", procNameString); #if DEBUG if (!fopAcM::HeapAdjustQuiet) { // Attempting registration with max heap size. %08x @@ -625,6 +626,7 @@ bool fopAcM_entrySolidHeap_(fopAc_ac_c* i_actor, heapCallbackFunc i_heapCallback if (alignedSize + adjOffset + 0x10 < freeSize) { newHeap = mDoExt_createSolidHeapFromGame(alignedSize, 0x20); + JKRHEAP_NAMEF(newHeap, "Actor mng (%s)", procNameString); } if (fopAcM::HeapAdjustVerbose) {