From b3e9a31bd7bf76e76a2890a61c1c76f8010a0384 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 18 Jan 2020 15:27:29 +1000 Subject: [PATCH] Decompile activemenuChangeScreen --- src/game/game_015470.c | 8 +- src/game/game_0f09f0.c | 139 ++++++++++----------------------- src/include/game/game_0f09f0.h | 4 +- src/include/types.h | 17 ++-- 4 files changed, 59 insertions(+), 109 deletions(-) diff --git a/src/game/game_015470.c b/src/game/game_015470.c index c806d4b15..bbf4805be 100644 --- a/src/game/game_015470.c +++ b/src/game/game_015470.c @@ -6855,7 +6855,7 @@ glabel func0f01b160 /* f01b484: 1700000d */ bnez $t8,.L0f01b4bc /* f01b488: 00000000 */ sll $zero,$zero,0x0 /* f01b48c: a2030034 */ sb $v1,0x34($s0) -/* f01b490: 0fc3fade */ jal func0f0feb78 +/* f01b490: 0fc3fade */ jal activemenuChangeScreen /* f01b494: a2190000 */ sb $t9,0x0($s0) /* f01b498: 3c08800a */ lui $t0,0x800a /* f01b49c: 8d0821b8 */ lw $t0,0x21b8($t0) @@ -6874,7 +6874,7 @@ glabel func0f01b160 /* f01b4cc: 50400005 */ beqzl $v0,.L0f01b4e4 /* f01b4d0: 324b0008 */ andi $t3,$s2,0x8 /* f01b4d4: a2020000 */ sb $v0,0x0($s0) -/* f01b4d8: 0fc3fade */ jal func0f0feb78 +/* f01b4d8: 0fc3fade */ jal activemenuChangeScreen /* f01b4dc: a2000034 */ sb $zero,0x34($s0) /* f01b4e0: 324b0008 */ andi $t3,$s2,0x8 .L0f01b4e4: @@ -7279,7 +7279,7 @@ glabel func0f01b160 .L0f01ba38: /* f01ba38: 11a0001f */ beqz $t5,.L0f01bab8 /* f01ba3c: 00000000 */ sll $zero,$zero,0x0 -/* f01ba40: 0fc3fade */ jal func0f0feb78 +/* f01ba40: 0fc3fade */ jal activemenuChangeScreen /* f01ba44: 01a02025 */ or $a0,$t5,$zero /* f01ba48: 3c0e800a */ lui $t6,0x800a /* f01ba4c: 8dce21b8 */ lw $t6,0x21b8($t6) @@ -7307,7 +7307,7 @@ glabel func0f01b160 /* f01baa4: 00000000 */ sll $zero,$zero,0x0 /* f01baa8: 14400003 */ bnez $v0,.L0f01bab8 /* f01baac: 00000000 */ sll $zero,$zero,0x0 -/* f01bab0: 0fc3fade */ jal func0f0feb78 +/* f01bab0: 0fc3fade */ jal activemenuChangeScreen /* f01bab4: 83a400c7 */ lb $a0,0xc7($sp) .L0f01bab8: /* f01bab8: 3c19800a */ lui $t9,0x800a diff --git a/src/game/game_0f09f0.c b/src/game/game_0f09f0.c index 52cca67c5..092f8c73f 100644 --- a/src/game/game_0f09f0.c +++ b/src/game/game_0f09f0.c @@ -16327,102 +16327,47 @@ glabel func0f0fea14 /* f0feb74: 01801025 */ or $v0,$t4,$zero ); -GLOBAL_ASM( -glabel func0f0feb78 -/* f0feb78: 3c0e800a */ lui $t6,0x800a -/* f0feb7c: 8dce21b8 */ lw $t6,0x21b8($t6) -/* f0feb80: 3c18800a */ lui $t8,%hi(g_ActiveMenuThings) -/* f0feb84: 271820d0 */ addiu $t8,$t8,%lo(g_ActiveMenuThings) -/* f0feb88: 000e78c0 */ sll $t7,$t6,0x3 -/* f0feb8c: 01ee7823 */ subu $t7,$t7,$t6 -/* f0feb90: 000f78c0 */ sll $t7,$t7,0x3 -/* f0feb94: 3c03800a */ lui $v1,%hi(g_Vars) -/* f0feb98: 01f81021 */ addu $v0,$t7,$t8 -/* f0feb9c: 80590000 */ lb $t9,0x0($v0) -/* f0feba0: 24639fc0 */ addiu $v1,$v1,%lo(g_Vars) -/* f0feba4: 8c690318 */ lw $t1,0x318($v1) -/* f0feba8: 27bdffe8 */ addiu $sp,$sp,-24 -/* f0febac: 03244021 */ addu $t0,$t9,$a0 -/* f0febb0: afbf0014 */ sw $ra,0x14($sp) -/* f0febb4: 1120000f */ beqz $t1,.L0f0febf4 -/* f0febb8: a0480000 */ sb $t0,0x0($v0) -/* f0febbc: 3c0a800b */ lui $t2,0x800b -/* f0febc0: 8d4acb94 */ lw $t2,-0x346c($t2) -/* f0febc4: 314b0002 */ andi $t3,$t2,0x2 -/* f0febc8: 1160000a */ beqz $t3,.L0f0febf4 -/* f0febcc: 00000000 */ sll $zero,$zero,0x0 -/* f0febd0: 904c0032 */ lbu $t4,0x32($v0) -/* f0febd4: 51800004 */ beqzl $t4,.L0f0febe8 -/* f0febd8: 8c6d0284 */ lw $t5,0x284($v1) -/* f0febdc: 1000001f */ beqz $zero,.L0f0fec5c -/* f0febe0: 24040002 */ addiu $a0,$zero,0x2 -/* f0febe4: 8c6d0284 */ lw $t5,0x284($v1) -.L0f0febe8: -/* f0febe8: 91a41be6 */ lbu $a0,0x1be6($t5) -/* f0febec: 1000001b */ beqz $zero,.L0f0fec5c -/* f0febf0: 24840001 */ addiu $a0,$a0,0x1 -.L0f0febf4: -/* f0febf4: 3c0e800a */ lui $t6,0x800a -/* f0febf8: 81cfdfeb */ lb $t7,-0x2015($t6) -/* f0febfc: 05e1000e */ bgez $t7,.L0f0fec38 -/* f0fec00: 00000000 */ sll $zero,$zero,0x0 -/* f0fec04: 0fc3f7a3 */ jal func0f0fde8c -/* f0fec08: 00000000 */ sll $zero,$zero,0x0 -/* f0fec0c: 0440000a */ bltz $v0,.L0f0fec38 -/* f0fec10: 24040002 */ addiu $a0,$zero,0x2 -/* f0fec14: 3c18800a */ lui $t8,0x800a -/* f0fec18: 8f1821b8 */ lw $t8,0x21b8($t8) -/* f0fec1c: 3c08800a */ lui $t0,%hi(g_ActiveMenuThings) -/* f0fec20: 250820d0 */ addiu $t0,$t0,%lo(g_ActiveMenuThings) -/* f0fec24: 0018c8c0 */ sll $t9,$t8,0x3 -/* f0fec28: 0338c823 */ subu $t9,$t9,$t8 -/* f0fec2c: 0019c8c0 */ sll $t9,$t9,0x3 -/* f0fec30: 1000000a */ beqz $zero,.L0f0fec5c -/* f0fec34: 03281021 */ addu $v0,$t9,$t0 -.L0f0fec38: -/* f0fec38: 3c09800a */ lui $t1,0x800a -/* f0fec3c: 8d2921b8 */ lw $t1,0x21b8($t1) -/* f0fec40: 3c0b800a */ lui $t3,%hi(g_ActiveMenuThings) -/* f0fec44: 256b20d0 */ addiu $t3,$t3,%lo(g_ActiveMenuThings) -/* f0fec48: 000950c0 */ sll $t2,$t1,0x3 -/* f0fec4c: 01495023 */ subu $t2,$t2,$t1 -/* f0fec50: 000a50c0 */ sll $t2,$t2,0x3 -/* f0fec54: 014b1021 */ addu $v0,$t2,$t3 -/* f0fec58: 24040001 */ addiu $a0,$zero,0x1 -.L0f0fec5c: -/* f0fec5c: 80430000 */ lb $v1,0x0($v0) -/* f0fec60: 240c000a */ addiu $t4,$zero,0xa -/* f0fec64: 240dff85 */ addiu $t5,$zero,-123 -/* f0fec68: 0083082a */ slt $at,$a0,$v1 -/* f0fec6c: 10200003 */ beqz $at,.L0f0fec7c -/* f0fec70: 240e0004 */ addiu $t6,$zero,0x4 -/* f0fec74: a0400000 */ sb $zero,0x0($v0) -/* f0fec78: 80430000 */ lb $v1,0x0($v0) -.L0f0fec7c: -/* f0fec7c: 04630003 */ bgezl $v1,.L0f0fec8c -/* f0fec80: 44802000 */ mtc1 $zero,$f4 -/* f0fec84: a0440000 */ sb $a0,0x0($v0) -/* f0fec88: 44802000 */ mtc1 $zero,$f4 -.L0f0fec8c: -/* f0fec8c: a44c0002 */ sh $t4,0x2($v0) -/* f0fec90: a44d000a */ sh $t5,0xa($v0) -/* f0fec94: a04e000e */ sb $t6,0xe($v0) -/* f0fec98: ac400014 */ sw $zero,0x14($v0) -/* f0fec9c: ac400010 */ sw $zero,0x10($v0) -/* f0feca0: 0fc3fa85 */ jal func0f0fea14 -/* f0feca4: e4440018 */ swc1 $f4,0x18($v0) -/* f0feca8: 3c0f800a */ lui $t7,0x800a -/* f0fecac: 8def21b8 */ lw $t7,0x21b8($t7) -/* f0fecb0: 8fbf0014 */ lw $ra,0x14($sp) -/* f0fecb4: 3c01800a */ lui $at,0x800a -/* f0fecb8: 000fc0c0 */ sll $t8,$t7,0x3 -/* f0fecbc: 030fc023 */ subu $t8,$t8,$t7 -/* f0fecc0: 0018c0c0 */ sll $t8,$t8,0x3 -/* f0fecc4: 00380821 */ addu $at,$at,$t8 -/* f0fecc8: a42220d4 */ sh $v0,0x20d4($at) -/* f0feccc: 03e00008 */ jr $ra -/* f0fecd0: 27bd0018 */ addiu $sp,$sp,0x18 -); +void activemenuChangeScreen(s32 step) +{ + s32 maxscreenindex; + + g_ActiveMenuThings[g_ActiveMenuIndex].screenindex += step; + + if (g_Vars.unk000318 && (g_MpSetup.options & MPOPTION_TEAMSENABLED)) { + if (g_ActiveMenuThings[g_ActiveMenuIndex].unk32) { + // Weapon selection, second function, and ...? + maxscreenindex = 2; + } else { + // Num sims on team + 1 for weapon selection? + maxscreenindex = g_Vars.currentplayer->unk1be6 + 1; + } + } else { + // Solo missions, or MP with no teams + if (g_MissionConfig.iscoop && func0f0fde8c() >= 0) { + // Weapon selection, second function and AI buddy commands + maxscreenindex = 2; + } else { + // Weapon selection and second function + maxscreenindex = 1; + } + } + + if (g_ActiveMenuThings[g_ActiveMenuIndex].screenindex > maxscreenindex) { + g_ActiveMenuThings[g_ActiveMenuIndex].screenindex = 0; + } + + if (g_ActiveMenuThings[g_ActiveMenuIndex].screenindex < 0) { + g_ActiveMenuThings[g_ActiveMenuIndex].screenindex = maxscreenindex; + } + + g_ActiveMenuThings[g_ActiveMenuIndex].unk02 = 10; + g_ActiveMenuThings[g_ActiveMenuIndex].unk0a = -123; + g_ActiveMenuThings[g_ActiveMenuIndex].unk0e = 4; + g_ActiveMenuThings[g_ActiveMenuIndex].unk14 = 0; + g_ActiveMenuThings[g_ActiveMenuIndex].unk10 = 0; + g_ActiveMenuThings[g_ActiveMenuIndex].unk18 = 0; + g_ActiveMenuThings[g_ActiveMenuIndex].unk04 = func0f0fea14(); +} GLOBAL_ASM( glabel func0f0fecd4 @@ -16649,7 +16594,7 @@ glabel func0f0fef68 /* f0fefd8: a0400000 */ sb $zero,0x0($v0) /* f0fefdc: 0fc3fb35 */ jal func0f0fecd4 /* f0fefe0: e444001c */ swc1 $f4,0x1c($v0) -/* f0fefe4: 0fc3fade */ jal func0f0feb78 +/* f0fefe4: 0fc3fade */ jal activemenuChangeScreen /* f0fefe8: 00002025 */ or $a0,$zero,$zero /* f0fefec: 3c0d800a */ lui $t5,0x800a /* f0feff0: 8dad21b8 */ lw $t5,0x21b8($t5) diff --git a/src/include/game/game_0f09f0.h b/src/include/game/game_0f09f0.h index b5934883e..13fc68241 100644 --- a/src/include/game/game_0f09f0.h +++ b/src/include/game/game_0f09f0.h @@ -82,12 +82,12 @@ bool currentPlayerIsInTraining(void); void func0f0fd660(void); u32 func0f0fdd00(void); u32 func0f0fdd84(void); -u32 func0f0fde8c(void); +s32 func0f0fde8c(void); u32 func0f0fdf14(void); u32 func0f0fe280(void); u32 func0f0fe848(void); u32 func0f0fea14(void); -u32 func0f0feb78(void); +void activemenuChangeScreen(s32 step); u32 func0f0fecd4(void); u32 func0f0fef68(void); u32 func0f0ff040(void); diff --git a/src/include/types.h b/src/include/types.h index 1745796c3..2b0cfdaf5 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -2652,7 +2652,8 @@ struct player { /*0x1bd8*/ u32 unk1bd8; /*0x1bdc*/ u32 unk1bdc; /*0x1be0*/ u32 unk1be0; - /*0x1be4*/ u32 unk1be4; + /*0x1be4*/ u16 unk1be4; + /*0x1be6*/ u8 unk1be6; /*0x1be8*/ u32 unk1be8; /*0x1bec*/ u32 unk1bec; /*0x1bf0*/ u32 bondexploding; @@ -4632,13 +4633,17 @@ struct trainingdata { }; struct activemenuthing { - /*0x00*/ u32 unk00; - /*0x04*/ u32 unk04; - /*0x08*/ u32 unk08; - /*0x0c*/ u32 unk0c; + /*0x00*/ s8 screenindex; + /*0x02*/ u16 unk02; + /*0x04*/ s16 unk04; + /*0x06*/ u16 unk06; + /*0x08*/ u16 unk08; + /*0x0a*/ s16 unk0a; + /*0x0c*/ u16 unk0c; + /*0x0e*/ u8 unk0e; /*0x10*/ u32 unk10; /*0x14*/ u32 unk14; - /*0x18*/ u32 unk18; + /*0x18*/ f32 unk18; /*0x1c*/ u32 unk1c; /*0x20*/ u32 unk20; /*0x24*/ u32 unk24;