From 1f713a8c4c7375f651ff005ea9b8a55320f4335c Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 18 May 2021 19:57:19 +1000 Subject: [PATCH] Decompile func0f04aeb0 --- src/game/bg.c | 6 +-- src/game/chr/chraction.c | 81 +++++++++------------------------- src/include/game/bg.h | 2 +- src/include/game/game_0b4950.h | 2 +- src/include/game/game_1657c0.h | 2 +- 5 files changed, 26 insertions(+), 67 deletions(-) diff --git a/src/game/bg.c b/src/game/bg.c index ae6910955..80b181547 100644 --- a/src/game/bg.c +++ b/src/game/bg.c @@ -262,12 +262,12 @@ void func0f158108(s32 roomnum, u8 *arg1, u8 *arg2) *arg2 = g_BgRooms[roomnum].unk11; } -struct var800a4640_00 *func0f158140(s32 arg0) +struct var800a4640_00 *func0f158140(s32 roomnum) { s32 index = 60; - if (var8007fc3c == var800a4ce8[arg0].unk00) { - index = var800a4ce8[arg0].unk02; + if (var8007fc3c == var800a4ce8[roomnum].unk00) { + index = var800a4ce8[roomnum].unk02; } return &var800a4640.unk000[index]; diff --git a/src/game/chr/chraction.c b/src/game/chr/chraction.c index 3f45b685a..01d791e4c 100644 --- a/src/game/chr/chraction.c +++ b/src/game/chr/chraction.c @@ -30483,67 +30483,26 @@ bool chrSetPadPresetToPadOnRouteToTarget(struct chrdata *chr) return false; } -GLOBAL_ASM( -glabel func0f04aeb0 -/* f04aeb0: 27bdffd0 */ addiu $sp,$sp,-48 -/* f04aeb4: afbf0024 */ sw $ra,0x24($sp) -/* f04aeb8: afa50034 */ sw $a1,0x34($sp) -/* f04aebc: 240e0001 */ addiu $t6,$zero,0x1 -/* f04aec0: afb20020 */ sw $s2,0x20($sp) -/* f04aec4: afb1001c */ sw $s1,0x1c($sp) -/* f04aec8: afb00018 */ sw $s0,0x18($sp) -/* f04aecc: afa40030 */ sw $a0,0x30($sp) -/* f04aed0: afae002c */ sw $t6,0x2c($sp) -/* f04aed4: 0fc599be */ jal func0f1666f8 -/* f04aed8: 24050000 */ addiu $a1,$zero,0x0 -/* f04aedc: 50400023 */ beqzl $v0,.L0f04af6c -/* f04aee0: 8fbf0024 */ lw $ra,0x24($sp) -/* f04aee4: 8fa20034 */ lw $v0,0x34($sp) -/* f04aee8: 2412ffff */ addiu $s2,$zero,-1 -/* f04aeec: 00008825 */ or $s1,$zero,$zero -/* f04aef0: 844f0000 */ lh $t7,0x0($v0) -/* f04aef4: 00408025 */ or $s0,$v0,$zero -/* f04aef8: 524f000f */ beql $s2,$t7,.L0f04af38 -/* f04aefc: 0011c040 */ sll $t8,$s1,0x1 -/* f04af00: 84440000 */ lh $a0,0x0($v0) -.L0f04af04: -/* f04af04: 0fc575ba */ jal roomIsVisibleByAnyPlayer -/* f04af08: 00000000 */ nop -/* f04af0c: 50400004 */ beqzl $v0,.L0f04af20 -/* f04af10: 86040002 */ lh $a0,0x2($s0) -/* f04af14: 10000007 */ b .L0f04af34 -/* f04af18: 8fa20034 */ lw $v0,0x34($sp) -/* f04af1c: 86040002 */ lh $a0,0x2($s0) -.L0f04af20: -/* f04af20: 26310001 */ addiu $s1,$s1,0x1 -/* f04af24: 26100002 */ addiu $s0,$s0,0x2 -/* f04af28: 1644fff6 */ bne $s2,$a0,.L0f04af04 -/* f04af2c: 00000000 */ nop -/* f04af30: 8fa20034 */ lw $v0,0x34($sp) -.L0f04af34: -/* f04af34: 0011c040 */ sll $t8,$s1,0x1 -.L0f04af38: -/* f04af38: 0058c821 */ addu $t9,$v0,$t8 -/* f04af3c: 87240000 */ lh $a0,0x0($t9) -/* f04af40: 5244000a */ beql $s2,$a0,.L0f04af6c -/* f04af44: 8fbf0024 */ lw $ra,0x24($sp) -/* f04af48: 0fc56050 */ jal func0f158140 -/* f04af4c: 00000000 */ nop -/* f04af50: 8fa40030 */ lw $a0,0x30($sp) -/* f04af54: 3c054348 */ lui $a1,0x4348 -/* f04af58: 0fc2d74e */ jal func0f0b5d38 -/* f04af5c: 00403025 */ or $a2,$v0,$zero -/* f04af60: 2c480001 */ sltiu $t0,$v0,0x1 -/* f04af64: afa8002c */ sw $t0,0x2c($sp) -/* f04af68: 8fbf0024 */ lw $ra,0x24($sp) -.L0f04af6c: -/* f04af6c: 8fa2002c */ lw $v0,0x2c($sp) -/* f04af70: 8fb00018 */ lw $s0,0x18($sp) -/* f04af74: 8fb1001c */ lw $s1,0x1c($sp) -/* f04af78: 8fb20020 */ lw $s2,0x20($sp) -/* f04af7c: 03e00008 */ jr $ra -/* f04af80: 27bd0030 */ addiu $sp,$sp,0x30 -); +bool func0f04aeb0(struct coord *pos, s16 *rooms) +{ + bool result = true; + s32 i; + + if (func0f1666f8(pos, 0)) { + for (i = 0; rooms[i] != -1; i++) { + if (roomIsVisibleByAnyPlayer(rooms[i])) { + break; + } + } + + if (rooms[i] != -1) { + // Room is visible by player + result = !func0f0b5d38(pos, 200, func0f158140(rooms[i])); + } + } + + return result; +} /** * Test if a chr can be spawned into or nearby the given position, taking into diff --git a/src/include/game/bg.h b/src/include/game/bg.h index 6ae400f7d..aaa564171 100644 --- a/src/include/game/bg.h +++ b/src/include/game/bg.h @@ -7,7 +7,7 @@ void roomMovePropsToList1(u32 roomnum, bool tintedglassonly); void func0f157e94(s32 room, s32 arg1, struct screenbox *arg2); void func0f158108(s32 roomnum, u8 *arg1, u8 *arg2); -struct var800a4640_00 *func0f158140(s32 index); +struct var800a4640_00 *func0f158140(s32 roomnum); u32 func0f158184(void); u32 func0f158400(void); u32 func0f158884(void); diff --git a/src/include/game/game_0b4950.h b/src/include/game/game_0b4950.h index d182357e9..1985e4229 100644 --- a/src/include/game/game_0b4950.h +++ b/src/include/game/game_0b4950.h @@ -42,7 +42,7 @@ f32 currentPlayerGetScreenTop(void); f32 currentPlayerGetPerspAspect(void); void func0f0b5838(void); u32 func0f0b5b9c(void); -u32 func0f0b5d38(void); +bool func0f0b5d38(struct coord *pos, f32 arg1, struct var800a4640_00 *arg2); u32 func0f0b6260(void); #endif diff --git a/src/include/game/game_1657c0.h b/src/include/game/game_1657c0.h index 61f8d9978..0684065b2 100644 --- a/src/include/game/game_1657c0.h +++ b/src/include/game/game_1657c0.h @@ -14,7 +14,7 @@ void func0f165eec(s32 stagenum, s32 arg1); void func0f1660a4(f32 arg0); Gfx *func0f1664a0(Gfx *gdl, u32 arg1); Gfx *gfxConsiderDisableFog(Gfx *gdl); -u32 func0f1666f8(void); +bool func0f1666f8(struct coord *pos, f32 arg1); u32 func0f1667e8(void); s32 func0f1667f4(struct prop *prop, f32 *arg1);