From f2f82e900600910ecacfbac2eae1c3fe63d6a327 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 4 Jan 2020 18:02:04 +1000 Subject: [PATCH] Attempt to decompile menuhandlerSaveLocation --- src/game/game_107fb0.c | 46 ++++++-- src/game/game_10ccd0.c | 16 +-- src/include/game/game_107fb0.h | 2 +- src/include/setup/setup_0160b0.h | 2 +- src/include/types.h | 188 ++++++++++++++++++++++++++++++- src/setup/setup_0160b0.c | 7 +- 6 files changed, 234 insertions(+), 27 deletions(-) diff --git a/src/game/game_107fb0.c b/src/game/game_107fb0.c index 6ec7d4be2..db99ecff3 100644 --- a/src/game/game_107fb0.c +++ b/src/game/game_107fb0.c @@ -1304,10 +1304,10 @@ glabel func0f108d8c /* f108e04: 0fc45a18 */ jal func0f116860 /* f108e08: 03002025 */ or $a0,$t8,$zero .L0f108e0c: -/* f108e0c: 3c028007 */ lui $v0,%hi(var80075bc0) +/* f108e0c: 3c028007 */ lui $v0,%hi(g_SaveLocations) /* f108e10: 3c058007 */ lui $a1,%hi(var80075bd0) /* f108e14: 24a55bd0 */ addiu $a1,$a1,%lo(var80075bd0) -/* f108e18: 24425bc0 */ addiu $v0,$v0,%lo(var80075bc0) +/* f108e18: 24425bc0 */ addiu $v0,$v0,%lo(g_SaveLocations) /* f108e1c: 24040001 */ addiu $a0,$zero,0x1 /* f108e20: 8c430000 */ lw $v1,0x0($v0) .L0f108e24: @@ -2475,8 +2475,8 @@ glabel func0f109ec4 /* f109eec: 000f7900 */ sll $t7,$t7,0x4 /* f109ef0: 01f81821 */ addu $v1,$t7,$t8 /* f109ef4: 90790e3f */ lbu $t9,0xe3f($v1) -/* f109ef8: 3c088007 */ lui $t0,%hi(var80075bc0) -/* f109efc: 25085bc0 */ addiu $t0,$t0,%lo(var80075bc0) +/* f109ef8: 3c088007 */ lui $t0,%hi(g_SaveLocations) +/* f109efc: 25085bc0 */ addiu $t0,$t0,%lo(g_SaveLocations) /* f109f00: 00194880 */ sll $t1,$t9,0x2 /* f109f04: 01095021 */ addu $t2,$t0,$t1 /* f109f08: 8d4b0000 */ lw $t3,0x0($t2) @@ -2511,8 +2511,8 @@ glabel func0f109ec4 /* f109f78: 000e7100 */ sll $t6,$t6,0x4 /* f109f7c: 01cf1821 */ addu $v1,$t6,$t7 /* f109f80: 90620e3e */ lbu $v0,0xe3e($v1) -/* f109f84: 3c088007 */ lui $t0,%hi(var80075bc0) -/* f109f88: 25085bc0 */ addiu $t0,$t0,%lo(var80075bc0) +/* f109f84: 3c088007 */ lui $t0,%hi(g_SaveLocations) +/* f109f88: 25085bc0 */ addiu $t0,$t0,%lo(g_SaveLocations) /* f109f8c: 14400005 */ bnez $v0,.L0f109fa4 /* f109f90: 24010005 */ addiu $at,$zero,0x5 /* f109f94: 0fc42655 */ jal func0f109954 @@ -2839,6 +2839,28 @@ glabel menuhandlerSaveLocation /* f10a450: 00000000 */ sll $zero,$zero,0x0 ); +// Mismatch because the game's code calculates g_MenuStack by loading a lower +// number into %hi then compensating with a larger number in %lo. +//s32 menuhandlerSaveLocation(u32 operation, struct menu_item *item, s32 *value) +//{ +// if (g_SaveLocations[g_MenuStack[g_MpPlayerNum].unk947] == NULL) { +// return 0; +// } +// +// if (operation == MENUOP_CHECKDISABLED) { +// if (g_SaveLocations[g_MenuStack[g_MpPlayerNum].unk947]->unk2d2[item->param] < 1) { +// return true; +// } +// } +// +// if (operation == MENUOP_SET) { +// g_MenuStack[g_MpPlayerNum].unk95a = item->param; +// func0f109ec4(); +// } +// +// return 0; +//} + s32 menuhandlerPakCancelSave(u32 operation, struct menu_item *item, s32 *value) { if (operation == MENUOP_SET) { @@ -3257,8 +3279,8 @@ glabel func0f10aad8 /* f10aae4: afb00034 */ sw $s0,0x34($sp) /* f10aae8: afa40088 */ sw $a0,0x88($sp) /* f10aaec: 90ae0001 */ lbu $t6,0x1($a1) -/* f10aaf0: 3c088007 */ lui $t0,%hi(var80075bc0) -/* f10aaf4: 25085bc0 */ addiu $t0,$t0,%lo(var80075bc0) +/* f10aaf0: 3c088007 */ lui $t0,%hi(g_SaveLocations) +/* f10aaf4: 25085bc0 */ addiu $t0,$t0,%lo(g_SaveLocations) /* f10aaf8: 24010001 */ addiu $at,$zero,0x1 /* f10aafc: 00c08025 */ or $s0,$a2,$zero /* f10ab00: 8d030000 */ lw $v1,0x0($t0) @@ -3446,8 +3468,8 @@ glabel menucustomFileToDelete /* f10ada8: 3c07800a */ lui $a3,%hi(var8009e000) /* f10adac: 01c90019 */ multu $t6,$t1 /* f10adb0: 24e7e000 */ addiu $a3,$a3,%lo(var8009e000) -/* f10adb4: 3c038007 */ lui $v1,%hi(var80075bc0) -/* f10adb8: 24635bc0 */ addiu $v1,$v1,%lo(var80075bc0) +/* f10adb4: 3c038007 */ lui $v1,%hi(g_SaveLocations) +/* f10adb8: 24635bc0 */ addiu $v1,$v1,%lo(g_SaveLocations) /* f10adbc: 27bdffe0 */ addiu $sp,$sp,-32 /* f10adc0: afa40020 */ sw $a0,0x20($sp) /* f10adc4: afbf0014 */ sw $ra,0x14($sp) @@ -3477,12 +3499,12 @@ glabel menucustomFileToDelete /* f10ae20: 00c02025 */ or $a0,$a2,$zero /* f10ae24: 0fc42a5f */ jal func0f10a97c /* f10ae28: afa6001c */ sw $a2,0x1c($sp) -/* f10ae2c: 3c038007 */ lui $v1,%hi(var80075bc0) +/* f10ae2c: 3c038007 */ lui $v1,%hi(g_SaveLocations) /* f10ae30: 3c07800a */ lui $a3,%hi(var8009e000) /* f10ae34: 3c088007 */ lui $t0,%hi(g_MpPlayerNum) /* f10ae38: 25081448 */ addiu $t0,$t0,%lo(g_MpPlayerNum) /* f10ae3c: 24e7e000 */ addiu $a3,$a3,%lo(var8009e000) -/* f10ae40: 24635bc0 */ addiu $v1,$v1,%lo(var80075bc0) +/* f10ae40: 24635bc0 */ addiu $v1,$v1,%lo(g_SaveLocations) /* f10ae44: 8fa6001c */ lw $a2,0x1c($sp) /* f10ae48: 10400011 */ beqz $v0,.L0f10ae90 /* f10ae4c: 24090e70 */ addiu $t1,$zero,0xe70 diff --git a/src/game/game_10ccd0.c b/src/game/game_10ccd0.c index 15e8ab3b5..8679a876c 100644 --- a/src/game/game_10ccd0.c +++ b/src/game/game_10ccd0.c @@ -4493,11 +4493,11 @@ glabel func0f110bf8 /* f110bf8: 27bdffe0 */ addiu $sp,$sp,-32 /* f110bfc: afb10018 */ sw $s1,0x18($sp) /* f110c00: afb00014 */ sw $s0,0x14($sp) -/* f110c04: 3c108007 */ lui $s0,%hi(var80075bc0) +/* f110c04: 3c108007 */ lui $s0,%hi(g_SaveLocations) /* f110c08: 3c118007 */ lui $s1,%hi(var80075bd0) /* f110c0c: afbf001c */ sw $ra,0x1c($sp) /* f110c10: 26315bd0 */ addiu $s1,$s1,%lo(var80075bd0) -/* f110c14: 26105bc0 */ addiu $s0,$s0,%lo(var80075bc0) +/* f110c14: 26105bc0 */ addiu $s0,$s0,%lo(g_SaveLocations) /* f110c18: 8e0e0000 */ lw $t6,0x0($s0) .L0f110c1c: /* f110c1c: 51c00008 */ beqzl $t6,.L0f110c40 @@ -4521,8 +4521,8 @@ glabel func0f110bf8 GLOBAL_ASM( glabel func0f110c5c -/* f110c5c: 3c0f8007 */ lui $t7,%hi(var80075bc0) -/* f110c60: 25ef5bc0 */ addiu $t7,$t7,%lo(var80075bc0) +/* f110c5c: 3c0f8007 */ lui $t7,%hi(g_SaveLocations) +/* f110c60: 25ef5bc0 */ addiu $t7,$t7,%lo(g_SaveLocations) /* f110c64: 00047080 */ sll $t6,$a0,0x2 /* f110c68: 01cf3021 */ addu $a2,$t6,$t7 /* f110c6c: 8cc30000 */ lw $v1,0x0($a2) @@ -4570,10 +4570,10 @@ glabel func0f110cf8 /* f110cfc: afb00018 */ sw $s0,0x18($sp) /* f110d00: 309000ff */ andi $s0,$a0,0xff /* f110d04: afa40028 */ sw $a0,0x28($sp) -/* f110d08: 3c058007 */ lui $a1,%hi(var80075bc0) +/* f110d08: 3c058007 */ lui $a1,%hi(g_SaveLocations) /* f110d0c: afbf001c */ sw $ra,0x1c($sp) /* f110d10: 2406ffff */ addiu $a2,$zero,-1 -/* f110d14: 24a55bc0 */ addiu $a1,$a1,%lo(var80075bc0) +/* f110d14: 24a55bc0 */ addiu $a1,$a1,%lo(g_SaveLocations) /* f110d18: 24040004 */ addiu $a0,$zero,0x4 /* f110d1c: 00001825 */ or $v1,$zero,$zero /* f110d20: 2407ffff */ addiu $a3,$zero,-1 @@ -4677,12 +4677,12 @@ glabel func0f110da8 /* f110e68: 2a410005 */ slti $at,$s2,0x5 /* f110e6c: 5420ffe6 */ bnezl $at,.L0f110e08 /* f110e70: 00128e00 */ sll $s1,$s2,0x18 -/* f110e74: 3c108007 */ lui $s0,%hi(var80075bc0) +/* f110e74: 3c108007 */ lui $s0,%hi(g_SaveLocations) /* f110e78: 3c148007 */ lui $s4,%hi(var80075bd0) /* f110e7c: 3c118007 */ lui $s1,%hi(var80075bd0) /* f110e80: 26315bd0 */ addiu $s1,$s1,%lo(var80075bd0) /* f110e84: 26945bd0 */ addiu $s4,$s4,%lo(var80075bd0) -/* f110e88: 26105bc0 */ addiu $s0,$s0,%lo(var80075bc0) +/* f110e88: 26105bc0 */ addiu $s0,$s0,%lo(g_SaveLocations) /* f110e8c: 24120001 */ addiu $s2,$zero,0x1 /* f110e90: 8e040000 */ lw $a0,0x0($s0) .L0f110e94: diff --git a/src/include/game/game_107fb0.h b/src/include/game/game_107fb0.h index 20332d47e..a40e818e9 100644 --- a/src/include/game/game_107fb0.h +++ b/src/include/game/game_107fb0.h @@ -82,6 +82,6 @@ s32 menuhandlerOpenCopyFile(u32 operation, struct menu_item *item, s32 *value); s32 menuhandlerOpenDeleteFile(u32 operation, struct menu_item *item, s32 *value); s32 menuhandlerRenameFile(u32 operation, struct menu_item *item, s32 *value); s32 menuhandlerSaveElsewhere(u32, u32, u32 *); -s32 menuhandlerSaveLocation(u32, u32, u32 *); +s32 menuhandlerSaveLocation(u32 operation, struct menu_item *item, s32 *value); #endif diff --git a/src/include/setup/setup_0160b0.h b/src/include/setup/setup_0160b0.h index f36f11010..03a74a774 100644 --- a/src/include/setup/setup_0160b0.h +++ b/src/include/setup/setup_0160b0.h @@ -252,7 +252,7 @@ extern struct menu_dialog menudialog_1bb74; extern struct menu_dialog menudialog_1bb8c; extern struct menu_dialog menudialog_1bba4; extern struct menu_dialog menudialog_1bbbc; -extern u32 var80075bc0; +extern struct savelocation *g_SaveLocations[]; extern u32 var80075bd0; extern u32 var80075be0; extern u32 var80075c00; diff --git a/src/include/types.h b/src/include/types.h index af6904a8e..6e72218ef 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -3591,7 +3591,8 @@ struct menustackitem { /*0x94c*/ u32 unk94c; /*0x950*/ u32 unk950; /*0x954*/ u32 unk954; - /*0x958*/ u32 unk958; + /*0x958*/ u16 unk958; + /*0x95a*/ u8 unk95a; /*0x95c*/ u32 unk95c; /*0x960*/ u32 unk960; /*0x964*/ u32 unk964; @@ -4084,4 +4085,189 @@ struct mpsim { /*0x48*/ u32 unk48; }; +struct savelocation { + /*0x000*/ u32 unk000; + /*0x004*/ u32 unk004; + /*0x008*/ u32 unk008; + /*0x00c*/ u32 unk00c; + /*0x010*/ u32 unk010; + /*0x014*/ u32 unk014; + /*0x018*/ u32 unk018; + /*0x01c*/ u32 unk01c; + /*0x020*/ u32 unk020; + /*0x024*/ u32 unk024; + /*0x028*/ u32 unk028; + /*0x02c*/ u32 unk02c; + /*0x030*/ u32 unk030; + /*0x034*/ u32 unk034; + /*0x038*/ u32 unk038; + /*0x03c*/ u32 unk03c; + /*0x040*/ u32 unk040; + /*0x044*/ u32 unk044; + /*0x048*/ u32 unk048; + /*0x04c*/ u32 unk04c; + /*0x050*/ u32 unk050; + /*0x054*/ u32 unk054; + /*0x058*/ u32 unk058; + /*0x05c*/ u32 unk05c; + /*0x060*/ u32 unk060; + /*0x064*/ u32 unk064; + /*0x068*/ u32 unk068; + /*0x06c*/ u32 unk06c; + /*0x070*/ u32 unk070; + /*0x074*/ u32 unk074; + /*0x078*/ u32 unk078; + /*0x07c*/ u32 unk07c; + /*0x080*/ u32 unk080; + /*0x084*/ u32 unk084; + /*0x088*/ u32 unk088; + /*0x08c*/ u32 unk08c; + /*0x090*/ u32 unk090; + /*0x094*/ u32 unk094; + /*0x098*/ u32 unk098; + /*0x09c*/ u32 unk09c; + /*0x0a0*/ u32 unk0a0; + /*0x0a4*/ u32 unk0a4; + /*0x0a8*/ u32 unk0a8; + /*0x0ac*/ u32 unk0ac; + /*0x0b0*/ u32 unk0b0; + /*0x0b4*/ u32 unk0b4; + /*0x0b8*/ u32 unk0b8; + /*0x0bc*/ u32 unk0bc; + /*0x0c0*/ u32 unk0c0; + /*0x0c4*/ u32 unk0c4; + /*0x0c8*/ u32 unk0c8; + /*0x0cc*/ u32 unk0cc; + /*0x0d0*/ u32 unk0d0; + /*0x0d4*/ u32 unk0d4; + /*0x0d8*/ u32 unk0d8; + /*0x0dc*/ u32 unk0dc; + /*0x0e0*/ u32 unk0e0; + /*0x0e4*/ u32 unk0e4; + /*0x0e8*/ u32 unk0e8; + /*0x0ec*/ u32 unk0ec; + /*0x0f0*/ u32 unk0f0; + /*0x0f4*/ u32 unk0f4; + /*0x0f8*/ u32 unk0f8; + /*0x0fc*/ u32 unk0fc; + /*0x100*/ u32 unk100; + /*0x104*/ u32 unk104; + /*0x108*/ u32 unk108; + /*0x10c*/ u32 unk10c; + /*0x110*/ u32 unk110; + /*0x114*/ u32 unk114; + /*0x118*/ u32 unk118; + /*0x11c*/ u32 unk11c; + /*0x120*/ u32 unk120; + /*0x124*/ u32 unk124; + /*0x128*/ u32 unk128; + /*0x12c*/ u32 unk12c; + /*0x130*/ u32 unk130; + /*0x134*/ u32 unk134; + /*0x138*/ u32 unk138; + /*0x13c*/ u32 unk13c; + /*0x140*/ u32 unk140; + /*0x144*/ u32 unk144; + /*0x148*/ u32 unk148; + /*0x14c*/ u32 unk14c; + /*0x150*/ u32 unk150; + /*0x154*/ u32 unk154; + /*0x158*/ u32 unk158; + /*0x15c*/ u32 unk15c; + /*0x160*/ u32 unk160; + /*0x164*/ u32 unk164; + /*0x168*/ u32 unk168; + /*0x16c*/ u32 unk16c; + /*0x170*/ u32 unk170; + /*0x174*/ u32 unk174; + /*0x178*/ u32 unk178; + /*0x17c*/ u32 unk17c; + /*0x180*/ u32 unk180; + /*0x184*/ u32 unk184; + /*0x188*/ u32 unk188; + /*0x18c*/ u32 unk18c; + /*0x190*/ u32 unk190; + /*0x194*/ u32 unk194; + /*0x198*/ u32 unk198; + /*0x19c*/ u32 unk19c; + /*0x1a0*/ u32 unk1a0; + /*0x1a4*/ u32 unk1a4; + /*0x1a8*/ u32 unk1a8; + /*0x1ac*/ u32 unk1ac; + /*0x1b0*/ u32 unk1b0; + /*0x1b4*/ u32 unk1b4; + /*0x1b8*/ u32 unk1b8; + /*0x1bc*/ u32 unk1bc; + /*0x1c0*/ u32 unk1c0; + /*0x1c4*/ u32 unk1c4; + /*0x1c8*/ u32 unk1c8; + /*0x1cc*/ u32 unk1cc; + /*0x1d0*/ u32 unk1d0; + /*0x1d4*/ u32 unk1d4; + /*0x1d8*/ u32 unk1d8; + /*0x1dc*/ u32 unk1dc; + /*0x1e0*/ u32 unk1e0; + /*0x1e4*/ u32 unk1e4; + /*0x1e8*/ u32 unk1e8; + /*0x1ec*/ u32 unk1ec; + /*0x1f0*/ u32 unk1f0; + /*0x1f4*/ u32 unk1f4; + /*0x1f8*/ u32 unk1f8; + /*0x1fc*/ u32 unk1fc; + /*0x200*/ u32 unk200; + /*0x204*/ u32 unk204; + /*0x208*/ u32 unk208; + /*0x20c*/ u32 unk20c; + /*0x210*/ u32 unk210; + /*0x214*/ u32 unk214; + /*0x218*/ u32 unk218; + /*0x21c*/ u32 unk21c; + /*0x220*/ u32 unk220; + /*0x224*/ u32 unk224; + /*0x228*/ u32 unk228; + /*0x22c*/ u32 unk22c; + /*0x230*/ u32 unk230; + /*0x234*/ u32 unk234; + /*0x238*/ u32 unk238; + /*0x23c*/ u32 unk23c; + /*0x240*/ u32 unk240; + /*0x244*/ u32 unk244; + /*0x248*/ u32 unk248; + /*0x24c*/ u32 unk24c; + /*0x250*/ u32 unk250; + /*0x254*/ u32 unk254; + /*0x258*/ u32 unk258; + /*0x25c*/ u32 unk25c; + /*0x260*/ u32 unk260; + /*0x264*/ u32 unk264; + /*0x268*/ u32 unk268; + /*0x26c*/ u32 unk26c; + /*0x270*/ u32 unk270; + /*0x274*/ u32 unk274; + /*0x278*/ u32 unk278; + /*0x27c*/ u32 unk27c; + /*0x280*/ u32 unk280; + /*0x284*/ u32 unk284; + /*0x288*/ u32 unk288; + /*0x28c*/ u32 unk28c; + /*0x290*/ u32 unk290; + /*0x294*/ u32 unk294; + /*0x298*/ u32 unk298; + /*0x29c*/ u32 unk29c; + /*0x2a0*/ u32 unk2a0; + /*0x2a4*/ u32 unk2a4; + /*0x2a8*/ u32 unk2a8; + /*0x2ac*/ u32 unk2ac; + /*0x2b0*/ u32 unk2b0; + /*0x2b4*/ u32 unk2b4; + /*0x2b8*/ u32 unk2b8; + /*0x2bc*/ u32 unk2bc; + /*0x2c0*/ u32 unk2c0; + /*0x2c4*/ u32 unk2c4; + /*0x2c8*/ u32 unk2c8; + /*0x2cc*/ u32 unk2cc; + /*0x2d0*/ u16 unk2d0; + /*0x2d2*/ s8 unk2d2[4]; +}; + #endif diff --git a/src/setup/setup_0160b0.c b/src/setup/setup_0160b0.c index be8308fe8..6b784d2f9 100644 --- a/src/setup/setup_0160b0.c +++ b/src/setup/setup_0160b0.c @@ -4129,10 +4129,9 @@ struct menu_dialog menudialog_1bbbc = { u32 var80075bb4 = 0x00000000; u32 var80075bb8 = 0x00000000; u32 var80075bbc = 0x00000000; -u32 var80075bc0 = 0x00000000; -u32 var80075bc4 = 0x00000000; -u32 var80075bc8 = 0x00000000; -u32 var80075bcc = 0x00000000; + +struct savelocation *g_SaveLocations[] = {NULL, NULL, NULL, NULL}; + u32 var80075bd0 = 0x00000001; u32 var80075bd4 = 0x00000001; u32 var80075bd8 = 0x00000001;