From 230473348b52d2bb4e1674bd0f511f25f2e6e98f Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 13 Apr 2020 21:56:18 +1000 Subject: [PATCH] Decompile mpGetChallengeNameBySlot --- src/game/game_179060.c | 4 +-- src/game/game_17f930.c | 2 +- src/game/game_19aa80.c | 66 +++++++++++----------------------- src/include/game/game_19aa80.h | 2 +- 4 files changed, 25 insertions(+), 49 deletions(-) diff --git a/src/game/game_179060.c b/src/game/game_179060.c index f30ad6868..852fa7874 100644 --- a/src/game/game_179060.c +++ b/src/game/game_179060.c @@ -5182,7 +5182,7 @@ glabel func0f17e318 /* f17e350: 01ee7823 */ subu $t7,$t7,$t6 /* f17e354: 000f7900 */ sll $t7,$t7,0x4 /* f17e358: 008f2021 */ addu $a0,$a0,$t7 -/* f17e35c: 0fc66dbe */ jal func0f19b6f8 +/* f17e35c: 0fc66dbe */ jal mpGetChallengeNameBySlot /* f17e360: 8c84ee1c */ lw $a0,%lo(g_MenuStack+0xe1c)($a0) /* f17e364: 3c048007 */ lui $a0,%hi(g_StringPointer) /* f17e368: 8c841440 */ lw $a0,%lo(g_StringPointer)($a0) @@ -5428,7 +5428,7 @@ glabel var7f1b8288 /* f17e658: 0fc54d8a */ jal func0f153628 /* f17e65c: afaf00a8 */ sw $t7,0xa8($sp) /* f17e660: afa200b4 */ sw $v0,0xb4($sp) -/* f17e664: 0fc66dbe */ jal func0f19b6f8 +/* f17e664: 0fc66dbe */ jal mpGetChallengeNameBySlot /* f17e668: 8ec40004 */ lw $a0,0x4($s6) /* f17e66c: 0c002f02 */ jal func0000bc08 /* f17e670: 00408825 */ or $s1,$v0,$zero diff --git a/src/game/game_17f930.c b/src/game/game_17f930.c index d1d4329ca..a10100dac 100644 --- a/src/game/game_17f930.c +++ b/src/game/game_17f930.c @@ -5556,7 +5556,7 @@ glabel func0f185568 /* f1855a4: afae00b8 */ sw $t6,0xb8($sp) /* f1855a8: 0fc66dfd */ jal mpGetCurrentChallengeIndex /* f1855ac: 00000000 */ sll $zero,$zero,0x0 -/* f1855b0: 0fc66dbe */ jal func0f19b6f8 +/* f1855b0: 0fc66dbe */ jal mpGetChallengeNameBySlot /* f1855b4: 00402025 */ or $a0,$v0,$zero /* f1855b8: 3c057f1c */ lui $a1,%hi(var7f1b88d0) /* f1855bc: 24a588d0 */ addiu $a1,$a1,%lo(var7f1b88d0) diff --git a/src/game/game_19aa80.c b/src/game/game_19aa80.c index a6ff811d6..ce972488c 100644 --- a/src/game/game_19aa80.c +++ b/src/game/game_19aa80.c @@ -24,11 +24,6 @@ #include "lib/lib_12dc0.h" #include "types.h" -const char var7f1b9170[] = ""; -const u32 var7f1b9174[] = {0x00000000}; -const u32 var7f1b9178[] = {0x00000000}; -const u32 var7f1b917c[] = {0x00000000}; - /** * @cmd 0185 */ @@ -889,46 +884,23 @@ char *mpChallengeGetName(s32 challengeindex) return langGet(g_MpChallenges[challengeindex].name); } -GLOBAL_ASM( -glabel func0f19b6f8 -/* f19b6f8: 27bdffd8 */ addiu $sp,$sp,-40 -/* f19b6fc: afb30020 */ sw $s3,0x20($sp) -/* f19b700: afb2001c */ sw $s2,0x1c($sp) -/* f19b704: afb10018 */ sw $s1,0x18($sp) -/* f19b708: afb00014 */ sw $s0,0x14($sp) -/* f19b70c: 00809825 */ or $s3,$a0,$zero -/* f19b710: afbf0024 */ sw $ra,0x24($sp) -/* f19b714: 00008825 */ or $s1,$zero,$zero -/* f19b718: 00008025 */ or $s0,$zero,$zero -/* f19b71c: 2412001e */ addiu $s2,$zero,0x1e -.L0f19b720: -/* f19b720: 0fc66be6 */ jal mpIsChallengeAvailable -/* f19b724: 02002025 */ or $a0,$s0,$zero -/* f19b728: 50400009 */ beqzl $v0,.L0f19b750 -/* f19b72c: 26100001 */ addiu $s0,$s0,0x1 -/* f19b730: 56330006 */ bnel $s1,$s3,.L0f19b74c -/* f19b734: 26310001 */ addiu $s1,$s1,0x1 -/* f19b738: 0fc66daf */ jal mpChallengeGetName -/* f19b73c: 02002025 */ or $a0,$s0,$zero -/* f19b740: 10000008 */ beqz $zero,.L0f19b764 -/* f19b744: 8fbf0024 */ lw $ra,0x24($sp) -/* f19b748: 26310001 */ addiu $s1,$s1,0x1 -.L0f19b74c: -/* f19b74c: 26100001 */ addiu $s0,$s0,0x1 -.L0f19b750: -/* f19b750: 1612fff3 */ bne $s0,$s2,.L0f19b720 -/* f19b754: 00000000 */ sll $zero,$zero,0x0 -/* f19b758: 3c027f1c */ lui $v0,%hi(var7f1b9170) -/* f19b75c: 24429170 */ addiu $v0,$v0,%lo(var7f1b9170) -/* f19b760: 8fbf0024 */ lw $ra,0x24($sp) -.L0f19b764: -/* f19b764: 8fb00014 */ lw $s0,0x14($sp) -/* f19b768: 8fb10018 */ lw $s1,0x18($sp) -/* f19b76c: 8fb2001c */ lw $s2,0x1c($sp) -/* f19b770: 8fb30020 */ lw $s3,0x20($sp) -/* f19b774: 03e00008 */ jr $ra -/* f19b778: 27bd0028 */ addiu $sp,$sp,0x28 -); +char *mpGetChallengeNameBySlot(s32 slot) +{ + s32 index = 0; + s32 i; + + for (i = 0; i < 30; i++) { + if (mpIsChallengeAvailable(i)) { + if (index == slot) { + return mpChallengeGetName(i); + } + + index++; + } + } + + return ""; +} void mpSetCurrentChallenge(s32 slotnum) { @@ -1650,6 +1622,8 @@ bool mpIsVar800884b4NonZero(void) return var800884b4 != 0; } +const char var7f1b9174[] = ""; + GLOBAL_ASM( glabel func0f19c288 /* f19c288: 3c038009 */ lui $v1,%hi(var800884b4) @@ -1665,6 +1639,8 @@ glabel func0f19c288 /* f19c2ac: 00000000 */ sll $zero,$zero,0x0 ); +const char var7f1b9178[] = ""; + GLOBAL_ASM( glabel func0f19c2b0 /* f19c2b0: 10800003 */ beqz $a0,.L0f19c2c0 diff --git a/src/include/game/game_19aa80.h b/src/include/game/game_19aa80.h index eb4f43752..cf9e55b1c 100644 --- a/src/include/game/game_19aa80.h +++ b/src/include/game/game_19aa80.h @@ -7,7 +7,7 @@ bool ai0176(void); u32 func0f19ab70(void); void func0f19afdc(void); void func0f19b540(void); -u32 func0f19b6f8(void); +char *mpGetChallengeNameBySlot(s32 slot); u32 func0f19b800(void); s32 mpLoadConfig(s16 arg0, char *buffer, s32 len); u32 func0f19bb50(void);