From b76af827e714ab0bc31dd56953d8beb8c9ecd9a5 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 12 Jul 2020 23:12:19 +1000 Subject: [PATCH] Decompile func0f110c5c --- src/game/data/data_0083d0.c | 2 +- src/game/gamefile.c | 60 ++++++++--------------------- src/include/game/data/data_0083d0.h | 2 +- src/include/game/game_157db0.h | 2 +- src/include/game/gamefile.h | 2 +- src/include/lib/lib_126b0.h | 2 +- src/include/lib/lib_13900.h | 2 +- src/include/types.h | 19 ++++++++- 8 files changed, 40 insertions(+), 51 deletions(-) diff --git a/src/game/data/data_0083d0.c b/src/game/data/data_0083d0.c index acbd97a9a..6ce953892 100644 --- a/src/game/data/data_0083d0.c +++ b/src/game/data/data_0083d0.c @@ -10,7 +10,7 @@ #include "types.h" u8 var80062940 = 0; -u32 var80062944 = 0x00000000; +u8 var80062944 = 0; u32 var80062948 = 0x00000000; u32 var8006294c = 0x00000000; u32 var80062950 = 0x00000064; diff --git a/src/game/gamefile.c b/src/game/gamefile.c index 317f50ed5..1f11c8d1f 100644 --- a/src/game/gamefile.c +++ b/src/game/gamefile.c @@ -1467,50 +1467,22 @@ glabel func0f110bf8 /* f110c58: 27bd0020 */ addiu $sp,$sp,0x20 ); -GLOBAL_ASM( -glabel func0f110c5c -/* 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) -/* f110c70: 27bdffe0 */ addiu $sp,$sp,-32 -/* f110c74: afbf0014 */ sw $ra,0x14($sp) -/* f110c78: 1460000e */ bnez $v1,.L0f110cb4 -/* f110c7c: afa50024 */ sw $a1,0x24($sp) -/* f110c80: 24040310 */ addiu $a0,$zero,0x310 -/* f110c84: 0fc5db69 */ jal align16 -/* f110c88: afa60018 */ sw $a2,0x18($sp) -/* f110c8c: 00402025 */ or $a0,$v0,$zero -/* f110c90: 0fc5796e */ jal func0f15e5b8 -/* f110c94: 24050001 */ addiu $a1,$zero,0x1 -/* f110c98: 0fc5db69 */ jal align16 -/* f110c9c: 24040310 */ addiu $a0,$zero,0x310 -/* f110ca0: 0c004aac */ jal func00012ab0 -/* f110ca4: 00402025 */ or $a0,$v0,$zero -/* f110ca8: 8fa60018 */ lw $a2,0x18($sp) -/* f110cac: 00401825 */ or $v1,$v0,$zero -/* f110cb0: acc20000 */ sw $v0,0x0($a2) -.L0f110cb4: -/* f110cb4: 24180001 */ addiu $t8,$zero,0x1 -/* f110cb8: a078030c */ sb $t8,0x30c($v1) -/* f110cbc: 8cc80000 */ lw $t0,0x0($a2) -/* f110cc0: 93b90027 */ lbu $t9,0x27($sp) -/* f110cc4: 3c098006 */ lui $t1,%hi(var80062944) -/* f110cc8: a119030b */ sb $t9,0x30b($t0) -/* f110ccc: 91292944 */ lbu $t1,%lo(var80062944)($t1) -/* f110cd0: 55200004 */ bnezl $t1,.L0f110ce4 -/* f110cd4: 8fbf0014 */ lw $ra,0x14($sp) -/* f110cd8: 0c004e63 */ jal func0001398c -/* f110cdc: 24040003 */ addiu $a0,$zero,0x3 -/* f110ce0: 8fbf0014 */ lw $ra,0x14($sp) -.L0f110ce4: -/* f110ce4: 240a0001 */ addiu $t2,$zero,0x1 -/* f110ce8: 3c018006 */ lui $at,%hi(var80062944) -/* f110cec: a02a2944 */ sb $t2,%lo(var80062944)($at) -/* f110cf0: 03e00008 */ jr $ra -/* f110cf4: 27bd0020 */ addiu $sp,$sp,0x20 -); +void func0f110c5c(s32 locationindex, u8 filetype) +{ + if (g_SaveLocations[locationindex] == NULL) { + func0f15e5b8(align16(0x310), 1); + g_SaveLocations[locationindex] = func00012ab0(align16(0x310)); + } + + g_SaveLocations[locationindex]->unk30c = 1; + g_SaveLocations[locationindex]->filetype = filetype; + + if (var80062944 == 0) { + func0001398c(3); + } + + var80062944 = 1; +} GLOBAL_ASM( glabel func0f110cf8 diff --git a/src/include/game/data/data_0083d0.h b/src/include/game/data/data_0083d0.h index 484f32288..8d61c908b 100644 --- a/src/include/game/data/data_0083d0.h +++ b/src/include/game/data/data_0083d0.h @@ -83,7 +83,7 @@ extern u32 var800628d4; extern u32 var80062914; extern s32 g_NumPlayers; extern u8 var80062940; -extern u32 var80062944; +extern u8 var80062944; extern u32 var80062948; extern u32 var80062950; extern bool g_WeatherTickEnabled; diff --git a/src/include/game/game_157db0.h b/src/include/game/game_157db0.h index 336e96d76..fd6cdc6fa 100644 --- a/src/include/game/game_157db0.h +++ b/src/include/game/game_157db0.h @@ -56,7 +56,7 @@ u32 func0f15dbb4(void); u32 func0f15dc58(void); void func0f15e474(s32 room); void func0f15e538(void); -u32 func0f15e5b8(void); +void func0f15e5b8(u32 size, u32 arg1); u32 func0f15e728(void); u32 func0f15e85c(void); u32 func0f15eb28(void); diff --git a/src/include/game/gamefile.h b/src/include/game/gamefile.h index bdec4ead9..9fbed9775 100644 --- a/src/include/game/gamefile.h +++ b/src/include/game/gamefile.h @@ -19,7 +19,7 @@ void func0f1109c0(void); void func0f110b68(void); void func0f110bf0(void); u32 func0f110bf8(void); -void func0f110c5c(s32 arg0, s32 arg1); +void func0f110c5c(s32 locationindex, u8 filetype); u32 func0f110cf8(void); u32 func0f110d90(void); u32 func0f110da8(void); diff --git a/src/include/lib/lib_126b0.h b/src/include/lib/lib_126b0.h index 0dba81b0a..6cdb0edc9 100644 --- a/src/include/lib/lib_126b0.h +++ b/src/include/lib/lib_126b0.h @@ -12,7 +12,7 @@ u32 func00012914(void); void func00012a0c(void); u32 func00012a14(void); u32 func00012a8c(void); -u32 func00012ab0(void); +void *func00012ab0(u32 size); // some kind of malloc for save files? u32 func00012c3c(void); u32 func00012cb4(void); u32 func00012cdc(void); diff --git a/src/include/lib/lib_13900.h b/src/include/lib/lib_13900.h index 71c274bab..e33e59874 100644 --- a/src/include/lib/lib_13900.h +++ b/src/include/lib/lib_13900.h @@ -7,7 +7,7 @@ void func00013900(void); void func00013938(void); u32 func00013974(void); u32 func00013980(void); -u32 func0001398c(void); +void func0001398c(u32 arg0); u32 func000139c8(void); u32 func000139e8(void); u32 func00013a40(void); diff --git a/src/include/types.h b/src/include/types.h index 00e85d2d0..e14207fcb 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -4344,7 +4344,7 @@ struct numandtext { }; struct savelocation { - /*0x000*/ u32 unk000; + /*0x000*/ struct savelocation00 *unk000; /*0x004*/ u32 unk004; /*0x008*/ u32 unk008; /*0x00c*/ u32 unk00c; @@ -4526,6 +4526,23 @@ struct savelocation { /*0x2cc*/ u32 unk2cc; /*0x2d0*/ u16 unk2d0; /*0x2d2*/ s8 unk2d2[4]; + /*0x2d8*/ u32 unk2d8; + /*0x2dc*/ u32 unk2dc; + /*0x2e0*/ u32 unk2e0; + /*0x2e4*/ u32 unk2e4; + /*0x2e8*/ u32 unk2e8; + /*0x2ec*/ u32 unk2ec; + /*0x2f0*/ u32 unk2f0; + /*0x2f4*/ u32 unk2f4; + /*0x2f8*/ u32 unk2f8; + /*0x2fc*/ u32 unk2fc; + /*0x300*/ u32 unk300; + /*0x304*/ u32 unk304; + /*0x308*/ u8 unk308; + /*0x309*/ u8 unk309; + /*0x30a*/ u8 unk30a; + /*0x30b*/ u8 filetype; + /*0x30c*/ u8 unk30c; // inuse? }; struct challenge {