From ae3fb1bce5d1e7444791b73e930277b116dfe701 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 31 Dec 2019 13:18:01 +1000 Subject: [PATCH] Decompile menuhandlerHiRes and optionsSetHiRes --- src/game/game_0b28d0.c | 10 ++- src/game/game_102240.c | 119 +++++++------------------------ src/game/game_10ccd0.c | 6 +- src/include/constants.h | 2 +- src/include/game/game_0b28d0.h | 2 +- src/include/setup/setup_0160b0.h | 1 + src/setup/setup_0160b0.c | 2 +- 7 files changed, 37 insertions(+), 105 deletions(-) diff --git a/src/game/game_0b28d0.c b/src/game/game_0b28d0.c index 5f23ec0b5..cf59d673b 100644 --- a/src/game/game_0b28d0.c +++ b/src/game/game_0b28d0.c @@ -11219,12 +11219,10 @@ glabel func0f0bc3f0 /* f0bc43c: 00000000 */ sll $zero,$zero,0x0 ); -GLOBAL_ASM( -glabel func0f0bc440 -/* f0bc440: 3c018007 */ lui $at,0x8007 -/* f0bc444: 03e00008 */ jr $ra -/* f0bc448: ac2406cc */ sw $a0,0x6cc($at) -); +void optionsSetHiRes(bool enable) +{ + g_HiRes = enable; +} GLOBAL_ASM( glabel func0f0bc44c diff --git a/src/game/game_102240.c b/src/game/game_102240.c index ac06b3c04..40d1528a8 100644 --- a/src/game/game_102240.c +++ b/src/game/game_102240.c @@ -786,7 +786,7 @@ s32 menuhandlerCutsceneSubtitles(u32 operation, struct menu_item *item, bool *en s32 menuhandlerAlternativeTitle(u32 operation, struct menu_item *item, bool *enable) { switch (operation) { - case MENUOP_24: + case MENUOP_CHECKHIDDEN: if (g_Vars.stagenum != STAGE_CITRAINING || var800a2328[3] == 0) { return true; } @@ -796,103 +796,36 @@ s32 menuhandlerAlternativeTitle(u32 operation, struct menu_item *item, bool *ena case MENUOP_SET: g_AltTitle = *enable; g_Vars.unk000458 |= 4; - break; } return 0; } -GLOBAL_ASM( -glabel menuhandlerHiRes -/* f102c9c: 27bdffe8 */ addiu $sp,$sp,-24 -/* f102ca0: 24010006 */ addiu $at,$zero,0x6 -/* f102ca4: afbf0014 */ sw $ra,0x14($sp) -/* f102ca8: 10810037 */ beq $a0,$at,.L0f102d88 -/* f102cac: afa5001c */ sw $a1,0x1c($sp) -/* f102cb0: 24010008 */ addiu $at,$zero,0x8 -/* f102cb4: 10810030 */ beq $a0,$at,.L0f102d78 -/* f102cb8: 3c028007 */ lui $v0,0x8007 -/* f102cbc: 24010018 */ addiu $at,$zero,0x18 -/* f102cc0: 1481003e */ bne $a0,$at,.L0f102dbc -/* f102cc4: 3c0e8009 */ lui $t6,0x8009 -/* f102cc8: 91ce0af0 */ lbu $t6,0xaf0($t6) -/* f102ccc: 24010001 */ addiu $at,$zero,0x1 -/* f102cd0: 3c02800a */ lui $v0,%hi(g_Vars) -/* f102cd4: 15c10003 */ bne $t6,$at,.L0f102ce4 -/* f102cd8: 24429fc0 */ addiu $v0,$v0,%lo(g_Vars) -/* f102cdc: 10000038 */ beqz $zero,.L0f102dc0 -/* f102ce0: 24020001 */ addiu $v0,$zero,0x1 -.L0f102ce4: -/* f102ce4: 8c4f0298 */ lw $t7,0x298($v0) -/* f102ce8: 05e30005 */ bgezl $t7,.L0f102d00 -/* f102cec: 8c59006c */ lw $t9,0x6c($v0) -/* f102cf0: 8c58029c */ lw $t8,0x29c($v0) -/* f102cf4: 07020032 */ bltzl $t8,.L0f102dc0 -/* f102cf8: 00001025 */ or $v0,$zero,$zero -/* f102cfc: 8c59006c */ lw $t9,0x6c($v0) -.L0f102d00: -/* f102d00: 00003025 */ or $a2,$zero,$zero -/* f102d04: 00001825 */ or $v1,$zero,$zero -/* f102d08: 13200003 */ beqz $t9,.L0f102d18 -/* f102d0c: 00002825 */ or $a1,$zero,$zero -/* f102d10: 10000001 */ beqz $zero,.L0f102d18 -/* f102d14: 24060001 */ addiu $a2,$zero,0x1 -.L0f102d18: -/* f102d18: 8c480068 */ lw $t0,0x68($v0) -/* f102d1c: 00002025 */ or $a0,$zero,$zero -/* f102d20: 11000003 */ beqz $t0,.L0f102d30 -/* f102d24: 00000000 */ sll $zero,$zero,0x0 -/* f102d28: 10000001 */ beqz $zero,.L0f102d30 -/* f102d2c: 24030001 */ addiu $v1,$zero,0x1 -.L0f102d30: -/* f102d30: 8c490064 */ lw $t1,0x64($v0) -/* f102d34: 11200003 */ beqz $t1,.L0f102d44 -/* f102d38: 00000000 */ sll $zero,$zero,0x0 -/* f102d3c: 10000001 */ beqz $zero,.L0f102d44 -/* f102d40: 24050001 */ addiu $a1,$zero,0x1 -.L0f102d44: -/* f102d44: 8c4a0070 */ lw $t2,0x70($v0) -/* f102d48: 11400003 */ beqz $t2,.L0f102d58 -/* f102d4c: 00000000 */ sll $zero,$zero,0x0 -/* f102d50: 10000001 */ beqz $zero,.L0f102d58 -/* f102d54: 24040001 */ addiu $a0,$zero,0x1 -.L0f102d58: -/* f102d58: 00855821 */ addu $t3,$a0,$a1 -/* f102d5c: 01636021 */ addu $t4,$t3,$v1 -/* f102d60: 01866821 */ addu $t5,$t4,$a2 -/* f102d64: 29a10002 */ slti $at,$t5,0x2 -/* f102d68: 54200015 */ bnezl $at,.L0f102dc0 -/* f102d6c: 00001025 */ or $v0,$zero,$zero -/* f102d70: 10000013 */ beqz $zero,.L0f102dc0 -/* f102d74: 24020001 */ addiu $v0,$zero,0x1 -.L0f102d78: -/* f102d78: 8c4206cc */ lw $v0,0x6cc($v0) -/* f102d7c: 384e0001 */ xori $t6,$v0,0x1 -/* f102d80: 1000000f */ beqz $zero,.L0f102dc0 -/* f102d84: 2dc20001 */ sltiu $v0,$t6,0x1 -.L0f102d88: -/* f102d88: 8ccf0000 */ lw $t7,0x0($a2) -/* f102d8c: 00002025 */ or $a0,$zero,$zero -/* f102d90: 11e00003 */ beqz $t7,.L0f102da0 -/* f102d94: 00000000 */ sll $zero,$zero,0x0 -/* f102d98: 10000001 */ beqz $zero,.L0f102da0 -/* f102d9c: 24040001 */ addiu $a0,$zero,0x1 -.L0f102da0: -/* f102da0: 0fc2f110 */ jal func0f0bc440 -/* f102da4: 00000000 */ sll $zero,$zero,0x0 -/* f102da8: 3c02800a */ lui $v0,%hi(g_Vars) -/* f102dac: 24429fc0 */ addiu $v0,$v0,%lo(g_Vars) -/* f102db0: 8c580458 */ lw $t8,0x458($v0) -/* f102db4: 37190001 */ ori $t9,$t8,0x1 -/* f102db8: ac590458 */ sw $t9,0x458($v0) -.L0f102dbc: -/* f102dbc: 00001025 */ or $v0,$zero,$zero -.L0f102dc0: -/* f102dc0: 8fbf0014 */ lw $ra,0x14($sp) -/* f102dc4: 27bd0018 */ addiu $sp,$sp,0x18 -/* f102dc8: 03e00008 */ jr $ra -/* f102dcc: 00000000 */ sll $zero,$zero,0x0 -); +s32 menuhandlerHiRes(u32 operation, struct menu_item *item, bool *enable) +{ + switch (operation) { + case MENUOP_CHECKHIDDEN: + if (var80090af0 == 1) { + return true; + } + if (g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) { + if ((g_Vars.players[0] ? 1 : 0) + + (g_Vars.players[1] ? 1 : 0) + + (g_Vars.players[2] ? 1 : 0) + + (g_Vars.players[3] ? 1 : 0) >= 2) { + return true; + } + } + break; + case MENUOP_GET: + return g_HiRes == true; + case MENUOP_SET: + optionsSetHiRes(*enable ? 1 : 0); + g_Vars.unk000458 |= 1; + } + + return 0; +} s32 menuhandlerAmmoOnScreen(u32 operation, struct menu_item *item, bool *enable) { diff --git a/src/game/game_10ccd0.c b/src/game/game_10ccd0.c index d48abc22b..6be46d5ef 100644 --- a/src/game/game_10ccd0.c +++ b/src/game/game_10ccd0.c @@ -2953,17 +2953,17 @@ glabel func0f10f204 /* f10f510: 24010001 */ addiu $at,$zero,0x1 /* f10f514: 15210005 */ bne $t1,$at,.L0f10f52c /* f10f518: 00000000 */ sll $zero,$zero,0x0 -/* f10f51c: 0fc2f110 */ jal func0f0bc440 +/* f10f51c: 0fc2f110 */ jal optionsSetHiRes /* f10f520: 00002025 */ or $a0,$zero,$zero /* f10f524: 10000007 */ beqz $zero,.L0f10f544 /* f10f528: 00000000 */ sll $zero,$zero,0x0 .L0f10f52c: -/* f10f52c: 0fc2f110 */ jal func0f0bc440 +/* f10f52c: 0fc2f110 */ jal optionsSetHiRes /* f10f530: 24040001 */ addiu $a0,$zero,0x1 /* f10f534: 10000003 */ beqz $zero,.L0f10f544 /* f10f538: 00000000 */ sll $zero,$zero,0x0 .L0f10f53c: -/* f10f53c: 0fc2f110 */ jal func0f0bc440 +/* f10f53c: 0fc2f110 */ jal optionsSetHiRes /* f10f540: 00002025 */ or $a0,$zero,$zero .L0f10f544: /* f10f544: 3c0a8009 */ lui $t2,0x8009 diff --git a/src/include/constants.h b/src/include/constants.h index 6cb37cf40..8caf72879 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -465,7 +465,7 @@ #define MENUOP_SET 6 #define MENUOP_GET 8 #define MENUOP_CHECKDISABLED 12 -#define MENUOP_24 24 +#define MENUOP_CHECKHIDDEN 24 // Object flags - bank 0 (object struct offset 0x08) #define OBJECTFLAG0_00000001 0x00000001 // Not used in scripts diff --git a/src/include/game/game_0b28d0.h b/src/include/game/game_0b28d0.h index 1b86ceb35..53c191077 100644 --- a/src/include/game/game_0b28d0.h +++ b/src/include/game/game_0b28d0.h @@ -119,7 +119,7 @@ u32 func0f0bbf78(void); void currentPlayerSurroundWithExplosions(u32 arg0); u32 func0f0bc120(void); u32 func0f0bc3f0(void); -u32 func0f0bc440(void); +void optionsSetHiRes(bool enable); u32 func0f0bc44c(void); u32 func0f0bc478(void); u32 func0f0bc4c0(void); diff --git a/src/include/setup/setup_0160b0.h b/src/include/setup/setup_0160b0.h index 48702b34d..36e5dcaa7 100644 --- a/src/include/setup/setup_0160b0.h +++ b/src/include/setup/setup_0160b0.h @@ -59,6 +59,7 @@ extern u32 var800705b8; extern u32 var800705bc; extern u32 var800705c0; extern u32 var800706c8; +extern bool g_HiRes; extern u32 var8007074c; extern u32 var80070764; extern u32 var80070768; diff --git a/src/setup/setup_0160b0.c b/src/setup/setup_0160b0.c index 2b74471a5..9d715830c 100644 --- a/src/setup/setup_0160b0.c +++ b/src/setup/setup_0160b0.c @@ -413,7 +413,7 @@ u32 var800706bc = 0x00000000; u32 var800706c0 = 0x0000012c; u32 var800706c4 = 0x00000000; u32 var800706c8 = 0x00000000; -u32 var800706cc = 0x00000000; +bool g_HiRes = false; u32 var800706d0 = 0x00000000; u32 var800706d4 = 0x00000000; u32 var800706d8 = 0x00000000;