From 5d5e99655cf19633bc4243e3c3019512b8bd578d Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 8 Apr 2020 22:32:35 +1000 Subject: [PATCH] Decompile roomIsVisibleByAnyAibot --- src/game/chr/chraction.c | 2 +- src/game/chr/chraicommands.c | 4 +-- src/game/game_0601b0.c | 2 +- src/game/game_157db0.c | 51 +++++++++++----------------------- src/game/game_190260.c | 4 +-- src/include/constants.h | 10 +++---- src/include/game/game_157db0.h | 10 +++---- 7 files changed, 32 insertions(+), 51 deletions(-) diff --git a/src/game/chr/chraction.c b/src/game/chr/chraction.c index 07c969557..268137eea 100644 --- a/src/game/chr/chraction.c +++ b/src/game/chr/chraction.c @@ -30085,7 +30085,7 @@ glabel func0f04aeb0 /* f04aefc: 0011c040 */ sll $t8,$s1,0x1 /* f04af00: 84440000 */ lh $a0,0x0($v0) .L0f04af04: -/* f04af04: 0fc575ba */ jal roomIsActive +/* f04af04: 0fc575ba */ jal roomIsVisibleByAnyPlayer /* f04af08: 00000000 */ sll $zero,$zero,0x0 /* f04af0c: 50400004 */ beqzl $v0,.L0f04af20 /* f04af10: 86040002 */ lh $a0,0x2($s0) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index d047adea4..e9e7565d3 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -1512,7 +1512,7 @@ bool aiIfChrInActiveRoom(void) if (chr && chr->prop) { for (i = 0; chr->prop->rooms[i] != -1; i++) { - if (roomIsActive(chr->prop->rooms[i])) { + if (roomIsVisibleByAnyPlayer(chr->prop->rooms[i])) { pass = true; } } @@ -1537,7 +1537,7 @@ bool aiIfRoomActive(void) u16 pad_id = cmd[3] | (cmd[2] << 8); s32 room_id = chrGetPadRoom(g_Vars.chrdata, pad_id); - if (room_id >= 0 && roomIsActive(room_id)) { + if (room_id >= 0 && roomIsVisibleByAnyPlayer(room_id)) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[4]); } else { g_Vars.aioffset += 5; diff --git a/src/game/game_0601b0.c b/src/game/game_0601b0.c index aeabc7d4a..35d80db4b 100644 --- a/src/game/game_0601b0.c +++ b/src/game/game_0601b0.c @@ -4441,7 +4441,7 @@ glabel var7f1a9f2c /* f063e34: 028e8021 */ addu $s0,$s4,$t6 /* f063e38: 0fc456ac */ jal padUnpack /* f063e3c: 8e040008 */ lw $a0,0x8($s0) -/* f063e40: 0fc575ba */ jal roomIsActive +/* f063e40: 0fc575ba */ jal roomIsVisibleByAnyPlayer /* f063e44: 8fa400e8 */ lw $a0,0xe8($sp) /* f063e48: 104000b9 */ beqz $v0,.L0f064130 /* f063e4c: 00000000 */ sll $zero,$zero,0x0 diff --git a/src/game/game_157db0.c b/src/game/game_157db0.c index c8aa98ede..a1866d71b 100644 --- a/src/game/game_157db0.c +++ b/src/game/game_157db0.c @@ -6072,59 +6072,40 @@ void boxCopy(struct screenbox *dst, struct screenbox *src) dst->ymax = src->ymax; } -bool roomIsActive(s32 room_id) +bool roomIsVisibleByAnyPlayer(s32 room) { if (g_Vars.mplayerisrunning) { - return (g_MpRoomVisibility[room_id] & 0xf) != 0; + return (g_MpRoomVisibility[room] & 0xf) != 0; } - return g_Rooms[room_id].flags & ROOMFLAG_ACTIVE; + return g_Rooms[room].flags & ROOMFLAG_VISIBLEBYPLAYER; } -GLOBAL_ASM( -glabel func0f15d744 -/* f15d744: 3c0e800a */ lui $t6,%hi(g_Vars+0x314) -/* f15d748: 8dcea2d4 */ lw $t6,%lo(g_Vars+0x314)($t6) -/* f15d74c: 000450c0 */ sll $t2,$a0,0x3 -/* f15d750: 01445021 */ addu $t2,$t2,$a0 -/* f15d754: 11c00008 */ beqz $t6,.L0f15d778 -/* f15d758: 3c09800a */ lui $t1,%hi(g_Rooms) -/* f15d75c: 3c0f800a */ lui $t7,%hi(g_MpRoomVisibility) -/* f15d760: 8def492c */ lw $t7,%lo(g_MpRoomVisibility)($t7) -/* f15d764: 01e4c021 */ addu $t8,$t7,$a0 -/* f15d768: 93020000 */ lbu $v0,0x0($t8) -/* f15d76c: 305900f0 */ andi $t9,$v0,0xf0 -/* f15d770: 03e00008 */ jr $ra -/* f15d774: 0019102b */ sltu $v0,$zero,$t9 -.L0f15d778: -/* f15d778: 8d294928 */ lw $t1,%lo(g_Rooms)($t1) -/* f15d77c: 000a5080 */ sll $t2,$t2,0x2 -/* f15d780: 01445023 */ subu $t2,$t2,$a0 -/* f15d784: 000a5080 */ sll $t2,$t2,0x2 -/* f15d788: 012a5821 */ addu $t3,$t1,$t2 -/* f15d78c: 95620000 */ lhu $v0,0x0($t3) -/* f15d790: 304c0008 */ andi $t4,$v0,0x8 -/* f15d794: 01801025 */ or $v0,$t4,$zero -/* f15d798: 03e00008 */ jr $ra -/* f15d79c: 00000000 */ sll $zero,$zero,0x0 -); +bool roomIsVisibleByAnyAibot(s32 room) +{ + if (g_Vars.mplayerisrunning) { + return (g_MpRoomVisibility[room] & 0xf0) != 0; + } -bool roomIsVisibleByPlayer(u32 room, u32 playernum) + return g_Rooms[room].flags & ROOMFLAG_VISIBLEBYAIBOT; +} + +bool roomIsVisibleByPlayer(s32 room, u32 playernum) { if (g_Vars.mplayerisrunning) { return (g_MpRoomVisibility[room] & (1 << playernum)) != 0; } - return g_Rooms[room].flags & ROOMFLAG_ACTIVE; + return g_Rooms[room].flags & ROOMFLAG_VISIBLEBYPLAYER; } -bool roomIsVisibleByAibot(u32 room, u32 aibotindex) +bool roomIsVisibleByAibot(s32 room, u32 aibotindex) { if (g_Vars.mplayerisrunning) { return (g_MpRoomVisibility[room] & (0x10 << aibotindex)) != 0; } - return g_Rooms[room].flags & ROOMFLAG_0008; + return g_Rooms[room].flags & ROOMFLAG_VISIBLEBYAIBOT; } GLOBAL_ASM( @@ -14739,7 +14720,7 @@ glabel func0f164c64 /* f164e44: 27bd0040 */ addiu $sp,$sp,0x40 ); -void portalSetEnabled(u32 portal, bool enable) +void portalSetEnabled(s32 portal, bool enable) { g_Portals[portal].flags = (g_Portals[portal].flags | PORTALFLAG_ENABLED) ^ (enable != false); } diff --git a/src/game/game_190260.c b/src/game/game_190260.c index a74ade616..7d7b4cc00 100644 --- a/src/game/game_190260.c +++ b/src/game/game_190260.c @@ -1608,12 +1608,12 @@ glabel var7f1b8ef0 /* f191958: 01801825 */ or $v1,$t4,$zero /* f19195c: 85840028 */ lh $a0,0x28($t4) .L0f191960: -/* f191960: 0fc575ba */ jal roomIsActive +/* f191960: 0fc575ba */ jal roomIsVisibleByAnyPlayer /* f191964: afa30028 */ sw $v1,0x28($sp) /* f191968: 14400006 */ bnez $v0,.L0f191984 /* f19196c: 8fa30028 */ lw $v1,0x28($sp) /* f191970: 84640028 */ lh $a0,0x28($v1) -/* f191974: 0fc575d1 */ jal func0f15d744 +/* f191974: 0fc575d1 */ jal roomIsVisibleByAnyAibot /* f191978: afa30028 */ sw $v1,0x28($sp) /* f19197c: 10400005 */ beqz $v0,.L0f191994 /* f191980: 8fa30028 */ lw $v1,0x28($sp) diff --git a/src/include/constants.h b/src/include/constants.h index 05b3174da..ef655a4bf 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -1862,11 +1862,11 @@ #define RACE_EYESPY 3 #define RACE_ROBOT 4 -#define ROOMFLAG_DISABLED 0x0001 -#define ROOMFLAG_ACTIVE 0x0004 -#define ROOMFLAG_0008 0x0008 -#define ROOMFLAG_4000 0x4000 -#define ROOMFLAG_8000 0x8000 +#define ROOMFLAG_DISABLED 0x0001 +#define ROOMFLAG_VISIBLEBYPLAYER 0x0004 +#define ROOMFLAG_VISIBLEBYAIBOT 0x0008 +#define ROOMFLAG_4000 0x4000 +#define ROOMFLAG_8000 0x8000 #define SAVEFILEFLAG_P1_FORWARDPITCH 0x00 #define SAVEFILEFLAG_P1_AUTOAIM 0x01 diff --git a/src/include/game/game_157db0.h b/src/include/game/game_157db0.h index 379fe94eb..766b31f34 100644 --- a/src/include/game/game_157db0.h +++ b/src/include/game/game_157db0.h @@ -44,10 +44,10 @@ u32 func0f15d4a8(void); bool boxGetIntersection(struct screenbox *a, struct screenbox *b); void boxExpand(struct screenbox *a, struct screenbox *b); void boxCopy(struct screenbox *dst, struct screenbox *src); -bool roomIsActive(s32 room_id); -u32 func0f15d744(void); -bool roomIsVisibleByPlayer(u32 room, u32 playernum); -bool roomIsVisibleByAibot(u32 room, u32 aibotindex); +bool roomIsVisibleByAnyPlayer(s32 room); +bool roomIsVisibleByAnyAibot(s32 room); +bool roomIsVisibleByPlayer(s32 room, u32 playernum); +bool roomIsVisibleByAibot(s32 room, u32 aibotindex); u32 func0f15d870(void); u32 func0f15d9a8(void); u32 func0f15da00(void); @@ -96,7 +96,7 @@ u32 func0f1648cc(void); void portalSwapProps(u32 portal); u32 func0f164ab8(void); u32 func0f164c64(void); -void portalSetEnabled(u32 portal, bool enable); +void portalSetEnabled(s32 portal, bool enable); u32 func0f164e8c(void); u32 func0f164f9c(void); u32 func0f165004(void);