From 4447e09fc20c71831d1e4c6c08e91eb78ba36e4b Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 30 Nov 2020 00:13:25 +1000 Subject: [PATCH] Decompile func0f1646b8 --- src/game/game_157db0.c | 57 +++++++++------------------------- src/gvars/gvars.c | 2 +- src/include/game/game_157db0.h | 2 +- src/include/gvars/gvars.h | 2 +- 4 files changed, 17 insertions(+), 46 deletions(-) diff --git a/src/game/game_157db0.c b/src/game/game_157db0.c index b4a87c1b6..9151882d0 100644 --- a/src/game/game_157db0.c +++ b/src/game/game_157db0.c @@ -15222,49 +15222,20 @@ glabel func0f1645a8 /* f1646b4: 00601025 */ or $v0,$v1,$zero ); -GLOBAL_ASM( -glabel func0f1646b8 -/* f1646b8: 000478c0 */ sll $t7,$a0,0x3 -/* f1646bc: 01e47821 */ addu $t7,$t7,$a0 -/* f1646c0: 3c0e800a */ lui $t6,%hi(g_Rooms) -/* f1646c4: 8dce4928 */ lw $t6,%lo(g_Rooms)($t6) -/* f1646c8: 000f7880 */ sll $t7,$t7,0x2 -/* f1646cc: 01e47823 */ subu $t7,$t7,$a0 -/* f1646d0: 000f7880 */ sll $t7,$t7,0x2 -/* f1646d4: 01cf1821 */ addu $v1,$t6,$t7 -/* f1646d8: 80660005 */ lb $a2,0x5($v1) -/* f1646dc: 00001025 */ or $v0,$zero,$zero -/* f1646e0: 3c18800a */ lui $t8,%hi(var800a4ce0) -/* f1646e4: 18c00015 */ blez $a2,.L0f16473c -/* f1646e8: 3c07800a */ lui $a3,%hi(g_Portals) -/* f1646ec: 8479000e */ lh $t9,0xe($v1) -/* f1646f0: 8f184ce0 */ lw $t8,%lo(var800a4ce0)($t8) -/* f1646f4: 8ce74cc8 */ lw $a3,%lo(g_Portals)($a3) -/* f1646f8: 00194840 */ sll $t1,$t9,0x1 -/* f1646fc: 03092021 */ addu $a0,$t8,$t1 -.L0f164700: -/* f164700: 84830000 */ lh $v1,0x0($a0) -/* f164704: 24420001 */ addiu $v0,$v0,0x1 -/* f164708: 0046082a */ slt $at,$v0,$a2 -/* f16470c: 000350c0 */ sll $t2,$v1,0x3 -/* f164710: 00ea4021 */ addu $t0,$a3,$t2 -/* f164714: 850b0002 */ lh $t3,0x2($t0) -/* f164718: 10ab0004 */ beq $a1,$t3,.L0f16472c -/* f16471c: 00000000 */ nop -/* f164720: 850c0004 */ lh $t4,0x4($t0) -/* f164724: 14ac0003 */ bne $a1,$t4,.L0f164734 -/* f164728: 00000000 */ nop -.L0f16472c: -/* f16472c: 03e00008 */ jr $ra -/* f164730: 24020001 */ addiu $v0,$zero,0x1 -.L0f164734: -/* f164734: 1420fff2 */ bnez $at,.L0f164700 -/* f164738: 24840002 */ addiu $a0,$a0,0x2 -.L0f16473c: -/* f16473c: 00001025 */ or $v0,$zero,$zero -/* f164740: 03e00008 */ jr $ra -/* f164744: 00000000 */ nop -); +bool func0f1646b8(s32 roomnum, s32 arg1) +{ + s32 i; + + for (i = 0; i < g_Rooms[roomnum].unk05; i++) { + s32 portalnum = var800a4ce0[g_Rooms[roomnum].unk0e + i]; + + if (g_Portals[portalnum].unk02 == arg1 || g_Portals[portalnum].unk04 == arg1) { + return true; + } + } + + return false; +} GLOBAL_ASM( glabel func0f164748 diff --git a/src/gvars/gvars.c b/src/gvars/gvars.c index 72ae4d5a2..ebcd40c9b 100644 --- a/src/gvars/gvars.c +++ b/src/gvars/gvars.c @@ -15560,7 +15560,7 @@ u8 *var800a4cd0 = NULL; struct portalcmd *g_PortalCommands = NULL; u8 *g_LightsFileData = NULL; u32 var800a4cdc = 0; -u32 var800a4ce0 = 0; +s16 *var800a4ce0 = NULL; s16 var800a4ce4[2] = {0}; struct var800a4ce8 *var800a4ce8 = NULL; struct portalthing *g_PortalThings = NULL; diff --git a/src/include/game/game_157db0.h b/src/include/game/game_157db0.h index ef54eca87..75805a033 100644 --- a/src/include/game/game_157db0.h +++ b/src/include/game/game_157db0.h @@ -90,7 +90,7 @@ void func0f163e34(void); Gfx *func0f164150(Gfx *gdl); u32 func0f164534(void); u32 func0f1645a8(s16 room, s16 *rooms, u32 arg2); -u32 func0f1646b8(void); +bool func0f1646b8(s32 roomnum, s32 arg1); u32 func0f164748(void); u32 func0f1648cc(void); void portalSwapProps(u32 portal); diff --git a/src/include/gvars/gvars.h b/src/include/gvars/gvars.h index d69e2c835..b1f4d8d0e 100644 --- a/src/include/gvars/gvars.h +++ b/src/include/gvars/gvars.h @@ -734,7 +734,7 @@ extern struct var800a4ccc *var800a4ccc; // indexed by portalnum extern u8 *var800a4cd0; extern struct portalcmd *g_PortalCommands; extern u8 *g_LightsFileData; -extern u32 var800a4ce0; +extern s16 *var800a4ce0; // portal numbers extern s16 var800a4ce4[2]; extern struct var800a4ce8 *var800a4ce8; extern struct portalthing *g_PortalThings;