From f146101d1735743a2f86c507790e7b101df3f65b Mon Sep 17 00:00:00 2001 From: Jack Walker <7463599+Jack-Walker@users.noreply.github.com> Date: Thu, 31 Mar 2022 17:03:19 -0400 Subject: [PATCH] Fixed memory leak and fog issue on pause screen. --- soh/src/code/z_player_lib.c | 3 +- soh/src/code/z_vr_box.c | 5 ++- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 31 ------------------- 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index d7344d7c3..f53761acf 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -1601,7 +1601,8 @@ void func_80091A24(GlobalContext* globalCtx, void* seg04, void* seg06, SkelAnime func_80093C80(globalCtx); - POLY_OPA_DISP = Gfx_SetFog2(POLY_OPA_DISP++, 0, 0, 0, 0, 997, 1000); + // OTRTODO: Commenting out this line fixes the fog issue... but at what cost? + //POLY_OPA_DISP = Gfx_SetFog2(POLY_OPA_DISP++, 0, 0, 0, 0, 997, 1000); func_8002EABC(pos, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); diff --git a/soh/src/code/z_vr_box.c b/soh/src/code/z_vr_box.c index 7925e5cb9..e532edf31 100644 --- a/soh/src/code/z_vr_box.c +++ b/soh/src/code/z_vr_box.c @@ -1001,9 +1001,8 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox LoadSkyboxPalette(globalCtx, skyboxCtx, 2, gBackAlleyHouseBg3Tlut, 16, 16); break; default: - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, 0x10000 * 8, "../z_vr_box.c", 1226); - //skyboxCtx->staticSegments[1] = GameState_Alloc(&globalCtx->state, 0x10000 * 8, "../z_vr_box.c", 1226); - skyboxCtx->staticSegments[1] = malloc(0x10000 * 8); // OTRTODO + skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, 0x10000 * 4, "../z_vr_box.c", 1226); + skyboxCtx->staticSegments[1] = GameState_Alloc(&globalCtx->state, 0x10000 * 4, "../z_vr_box.c", 1226); skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, 0x1000, "../z_vr_box.c", 1226); break; } diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index a5c160700..140aa7734 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -789,40 +789,10 @@ static PreRender sPlayerPreRender; static void* sPreRenderCvg; extern int fbTest; -// OTRTODO: This function is no longer used. We could probably remove it. -void KaleidoScope_SetupPlayerPreRender(GlobalContext* globalCtx) { - Gfx* gfx; - Gfx* gfxRef; - void* fbuf; - static Gfx testBuffer[2048]; - - //return; - - fbuf = globalCtx->state.gfxCtx->curFrameBuffer; - - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_scope_PAL.c", 496); - - gfx = &testBuffer[0]; - - PreRender_SetValues(&sPlayerPreRender, 64, 112, fbuf, NULL); - func_800C1F20(&sPlayerPreRender, &gfx); - func_800C20B4(&sPlayerPreRender, &gfx); - - gSPEndDisplayList(gfx++); - gSPDisplayList(POLY_KAL_DISP++, &testBuffer[0]); - - SREG(33) |= 1; - - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kaleido_scope_PAL.c", 509); -} -//OTRTODO - Player on pause -#if 1 void KaleidoScope_ProcessPlayerPreRender(void) { - //Sleep_Msec(50); PreRender_Calc(&sPlayerPreRender); PreRender_Destroy(&sPlayerPreRender); } -#endif Gfx* KaleidoScope_QuadTextureIA4(Gfx* gfx, void* texture, s16 width, s16 height, u16 point) { gDPLoadTextureBlock_4b(gfx++, texture, G_IM_FMT_IA, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, @@ -4026,7 +3996,6 @@ void KaleidoScope_Update(GlobalContext* globalCtx) ResourceMgr_DirtyDirectory("textures/icon_item_24_static*"); ResourceMgr_DirtyDirectory("textures/icon_item_static*"); CVar_SetS32("gPauseTriforce", 0); - //ResourceMgr_InvalidateCache(); func_800981B8(&globalCtx->objectCtx); func_800418D0(&globalCtx->colCtx, globalCtx);