From f63ebddd68e414ea1cbba4c67e7f61cb7976c25a Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 12 Jun 2020 19:31:27 +1000 Subject: [PATCH] Decompile explosionGetBboxAtFrame --- src/game/chr/chraction.c | 2 +- src/game/chr/chraicommands.c | 4 +- src/game/explosion.c | 95 +++++++++------------------------- src/game/game_00c490.c | 4 +- src/game/game_011110.c | 4 +- src/game/game_0147d0.c | 2 +- src/game/game_02cde0.c | 4 +- src/game/game_0601b0.c | 4 +- src/game/game_097ba0.c | 2 +- src/game/game_12d3f0.c | 2 +- src/game/game_17f930.c | 2 +- src/game/propobj.c | 4 +- src/include/constants.h | 10 ++-- src/include/game/explosion.h | 4 +- src/include/game/game_0601b0.h | 2 +- src/include/types.h | 2 + 16 files changed, 52 insertions(+), 95 deletions(-) diff --git a/src/game/chr/chraction.c b/src/game/chr/chraction.c index 537fbfba1..40dd47a6e 100644 --- a/src/game/chr/chraction.c +++ b/src/game/chr/chraction.c @@ -28998,7 +28998,7 @@ glabel chrSpawnAtCoord /* f04b3cc: 00402025 */ or $a0,$v0,$zero /* f04b3d0: 0fc1814e */ jal func0f060538 /* f04b3d4: afa20074 */ sw $v0,0x74($sp) -/* f04b3d8: 0fc180bc */ jal propHide +/* f04b3d8: 0fc180bc */ jal propShow /* f04b3dc: 8fa40074 */ lw $a0,0x74($sp) /* f04b3e0: 8faf0074 */ lw $t7,0x74($sp) /* f04b3e4: 8fb8007c */ lw $t8,0x7c($sp) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index aef696ae9..604cf3ee6 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -5379,7 +5379,7 @@ bool aiShowChr(void) if (chr && chr->prop && chr->model) { func0f0604bc(chr->prop); - propHide(chr->prop); + propShow(chr->prop); func0f0220ac(chr); } @@ -5417,7 +5417,7 @@ bool aiShowObj(void) if (obj && obj->prop && obj->model) { func0f0604bc(obj->prop); - propHide(obj->prop); + propShow(obj->prop); if (g_Vars.currentplayer->eyespy == NULL && obj->type == OBJTYPE_WEAPON) { struct weaponobj *weapon = (struct weaponobj *) obj; diff --git a/src/game/explosion.c b/src/game/explosion.c index 58fab0bc8..57e7fa250 100644 --- a/src/game/explosion.c +++ b/src/game/explosion.c @@ -130,72 +130,27 @@ f32 explosionGetVerticalRangeAtFrame(struct explosion *exp, s32 frame) return result; } -GLOBAL_ASM( -glabel func0f129c08 -/* f129c08: 27bdffd8 */ addiu $sp,$sp,-40 -/* f129c0c: afbf0014 */ sw $ra,0x14($sp) -/* f129c10: afa40028 */ sw $a0,0x28($sp) -/* f129c14: afa5002c */ sw $a1,0x2c($sp) -/* f129c18: afa60030 */ sw $a2,0x30($sp) -/* f129c1c: 8ce40004 */ lw $a0,0x4($a3) -/* f129c20: 3c188008 */ lui $t8,%hi(g_ExplosionTypes) -/* f129c24: 2718e4b8 */ addiu $t8,$t8,%lo(g_ExplosionTypes) -/* f129c28: 808e03cc */ lb $t6,0x3cc($a0) -/* f129c2c: afa70034 */ sw $a3,0x34($sp) -/* f129c30: 00c02825 */ or $a1,$a2,$zero -/* f129c34: 000e7880 */ sll $t7,$t6,0x2 -/* f129c38: 01ee7823 */ subu $t7,$t7,$t6 -/* f129c3c: 000f7880 */ sll $t7,$t7,0x2 -/* f129c40: 01ee7823 */ subu $t7,$t7,$t6 -/* f129c44: 000f7880 */ sll $t7,$t7,0x2 -/* f129c48: 01f8c821 */ addu $t9,$t7,$t8 -/* f129c4c: afb90020 */ sw $t9,0x20($sp) -/* f129c50: 0fc4a6c2 */ jal explosionGetHorizontalRangeAtFrame -/* f129c54: afa40024 */ sw $a0,0x24($sp) -/* f129c58: 8fa40024 */ lw $a0,0x24($sp) -/* f129c5c: 8fa50030 */ lw $a1,0x30($sp) -/* f129c60: 0fc4a6e9 */ jal explosionGetVerticalRangeAtFrame -/* f129c64: e7a0001c */ swc1 $f0,0x1c($sp) -/* f129c68: 8fa80020 */ lw $t0,0x20($sp) -/* f129c6c: 3c013f00 */ lui $at,0x3f00 -/* f129c70: 44818000 */ mtc1 $at,$f16 -/* f129c74: 3c013fc0 */ lui $at,0x3fc0 -/* f129c78: 44813000 */ mtc1 $at,$f6 -/* f129c7c: c5040010 */ lwc1 $f4,0x10($t0) -/* f129c80: c7a2001c */ lwc1 $f2,0x1c($sp) -/* f129c84: 8fa70034 */ lw $a3,0x34($sp) -/* f129c88: 46062302 */ mul.s $f12,$f4,$f6 -/* f129c8c: 8fa20028 */ lw $v0,0x28($sp) -/* f129c90: c4f20008 */ lwc1 $f18,0x8($a3) -/* f129c94: 46101202 */ mul.s $f8,$f2,$f16 -/* f129c98: 8fa3002c */ lw $v1,0x2c($sp) -/* f129c9c: 46100282 */ mul.s $f10,$f0,$f16 -/* f129ca0: 460c4080 */ add.s $f2,$f8,$f12 -/* f129ca4: 460c5380 */ add.s $f14,$f10,$f12 -/* f129ca8: 46029101 */ sub.s $f4,$f18,$f2 -/* f129cac: e4440000 */ swc1 $f4,0x0($v0) -/* f129cb0: c4e6000c */ lwc1 $f6,0xc($a3) -/* f129cb4: 460e3201 */ sub.s $f8,$f6,$f14 -/* f129cb8: e4480004 */ swc1 $f8,0x4($v0) -/* f129cbc: c4ea0010 */ lwc1 $f10,0x10($a3) -/* f129cc0: 46025481 */ sub.s $f18,$f10,$f2 -/* f129cc4: e4520008 */ swc1 $f18,0x8($v0) -/* f129cc8: c4e40008 */ lwc1 $f4,0x8($a3) -/* f129ccc: 46022180 */ add.s $f6,$f4,$f2 -/* f129cd0: e4660000 */ swc1 $f6,0x0($v1) -/* f129cd4: c4e8000c */ lwc1 $f8,0xc($a3) -/* f129cd8: 460e4280 */ add.s $f10,$f8,$f14 -/* f129cdc: e46a0004 */ swc1 $f10,0x4($v1) -/* f129ce0: c4f20010 */ lwc1 $f18,0x10($a3) -/* f129ce4: 46029100 */ add.s $f4,$f18,$f2 -/* f129ce8: e4640008 */ swc1 $f4,0x8($v1) -/* f129cec: 8fbf0014 */ lw $ra,0x14($sp) -/* f129cf0: 27bd0028 */ addiu $sp,$sp,0x28 -/* f129cf4: 03e00008 */ jr $ra -/* f129cf8: 00000000 */ sll $zero,$zero,0x0 -); +void explosionGetBboxAtFrame(struct coord *lower, struct coord *upper, s32 frame, struct prop *prop) +{ + struct explosion *exp = prop->explosion; + struct explosiontype *type = &g_ExplosionTypes[exp->type]; -void alertNearbyChrsToNoise(f32 *radius, struct coord *noisepos) + f32 rangeh = explosionGetHorizontalRangeAtFrame(exp, frame); + f32 rangev = explosionGetVerticalRangeAtFrame(exp, frame); + + rangeh = rangeh * 0.5f + type->innersize * 1.5f; + rangev = rangev * 0.5f + type->innersize * 1.5f; + + lower->x = prop->pos.x - rangeh; + lower->y = prop->pos.y - rangev; + lower->z = prop->pos.z - rangeh; + + upper->x = prop->pos.x + rangeh; + upper->y = prop->pos.y + rangev; + upper->z = prop->pos.z + rangeh; +} + +void explosionAlertChrs(f32 *radius, struct coord *noisepos) { u32 stack[2]; s32 *end = (s32 *)&func0f084e58; @@ -206,7 +161,7 @@ void alertNearbyChrsToNoise(f32 *radius, struct coord *noisepos) && chrGetTargetProp(&g_ChrsA[i]) == g_Vars.currentplayer->prop && g_ChrsA[i].prop && g_ChrsA[i].prop->type == PROPTYPE_CHR - && (g_ChrsA[i].prop->flags & 4)) { + && (g_ChrsA[i].prop->flags & PROPFLAG_TANGIBLE)) { f32 distance = chrGetDistanceToCoord(&g_ChrsA[i], noisepos); if (distance == 0) { @@ -500,7 +455,7 @@ glabel var7f1b5584 /* f12a2c8: afaa0158 */ sw $t2,0x158($sp) /* f12a2cc: 0fc1814e */ jal func0f060538 /* f12a2d0: 02a02025 */ or $a0,$s5,$zero -/* f12a2d4: 0fc180bc */ jal propHide +/* f12a2d4: 0fc180bc */ jal propShow /* f12a2d8: 02a02025 */ or $a0,$s5,$zero /* f12a2dc: 8faa0158 */ lw $t2,0x158($sp) /* f12a2e0: 3c188008 */ lui $t8,%hi(g_ExplosionTypes+0x2c) @@ -532,7 +487,7 @@ glabel var7f1b5584 /* f12a340: 85a6001c */ lh $a2,0x1c($t5) /* f12a344: afaa0158 */ sw $t2,0x158($sp) /* f12a348: 27a500c8 */ addiu $a1,$sp,0xc8 -/* f12a34c: 0fc4a702 */ jal func0f129c08 +/* f12a34c: 0fc4a702 */ jal explosionGetBboxAtFrame /* f12a350: 02a03825 */ or $a3,$s5,$zero /* f12a354: 3c013f80 */ lui $at,0x3f80 /* f12a358: 4481b000 */ mtc1 $at,$f22 @@ -1157,7 +1112,7 @@ glabel var7f1b5584 /* f12ac80: 8fa4009c */ lw $a0,0x9c($sp) .L0f12ac84: /* f12ac84: 8fa50164 */ lw $a1,0x164($sp) -/* f12ac88: 0fc4a73f */ jal alertNearbyChrsToNoise +/* f12ac88: 0fc4a73f */ jal explosionAlertChrs /* f12ac8c: afaa0158 */ sw $t2,0x158($sp) /* f12ac90: 8faa0158 */ lw $t2,0x158($sp) .L0f12ac94: @@ -2652,7 +2607,7 @@ glabel var7f1b55a8 /* f12c1a8: 27b20130 */ addiu $s2,$sp,0x130 /* f12c1ac: 02402825 */ or $a1,$s2,$zero /* f12c1b0: 02002025 */ or $a0,$s0,$zero -/* f12c1b4: 0fc4a702 */ jal func0f129c08 +/* f12c1b4: 0fc4a702 */ jal explosionGetBboxAtFrame /* f12c1b8: 02e03825 */ or $a3,$s7,$zero /* f12c1bc: 26e60028 */ addiu $a2,$s7,0x28 /* f12c1c0: afa6009c */ sw $a2,0x9c($sp) diff --git a/src/game/game_00c490.c b/src/game/game_00c490.c index acfbe323f..b16171d43 100644 --- a/src/game/game_00c490.c +++ b/src/game/game_00c490.c @@ -1317,7 +1317,7 @@ glabel var7f1a7f80 /* f00d64c: 0fc1812f */ jal func0f0604bc /* f00d650: 8fa4007c */ lw $a0,0x7c($sp) .L0f00d654: -/* f00d654: 0fc180bc */ jal propHide +/* f00d654: 0fc180bc */ jal propShow /* f00d658: 8fa4007c */ lw $a0,0x7c($sp) .L0f00d65c: /* f00d65c: 8fbf0034 */ lw $ra,0x34($sp) @@ -2726,7 +2726,7 @@ glabel var7f1a8064 .L0f00e8dc: /* f00e8dc: 0fc1812f */ jal func0f0604bc /* f00e8e0: 8fa4010c */ lw $a0,0x10c($sp) -/* f00e8e4: 0fc180bc */ jal propHide +/* f00e8e4: 0fc180bc */ jal propShow /* f00e8e8: 8fa4010c */ lw $a0,0x10c($sp) /* f00e8ec: 10000003 */ beqz $zero,.L0f00e8fc /* f00e8f0: 8fbf0034 */ lw $ra,0x34($sp) diff --git a/src/game/game_011110.c b/src/game/game_011110.c index 6adad84b5..fcb44c97e 100644 --- a/src/game/game_011110.c +++ b/src/game/game_011110.c @@ -972,7 +972,7 @@ glabel var7f1a827c /* f011fb8: 0fc1812f */ jal func0f0604bc /* f011fbc: 8de400bc */ lw $a0,0xbc($t7) /* f011fc0: 8e290284 */ lw $t1,0x284($s1) -/* f011fc4: 0fc180bc */ jal propHide +/* f011fc4: 0fc180bc */ jal propShow /* f011fc8: 8d2400bc */ lw $a0,0xbc($t1) /* f011fcc: 8e2a0284 */ lw $t2,0x284($s1) /* f011fd0: 00002825 */ or $a1,$zero,$zero @@ -1528,7 +1528,7 @@ glabel var7f1a827c // g_Vars.currentplayer->prop->chr = NULL; // g_Vars.currentplayer->prop->type = PROPTYPE_PLAYER; // func0f0604bc(g_Vars.currentplayer->prop); -// propHide(g_Vars.currentplayer->prop); +// propShow(g_Vars.currentplayer->prop); // chrInit(g_Vars.currentplayer->prop, 0); // // if (g_Vars.coopplayernum >= 0) { diff --git a/src/game/game_0147d0.c b/src/game/game_0147d0.c index 4b2cab1be..0ae60735b 100644 --- a/src/game/game_0147d0.c +++ b/src/game/game_0147d0.c @@ -141,7 +141,7 @@ glabel var7f1a82b4 /* f014928: 00402025 */ or $a0,$v0,$zero /* f01492c: 0fc1812f */ jal func0f0604bc /* f014930: afa20070 */ sw $v0,0x70($sp) -/* f014934: 0fc180bc */ jal propHide +/* f014934: 0fc180bc */ jal propShow /* f014938: 8fa40070 */ lw $a0,0x70($sp) /* f01493c: 8fb80070 */ lw $t8,0x70($sp) /* f014940: 87a5007a */ lh $a1,0x7a($sp) diff --git a/src/game/game_02cde0.c b/src/game/game_02cde0.c index 9316fdcd4..6aa8727b2 100644 --- a/src/game/game_02cde0.c +++ b/src/game/game_02cde0.c @@ -649,7 +649,7 @@ glabel func0f02d4fc /* f02d744: 00402025 */ or $a0,$v0,$zero /* f02d748: 0fc1812f */ jal func0f0604bc /* f02d74c: afa20050 */ sw $v0,0x50($sp) -/* f02d750: 0fc180bc */ jal propHide +/* f02d750: 0fc180bc */ jal propShow /* f02d754: 8fa40050 */ lw $a0,0x50($sp) /* f02d758: 8fae0050 */ lw $t6,0x50($sp) /* f02d75c: 86050008 */ lh $a1,0x8($s0) @@ -998,7 +998,7 @@ struct prop *propAllocateEyespy(struct pad *pad, s16 room) if (prop) { func0f0604bc(prop); - propHide(prop); + propShow(prop); chr = prop->chr; chrSetChrnum(chr, getLowestUnusedChrId()); chr->bodynum = BODY_EYESPY; diff --git a/src/game/game_0601b0.c b/src/game/game_0601b0.c index cf4c0d008..c6a11c1de 100644 --- a/src/game/game_0601b0.c +++ b/src/game/game_0601b0.c @@ -140,9 +140,9 @@ glabel func0f0601b0 /* f0602ec: 27bd0348 */ addiu $sp,$sp,0x348 ); -void propHide(struct prop *prop) +void propShow(struct prop *prop) { - prop->flags |= PROPFLAG_HIDDEN; + prop->flags |= PROPFLAG_TANGIBLE; } GLOBAL_ASM( diff --git a/src/game/game_097ba0.c b/src/game/game_097ba0.c index 166807653..104966bd6 100644 --- a/src/game/game_097ba0.c +++ b/src/game/game_097ba0.c @@ -9050,7 +9050,7 @@ glabel func0f09ebcc /* f09ebf4: 8fbf001c */ lw $ra,0x1c($sp) /* f09ebf8: 0fc1812f */ jal func0f0604bc /* f09ebfc: 02202025 */ or $a0,$s1,$zero -/* f09ec00: 0fc180bc */ jal propHide +/* f09ec00: 0fc180bc */ jal propShow /* f09ec04: 02202025 */ or $a0,$s1,$zero /* f09ec08: 8e0e0018 */ lw $t6,0x18($s0) /* f09ec0c: 8fa50034 */ lw $a1,0x34($sp) diff --git a/src/game/game_12d3f0.c b/src/game/game_12d3f0.c index b7f85ab82..ab284151f 100644 --- a/src/game/game_12d3f0.c +++ b/src/game/game_12d3f0.c @@ -1131,7 +1131,7 @@ glabel func0f12e1c0 /* f12e3fc: a5c60028 */ sh $a2,0x28($t6) /* f12e400: 0fc1814e */ jal func0f060538 /* f12e404: 02202025 */ or $a0,$s1,$zero -/* f12e408: 0fc180bc */ jal propHide +/* f12e408: 0fc180bc */ jal propShow /* f12e40c: 02202025 */ or $a0,$s1,$zero /* f12e410: 8faf002c */ lw $t7,0x2c($sp) /* f12e414: 00107040 */ sll $t6,$s0,0x1 diff --git a/src/game/game_17f930.c b/src/game/game_17f930.c index f47b48d18..1a3eba6aa 100644 --- a/src/game/game_17f930.c +++ b/src/game/game_17f930.c @@ -6664,7 +6664,7 @@ glabel func0f186508 /* f186690: 0fc1812f */ jal func0f0604bc /* f186694: 8da40014 */ lw $a0,0x14($t5) /* f186698: 8fb90018 */ lw $t9,0x18($sp) -/* f18669c: 0fc180bc */ jal propHide +/* f18669c: 0fc180bc */ jal propShow /* f1866a0: 8f240014 */ lw $a0,0x14($t9) /* f1866a4: 8fb80018 */ lw $t8,0x18($sp) /* f1866a8: 8fbf0014 */ lw $ra,0x14($sp) diff --git a/src/game/propobj.c b/src/game/propobj.c index 776bd2af5..2ee91b31f 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -27992,7 +27992,7 @@ glabel func0f07e474 /* f07e5dc: 1000001c */ beqz $zero,.L0f07e650 /* f07e5e0: afad0060 */ sw $t5,0x60($sp) .L0f07e5e4: -/* f07e5e4: 0fc180bc */ jal propHide +/* f07e5e4: 0fc180bc */ jal propShow /* f07e5e8: 02202025 */ or $a0,$s1,$zero /* f07e5ec: 0fc248f5 */ jal func0f0923d4 /* f07e5f0: 02002025 */ or $a0,$s0,$zero @@ -33645,7 +33645,7 @@ glabel var7f1aa978 /* f083cb8: 8fa40140 */ lw $a0,0x140($sp) /* f083cbc: 0fc1812f */ jal func0f0604bc /* f083cc0: 8fa40140 */ lw $a0,0x140($sp) -/* f083cc4: 0fc180bc */ jal propHide +/* f083cc4: 0fc180bc */ jal propShow /* f083cc8: 8fa40140 */ lw $a0,0x140($sp) /* f083ccc: 8fa40140 */ lw $a0,0x140($sp) /* f083cd0: c7b20120 */ lwc1 $f18,0x120($sp) diff --git a/src/include/constants.h b/src/include/constants.h index e0614c1d8..e06c1c785 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -2186,11 +2186,11 @@ #define PORTALMODE_SHOW 0 #define PORTALMODE_HIDE 1 -#define PROPFLAG_02 0x02 -#define PROPFLAG_HIDDEN 0x04 -#define PROPFLAG_08 0x08 -#define PROPFLAG_40 0x40 -#define PROPFLAG_80 0x80 +#define PROPFLAG_02 0x02 +#define PROPFLAG_TANGIBLE 0x04 +#define PROPFLAG_08 0x08 +#define PROPFLAG_40 0x40 +#define PROPFLAG_80 0x80 #define PROPTYPE_OBJ 1 #define PROPTYPE_DOOR 2 diff --git a/src/include/game/explosion.h b/src/include/game/explosion.h index c278611be..d364f09b8 100644 --- a/src/include/game/explosion.h +++ b/src/include/game/explosion.h @@ -7,8 +7,8 @@ bool explosionCreateSimple(struct prop *prop, struct coord *pos, s16 *rooms, s16 bool explosionCreateComplex(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, s32 playernum); f32 explosionGetHorizontalRangeAtFrame(struct explosion *exp, s32 frame); f32 explosionGetVerticalRangeAtFrame(struct explosion *exp, s32 frame); -u32 func0f129c08(void); -void alertNearbyChrsToNoise(f32 *radius, struct coord *noisepos); +void explosionGetBboxAtFrame(struct coord *lower, struct coord *upper, s32 frame, struct prop *prop); +void explosionAlertChrs(f32 *radius, struct coord *noisepos); bool explosionCreate(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, s32 playernum, bool arg5, struct coord *arg6, s16 arg7, struct coord *arg8); u32 func0f12acec(void); u32 func0f12af5c(void); diff --git a/src/include/game/game_0601b0.h b/src/include/game/game_0601b0.h index 3a5b2f427..8e6968a94 100644 --- a/src/include/game/game_0601b0.h +++ b/src/include/game/game_0601b0.h @@ -4,7 +4,7 @@ #include "types.h" u32 func0f0601b0(void); -void propHide(struct prop *prop); +void propShow(struct prop *prop); void func0f060300(struct prop *prop); struct prop *propAllocate(void); void propFree(struct prop *prop); diff --git a/src/include/types.h b/src/include/types.h index 529a2321b..5c1ee9911 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -22,6 +22,7 @@ struct bbox { struct weaponobj; struct prop; +struct explosion; /** * Most, if not all, entity types (chrs, objs, weapons etc) have a pointer to a @@ -43,6 +44,7 @@ struct prop { struct defaultobj *obj; struct doorobj *door; struct weaponobj *weapon; + struct explosion *explosion; }; /*0x08*/ struct coord pos;