From bec3673da8e610f7e06c996c25db61d24a17f91a Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 24 Nov 2020 00:33:27 +1000 Subject: [PATCH] Decompile currentPlayerUpdatePerimInfo --- src/game/bondbike.c | 2 +- src/game/bondgrab.c | 2 +- src/game/bondwalk.c | 2 +- src/game/chr/chr.c | 4 +- src/game/game_0b63b0.c | 78 +++++++++++----------------------- src/game/propobj.c | 4 +- src/include/game/game_0b63b0.h | 2 +- src/include/types.h | 30 +++++-------- 8 files changed, 42 insertions(+), 82 deletions(-) diff --git a/src/game/bondbike.c b/src/game/bondbike.c index 02f9e8105..d2166fadd 100644 --- a/src/game/bondbike.c +++ b/src/game/bondbike.c @@ -2535,7 +2535,7 @@ glabel var7f1adb9c /* f0d4644: 46043302 */ mul.s $f12,$f6,$f4 /* f0d4648: 0fc288a4 */ jal func0f0a2290 /* f0d464c: 00000000 */ nop -/* f0d4650: 0fc307fd */ jal func0f0c1ff4 +/* f0d4650: 0fc307fd */ jal currentPlayerUpdatePerimInfo /* f0d4654: 00000000 */ nop /* f0d4658: 0fc32e31 */ jal func0f0cb8c4 /* f0d465c: 8e040284 */ lw $a0,0x284($s0) diff --git a/src/game/bondgrab.c b/src/game/bondgrab.c index 1b470bee4..036fcf11c 100644 --- a/src/game/bondgrab.c +++ b/src/game/bondgrab.c @@ -2271,7 +2271,7 @@ glabel var7f1ada30 /* f0cefe8: 8d8400bc */ lw $a0,0xbc($t4) /* f0cefec: 0fc33067 */ jal func0f0cc19c /* f0ceff0: 24840008 */ addiu $a0,$a0,0x8 -/* f0ceff4: 0fc307fd */ jal func0f0c1ff4 +/* f0ceff4: 0fc307fd */ jal currentPlayerUpdatePerimInfo /* f0ceff8: 00000000 */ nop /* f0ceffc: 0fc23064 */ jal func0f08c190 /* f0cf000: 00000000 */ nop diff --git a/src/game/bondwalk.c b/src/game/bondwalk.c index 574dab68b..97b2ea754 100644 --- a/src/game/bondwalk.c +++ b/src/game/bondwalk.c @@ -3079,6 +3079,6 @@ void func0f0c785c(void) func0f0cc19c(&g_Vars.currentplayer->prop->pos); } - func0f0c1ff4(); + currentPlayerUpdatePerimInfo(); func0f08c190(); } diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index 5410e2d85..a101e375f 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -10274,9 +10274,9 @@ bool chrUpdateGeometry(struct prop *prop, struct geo **arg1, struct geo **arg2) chr->geo.type = PROPTYPE_CHR; if (chr->actiontype == ACT_DIE || chr->actiontype == ACT_DRUGGEDDROP) { - chr->geo.unk136 = 16; + chr->geo.unk02 = 16; } else { - chr->geo.unk136 = 20; + chr->geo.unk02 = 20; } chr->geo.ymin = chr->manground; diff --git a/src/game/game_0b63b0.c b/src/game/game_0b63b0.c index 0f6b8ba6b..41303451a 100644 --- a/src/game/game_0b63b0.c +++ b/src/game/game_0b63b0.c @@ -2609,7 +2609,7 @@ glabel var7f1ad574 /* f0b8558: 0fc2e2e8 */ jal func0f0b8ba0 /* f0b855c: 00000000 */ nop .L0f0b8560: -/* f0b8560: 0fc307fd */ jal func0f0c1ff4 +/* f0b8560: 0fc307fd */ jal currentPlayerUpdatePerimInfo /* f0b8564: 00000000 */ nop /* f0b8568: 8fbf004c */ lw $ra,0x4c($sp) /* f0b856c: d7b40018 */ ldc1 $f20,0x18($sp) @@ -13499,59 +13499,29 @@ glabel func0f0c1f08 /* f0c1ff0: 00000000 */ nop ); -GLOBAL_ASM( -glabel func0f0c1ff4 -/* f0c1ff4: 3c03800a */ lui $v1,%hi(g_Vars) -/* f0c1ff8: 24639fc0 */ addiu $v1,$v1,%lo(g_Vars) -/* f0c1ffc: 8c6f0284 */ lw $t7,0x284($v1) -/* f0c2000: 240e0003 */ addiu $t6,$zero,0x3 -/* f0c2004: 24180014 */ addiu $t8,$zero,0x14 -/* f0c2008: a1ee19cc */ sb $t6,0x19cc($t7) -/* f0c200c: 8c790284 */ lw $t9,0x284($v1) -/* f0c2010: a73819ce */ sh $t8,0x19ce($t9) -/* f0c2014: 8c620284 */ lw $v0,0x284($v1) -/* f0c2018: c4440074 */ lwc1 $f4,0x74($v0) -/* f0c201c: e44419d4 */ swc1 $f4,0x19d4($v0) -/* f0c2020: 8c620284 */ lw $v0,0x284($v1) -/* f0c2024: c4460074 */ lwc1 $f6,0x74($v0) -/* f0c2028: c44819c0 */ lwc1 $f8,0x19c0($v0) -/* f0c202c: 46083280 */ add.s $f10,$f6,$f8 -/* f0c2030: e44a19d0 */ swc1 $f10,0x19d0($v0) -/* f0c2034: 8c620284 */ lw $v0,0x284($v1) -/* f0c2038: 8c4801b0 */ lw $t0,0x1b0($v0) -/* f0c203c: 55000014 */ bnezl $t0,.L0f0c2090 -/* f0c2040: 8c4a00bc */ lw $t2,0xbc($v0) -/* f0c2044: 8c4919b8 */ lw $t1,0x19b8($v0) -/* f0c2048: c45019d0 */ lwc1 $f16,0x19d0($v0) -/* f0c204c: 3c0142a0 */ lui $at,0x42a0 -/* f0c2050: 44899000 */ mtc1 $t1,$f18 -/* f0c2054: 44815000 */ mtc1 $at,$f10 -/* f0c2058: 46809120 */ cvt.s.w $f4,$f18 -/* f0c205c: 46048180 */ add.s $f6,$f16,$f4 -/* f0c2060: e44619d0 */ swc1 $f6,0x19d0($v0) -/* f0c2064: 8c620284 */ lw $v0,0x284($v1) -/* f0c2068: c4480074 */ lwc1 $f8,0x74($v0) -/* f0c206c: c45219d0 */ lwc1 $f18,0x19d0($v0) -/* f0c2070: 460a4000 */ add.s $f0,$f8,$f10 -/* f0c2074: 4600903c */ c.lt.s $f18,$f0 -/* f0c2078: 00000000 */ nop -/* f0c207c: 45020004 */ bc1fl .L0f0c2090 -/* f0c2080: 8c4a00bc */ lw $t2,0xbc($v0) -/* f0c2084: e44019d0 */ swc1 $f0,0x19d0($v0) -/* f0c2088: 8c620284 */ lw $v0,0x284($v1) -/* f0c208c: 8c4a00bc */ lw $t2,0xbc($v0) -.L0f0c2090: -/* f0c2090: c5500008 */ lwc1 $f16,0x8($t2) -/* f0c2094: e45019d8 */ swc1 $f16,0x19d8($v0) -/* f0c2098: 8c620284 */ lw $v0,0x284($v1) -/* f0c209c: 8c4b00bc */ lw $t3,0xbc($v0) -/* f0c20a0: c5640010 */ lwc1 $f4,0x10($t3) -/* f0c20a4: e44419dc */ swc1 $f4,0x19dc($v0) -/* f0c20a8: 8c620284 */ lw $v0,0x284($v1) -/* f0c20ac: c4460378 */ lwc1 $f6,0x378($v0) -/* f0c20b0: 03e00008 */ jr $ra -/* f0c20b4: e44619e0 */ swc1 $f6,0x19e0($v0) -); +void currentPlayerUpdatePerimInfo(void) +{ + g_Vars.currentplayer->periminfo.type = 3; + g_Vars.currentplayer->periminfo.unk02 = 20; + + g_Vars.currentplayer->periminfo.ymin = g_Vars.currentplayer->vv_manground; + g_Vars.currentplayer->periminfo.ymax = g_Vars.currentplayer->vv_manground + g_Vars.currentplayer->vv_headheight; + + if (g_Vars.currentplayer->bondmovemode == MOVEMODE_WALK) { + // note: crouchoffsetrealsmall is negative + f32 minsane; + g_Vars.currentplayer->periminfo.ymax += g_Vars.currentplayer->crouchoffsetrealsmall; + minsane = g_Vars.currentplayer->vv_manground + 80; + + if (g_Vars.currentplayer->periminfo.ymax < minsane) { + g_Vars.currentplayer->periminfo.ymax = minsane; + } + } + + g_Vars.currentplayer->periminfo.x = g_Vars.currentplayer->prop->pos.x; + g_Vars.currentplayer->periminfo.z = g_Vars.currentplayer->prop->pos.z; + g_Vars.currentplayer->periminfo.width = g_Vars.currentplayer->bond2.width; +} /** * Populates the width, ymax and ymin arguments with absolute coordinates. diff --git a/src/game/propobj.c b/src/game/propobj.c index 29b6e4c59..e5017c5be 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -20213,7 +20213,7 @@ glabel var7f1aa454 /* f077a14: 24050001 */ addiu $a1,$zero,0x1 /* f077a18: 0fc318ef */ jal func0f0c63bc /* f077a1c: 24060020 */ addiu $a2,$zero,0x20 -/* f077a20: 0fc307fd */ jal func0f0c1ff4 +/* f077a20: 0fc307fd */ jal currentPlayerUpdatePerimInfo /* f077a24: 00000000 */ nop /* f077a28: 0fc32e31 */ jal func0f0cb8c4 /* f077a2c: 8e440064 */ lw $a0,0x64($s2) @@ -20307,7 +20307,7 @@ glabel var7f1aa454 /* f077b80: 46188203 */ div.s $f8,$f16,$f24 /* f077b84: e6080070 */ swc1 $f8,0x70($s0) .L0f077b88: -/* f077b88: 0fc307fd */ jal func0f0c1ff4 +/* f077b88: 0fc307fd */ jal currentPlayerUpdatePerimInfo /* f077b8c: 00000000 */ nop /* f077b90: 0fc32e31 */ jal func0f0cb8c4 /* f077b94: 8e440064 */ lw $a0,0x64($s2) diff --git a/src/include/game/game_0b63b0.h b/src/include/game/game_0b63b0.h index 7551a2846..5d92fca40 100644 --- a/src/include/game/game_0b63b0.h +++ b/src/include/game/game_0b63b0.h @@ -75,7 +75,7 @@ void func0f0c1bd8(struct coord *pos, struct coord *up, struct coord *look); void func0f0c1d20(void); void func0f0c1e54(struct prop *prop, bool enable); u32 func0f0c1f08(void); -void func0f0c1ff4(void); +void currentPlayerUpdatePerimInfo(void); void propPlayerGetBbox(struct prop *prop, f32 *width, f32 *ymax, f32 *ymin); f32 currentPlayerGetHealth(void); f32 currentPlayerGetShieldFrac(void); diff --git a/src/include/types.h b/src/include/types.h index cd0c6a01e..f4762a1b7 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -832,14 +832,14 @@ struct act_skjump { }; struct geo { - /*0x134*/ u8 type; - /*0x135*/ u8 unk01; - /*0x136*/ u16 unk136; - /*0x138*/ f32 ymax; - /*0x13c*/ f32 ymin; - /*0x140*/ f32 x; - /*0x144*/ f32 z; - /*0x148*/ f32 width; + /*0x00*/ u8 type; + /*0x01*/ u8 unk01; + /*0x02*/ u16 unk02; + /*0x04*/ f32 ymax; + /*0x08*/ f32 ymin; + /*0x0c*/ f32 x; + /*0x10*/ f32 z; + /*0x14*/ f32 width; }; struct chrdata { @@ -2687,18 +2687,8 @@ struct player { /*0x19c0*/ f32 vv_headheight; // 172 when Jo, regardless of crouch state /*0x19c4*/ f32 vv_eyeheight; // 159 when Jo, regardless of crouch state /*0x19c8*/ bool haschrbody; - /*0x19cc*/ u32 unk19cc; - /*0x19d0*/ u32 unk19d0; - /*0x19d4*/ u32 unk19d4; - /*0x19d8*/ u32 unk19d8; - /*0x19dc*/ u32 unk19dc; - /*0x19e0*/ u32 unk19e0; - /*0x19e4*/ u32 unk19e4; - /*0x19e8*/ u32 unk19e8; - /*0x19ec*/ u32 unk19ec; - /*0x19f0*/ u32 unk19f0; - /*0x19f4*/ u32 unk19f4; - /*0x19f8*/ u32 unk19f8; + /*0x19cc*/ struct geo periminfo; + /*0x19e4*/ struct geo perimshoot; /*0x19fc*/ f32 bondprevtheta; /*0x1a00*/ struct coord grabbedprevpos; /*0x1a0c*/ f32 grabbedrotoffset;