From c43a30b87bd8987bec38af9b8da1ba9d1fa98e00 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 1 Jan 2020 20:35:57 +1000 Subject: [PATCH] Decompile menuhandlerReplayPreviousMission --- src/game/game_102240.c | 6 +++--- src/game/game_10ccd0.c | 37 +++++++++------------------------- src/include/game/game_102240.h | 2 +- src/include/game/game_10ccd0.h | 2 +- src/include/types.h | 2 +- src/setup/setup_0160b0.c | 2 +- 6 files changed, 16 insertions(+), 35 deletions(-) diff --git a/src/game/game_102240.c b/src/game/game_102240.c index 7cc6e23f3..b7438fc81 100644 --- a/src/game/game_102240.c +++ b/src/game/game_102240.c @@ -1743,7 +1743,7 @@ s32 menuhandlerSoloDifficulty(u32 operation, struct menu_item *item, s32 *value) { switch (operation) { case MENUOP_CHECKPREFOCUSED: - if (isStageDifficultyUnlocked(g_MissionConfig.unk02, item->param)) { + if (isStageDifficultyUnlocked(g_MissionConfig.stageindex, item->param)) { if (item->right == 0) { return true; } @@ -1760,7 +1760,7 @@ s32 menuhandlerSoloDifficulty(u32 operation, struct menu_item *item, s32 *value) menuPushDialog(&g_ObjectivesMenuDialog); break; case MENUOP_CHECKDISABLED: - if (!isStageDifficultyUnlocked(g_MissionConfig.unk02, item->param)) { + if (!isStageDifficultyUnlocked(g_MissionConfig.stageindex, item->param)) { return true; } } @@ -2250,7 +2250,7 @@ s32 menuhandlerCoopDifficulty(u32 operation, struct menu_item *item, s32 *value) menuPushDialog(&g_CoopOptionsMenuDialog); break; case MENUOP_CHECKDISABLED: - if (!isStageDifficultyUnlocked(g_MissionConfig.unk02, item->param)) { + if (!isStageDifficultyUnlocked(g_MissionConfig.stageindex, item->param)) { return true; } } diff --git a/src/game/game_10ccd0.c b/src/game/game_10ccd0.c index caa4c817a..269f48c52 100644 --- a/src/game/game_10ccd0.c +++ b/src/game/game_10ccd0.c @@ -290,34 +290,15 @@ glabel func0f10cf2c /* f10cfe0: 00000000 */ sll $zero,$zero,0x0 ); -GLOBAL_ASM( -glabel menuhandlerReplyPreviousMission -/* f10cfe4: 27bdffe8 */ addiu $sp,$sp,-24 -/* f10cfe8: 24010006 */ addiu $at,$zero,0x6 -/* f10cfec: afbf0014 */ sw $ra,0x14($sp) -/* f10cff0: 1481000e */ bne $a0,$at,.L0f10d02c -/* f10cff4: afa5001c */ sw $a1,0x1c($sp) -/* f10cff8: 3c02800a */ lui $v0,%hi(g_MissionConfig) -/* f10cffc: 2442dfe8 */ addiu $v0,$v0,%lo(g_MissionConfig) -/* f10d000: 904e0002 */ lbu $t6,0x2($v0) -/* f10d004: 3c088007 */ lui $t0,0x8007 -/* f10d008: 25cfffff */ addiu $t7,$t6,-1 -/* f10d00c: 31f800ff */ andi $t8,$t7,0xff -/* f10d010: 0018c880 */ sll $t9,$t8,0x2 -/* f10d014: 0338c823 */ subu $t9,$t9,$t8 -/* f10d018: 0019c880 */ sll $t9,$t9,0x2 -/* f10d01c: a04f0002 */ sb $t7,0x2($v0) -/* f10d020: 01194021 */ addu $t0,$t0,$t9 -/* f10d024: 8d081e6c */ lw $t0,0x1e6c($t0) -/* f10d028: a0480001 */ sb $t0,0x1($v0) -.L0f10d02c: -/* f10d02c: 0fc40cfe */ jal menuhandlerAcceptMission -/* f10d030: 00002825 */ or $a1,$zero,$zero -/* f10d034: 8fbf0014 */ lw $ra,0x14($sp) -/* f10d038: 27bd0018 */ addiu $sp,$sp,0x18 -/* f10d03c: 03e00008 */ jr $ra -/* f10d040: 00000000 */ sll $zero,$zero,0x0 -); +s32 menuhandlerReplayPreviousMission(u32 operation, struct menu_item *item, s32 *value) +{ + if (operation == MENUOP_SET) { + g_MissionConfig.stageindex--; + g_MissionConfig.stagenum = g_StageNames[g_MissionConfig.stageindex].stage_id; + } + + return menuhandlerAcceptMission(operation, NULL, value); +} GLOBAL_ASM( glabel func0f10d044 diff --git a/src/include/game/game_102240.h b/src/include/game/game_102240.h index 7488573f5..cfc4b2e65 100644 --- a/src/include/game/game_102240.h +++ b/src/include/game/game_102240.h @@ -8,7 +8,7 @@ char *menutextDifficulty(s32 arg0); s32 func0f102330(u32 operation, struct menu_item *item, s32 *value, s32 arg3); u32 func0f103550(void); f32 func0f1036ac(s32 arg0, s32 arg1); -bool isStageDifficultyUnlocked(s32 stagenum, s32 difficulty); +bool isStageDifficultyUnlocked(s32 stageindex, s32 difficulty); u32 func0f103e68(void); u32 func0f10408c(void); u32 func0f104664(void); diff --git a/src/include/game/game_10ccd0.h b/src/include/game/game_10ccd0.h index 8903989e0..b0717552d 100644 --- a/src/include/game/game_10ccd0.h +++ b/src/include/game/game_10ccd0.h @@ -58,6 +58,6 @@ s32 menuhandlerDeclineMission(u32 operation, struct menu_item *item, s32 *value) s32 menuhandler0010e064(u32, u32, u32 *); s32 menuhandlerContinueToCredits(u32, u32, u32 *); s32 menuhandlerReplyLastLevel(u32, u32, u32 *); -s32 menuhandlerReplyPreviousMission(u32, u32, u32 *); +s32 menuhandlerReplayPreviousMission(u32 operation, struct menu_item *item, s32 *value); #endif diff --git a/src/include/types.h b/src/include/types.h index 4b6f72ce5..418b6b2cc 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -3985,7 +3985,7 @@ struct missionconfig { u8 pdmode : 1; /*0x01*/ u8 stagenum; - /*0x02*/ u8 unk02; + /*0x02*/ u8 stageindex; u8 iscoop : 1; u8 isanti : 1; diff --git a/src/setup/setup_0160b0.c b/src/setup/setup_0160b0.c index 4d4e4f12d..1b31ee79c 100644 --- a/src/setup/setup_0160b0.c +++ b/src/setup/setup_0160b0.c @@ -3924,7 +3924,7 @@ struct menu_item menuitems_promptnextmission[] = { { MENUITEMTYPE_SELECTABLE, 0, 0x00000000, 0x0000572a, 0x00000000, menuhandlerAcceptMission }, // "Accept" { MENUITEMTYPE_SELECTABLE, 0, 0x00000000, 0x0000572b, 0x00000000, menuhandlerDeclineMission }, // "Decline" { MENUITEMTYPE_SEPARATOR, 0, 0x00000000, 0x00000000, 0x00000000, NULL }, - { MENUITEMTYPE_SELECTABLE, 0, 0x00000000, 0x000059d6, 0x00000000, menuhandlerReplyPreviousMission }, // "Replay Previous Mission" + { MENUITEMTYPE_SELECTABLE, 0, 0x00000000, 0x000059d6, 0x00000000, menuhandlerReplayPreviousMission }, // "Replay Previous Mission" { MENUITEMTYPE_END, 0, 0x00000000, 0x00000000, 0x00000000, NULL }, };