• Welcome to Smashboards, the world's largest Super Smash Brothers community! Over 250,000 Smash Bros. fans from around the world have come to discuss these great games in over 19 million posts!

    You are currently viewing our boards as a visitor. Click here to sign up right now and start on your path in the Smash community!

Completed Triggering a Save to Memory Card

DRGN

Technowizard
Moderator
Joined
Aug 20, 2005
Messages
2,178
Location
Sacramento, CA
Looking into the "MemoryCard_CheckToSaveData" function and a few others, I found a few important flags related to the memory card and saving, and a simple way to force the game to save.

80433320 - indicates presence of memory card save data:
0 = card/save data was found and loaded (saving possible),​
2 = no card/data,​
4 = user does not wish to save (and has been prompted)​
80433324 - normally = 0; trigger game save if = 1
80433328 - indicates whether saving is currently in-progress; 0 = not currently saving; 1 = save routine is ongoing

During normal runtime, i.e. if a memory card is inserted in slot A with a SSBM save file on it, each of the above will be zeroes. And at any time, simply setting 80433324 to 1 will trigger an asyncronous game save. That address will immediately revert back to 0 when the save call is made. And at that point, 80433328 will be set to 1, and will revert back to 0 once the whole process is complete. This doesn't work for any scene however; it works in the Main Menus, on the CSSs (including 1-P mode CSSs), but not on the title screen, SSS, or within a match, for example.

I was looking into this for 20XX, because it's annoying to have to exit the CSS to the main menus (after changing something in the Debug Menu) just to get the game to save. So here's an example using the above to trigger a save when transitioning from the Debug Menu to the CSS:

Save When Transitioning from Debug Menu to CSS (v1.1)
[DRGN]
Revision ---- DOL Offset ---- Hex to Replace ---------- ASM Code -
NTSC 1.02 --- 0x801a4fa4 ---- 80790000 -> Branch

# Injects into "updateFunction"

# Load address of the scene controller
lis r3, 0x80479D30@h
ori r3, r3, 0x80479D30@l

# Check if on frame 2
lwz r4, 0x30(r3) # Load scene-processed frame count
cmpwi r4, 2
bne+ OrigLine

# Check if transitioned from the Debug Menu
lbz r4, 2(r3) # Load previous major scene ID
cmpwi r4, 6 # Checking that the previous scene was Debug Menu
bne+ OrigLine
lhz r4, 0(r3) # Load current and pending major scene IDs
cmpwi r4, 0x0202 # Checking current & pending IDs together
bne+ OrigLine

# Ensure currently on the CSS (checking minor ID)
lbz r4, 3(r3) # Load current minor scene ID
cmpwi r4, 0 # Check if minor scene is CSS
bne+ OrigLine

# Check previous minor scene; must be 0 (2=return from game; 4=return from results screen)
lbz r4, 4(r3) # Load current minor scene ID
cmpwi r4, 0
bne+ OrigLine

# Trigger a game save (flag picked up by MemoryCard_CheckToSaveData)
lis r3, 0x8043
ori r3, r3, 0x3324
li r4, 1
stw r4, 0(r3)

OrigLine:
lwz r3, 0 (r25)
END:
b 0
Save When Transitioning from Debug Menu to CSS (v1.1)
[DRGN]
Revision ---- DOL Offset ---- Hex to Replace ---------- ASM Code -
NTSC 1.02 --- 0x801a4fa4 ---- 80790000 -> Branch

3C608047 60639D30
80830030 2C040002
40A20044 88830002
2C040006 40A20038
A0830000 2C040202
40A2002C 88830003
2C040000 40A20020
88830004 2C040000
40A20014 3C608043
60633324 38800001
90830000 80790000
48000000

You can add this to your copy of 20XX (or other codes) by going to the 20XX GitHub library and assembling a new DOL with all of the mods there using MCM. But it's probably not worth it at this point, as I'll hopefully be releasing a patch for 20XX in a few days, which will have this and a few other things included. Assuming I don't find any major issues with this method. :p
 
Last edited:

DRGN

Technowizard
Moderator
Joined
Aug 20, 2005
Messages
2,178
Location
Sacramento, CA
I updated the code. The first version could crash on the SSS because I left out some checks for minor scene transitions. CSS, SSS, in-game, and more are all part of the same major scene, and the ID of the previous major scene doesn't reset when changing minor scenes. Also, the 'scene frame count' that the code checks for resets for minor scene changes, not major ones. So on the SSS, all of this led the code to thinking it's transitioning from the Debug Menu (again), and triggers a save, which doesn't work on the SSS. Makes sense. The one thing that doesn't make sense is how I didn't see this bug before I first released this! 😭 Maybe when I was doing in-game tests I didn't have the code installed a the time.
 
Top Bottom