From ee71f500b350fdac2fd8d88adfd257c1c76ded43 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 27 Mar 2020 23:08:35 +1000 Subject: [PATCH] Decompile mpGetNumSimulants --- src/game/game_179060.c | 8 ++++---- src/game/mplayer.c | 33 +++++++++++---------------------- src/include/game/mplayer.h | 2 +- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/game/game_179060.c b/src/game/game_179060.c index 1d7a36598..02ee4d0d8 100644 --- a/src/game/game_179060.c +++ b/src/game/game_179060.c @@ -3711,7 +3711,7 @@ glabel var7f1b81e8 /* f17c7d8: 3c18800b */ lui $t8,%hi(g_MpSetup+0x16) /* f17c7dc: 05810007 */ bgez $t4,.L0f17c7fc /* f17c7e0: afac003c */ sw $t4,0x3c($sp) -/* f17c7e4: 0fc632ee */ jal func0f18cbb8 +/* f17c7e4: 0fc632ee */ jal mpGetNumSimulants /* f17c7e8: 00000000 */ sll $zero,$zero,0x0 /* f17c7ec: 240d0001 */ addiu $t5,$zero,0x1 /* f17c7f0: afa2003c */ sw $v0,0x3c($sp) @@ -6111,7 +6111,7 @@ glabel var7f1b82dc /* f17f2c0: 19e0000c */ blez $t7,.L0f17f2f4 /* f17f2c4: 00000000 */ sll $zero,$zero,0x0 .L0f17f2c8: -/* f17f2c8: 0fc632ee */ jal func0f18cbb8 +/* f17f2c8: 0fc632ee */ jal mpGetNumSimulants /* f17f2cc: 00000000 */ sll $zero,$zero,0x0 /* f17f2d0: 04400003 */ bltz $v0,.L0f17f2e0 /* f17f2d4: 00402025 */ or $a0,$v0,$zero @@ -6133,7 +6133,7 @@ glabel var7f1b82dc /* f17f30c: 1b20000c */ blez $t9,.L0f17f340 /* f17f310: 00000000 */ sll $zero,$zero,0x0 .L0f17f314: -/* f17f314: 0fc632ee */ jal func0f18cbb8 +/* f17f314: 0fc632ee */ jal mpGetNumSimulants /* f17f318: 00000000 */ sll $zero,$zero,0x0 /* f17f31c: 04400003 */ bltz $v0,.L0f17f32c /* f17f320: 00402025 */ or $a0,$v0,$zero @@ -6175,7 +6175,7 @@ glabel var7f1b82dc /* f17f3a0: 59200013 */ blezl $t1,.L0f17f3f0 /* f17f3a4: 26d6ffff */ addiu $s6,$s6,-1 .L0f17f3a8: -/* f17f3a8: 0fc632ee */ jal func0f18cbb8 +/* f17f3a8: 0fc632ee */ jal mpGetNumSimulants /* f17f3ac: 00000000 */ sll $zero,$zero,0x0 /* f17f3b0: 04400009 */ bltz $v0,.L0f17f3d8 /* f17f3b4: 00408025 */ or $s0,$v0,$zero diff --git a/src/game/mplayer.c b/src/game/mplayer.c index f0cd970d0..f9c1eb2c4 100644 --- a/src/game/mplayer.c +++ b/src/game/mplayer.c @@ -6152,28 +6152,17 @@ glabel func0f18cb60 /* f18cbb4: 00000000 */ sll $zero,$zero,0x0 ); -GLOBAL_ASM( -glabel func0f18cbb8 -/* f18cbb8: 3c02800b */ lui $v0,%hi(g_MpSetup+0x16) -/* f18cbbc: 9442cb9e */ lhu $v0,%lo(g_MpSetup+0x16)($v0) -/* f18cbc0: 00001825 */ or $v1,$zero,$zero -/* f18cbc4: 304e0010 */ andi $t6,$v0,0x10 -/* f18cbc8: 11c0000a */ beqz $t6,.L0f18cbf4 -/* f18cbcc: 00000000 */ sll $zero,$zero,0x0 -/* f18cbd0: 24630001 */ addiu $v1,$v1,0x1 -.L0f18cbd4: -/* f18cbd4: 28610007 */ slti $at,$v1,0x7 -/* f18cbd8: 10200006 */ beqz $at,.L0f18cbf4 -/* f18cbdc: 246f0004 */ addiu $t7,$v1,0x4 -/* f18cbe0: 24180001 */ addiu $t8,$zero,0x1 -/* f18cbe4: 01f8c804 */ sllv $t9,$t8,$t7 -/* f18cbe8: 00594024 */ and $t0,$v0,$t9 -/* f18cbec: 5500fff9 */ bnezl $t0,.L0f18cbd4 -/* f18cbf0: 24630001 */ addiu $v1,$v1,0x1 -.L0f18cbf4: -/* f18cbf4: 03e00008 */ jr $ra -/* f18cbf8: 00601025 */ or $v0,$v1,$zero -); +s32 mpGetNumSimulants(void) +{ + s32 i = 0; + + // @bug: This won't count the last simulant if there's 8 + while (i < MAX_SIMULANTS - 1 && g_MpSetup.chrslots & (1 << (i + 4))) { + i++; + } + + return i; +} void mpRemoveSimulant(s32 index) { diff --git a/src/include/game/mplayer.h b/src/include/game/mplayer.h index 70f672f34..976152140 100644 --- a/src/include/game/mplayer.h +++ b/src/include/game/mplayer.h @@ -85,7 +85,7 @@ u32 func0f18c87c(void); u32 func0f18c8b8(void); u32 func0f18c984(void); u32 func0f18cb60(void); -u32 func0f18cbb8(void); +s32 mpGetNumSimulants(void); void mpRemoveSimulant(s32 index); bool mpHasSimulants(void); u32 func0f18cc8c(void);