From 4f28c4ed10382ef2e0933aa337df7ec0318ce094 Mon Sep 17 00:00:00 2001 From: Lurs <2795933+Lurs@users.noreply.github.com> Date: Mon, 6 Apr 2026 09:21:26 +0200 Subject: [PATCH 1/4] double heaps to fix Midna's eye (#106) and various other error messages I got. Also updating aurora. --- extern/aurora | 2 +- libs/JSystem/src/J3DGraphLoader/J3DModelLoader.cpp | 2 +- src/d/actor/d_a_alink_swindow.inc | 3 +++ src/d/actor/d_a_player.cpp | 7 +++---- src/d/d_k_wmark.cpp | 4 ++++ src/d/d_kankyo.cpp | 4 ++++ src/f_op/f_op_actor_mng.cpp | 3 +++ 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/extern/aurora b/extern/aurora index b17da31593..5a23bcbd5e 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit b17da315932b85d7d708eaf3e44914f70045a44e +Subproject commit 5a23bcbd5e758c3a854ebda2c0bd8332b346e1ff diff --git a/libs/JSystem/src/J3DGraphLoader/J3DModelLoader.cpp b/libs/JSystem/src/J3DGraphLoader/J3DModelLoader.cpp index 72a48007c0..3d064e33de 100644 --- a/libs/JSystem/src/J3DGraphLoader/J3DModelLoader.cpp +++ b/libs/JSystem/src/J3DGraphLoader/J3DModelLoader.cpp @@ -242,7 +242,7 @@ void J3DModelLoader::setupBBoardInfo() { J3DMaterial* mesh = mpModelData->getJointNodePointer(i)->getMesh(); if (mesh != NULL) { u32 shape_index = mesh->getShape()->getIndex(); - u16* index_table = JSUConvertOffsetToPtr(mpShapeBlock, + BE(u16)* index_table = JSUConvertOffsetToPtr(mpShapeBlock, (uintptr_t)mpShapeBlock->mpIndexTable); J3DShapeInitData* shape_init_data = JSUConvertOffsetToPtr(mpShapeBlock, diff --git a/src/d/actor/d_a_alink_swindow.inc b/src/d/actor/d_a_alink_swindow.inc index cf3593dfce..81c7a1ca18 100644 --- a/src/d/actor/d_a_alink_swindow.inc +++ b/src/d/actor/d_a_alink_swindow.inc @@ -40,6 +40,9 @@ void daAlink_c::setOriginalHeap(JKRExpHeap** i_ppheap, u32 i_size) { u32 var_r29 = 0x90; u32 var_r28 = 0x10; u32 size = ROUND(i_size, 16); +#if TARGET_PC + size *= 2; +#endif JKRHeap* parent = mDoExt_getGameHeap(); JKRExpHeap* heap = JKRExpHeap::create(size + (var_r29 + var_r28), parent, true); diff --git a/src/d/actor/d_a_player.cpp b/src/d/actor/d_a_player.cpp index f38fe15a3b..43646380b3 100644 --- a/src/d/actor/d_a_player.cpp +++ b/src/d/actor/d_a_player.cpp @@ -237,11 +237,7 @@ void* daPy_anmHeap_c::mallocBuffer() { return mBuffer; } -#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) { @@ -255,6 +251,9 @@ void daPy_anmHeap_c::createHeap(daPy_anmHeap_c::daAlinkHEAP_TYPE i_heapType, con } else { size = 0xA0; } +#if TARGET_PC + size *= 2; +#endif char* tmpWork; mDoExt_transAnmBas* tmpTransBas; diff --git a/src/d/d_k_wmark.cpp b/src/d/d_k_wmark.cpp index 379b55f532..3894e965c3 100644 --- a/src/d/d_k_wmark.cpp +++ b/src/d/d_k_wmark.cpp @@ -33,7 +33,11 @@ int dkWmark_c::create() { mColorType = this->parameters; } +#if TARGET_PC + mpHeap = mDoExt_createSolidHeapFromGameToCurrent(0x1100, 0x20); +#else mpHeap = mDoExt_createSolidHeapFromGameToCurrent(0x880, 0x20); +#endif if (mpHeap != NULL) { JKRHEAP_NAME(mpHeap, "dkWmark_c::mpHeap"); J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("Alink", 0x23); diff --git a/src/d/d_kankyo.cpp b/src/d/d_kankyo.cpp index 50f9d716fc..9326555777 100644 --- a/src/d/d_kankyo.cpp +++ b/src/d/d_kankyo.cpp @@ -1175,7 +1175,11 @@ static void undwater_init() { J3DModelData* modelData2 = (J3DModelData*)dComIfG_getObjectRes("Always", 0x1D); JUT_ASSERT(1867, modelData2 != NULL); +#if TARGET_PC + g_env_light.undwater_ef_heap = mDoExt_createSolidHeapFromGameToCurrent(0xC00, 0x20); +#else g_env_light.undwater_ef_heap = mDoExt_createSolidHeapFromGameToCurrent(0x600, 0x20); +#endif JKRHEAP_NAME(g_env_light.undwater_ef_heap, "g_env_light.undwater_ef_heap"); if (g_env_light.undwater_ef_heap != NULL) { diff --git a/src/f_op/f_op_actor_mng.cpp b/src/f_op/f_op_actor_mng.cpp index 36217076bf..dca07f98ba 100644 --- a/src/f_op/f_op_actor_mng.cpp +++ b/src/f_op/f_op_actor_mng.cpp @@ -730,6 +730,9 @@ u8 var_r30 = fopAcM::HeapAdjustEntry; #endif u32 size = i_size & 0xFFFFFF; +#if TARGET_PC + size *= 2; +#endif bool result = fopAcM_entrySolidHeap_(i_actor, i_heapCallback, size); #if DEBUG fopAcM::HeapDummyCheck = var_r29; From 83a9df4016f18204e419a22737fb904d7a911bac Mon Sep 17 00:00:00 2001 From: Lurs <2795933+Lurs@users.noreply.github.com> Date: Mon, 6 Apr 2026 21:13:23 +0200 Subject: [PATCH 2/4] Fix "[NEW] JKRHeap (d_a_bg Anms) FULL! Fallback to malloc for size XXX" errors/warnings --- src/d/d_stage.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/d/d_stage.cpp b/src/d/d_stage.cpp index 057bcdf4ff..f3cdfed17b 100644 --- a/src/d/d_stage.cpp +++ b/src/d/d_stage.cpp @@ -393,13 +393,7 @@ static void dummy1(dStage_roomControl_c* roomControl) { JKRExpHeap* dStage_roomControl_c::createMemoryBlock(int i_blockIdx, u32 i_heapSize) { #if TARGET_PC - // Cave of Ordeals crashes around floor 29 due to no free heap space - // Increasing the size here avoids that, though its ugly. maybe TODO a better fix - if (strcmp(dComIfGp_getStartStageName(), "D_SB01") == 0) { - u32 prev = i_heapSize; - i_heapSize *= 2; - DuskLog.warn("Doubling heap size for D_SB01... ({}) -> ({})", prev, i_heapSize); - } + i_heapSize *= 2; #endif if (mMemoryBlock[i_blockIdx] == NULL) { From 168d8192546d6755978695a29c3c598b3b4f93b0 Mon Sep 17 00:00:00 2001 From: Lurs <2795933+Lurs@users.noreply.github.com> Date: Mon, 6 Apr 2026 22:09:50 +0200 Subject: [PATCH 3/4] Fix "[ERROR] memory free error!!" message while leaving options menu --- src/d/d_menu_window.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/d/d_menu_window.cpp b/src/d/d_menu_window.cpp index 3e173049bd..e9131462c3 100644 --- a/src/d/d_menu_window.cpp +++ b/src/d/d_menu_window.cpp @@ -1507,7 +1507,11 @@ void dMw_c::checkMemSize() { OS_REPORT("memory check ===> diff ==> %d, start ==> %d, now ==> %d\n", diff, mMemSize, now_size); +#if TARGET_PC + if (diff > 0x40) { +#else if (diff > 0x20) { +#endif OSReport_Error("memory free error!!\n"); } mMemSize = 0; From 3d66c127abf477cfd6b742755420e15d305ed693 Mon Sep 17 00:00:00 2001 From: Lurs <2795933+Lurs@users.noreply.github.com> Date: Mon, 6 Apr 2026 23:08:34 +0200 Subject: [PATCH 4/4] Use HEAP_SIZE() --- src/d/d_k_wmark.cpp | 7 ++----- src/d/d_kankyo.cpp | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/d/d_k_wmark.cpp b/src/d/d_k_wmark.cpp index 3894e965c3..b93ab14211 100644 --- a/src/d/d_k_wmark.cpp +++ b/src/d/d_k_wmark.cpp @@ -6,6 +6,7 @@ #include "d/dolzel.h" // IWYU pragma: keep #include "d/d_k_wmark.h" +#include "dusk/memory.h" #include "JSystem/J3DGraphBase/J3DMaterial.h" #include "SSystem/SComponent/c_math.h" #include "d/actor/d_a_player.h" @@ -33,11 +34,7 @@ int dkWmark_c::create() { mColorType = this->parameters; } -#if TARGET_PC - mpHeap = mDoExt_createSolidHeapFromGameToCurrent(0x1100, 0x20); -#else - mpHeap = mDoExt_createSolidHeapFromGameToCurrent(0x880, 0x20); -#endif + mpHeap = mDoExt_createSolidHeapFromGameToCurrent(HEAP_SIZE(0x880, 0x1100), 0x20); if (mpHeap != NULL) { JKRHEAP_NAME(mpHeap, "dkWmark_c::mpHeap"); J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("Alink", 0x23); diff --git a/src/d/d_kankyo.cpp b/src/d/d_kankyo.cpp index 9326555777..1652f3c2a0 100644 --- a/src/d/d_kankyo.cpp +++ b/src/d/d_kankyo.cpp @@ -1,6 +1,7 @@ #include "d/dolzel.h" // IWYU pragma: keep #include "d/d_kankyo.h" +#include "dusk/memory.h" #ifdef __REVOLUTION_SDK__ #include #else @@ -1175,11 +1176,7 @@ static void undwater_init() { J3DModelData* modelData2 = (J3DModelData*)dComIfG_getObjectRes("Always", 0x1D); JUT_ASSERT(1867, modelData2 != NULL); -#if TARGET_PC - g_env_light.undwater_ef_heap = mDoExt_createSolidHeapFromGameToCurrent(0xC00, 0x20); -#else - g_env_light.undwater_ef_heap = mDoExt_createSolidHeapFromGameToCurrent(0x600, 0x20); -#endif + g_env_light.undwater_ef_heap = mDoExt_createSolidHeapFromGameToCurrent(HEAP_SIZE(0x600, 0xC00), 0x20); JKRHEAP_NAME(g_env_light.undwater_ef_heap, "g_env_light.undwater_ef_heap"); if (g_env_light.undwater_ef_heap != NULL) {