only free bootloader buffer in alloc process

originally the free was added to fix the GFX artifacts on Nana despawn / food consume but the way it was written caused the game to crash when going directly to change the language to japanese.

I also added a place to free the new scene buffers on scene exit instead of where it was before though I don't know if that's completely necessary.
This commit is contained in:
Jas Laferriere
2025-09-24 17:14:25 -04:00
parent 95fb888b92
commit 476af86196
5 changed files with 87 additions and 23 deletions

View File

@@ -1,21 +0,0 @@
################################################################################
# Address: 0x801a4cb4
################################################################################
.include "Common/Common.s"
.include "Online/Online.s"
# Free old buffer if it exists
lwz r3,OFST_R13_SB_ADDR(r13)
cmpwi r3,0
beq Alloc
branchl r12, HSD_Free
# Alloc buffer
Alloc:
li r3,128
branchl r12,HSD_MemAlloc
stw r3,OFST_R13_SB_ADDR(r13)
# Original
li r0, 0

View File

@@ -0,0 +1,51 @@
################################################################################
# Address: 0x801a4cb4
################################################################################
.include "Common/Common.s"
.include "Online/Online.s"
# This file allocates a scene buffer. This buffer will persist throughout a scene
# and should be guaranteed to exist. It is typically used to execute EXI commands
# without allocating a new buffer. An argument could be made that we should just
# allocate new buffers when they're needed but that would be kind of slow if
# we need to do it often, say for example for logging. Though we shouldn't have
# logs that are frequently hit in prod anyways so maybe we should consider getting
# rid of this?
# The buffer is cleaned up on scene exit, look at FreeSceneBuffer.asm
b CODE_START
DATA_BLRL:
blrl
.byte 0 # one shot bool
.align 2
CODE_START:
# On Dolphin a buffer has been allocated from the heap created in Bootloader/main.asm.
# We want to free that buffer the first time we execute this logic so that the
# buffer always exists prior and after.
bl DATA_BLRL
mflr r4
lbz r3, 0x0(r4)
cmpwi r3, 0
bne SKIP_FREE
li r3, 1
stb r3, 0x0(r4) # Set one shot to true
lwz r3, OFST_R13_SB_ADDR(r13)
cmpwi r3, 0
beq SKIP_FREE
branchl r12, HSD_Free
SKIP_FREE:
li r3, 128
branchl r12, HSD_MemAlloc
# Store to r13 offset since this is what the other codes reference. But in the
# future if we want to transition off r13 offsets we could store the buffer
# in data in this file and use computeBranchTargetAddress to fetch it.
stw r3, OFST_R13_SB_ADDR(r13)
# Original
li r0, 0

View File

@@ -0,0 +1,14 @@
################################################################################
# Address: 0x801a41d8
################################################################################
.include "Common/Common.s"
.include "Online/Online.s"
# Look at AllocSceneBuffer.asm for context
lwz r3, OFST_R13_SB_ADDR(r13)
branchl r12, HSD_Free
# Original
li r3, 11

View File

@@ -1230,7 +1230,12 @@ C21D4FD8 00000012 #Recording/Stages/SendStadiumInfo.asm
818DB650 398C0009
918DB650 BB610084
60000000 00000000
C21A4CB4 00000008 #Common/AllocBuffer.asm
C21A4CB4 0000000D #Common/AllocSceneBuffer.asm
4800000C 4E800021
00000000 4BFFFFF9
7C8802A6 88640000
2C030000 40820028
38600001 98640000
806DAFC4 2C030000
41820014 3D808037
618CF1B0 7D8903A6
@@ -1239,6 +1244,11 @@ C21A4CB4 00000008 #Common/AllocBuffer.asm
7D8903A6 4E800421
906DAFC4 38000000
60000000 00000000
C21A41D8 00000004 #Common/FreeSceneBuffer.asm
806DAFC4 3D808037
618CF1B0 7D8903A6
4E800421 3860000B
60000000 00000000
C20055F8 0000000F #Common/GetIsFollower.asm
7C0802A6 90010004
9421FF20 BE8100B0

View File

@@ -1229,7 +1229,12 @@ C21D4FD8 00000012 #Recording/Stages/SendStadiumInfo.asm
818DB650 398C0009
918DB650 BB610084
60000000 00000000
C21A4CB4 00000008 #Common/AllocBuffer.asm
C21A4CB4 0000000D #Common/AllocSceneBuffer.asm
4800000C 4E800021
00000000 4BFFFFF9
7C8802A6 88640000
2C030000 40820028
38600001 98640000
806DAFC4 2C030000
41820014 3D808037
618CF1B0 7D8903A6
@@ -1238,6 +1243,11 @@ C21A4CB4 00000008 #Common/AllocBuffer.asm
7D8903A6 4E800421
906DAFC4 38000000
60000000 00000000
C21A41D8 00000004 #Common/FreeSceneBuffer.asm
806DAFC4 3D808037
618CF1B0 7D8903A6
4E800421 3860000B
60000000 00000000
C20055F8 0000000F #Common/GetIsFollower.asm
7C0802A6 90010004
9421FF20 BE8100B0