From af8c4bbd36a7f7a5fcbfee1020d122217678c725 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 1 Jan 2020 15:09:25 +1000 Subject: [PATCH] Decompile menuhandlerAntiDifficulty --- src/game/game_102240.c | 46 +++++++++----------------------- src/include/game/game_102240.h | 2 +- src/include/setup/setup_0160b0.h | 2 +- src/setup/setup_0160b0.c | 8 +++--- 4 files changed, 19 insertions(+), 39 deletions(-) diff --git a/src/game/game_102240.c b/src/game/game_102240.c index d9b7154bb..67f319b32 100644 --- a/src/game/game_102240.c +++ b/src/game/game_102240.c @@ -2378,39 +2378,19 @@ s32 menuhandlerCoopDifficulty(u32 operation, struct menu_item *item, s32 *value) return 0; } -GLOBAL_ASM( -glabel menuhandler001045f0 -/* f1045f0: 27bdffe8 */ addiu $sp,$sp,-24 -/* f1045f4: 24010006 */ addiu $at,$zero,0x6 -/* f1045f8: afbf0014 */ sw $ra,0x14($sp) -/* f1045fc: 14810014 */ bne $a0,$at,.L0f104650 -/* f104600: afa60020 */ sw $a2,0x20($sp) -/* f104604: 3c02800a */ lui $v0,%hi(g_MissionConfig) -/* f104608: 2442dfe8 */ addiu $v0,$v0,%lo(g_MissionConfig) -/* f10460c: 904e0000 */ lbu $t6,0x0($v0) -/* f104610: 31cafffe */ andi $t2,$t6,0xfffe -/* f104614: a04a0000 */ sb $t2,0x0($v0) -/* f104618: 90b90001 */ lbu $t9,0x1($a1) -/* f10461c: 314b0001 */ andi $t3,$t2,0x1 -/* f104620: 00194840 */ sll $t1,$t9,0x1 -/* f104624: 012b6025 */ or $t4,$t1,$t3 -/* f104628: a04c0000 */ sb $t4,0x0($v0) -/* f10462c: 8c440000 */ lw $a0,0x0($v0) -/* f104630: 00046e42 */ srl $t5,$a0,0x19 -/* f104634: 0fc5b36a */ jal setDifficulty -/* f104638: 01a02025 */ or $a0,$t5,$zero -/* f10463c: 0fc3cdb7 */ jal func0f0f36dc -/* f104640: 00000000 */ sll $zero,$zero,0x0 -/* f104644: 3c048007 */ lui $a0,%hi(menudialog_counteroperativeoptions) -/* f104648: 0fc3cbd3 */ jal menuPushDialog -/* f10464c: 24841d34 */ addiu $a0,$a0,%lo(menudialog_counteroperativeoptions) -.L0f104650: -/* f104650: 8fbf0014 */ lw $ra,0x14($sp) -/* f104654: 27bd0018 */ addiu $sp,$sp,0x18 -/* f104658: 00001025 */ or $v0,$zero,$zero -/* f10465c: 03e00008 */ jr $ra -/* f104660: 00000000 */ sll $zero,$zero,0x0 -); +s32 menuhandlerAntiDifficulty(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_AntiOptionsMenuDialog); + } + + return 0; +} GLOBAL_ASM( glabel func0f104664 diff --git a/src/include/game/game_102240.h b/src/include/game/game_102240.h index a6a3908bb..ffb61f14a 100644 --- a/src/include/game/game_102240.h +++ b/src/include/game/game_102240.h @@ -39,7 +39,7 @@ 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 menuhandlerCoopDifficulty(u32 operation, struct menu_item *item, s32 *value); -s32 menuhandler001045f0(u32 operation, struct menu_item *item, bool *enable); +s32 menuhandlerAntiDifficulty(u32 operation, struct menu_item *item, s32 *value); s32 menuhandler0010476c(u32 operation, struct menu_item *item, bool *enable); s32 menuhandlerControlStyle(s32 operation, struct menu_item *item, u32 *value); s32 menuhandler00106028(u32 operation, struct menu_item *item, bool *enable); diff --git a/src/include/setup/setup_0160b0.h b/src/include/setup/setup_0160b0.h index 011b31dfe..894ab8549 100644 --- a/src/include/setup/setup_0160b0.h +++ b/src/include/setup/setup_0160b0.h @@ -184,7 +184,7 @@ extern struct menu_dialog g_ObjectivesMenuDialog; extern struct menu_dialog g_PdModeSettingsDialog; extern struct menu_dialog menudialog_selectdifficulty; extern struct menu_dialog g_CoopOptionsMenuDialog; -extern struct menu_dialog menudialog_counteroperativeoptions; +extern struct menu_dialog g_AntiOptionsMenuDialog; extern struct menu_dialog menudialog_selectdifficulty2; extern struct menu_dialog menudialog_selectdifficulty3; extern struct stageoverviewentry g_StageNames[]; diff --git a/src/setup/setup_0160b0.c b/src/setup/setup_0160b0.c index cf0afb804..05a4c7f42 100644 --- a/src/setup/setup_0160b0.c +++ b/src/setup/setup_0160b0.c @@ -1692,7 +1692,7 @@ struct menu_item menuitems_counteroperativeoptions[] = { }; // 17d54 -struct menu_dialog menudialog_counteroperativeoptions = { +struct menu_dialog g_AntiOptionsMenuDialog = { MENUDIALOGTYPE_DEFAULT, 0x570a, // "Counter-Operative Options" menuitems_counteroperativeoptions, @@ -1723,9 +1723,9 @@ struct menu_dialog menudialog_selectdifficulty2 = { // 17dfc struct menu_item menuitems_selectdifficulty3[] = { - { MENUITEMTYPE_SELECTABLE, 0, 0x00000000, 0x000056fb, 0x00000000, menuhandler001045f0 }, // "Agent" - { MENUITEMTYPE_SELECTABLE, 1, 0x00000000, 0x000056fc, 0x00000000, menuhandler001045f0 }, // "Special Agent" - { MENUITEMTYPE_SELECTABLE, 2, 0x00000000, 0x000056fd, 0x00000000, menuhandler001045f0 }, // "Perfect Agent" + { MENUITEMTYPE_SELECTABLE, 0, 0x00000000, 0x000056fb, 0x00000000, menuhandlerAntiDifficulty }, // "Agent" + { MENUITEMTYPE_SELECTABLE, 1, 0x00000000, 0x000056fc, 0x00000000, menuhandlerAntiDifficulty }, // "Special Agent" + { MENUITEMTYPE_SELECTABLE, 2, 0x00000000, 0x000056fd, 0x00000000, menuhandlerAntiDifficulty }, // "Perfect Agent" { MENUITEMTYPE_SEPARATOR, 0, 0x00000000, 0x00000000, 0x00000000, NULL }, { MENUITEMTYPE_SELECTABLE, 0, 0x00000008, 0x000056fe, 0x00000000, NULL }, // "Cancel" { MENUITEMTYPE_END, 0, 0x00000000, 0x00000000, 0x00000000, NULL },