From 17ad57d96b90e3eb69fb92de4baab59059d33548 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 11 Jun 2020 23:58:46 +1000 Subject: [PATCH] Decompile explosionGetVerticalRangeAtFrame --- src/game/explosion.c | 47 ++++++++++++------------------------ src/include/constants.h | 7 +++--- src/include/game/explosion.h | 2 +- src/include/types.h | 9 +++++++ 4 files changed, 30 insertions(+), 35 deletions(-) diff --git a/src/game/explosion.c b/src/game/explosion.c index 94e6786f1..5c70d9f43 100644 --- a/src/game/explosion.c +++ b/src/game/explosion.c @@ -142,35 +142,20 @@ glabel func0f129b08 /* f129ba0: 46001006 */ mov.s $f0,$f2 ); -GLOBAL_ASM( -glabel func0f129ba4 -/* f129ba4: 808303cc */ lb $v1,0x3cc($a0) -/* f129ba8: 3c0f8008 */ lui $t7,%hi(g_ExplosionTypes) -/* f129bac: 25efe4b8 */ addiu $t7,$t7,%lo(g_ExplosionTypes) -/* f129bb0: 00037080 */ sll $t6,$v1,0x2 -/* f129bb4: 01c37023 */ subu $t6,$t6,$v1 -/* f129bb8: 000e7080 */ sll $t6,$t6,0x2 -/* f129bbc: 01c37023 */ subu $t6,$t6,$v1 -/* f129bc0: 000e7080 */ sll $t6,$t6,0x2 -/* f129bc4: 01cf1021 */ addu $v0,$t6,$t7 -/* f129bc8: 2401000e */ addiu $at,$zero,0xe -/* f129bcc: 14610007 */ bne $v1,$at,.L0f129bec -/* f129bd0: c440000c */ lwc1 $f0,0xc($v0) -/* f129bd4: 28a10021 */ slti $at,$a1,0x21 -/* f129bd8: 14200004 */ bnez $at,.L0f129bec -/* f129bdc: 3c0141a0 */ lui $at,0x41a0 -/* f129be0: 44811000 */ mtc1 $at,$f2 -/* f129be4: 03e00008 */ jr $ra -/* f129be8: 46001006 */ mov.s $f0,$f2 -.L0f129bec: -/* f129bec: 44853000 */ mtc1 $a1,$f6 -/* f129bf0: c4440004 */ lwc1 $f4,0x4($v0) -/* f129bf4: 46803220 */ cvt.s.w $f8,$f6 -/* f129bf8: 46080282 */ mul.s $f10,$f0,$f8 -/* f129bfc: 460a2080 */ add.s $f2,$f4,$f10 -/* f129c00: 03e00008 */ jr $ra -/* f129c04: 46001006 */ mov.s $f0,$f2 -); +f32 explosionGetVerticalRangeAtFrame(struct explosion *exp, s32 frame) +{ + struct explosiontype *type = &g_ExplosionTypes[exp->type]; + f32 changeratev = type->changeratev; + f32 result; + + if (exp->type == EXPLOSIONTYPE_14 && frame > 32) { + result = 20; + } else { + result = type->rangev + changeratev * frame; + } + + return result; +} GLOBAL_ASM( glabel func0f129c08 @@ -196,7 +181,7 @@ glabel func0f129c08 /* f129c54: afa40024 */ sw $a0,0x24($sp) /* f129c58: 8fa40024 */ lw $a0,0x24($sp) /* f129c5c: 8fa50030 */ lw $a1,0x30($sp) -/* f129c60: 0fc4a6e9 */ jal func0f129ba4 +/* f129c60: 0fc4a6e9 */ jal explosionGetVerticalRangeAtFrame /* f129c64: e7a0001c */ swc1 $f0,0x1c($sp) /* f129c68: 8fa80020 */ lw $t0,0x20($sp) /* f129c6c: 3c013f00 */ lui $at,0x3f00 @@ -2345,7 +2330,7 @@ glabel var7f1b55a8 /* f12bca8: 00c02825 */ or $a1,$a2,$zero /* f12bcac: 46000506 */ mov.s $f20,$f0 /* f12bcb0: 02202025 */ or $a0,$s1,$zero -/* f12bcb4: 0fc4a6e9 */ jal func0f129ba4 +/* f12bcb4: 0fc4a6e9 */ jal explosionGetVerticalRangeAtFrame /* f12bcb8: 862503c8 */ lh $a1,0x3c8($s1) /* f12bcbc: 3c013f00 */ lui $at,0x3f00 /* f12bcc0: 44815000 */ mtc1 $at,$f10 diff --git a/src/include/constants.h b/src/include/constants.h index 4ee347fb0..e0614c1d8 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -553,9 +553,10 @@ #define ENTITYTYPE_DONTTURN 0x0040 // don't do a shooting animation that would change the chr's direction #define ENTITYTYPE_TARGET 0x0200 // aim/shoot at whatever is in the chr's `target` field -#define EXPLOSIONTYPE_0 0 -#define EXPLOSIONTYPE_3 3 -#define EXPLOSIONTYPE_8 8 +#define EXPLOSIONTYPE_0 0 +#define EXPLOSIONTYPE_3 3 +#define EXPLOSIONTYPE_8 8 +#define EXPLOSIONTYPE_14 14 #define EYESPYMODE_CAMSPY 0 #define EYESPYMODE_DRUGSPY 1 diff --git a/src/include/game/explosion.h b/src/include/game/explosion.h index 97664876a..b1f05329e 100644 --- a/src/include/game/explosion.h +++ b/src/include/game/explosion.h @@ -6,7 +6,7 @@ bool explosionCreateSimple(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, s32 playernum); bool explosionCreateComplex(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, s32 playernum); u32 func0f129b08(void); -u32 func0f129ba4(void); +f32 explosionGetVerticalRangeAtFrame(struct explosion *exp, s32 frame); u32 func0f129c08(void); void alertNearbyChrsToNoise(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); diff --git a/src/include/types.h b/src/include/types.h index e350c0e2e..e4ef6cff1 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -4529,6 +4529,15 @@ struct explosiontype { /*0x28*/ f32 damage; }; +struct explosion { + u8 unk[0x3c8]; + /*0x3c8*/ s32 frame60; + /*0x3cc*/ s8 type; + /*0x3cd*/ s8 makescorch; + /*0x3ce*/ s8 owner; + /*0x3cf*/ s8 numbb; +}; + struct smoketype { u16 duration; u16 fadespeed;