From 8ee7fcffab2231716b4bbe683928c0406f1371ae Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 11 Jan 2021 09:18:50 +1000 Subject: [PATCH] Decompile func0002a9f0 --- src/game/bondwalk.c | 6 +-- src/include/game/bondwalk.h | 2 +- src/include/lib/lib_233c0.h | 6 +-- src/lib/lib_233c0.c | 77 ++++++++++--------------------------- 4 files changed, 27 insertions(+), 64 deletions(-) diff --git a/src/game/bondwalk.c b/src/game/bondwalk.c index ef73f42a4..893430f00 100644 --- a/src/game/bondwalk.c +++ b/src/game/bondwalk.c @@ -377,15 +377,13 @@ bool bwalkCalculateNewPosition(struct coord *vel, f32 rotateamount, bool apply, if (valid == true) { valid = func0002a9f0(&g_Vars.currentplayer->prop->pos, - &dstpos, - width, dstrooms, sp60, 1, + &dstpos, width, dstrooms, sp60, 1, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y); } } else { valid = func0002a9f0(&g_Vars.currentplayer->prop->pos, - &dstpos, - width, sp64, sp60, 1, + &dstpos, width, sp64, sp60, 1, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y); } diff --git a/src/include/game/bondwalk.h b/src/include/game/bondwalk.h index 61abe38d9..e0ae3764a 100644 --- a/src/include/game/bondwalk.h +++ b/src/include/game/bondwalk.h @@ -8,7 +8,7 @@ void currentPlayerSetSwayTarget(s32 value); void currentPlayerAdjustCrouchPos(s32 value); void func0f0c3b38(struct coord *param_1, struct defaultobj *obj); bool currentPlayerHasGapToCeiling(f32 y); -bool bwalkCalculateNewPosition(struct coord *vel, f32 arg1, bool arg2, f32 arg3, s32 arg4); +bool bwalkCalculateNewPosition(struct coord *vel, f32 rotateamount, bool apply, f32 extrawidth, s32 arg4); bool func0f0c4250(struct coord *delta, f32 arg1, bool arg2, f32 arg3, s32 arg4); bool func0f0c4764(struct coord *delta, struct coord *arg1, struct coord *arg2, s32 arg3); s32 func0f0c47d0(struct coord *a, struct coord *b, struct coord *c, struct coord *d, struct coord *e, s32 arg6); diff --git a/src/include/lib/lib_233c0.h b/src/include/lib/lib_233c0.h index eb814c8fb..ccf31e478 100644 --- a/src/include/lib/lib_233c0.h +++ b/src/include/lib/lib_233c0.h @@ -72,8 +72,8 @@ u32 func0002840c(void); u32 func00028638(void); u32 func0002885c(void); u32 func00028914(void); -u32 func00028df0(void); -u32 func0002901c(void); +void func00028df0(struct coord *dstpos, f32 width, s16 *dstrooms, s32 arg3, s32 arg4, s32 arg5, f32 ymax, f32 ymin, s32 *arg8, s32 arg9); +void func0002901c(struct coord *pos, struct coord *dist, f32 width, s32 *arg3); f32 func000296a0(u32 *arg0, struct coord *pos, struct tilething **arg2, f32 width); bool func00029ffc(struct coord *pos, f32 width, f32 foreheadheight, f32 inversefeettoeyesheight, s16 *rooms, u32 arg5, struct coord *laddernormal); u32 func0002a13c(void); @@ -87,7 +87,7 @@ s32 func0002a564(struct coord *pos, s16 *rooms, f32 *arg2, u32 arg3, struct coor u32 func0002a5e4(void); s32 func0002a684(struct coord *pos, f32 width, s16 *rooms, s32 arg3, s32 arg4, f32 arg5, f32 arg6); u32 func0002a6fc(void); -s32 func0002a9f0(struct coord *pos, struct coord *arg1, f32 arg2, s16 *arg3, s32 arg4, s32 arg5, f32 arg6, f32 arg7); +s32 func0002a9f0(struct coord *origpos, struct coord *dstpos, f32 width, s16 *dstrooms, s32 arg4, s32 arg5, f32 ymax, f32 ymin); u32 func0002aac0(void); u32 func0002ab98(void); u32 func0002ac70(void); diff --git a/src/lib/lib_233c0.c b/src/lib/lib_233c0.c index 68a2df702..a67f91f7f 100644 --- a/src/lib/lib_233c0.c +++ b/src/lib/lib_233c0.c @@ -8307,62 +8307,27 @@ glabel func0002a6fc /* 2a9ec: 27bd00a8 */ addiu $sp,$sp,0xa8 ); -GLOBAL_ASM( -glabel func0002a9f0 -/* 2a9f0: 27bdfe18 */ addiu $sp,$sp,-488 -/* 2a9f4: afa401e8 */ sw $a0,0x1e8($sp) -/* 2a9f8: afa501ec */ sw $a1,0x1ec($sp) -/* 2a9fc: 00a02025 */ or $a0,$a1,$zero -/* 2aa00: 8fb801fc */ lw $t8,0x1fc($sp) -/* 2aa04: c7a40200 */ lwc1 $f4,0x200($sp) -/* 2aa08: c7a60204 */ lwc1 $f6,0x204($sp) -/* 2aa0c: afa601f0 */ sw $a2,0x1f0($sp) -/* 2aa10: 00c02825 */ or $a1,$a2,$zero -/* 2aa14: afbf002c */ sw $ra,0x2c($sp) -/* 2aa18: afa701f4 */ sw $a3,0x1f4($sp) -/* 2aa1c: 240e0001 */ addiu $t6,$zero,0x1 -/* 2aa20: 00e03025 */ or $a2,$a3,$zero -/* 2aa24: 27b90044 */ addiu $t9,$sp,0x44 -/* 2aa28: 240f0004 */ addiu $t7,$zero,0x4 -/* 2aa2c: 24080014 */ addiu $t0,$zero,0x14 -/* 2aa30: afae0034 */ sw $t6,0x34($sp) -/* 2aa34: afa80024 */ sw $t0,0x24($sp) -/* 2aa38: afaf0010 */ sw $t7,0x10($sp) -/* 2aa3c: afb90020 */ sw $t9,0x20($sp) -/* 2aa40: 8fa701f8 */ lw $a3,0x1f8($sp) -/* 2aa44: afb80014 */ sw $t8,0x14($sp) -/* 2aa48: e7a40018 */ swc1 $f4,0x18($sp) -/* 2aa4c: 0c00a37c */ jal func00028df0 -/* 2aa50: e7a6001c */ swc1 $f6,0x1c($sp) -/* 2aa54: 8fa90044 */ lw $t1,0x44($sp) -/* 2aa58: 8fa201ec */ lw $v0,0x1ec($sp) -/* 2aa5c: 8fa401e8 */ lw $a0,0x1e8($sp) -/* 2aa60: 51200013 */ beqzl $t1,.L0002aab0 -/* 2aa64: 8fbf002c */ lw $ra,0x2c($sp) -/* 2aa68: afa00034 */ sw $zero,0x34($sp) -/* 2aa6c: c48a0000 */ lwc1 $f10,0x0($a0) -/* 2aa70: c4480000 */ lwc1 $f8,0x0($v0) -/* 2aa74: 27a50038 */ addiu $a1,$sp,0x38 -/* 2aa78: 8fa601f0 */ lw $a2,0x1f0($sp) -/* 2aa7c: 460a4401 */ sub.s $f16,$f8,$f10 -/* 2aa80: 27a70044 */ addiu $a3,$sp,0x44 -/* 2aa84: e7b00038 */ swc1 $f16,0x38($sp) -/* 2aa88: c4840004 */ lwc1 $f4,0x4($a0) -/* 2aa8c: c4520004 */ lwc1 $f18,0x4($v0) -/* 2aa90: 46049181 */ sub.s $f6,$f18,$f4 -/* 2aa94: e7a6003c */ swc1 $f6,0x3c($sp) -/* 2aa98: c48a0008 */ lwc1 $f10,0x8($a0) -/* 2aa9c: c4480008 */ lwc1 $f8,0x8($v0) -/* 2aaa0: 460a4401 */ sub.s $f16,$f8,$f10 -/* 2aaa4: 0c00a407 */ jal func0002901c -/* 2aaa8: e7b00040 */ swc1 $f16,0x40($sp) -/* 2aaac: 8fbf002c */ lw $ra,0x2c($sp) -.L0002aab0: -/* 2aab0: 8fa20034 */ lw $v0,0x34($sp) -/* 2aab4: 27bd01e8 */ addiu $sp,$sp,0x1e8 -/* 2aab8: 03e00008 */ jr $ra -/* 2aabc: 00000000 */ nop -); +s32 func0002a9f0(struct coord *origpos, struct coord *dstpos, f32 width, s16 *dstrooms, s32 arg4, s32 arg5, f32 ymax, f32 ymin) +{ + u32 stack[104]; + s32 sp44; + struct coord dist; + s32 result = 1; + + func00028df0(dstpos, width, dstrooms, arg4, 4, arg5, ymax, ymin, &sp44, 20); + + if (sp44) { + result = 0; + + dist.x = dstpos->x - origpos->x; + dist.y = dstpos->y - origpos->y; + dist.z = dstpos->z - origpos->z; + + func0002901c(origpos, &dist, width, &sp44); + } + + return result; +} GLOBAL_ASM( glabel func0002aac0