From 6fd45f0eeac62d5186bbab8edc3aa019f26aab99 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 1 Jan 2020 15:06:12 +1000 Subject: [PATCH] Decompile menuhandlerCoopDifficulty --- src/game/game_102240.c | 70 ++++++++------------------------ src/include/game/game_102240.h | 2 +- src/include/setup/setup_0160b0.h | 2 +- src/setup/setup_0160b0.c | 8 ++-- 4 files changed, 24 insertions(+), 58 deletions(-) diff --git a/src/game/game_102240.c b/src/game/game_102240.c index a6accf2c9..d9b7154bb 100644 --- a/src/game/game_102240.c +++ b/src/game/game_102240.c @@ -2359,58 +2359,24 @@ glabel menuhandlerAntiPlayer /* f104534: 00000000 */ sll $zero,$zero,0x0 ); -GLOBAL_ASM( -glabel menuhandler00104538 -/* f104538: 27bdffe8 */ addiu $sp,$sp,-24 -/* f10453c: afa60020 */ sw $a2,0x20($sp) -/* f104540: 24010006 */ addiu $at,$zero,0x6 -/* f104544: 00a03025 */ or $a2,$a1,$zero -/* f104548: afbf0014 */ sw $ra,0x14($sp) -/* f10454c: 10810006 */ beq $a0,$at,.L0f104568 -/* f104550: afa5001c */ sw $a1,0x1c($sp) -/* f104554: 2401000c */ addiu $at,$zero,0xc -/* f104558: 10810018 */ beq $a0,$at,.L0f1045bc -/* f10455c: 3c02800a */ lui $v0,%hi(g_MissionConfig) -/* f104560: 1000001f */ beqz $zero,.L0f1045e0 -/* f104564: 00001025 */ or $v0,$zero,$zero -.L0f104568: -/* f104568: 3c02800a */ lui $v0,%hi(g_MissionConfig) -/* f10456c: 2442dfe8 */ addiu $v0,$v0,%lo(g_MissionConfig) -/* f104570: 904e0000 */ lbu $t6,0x0($v0) -/* f104574: 31cafffe */ andi $t2,$t6,0xfffe -/* f104578: a04a0000 */ sb $t2,0x0($v0) -/* f10457c: 90d90001 */ lbu $t9,0x1($a2) -/* f104580: 314b0001 */ andi $t3,$t2,0x1 -/* f104584: 00194840 */ sll $t1,$t9,0x1 -/* f104588: 012b6025 */ or $t4,$t1,$t3 -/* f10458c: a04c0000 */ sb $t4,0x0($v0) -/* f104590: 8c440000 */ lw $a0,0x0($v0) -/* f104594: 00046e42 */ srl $t5,$a0,0x19 -/* f104598: 0fc5b36a */ jal setDifficulty -/* f10459c: 01a02025 */ or $a0,$t5,$zero -/* f1045a0: 0fc3cdb7 */ jal func0f0f36dc -/* f1045a4: 00000000 */ sll $zero,$zero,0x0 -/* f1045a8: 3c048007 */ lui $a0,%hi(menudialog_cooperativeoptions) -/* f1045ac: 0fc3cbd3 */ jal menuPushDialog -/* f1045b0: 24841ca4 */ addiu $a0,$a0,%lo(menudialog_cooperativeoptions) -/* f1045b4: 1000000a */ beqz $zero,.L0f1045e0 -/* f1045b8: 00001025 */ or $v0,$zero,$zero -.L0f1045bc: -/* f1045bc: 2442dfe8 */ addiu $v0,$v0,%lo(g_MissionConfig) -/* f1045c0: 90440002 */ lbu $a0,0x2($v0) -/* f1045c4: 0fc40e3b */ jal isStageDifficultyUnlocked -/* f1045c8: 90c50001 */ lbu $a1,0x1($a2) -/* f1045cc: 54400004 */ bnezl $v0,.L0f1045e0 -/* f1045d0: 00001025 */ or $v0,$zero,$zero -/* f1045d4: 10000002 */ beqz $zero,.L0f1045e0 -/* f1045d8: 24020001 */ addiu $v0,$zero,0x1 -/* f1045dc: 00001025 */ or $v0,$zero,$zero -.L0f1045e0: -/* f1045e0: 8fbf0014 */ lw $ra,0x14($sp) -/* f1045e4: 27bd0018 */ addiu $sp,$sp,0x18 -/* f1045e8: 03e00008 */ jr $ra -/* f1045ec: 00000000 */ sll $zero,$zero,0x0 -); +s32 menuhandlerCoopDifficulty(u32 operation, struct menu_item *item, s32 *value) +{ + switch (operation) { + case MENUOP_SET: + g_MissionConfig.bits0_07 = 0; + g_MissionConfig.difficulty = item->param; + setDifficulty(g_MissionConfig.difficulty); + func0f0f36dc(); + menuPushDialog(&g_CoopOptionsMenuDialog); + break; + case MENUOP_CHECKDISABLED: + if (!isStageDifficultyUnlocked(g_MissionConfig.unk02, item->param)) { + return true; + } + } + + return 0; +} GLOBAL_ASM( glabel menuhandler001045f0 diff --git a/src/include/game/game_102240.h b/src/include/game/game_102240.h index b9c45151e..a6a3908bb 100644 --- a/src/include/game/game_102240.h +++ b/src/include/game/game_102240.h @@ -38,7 +38,7 @@ s32 menuhandler001024fc(u32 operation, struct menu_item *item, bool *enable); s32 menuhandlerAcceptMission(u32 operation, struct menu_item *item, s32 *value); s32 menuhandlerAcceptPdModeSettings(s32 operation, struct menu_item *item, bool *value); s32 menuhandlerBuddyOptionsContinue(u32 operation, struct menu_item *item, s32 *value); -s32 menuhandler00104538(u32 operation, struct menu_item *item, bool *enable); +s32 menuhandlerCoopDifficulty(u32 operation, struct menu_item *item, s32 *value); s32 menuhandler001045f0(u32 operation, struct menu_item *item, bool *enable); s32 menuhandler0010476c(u32 operation, struct menu_item *item, bool *enable); s32 menuhandlerControlStyle(s32 operation, struct menu_item *item, u32 *value); diff --git a/src/include/setup/setup_0160b0.h b/src/include/setup/setup_0160b0.h index 846faffa9..011b31dfe 100644 --- a/src/include/setup/setup_0160b0.h +++ b/src/include/setup/setup_0160b0.h @@ -183,7 +183,7 @@ extern u16 g_ScreenSplitOptions[]; extern struct menu_dialog g_ObjectivesMenuDialog; extern struct menu_dialog g_PdModeSettingsDialog; extern struct menu_dialog menudialog_selectdifficulty; -extern struct menu_dialog menudialog_cooperativeoptions; +extern struct menu_dialog g_CoopOptionsMenuDialog; extern struct menu_dialog menudialog_counteroperativeoptions; extern struct menu_dialog menudialog_selectdifficulty2; extern struct menu_dialog menudialog_selectdifficulty3; diff --git a/src/setup/setup_0160b0.c b/src/setup/setup_0160b0.c index a1225d7f4..cf0afb804 100644 --- a/src/setup/setup_0160b0.c +++ b/src/setup/setup_0160b0.c @@ -1672,7 +1672,7 @@ struct menu_item menuitems_cooperativeoptions[] = { }; // 17cc4 -struct menu_dialog menudialog_cooperativeoptions = { +struct menu_dialog g_CoopOptionsMenuDialog = { MENUDIALOGTYPE_DEFAULT, 0x56ff, // "Co-Operative Options" menuitems_cooperativeoptions, @@ -1703,9 +1703,9 @@ struct menu_dialog menudialog_counteroperativeoptions = { // 17d6c struct menu_item menuitems_selectdifficulty2[] = { - { MENUITEMTYPE_SELECTABLE, 0, 0x00000000, 0x000056fb, 0x00000000, menuhandler00104538 }, // "Agent" - { MENUITEMTYPE_SELECTABLE, 1, 0x00000000, 0x000056fc, 0x00000000, menuhandler00104538 }, // "Special Agent" - { MENUITEMTYPE_SELECTABLE, 2, 0x00000000, 0x000056fd, 0x00000000, menuhandler00104538 }, // "Perfect Agent" + { MENUITEMTYPE_SELECTABLE, 0, 0x00000000, 0x000056fb, 0x00000000, menuhandlerCoopDifficulty }, // "Agent" + { MENUITEMTYPE_SELECTABLE, 1, 0x00000000, 0x000056fc, 0x00000000, menuhandlerCoopDifficulty }, // "Special Agent" + { MENUITEMTYPE_SELECTABLE, 2, 0x00000000, 0x000056fd, 0x00000000, menuhandlerCoopDifficulty }, // "Perfect Agent" { MENUITEMTYPE_SEPARATOR, 0, 0x00000000, 0x00000000, 0x00000000, NULL }, { MENUITEMTYPE_SELECTABLE, 0, 0x00000008, 0x000056fe, 0x00000000, NULL }, // "Cancel" { MENUITEMTYPE_END, 0, 0x00000000, 0x00000000, 0x00000000, NULL },