From be8b5e5335c4d39b76e86ab9163cf4e438bf2d3a Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 2 Jan 2020 21:03:31 +1000 Subject: [PATCH] Decompile menuhandlerMpSimulantSlot --- src/game/game_00c490.c | 2 +- src/game/game_176d70.c | 110 ++++++++------------------------- src/game/game_187770.c | 2 +- src/include/game/game_176d70.h | 2 +- src/include/game/game_187770.h | 4 +- src/include/types.h | 1 + 6 files changed, 33 insertions(+), 88 deletions(-) diff --git a/src/game/game_00c490.c b/src/game/game_00c490.c index f217138d9..e82adac74 100644 --- a/src/game/game_00c490.c +++ b/src/game/game_00c490.c @@ -4600,7 +4600,7 @@ glabel func0f00f174 /* f0103b0: 1180000e */ beqz $t4,.L0f0103ec /* f0103b4: afae005c */ sw $t6,0x5c($sp) /* f0103b8: 02002025 */ or $a0,$s0,$zero -/* f0103bc: 0fc6333e */ jal func0f18ccf8 +/* f0103bc: 0fc6333e */ jal mpIsSimSlotEnabled /* f0103c0: afa60120 */ sw $a2,0x120($sp) /* f0103c4: 10400009 */ beqz $v0,.L0f0103ec /* f0103c8: 8fa60120 */ lw $a2,0x120($sp) diff --git a/src/game/game_176d70.c b/src/game/game_176d70.c index 38ca4268d..ad53f9f7c 100644 --- a/src/game/game_176d70.c +++ b/src/game/game_176d70.c @@ -7522,89 +7522,33 @@ s32 menuhandlerMpAddSimulant(u32 operation, struct menu_item *item, s32 *value) return 0; } -GLOBAL_ASM( -glabel menuhandlerMpSimulantSlot -/* f17d250: 27bdffe8 */ addiu $sp,$sp,-24 -/* f17d254: 24010006 */ addiu $at,$zero,0x6 -/* f17d258: afbf0014 */ sw $ra,0x14($sp) -/* f17d25c: 10810008 */ beq $a0,$at,.L0f17d280 -/* f17d260: afa60020 */ sw $a2,0x20($sp) -/* f17d264: 2401000c */ addiu $at,$zero,0xc -/* f17d268: 10810038 */ beq $a0,$at,.L0f17d34c -/* f17d26c: 24010018 */ addiu $at,$zero,0x18 -/* f17d270: 5081002d */ beql $a0,$at,.L0f17d328 -/* f17d274: 90af0001 */ lbu $t7,0x1($a1) -/* f17d278: 1000003b */ beqz $zero,.L0f17d368 -/* f17d27c: 00001025 */ or $v0,$zero,$zero -.L0f17d280: -/* f17d280: 3c0f8007 */ lui $t7,0x8007 -/* f17d284: 8def1448 */ lw $t7,0x1448($t7) -/* f17d288: 90ae0001 */ lbu $t6,0x1($a1) -/* f17d28c: 3c01800a */ lui $at,0x800a -/* f17d290: 000fc0c0 */ sll $t8,$t7,0x3 -/* f17d294: 030fc023 */ subu $t8,$t8,$t7 -/* f17d298: 0018c080 */ sll $t8,$t8,0x2 -/* f17d29c: 030fc021 */ addu $t8,$t8,$t7 -/* f17d2a0: 0018c0c0 */ sll $t8,$t8,0x3 -/* f17d2a4: 030fc023 */ subu $t8,$t8,$t7 -/* f17d2a8: 0018c100 */ sll $t8,$t8,0x4 -/* f17d2ac: 00380821 */ addu $at,$at,$t8 -/* f17d2b0: ac2eee1c */ sw $t6,-0x11e4($at) -/* f17d2b4: 90a80001 */ lbu $t0,0x1($a1) -/* f17d2b8: 3c19800b */ lui $t9,0x800b -/* f17d2bc: 9739cb9e */ lhu $t9,-0x3462($t9) -/* f17d2c0: 240a0001 */ addiu $t2,$zero,0x1 -/* f17d2c4: 25090004 */ addiu $t1,$t0,0x4 -/* f17d2c8: 012a5804 */ sllv $t3,$t2,$t1 -/* f17d2cc: 032b6024 */ and $t4,$t9,$t3 -/* f17d2d0: 15800006 */ bnez $t4,.L0f17d2ec -/* f17d2d4: 3c0d8009 */ lui $t5,0x8009 -/* f17d2d8: 3c048008 */ lui $a0,%hi(g_MpAddSimulantMenuDialog) -/* f17d2dc: 0fc3cbd3 */ jal menuPushDialog -/* f17d2e0: 2484581c */ addiu $a0,$a0,%lo(g_MpAddSimulantMenuDialog) -/* f17d2e4: 10000020 */ beqz $zero,.L0f17d368 -/* f17d2e8: 00001025 */ or $v0,$zero,$zero -.L0f17d2ec: -/* f17d2ec: 91ad0af0 */ lbu $t5,0xaf0($t5) -/* f17d2f0: 24010001 */ addiu $at,$zero,0x1 -/* f17d2f4: 3c048008 */ lui $a0,%hi(menudialog_mpeditsimulant) -/* f17d2f8: 15a10006 */ bne $t5,$at,.L0f17d314 -/* f17d2fc: 00000000 */ sll $zero,$zero,0x0 -/* f17d300: 3c048007 */ lui $a0,%hi(menudialog_1b414) -/* f17d304: 0fc3cbd3 */ jal menuPushDialog -/* f17d308: 248453f4 */ addiu $a0,$a0,%lo(menudialog_1b414) -/* f17d30c: 10000016 */ beqz $zero,.L0f17d368 -/* f17d310: 00001025 */ or $v0,$zero,$zero -.L0f17d314: -/* f17d314: 0fc3cbd3 */ jal menuPushDialog -/* f17d318: 2484592c */ addiu $a0,$a0,%lo(menudialog_mpeditsimulant) -/* f17d31c: 10000012 */ beqz $zero,.L0f17d368 -/* f17d320: 00001025 */ or $v0,$zero,$zero -/* f17d324: 90af0001 */ lbu $t7,0x1($a1) -.L0f17d328: -/* f17d328: 29e10004 */ slti $at,$t7,0x4 -/* f17d32c: 5420000e */ bnezl $at,.L0f17d368 -/* f17d330: 00001025 */ or $v0,$zero,$zero -/* f17d334: 0fc67244 */ jal mpIsOptionAvailable -/* f17d338: 24040040 */ addiu $a0,$zero,0x40 -/* f17d33c: 5440000a */ bnezl $v0,.L0f17d368 -/* f17d340: 00001025 */ or $v0,$zero,$zero -/* f17d344: 10000008 */ beqz $zero,.L0f17d368 -/* f17d348: 24020001 */ addiu $v0,$zero,0x1 -.L0f17d34c: -/* f17d34c: 0fc6333e */ jal func0f18ccf8 -/* f17d350: 90a40001 */ lbu $a0,0x1($a1) -/* f17d354: 54400004 */ bnezl $v0,.L0f17d368 -/* f17d358: 00001025 */ or $v0,$zero,$zero -/* f17d35c: 10000002 */ beqz $zero,.L0f17d368 -/* f17d360: 24020001 */ addiu $v0,$zero,0x1 -/* f17d364: 00001025 */ or $v0,$zero,$zero -.L0f17d368: -/* f17d368: 8fbf0014 */ lw $ra,0x14($sp) -/* f17d36c: 27bd0018 */ addiu $sp,$sp,0x18 -/* f17d370: 03e00008 */ jr $ra -/* f17d374: 00000000 */ sll $zero,$zero,0x0 -); +s32 menuhandlerMpSimulantSlot(u32 operation, struct menu_item *item, s32 *value) +{ + switch (operation) { + case MENUOP_SET: + g_MenuStack[g_MenuStackDepth].slotindex = item->param; + + if ((g_MpSetup.simslots & (1 << (item->param + 4))) == 0) { + menuPushDialog(&g_MpAddSimulantMenuDialog); + } else if (var80090af0 == 1) { + menuPushDialog(&menudialog_1b414); + } else { + menuPushDialog(&menudialog_mpeditsimulant); + } + break; + case MENUOP_CHECKHIDDEN: + if (item->param >= 4 && !mpIsOptionAvailable(0x40)) { + return true; + } + break; + case MENUOP_CHECKDISABLED: + if (!mpIsSimSlotEnabled(item->param)) { + return true; + } + } + + return 0; +} GLOBAL_ASM( glabel func0f17d378 diff --git a/src/game/game_187770.c b/src/game/game_187770.c index 47fa0873a..ae14cb252 100644 --- a/src/game/game_187770.c +++ b/src/game/game_187770.c @@ -6576,7 +6576,7 @@ glabel func0f18cc8c ); GLOBAL_ASM( -glabel func0f18ccf8 +glabel mpIsSimSlotEnabled /* f18ccf8: 3c03800b */ lui $v1,0x800b /* f18ccfc: 9463cb9e */ lhu $v1,-0x3462($v1) /* f18cd00: 248e0004 */ addiu $t6,$a0,0x4 diff --git a/src/include/game/game_176d70.h b/src/include/game/game_176d70.h index 1ce92a61e..58cdff296 100644 --- a/src/include/game/game_176d70.h +++ b/src/include/game/game_176d70.h @@ -250,7 +250,7 @@ s32 menuhandlerMpScoreLimitSlider(u32 operation, struct menu_item *item, struct s32 menuhandlerMpSimulantBody(u32, u32, u32 *); s32 menuhandlerMpSimulantDifficulty(u32, u32, u32 *); s32 menuhandlerMpSimulantHead(u32, u32, u32 *); -s32 menuhandlerMpSimulantSlot(u32, u32, u32 *); +s32 menuhandlerMpSimulantSlot(u32 operation, struct menu_item *item, s32 *value); s32 menuhandlerMpSimulantsPerTeam(u32, u32, u32 *); s32 menuhandlerMpSlowMotion(u32, u32, u32 *); s32 menuhandlerMpStartChallenge(u32 operation, struct menu_item *item, s32 *value); diff --git a/src/include/game/game_187770.h b/src/include/game/game_187770.h index 351e69139..778867cca 100644 --- a/src/include/game/game_187770.h +++ b/src/include/game/game_187770.h @@ -86,10 +86,10 @@ u32 func0f18c8b8(void); u32 func0f18c984(void); u32 func0f18cb60(void); u32 func0f18cbb8(void); -void mpRemoveSimulant(s32 simindex); +void mpRemoveSimulant(s32 slotindex); u32 func0f18cc64(void); u32 func0f18cc8c(void); -u32 func0f18ccf8(void); +bool mpIsSimSlotEnabled(s32 slotindex); u32 func0f18cd68(void); u32 func0f18cddc(void); s32 func0f18cff8(struct chrdata *chr); diff --git a/src/include/types.h b/src/include/types.h index d650a6948..8de2dd33c 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -4013,6 +4013,7 @@ struct mpsetup { /*0x8009cb9a*/ u8 timelimit; /*0x8009cb9b*/ u8 scorelimit; /*0x8009cb9c*/ u16 teamscorelimit; + /*0x8009cb9e*/ u16 simslots; /*0x8009cba0*/ u32 unk18; /*0x8009cba4*/ u32 unk1c; /*0x8009cba8*/ bool saved;