From 6b14e7626e09a01b26318b49f8c54ccdf90793aa Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Tue, 13 Aug 2024 02:34:16 -0400 Subject: [PATCH] Match 16.76% of `ftCo_0A01` (81.08 KB) (#1430) --- src/melee/ft/chara/ftCommon/ftCo_0A01.c | 383 +++++++++++++++++++++++- src/melee/ft/chara/ftCommon/ftCo_0A01.h | 24 +- src/melee/ft/types.h | 39 +-- src/melee/gr/ground.c | 24 +- src/melee/gr/stage.c | 14 +- src/melee/gr/types.h | 63 ++-- 6 files changed, 457 insertions(+), 90 deletions(-) diff --git a/src/melee/ft/chara/ftCommon/ftCo_0A01.c b/src/melee/ft/chara/ftCommon/ftCo_0A01.c index 5433be04bb..0a5331b650 100644 --- a/src/melee/ft/chara/ftCommon/ftCo_0A01.c +++ b/src/melee/ft/chara/ftCommon/ftCo_0A01.c @@ -25,6 +25,7 @@ #include "gr/ground.h" #include "gr/grvenom.h" #include "gr/stage.h" +#include "gr/types.h" #include "it/inlines.h" #include "it/item.h" #include "it/types.h" @@ -44,7 +45,7 @@ int ftCo_803C5A68[] = { 5, 2, 2, 2, 3, 3, 3, 4, 0, 0, 8, 4, 1, 4, 4, 5, 5, }; -extern UNK_T* ftCo_803C6594; +/* static */ extern StageBlastZone** ftCo_803C6594; #pragma force_active on @@ -477,8 +478,7 @@ void ftCo_800A1F3C(Fighter* fp, float arg1, float arg2, float arg3) data->x54.x = arg1; data->x54.y = arg2; data->x38 = arg3; - ftCo_800A1CC4(ftCo_803C6594[stage_info.internal_stage_id], - &stage_info.cam_info, data); + ftCo_800A1CC4(fp, ftCo_803C6594[stage_info.internal_stage_id]); } } @@ -867,7 +867,27 @@ bool ftCo_800A3498(ftCo_Fighter* fp) return false; } -/// #ftCo_800A3554 +bool ftCo_800A3554(ftCo_Fighter* fp, float arg1) +{ + struct Fighter_x1A88_t* data = &fp->x1A88; + if (!ftCo_800A21FC(fp)) { + return false; + } + { + float x = data->x54.x - fp->cur_pos.x, y = data->x54.y - fp->cur_pos.y; + if (sqrtf(SQ(x) + SQ(y)) < data->x38 + arg1) { + if (data->x60 != 0) { + data->x60 = 0; + data->x54.x = data->x64.x; + data->x54.y = data->x64.y; + ftCo_800A1CC4(fp, ftCo_803C6594[stage_info.internal_stage_id]); + return false; + } + return true; + } + return false; + } +} bool ftCo_800A3710(ftCo_Fighter* fp) { @@ -990,6 +1010,8 @@ static inline bool inlineD1(ftCo_Fighter* fp) } } +static inline void inlineD3(ftCo_Fighter* fp) {} + ftCo_Fighter* ftCo_800A4A40(ftCo_Fighter* fp) { if (fp == NULL) { @@ -1034,6 +1056,74 @@ ftCo_Fighter* ftCo_800A4A40(ftCo_Fighter* fp) /// #ftCo_800A50D4 +static inline void inlineD2(ftCo_Fighter* var_r28, ftCo_Fighter* fp, + ftCo_Fighter* temp_r31, ftCo_Fighter* temp_r29) +{ + f32 var_f31 = 0; + f32 temp_f1; + f32 temp_f2; + f32 temp_f1_2; + f32 temp_f2_2; + f32 temp_f1_3; + HSD_GObj* var_r27 = NULL; + if (!(ftCo_IsAlly(fp, temp_r29) != 0)) { + return; + } + if (inlineD1(temp_r29) == 0) { + if (var_r28 == NULL) { + var_r28 = temp_r29; + temp_f1 = fp->cur_pos.y - M2C_FIELD(temp_r29, f32*, 0xB4); + temp_f2 = fp->cur_pos.x - M2C_FIELD(temp_r29, f32*, 0xB0); + var_f31 = sqrtf__Ff((temp_f2 * temp_f2) + (temp_f1 * temp_f1)); + } else { + ftCo_Fighter* fp1; + fp1 = GET_FIGHTER(var_r27); + temp_f1_2 = fp->cur_pos.y - M2C_FIELD(fp1, f32*, 0xB4); + temp_f2_2 = fp->cur_pos.x - M2C_FIELD(fp1, f32*, 0xB0); + temp_f1_3 = + sqrtf__Ff((temp_f2_2 * temp_f2_2) + (temp_f1_2 * temp_f1_2)); + if (var_f31 > temp_f1_3) { + var_f31 = temp_f1_3; + var_r28 = fp1; + } + } + } +} + +Fighter* ftCo_800A50D4(ftCo_Fighter* fp) +{ + Fighter_GObj* temp_r30; + HSD_GObj* var_r27; + f32 temp_f29; + f32 temp_f30; + s32 var_r0; + s32 var_r0_2; + void* temp_r31; + void* var_r28; + void* temp_r29 = NULL; + + // var_f31 = saved_reg_f31; + if (fp == NULL) { + return NULL; + } + + /// @todo #ftCo_800A4A40 but with #ftCo_IsAlly. Same inline somehow. + temp_r31 = fp + 0x1A88; + var_r28 = NULL; + var_r27 = HSD_GObj_Entities->fighters; +loop_24: + if (var_r27 != NULL) { + if (fp->gobj != var_r27) { + if (inlineD0(fp, temp_r31) == 0) { + inlineD2(var_r28, fp, temp_r31, temp_r29); + } + } + var_r27 = var_r27->next; + goto loop_24; + } + return var_r28; +} + ftCo_Fighter* ftCo_800A5294(ftCo_Fighter* fp, int player_id) { PAD_STACK(2 * 4); @@ -1254,18 +1344,48 @@ void ftCo_800A8DE4(Fighter* fp) /// #ftCo_800A8EB0 -/// #ftCo_800A92CC - static inline float inlineE0(ftCo_Fighter* fp) { struct Fighter_x1A88_t* data = &fp->x1A88; - if ((data->x54.x - fp->cur_pos.x) < 0.0f) { + if (data->x54.x - fp->cur_pos.x < 0.0f) { return -(data->x54.x - fp->cur_pos.x); } else { return data->x54.x - fp->cur_pos.x; } } +void ftCo_800A92CC(ftCo_Fighter* fp) +{ + if (inlineE0(fp) > 60.0) { + ftCo_800B46B8(fp, 0x81, 0x7F); + ftCo_800B46B8(fp, 0x80, 0); + ftCo_800B46B8(fp, 0x88, 1); + ftCo_800B463C(fp, 4); + ftCo_800B46B8(fp, 0x81, 0x58); + ftCo_800B46B8(fp, 0x90, 0x58); + ftCo_800B46B8(fp, 0x8E, 0xF); + ftCo_800B46B8(fp, 0x90, 0x7F); + ftCo_800B46B8(fp, 0x81, 0); + ftCo_800B46B8(fp, 0x8E, 0xF); + ftCo_800B463C(fp, 0x7F); + return; + } + ftCo_800B46B8(fp, 0x81, 0x7F); + ftCo_800B46B8(fp, 0x80, 0); + ftCo_800B46B8(fp, 0x88, 1); + ftCo_800B463C(fp, 4); + ftCo_800B46B8(fp, 0x8E, 0xF); + if (HSD_Randf() > 0.5) { + ftCo_800B46B8(fp, 0x90, 0x58); + ftCo_800B46B8(fp, 0x81, 0x58); + } else { + ftCo_800B46B8(fp, 0x90, 0x7F); + ftCo_800B46B8(fp, 0x81, 0); + } + ftCo_800B46B8(fp, 0x8E, 0xF); + ftCo_800B463C(fp, 0x7F); +} + void ftCo_800A949C(ftCo_Fighter* fp) { if (inlineE0(fp) > 30.0) { @@ -1580,7 +1700,91 @@ void ftCo_800AD42C(ftCo_Fighter* fp) /// #ftCo_800AF78C -/// #ftCo_800AFC40 +void ftCo_800AFC40(ftCo_Fighter* fp) +{ + Fighter* temp_r3_3; + Item_GObj* temp_r3; + enum ItemKind temp_r0; + s32 temp_r3_2; + s32 var_r0; + s32 var_r0_2; + s32 var_r27; + struct Fighter_x1A88_t* temp_r28; + struct Fighter_x1A88_t* temp_r4; + void* temp_r31; + + temp_r31 = fp + 0x1A88; + if ((fp->x221D >> 1) & 1) { + var_r0 = 1; + } else if ((fp->x2168 != 0) && (fp->x2338.x == 0)) { + var_r0 = 1; + } else { + var_r0 = 0; + } + if (var_r0 != 0) { + ftCo_800AECF0(fp); + return; + } + var_r27 = 1; + M2C_FIELD(temp_r31, u8*, 0xF8) = M2C_FIELD(temp_r31, u8*, 0xF8) | 0x80; + M2C_FIELD(temp_r31, u8*, 0xF9) = M2C_FIELD(temp_r31, u8*, 0xF9) | 0x20; + M2C_FIELD(temp_r31, u8*, 0xF9) = M2C_FIELD(temp_r31, u8*, 0xF9) | 8; + M2C_FIELD(temp_r31, u8*, 0xF9) = M2C_FIELD(temp_r31, u8*, 0xF9) | 0x10; + M2C_FIELD(temp_r31, u8*, 0xF9) = M2C_FIELD(temp_r31, u8*, 0xF9) | 4; + M2C_FIELD(temp_r31, u8*, 0xF9) = M2C_FIELD(temp_r31, u8*, 0xF9) | 2; + M2C_FIELD(temp_r31, u8*, 0xF9) = M2C_FIELD(temp_r31, u8*, 0xF9) & ~1; + M2C_FIELD(temp_r31, u8*, 0xF9) = M2C_FIELD(temp_r31, u8*, 0xF9) & ~0x40; + fp->x1A88.x44 = ftCo_800A4BEC(fp); + temp_r28 = &fp->x1A88; + temp_r3 = fp->item_gobj; + if (temp_r3 != NULL) { + temp_r0 = GET_ITEM(temp_r3)->kind; + switch (temp_r0) { /* irregular */ + case It_Kind_Heart: + break; + case It_Kind_Tomato: + break; + case It_Kind_Foods: + break; + default: + var_r27 = 0; + break; + } + if (var_r27 == 0) { + temp_r28->x4C = NULL; + } else { + goto block_18; + } + } else { + block_18: + if (fp->x2168 != 0) { + temp_r28->x4C = NULL; + } else { + temp_r28->x4C = ftCo_800A5F4C(fp, 0x23); + } + } + fp->x1A88.x50 = ftCo_800A648C(fp); + temp_r4 = &fp->x1A88; + temp_r3_2 = fp->x1A88.x18; + if ((temp_r3_2 != fp->x1A88.x20) && (temp_r3_2 != temp_r4->x1C)) { + temp_r4->x60 = 0; + } + if (temp_r4->x18 == 4) { + var_r0_2 = 0; + } else { + M2C_FIELD(temp_r4, u8*, 0xFA) = M2C_FIELD(temp_r4, u8*, 0xFA) & ~0x20; + var_r0_2 = 1; + } + if (var_r0_2 != 0) { + temp_r3_3 = ftCo_800A50D4(fp); + if (temp_r3_3 != NULL) { + ftCo_800A75DC(fp, temp_r3_3); + } else { + ftCo_800A75DC(fp, M2C_FIELD(temp_r31, Fighter**, 0x44)); + } + } + ftCo_800ADE48(fp); +} /// #ftCo_800AFE3C @@ -1660,7 +1864,36 @@ void ftCo_800B0760(ftCo_Fighter* fp) ftCo_800ADE48(fp); } -/// #ftCo_800B0918 +/// @todo Maybe a macro? +static inline float inlineM0(float x) +{ + return x >= 0 ? 127.0F * x : 128.0F * x; +} + +void ftCo_800B0918(Fighter* fp0, Fighter* fp1) +{ + struct Fighter_x1A88_t* temp_r4 = &fp1->x1A88; + temp_r4->x444 = temp_r4->x444->x1C; + temp_r4->x448 = temp_r4->x448->x1C; + if (temp_r4->x444 == temp_r4->x444) { + temp_r4->x444 = &temp_r4->xFC; + } + if (temp_r4->x448 == temp_r4->x444) { + temp_r4->x448 = &temp_r4->xFC; + } + temp_r4->x444->x6 = inlineM0(fp0->input.lstick.x); + temp_r4->x444->x7 = inlineM0(fp0->input.lstick.y); + temp_r4->x444->x8 = inlineM0(fp0->input.cstick.x); + temp_r4->x444->x9 = inlineM0(fp0->input.cstick.y); + temp_r4->x444->x4 = fp0->input.x650; + temp_r4->x444->x5 = fp0->input.x650; + temp_r4->x444->x0 = fp0->input.held_inputs; + { + struct Fighter_x1A88_xFC_t* temp_r6 = temp_r4->x444; + temp_r6->cur_pos = fp0->cur_pos; + temp_r4->x444->facing_dir = fp0->facing_dir; + } +} static inline bool inlineJ0(ftCo_Fighter* fp, ftCo_Fighter* nana_fp) { @@ -1696,8 +1929,10 @@ void ftCo_800B0AF4(ftCo_Fighter* fp) data->x8 = data->x448->x4; data->x9 = data->x448->x5; if (fp->x2225_b3) { - fp->cur_pos.x = 0.95 * fp->cur_pos.x + 0.05 * data->x448->offset.x; - fp->cur_pos.y = 0.95 * fp->cur_pos.y + 0.05 * data->x448->offset.y; + fp->cur_pos.x = + 0.95 * fp->cur_pos.x + 0.05 * data->x448->cur_pos.x; + fp->cur_pos.y = + 0.95 * fp->cur_pos.y + 0.05 * data->x448->cur_pos.y; if (fp->motion_id != ftPp_MS_SpecialLw && fp->motion_id != ftPp_MS_SpecialAirLw) { @@ -1707,7 +1942,129 @@ void ftCo_800B0AF4(ftCo_Fighter* fp) } } -/// #ftCo_800B0CA8 +bool ftCo_800B0CA8(Fighter* fp0, Fighter* fp1) +{ + Item_GObj* temp_r5_2; + enum ItemKind temp_r0; + s32 temp_r0_2; + s32 temp_r5; + s32 var_r0; + s32 var_r0_2; + s32 var_r0_3; + s32 var_r0_4; + + temp_r5 = fp1->motion_id; + switch (temp_r5) { /* irregular */ + case 0xFC: + var_r0 = 1; + break; + case 0xFD: + var_r0 = 2; + break; + default: + var_r0 = 0; + break; + } + if (var_r0 == 0) { + if (temp_r5 == 0xE0) { + var_r0_2 = 1; + } else if (temp_r5 == 0xE3) { + var_r0_2 = 1; + } else if ((temp_r5 >= 0x10A) && (temp_r5 <= 0x10E)) { + var_r0_2 = 1; + } else { + var_r0_2 = 0; + } + if (var_r0_2 == 0) { + if ((temp_r5 - 0xF5) <= 1) { + var_r0_3 = 1; + } else { + var_r0_3 = 0; + } + if (var_r0_3 != 0) { + /* Duplicate return node #21. Try simplifying control flow for + * better match */ + return 0; + } + if ((temp_r5 >= 0x120) && (temp_r5 <= 0x121)) { + return 0; + } + if ((temp_r5 >= 0xC) && (temp_r5 <= 0xD)) { + return 0; + } + if ((temp_r5 >= 0x131) && (temp_r5 <= 0x132)) { + return 0; + } + if ((temp_r5 >= 0x91) && (temp_r5 <= 0x93)) { + return 0; + } + temp_r5_2 = fp0->item_gobj; + if (temp_r5_2 != NULL) { + temp_r0 = GET_ITEM(temp_r5_2)->kind; + if (temp_r0 != It_Kind_Egg) { + if (temp_r0 < 3) { + if (temp_r0 < 1) { + goto block_41; + } + goto block_40; + } + if (temp_r0 < 6) { + block_40: + var_r0_4 = 1; + } else { + goto block_41; + } + } else { + block_41: + var_r0_4 = 0; + } + if (var_r0_4 != 0) { + return 0; + } + goto block_44; + } + block_44: + if ((fp1->ground_or_air == GA_Ground) && + (fp0->ground_or_air == GA_Air) && + (fp1->cur_pos.y > fp0->cur_pos.y) && (fp0->pos_delta.y < 0.0f)) + { + return 0; + } + if ((M2C_FIELD(fp0, u8*, 0x2225) >> 4) & 1) { + return 1; + } + temp_r0_2 = fp0->motion_id; + if (temp_r0_2 < 0x2C) { + if (temp_r0_2 != 0x29) { + if ((temp_r0_2 < 0x29) && (temp_r0_2 < 0x27)) { + /* Duplicate return node #60. Try simplifying control + * flow for better match */ + return 0; + } + /* Duplicate return node #59. Try simplifying control flow + * for better match */ + return 1; + } + /* Duplicate return node #60. Try simplifying control flow for + * better match */ + return 0; + } + if (temp_r0_2 < 0x4B) { + if (temp_r0_2 < 0x46) { + /* Duplicate return node #60. Try simplifying control flow + * for better match */ + return 0; + } + return 1; + } + return 0; + } + /* Duplicate return node #21. Try simplifying control flow for better + * match */ + return 0; + } + return 0; +} static inline bool inlineK0(ftCo_Fighter* fp0) { @@ -1724,7 +2081,7 @@ bool ftCo_800B0E98(Fighter* fp0, Fighter* fp1) s32 var_r0; s32 var_r0_2; - if (ftCo_800B0CA8(fp0) != 0) { + if (ftCo_800B0CA8(fp0, fp1) != 0) { struct Fighter_x1A88_t* data = &fp0->x1A88; if (fp1->ground_or_air == GA_Air) { return false; diff --git a/src/melee/ft/chara/ftCommon/ftCo_0A01.h b/src/melee/ft/chara/ftCommon/ftCo_0A01.h index 25bb9c00ac..57ab521df2 100644 --- a/src/melee/ft/chara/ftCommon/ftCo_0A01.h +++ b/src/melee/ft/chara/ftCommon/ftCo_0A01.h @@ -8,10 +8,18 @@ #include "mp/forward.h" #include "ft/types.h" +#include "gr/types.h" #include #include +struct _m2c_stack_ftCo_800A3554 { + /* 0x00 */ char pad_0[0x10]; + /* 0x10 */ f32 f; + /* 0x14 */ Vec3 vec; + /* 0x20 */ char pad_20[0x18]; +}; /* size = 0x38 */ + /* 09D4F0 */ void ftCo_800A05F4(ftCo_Fighter* fp); /* 09D694 */ void ftCo_800A0798(ftCo_Fighter* fp); /* 09DB88 */ void ftCo_800A0C8C(ftCo_Fighter* fp); @@ -72,7 +80,7 @@ /* 09E094 */ static UNK_RET ftCo_800AD7FC(UNK_PARAMS); /* 09E4C0 */ static UNK_RET ftCo_800ADC28(UNK_PARAMS); /* 09E6E0 */ static void ftCo_800ADE48(ftCo_Fighter* fp); -/* 09EBC0 */ static void ftCo_800A1CC4(UNK_T, UNK_T, UNK_T); +/* 09EBC0 */ static void ftCo_800A1CC4(ftCo_Fighter* fp, StageBlastZone*); /* 09EE38 */ static void ftCo_800A1F3C(ftCo_Fighter* fp, float arg1, float arg2, float arg3); /* 09EE94 */ static bool ftCo_800A1F98(int x, float y); @@ -81,7 +89,7 @@ /* 09F0F8 */ static bool ftCo_800A21FC(ftCo_Fighter* fp); /* 09F198 */ static UNK_RET ftCo_800A229C(UNK_PARAMS); /* 09F324 */ static UNK_RET ftCo_800AEA8C(UNK_PARAMS); -/* 09F588 */ static UNK_RET ftCo_800AECF0(UNK_PARAMS); +/* 09F588 */ static void ftCo_800AECF0(ftCo_Fighter* fp); /* 09F614 */ static bool ftCo_800A2718(mp_UnkStruct0*); /* 09F850 */ static UNK_RET ftCo_800AEFB8(UNK_PARAMS); /* 09FB28 */ static UNK_RET ftCo_800AF290(UNK_PARAMS); @@ -90,7 +98,7 @@ /* 0A0130 */ static UNK_RET ftCo_800A3234(UNK_PARAMS); /* 0A0394 */ static bool ftCo_800A3498(ftCo_Fighter* fp); /* 0A0450 */ static bool ftCo_800A3554(ftCo_Fighter* fp, float); -/* 0A04D8 */ static UNK_RET ftCo_800AFC40(UNK_PARAMS); +/* 0A04D8 */ static void ftCo_800AFC40(ftCo_Fighter* fp); /* 0A060C */ static bool ftCo_800A3710(ftCo_Fighter* fp); /* 0A06D4 */ static UNK_RET ftCo_800AFE3C(UNK_PARAMS); /* 0A0804 */ static bool ftCo_800A3908(ftCo_Fighter* fp, bool); @@ -98,9 +106,9 @@ /* 0A0D74 */ static UNK_RET ftCo_800B04DC(UNK_PARAMS); /* 0A0F34 */ static bool ftCo_800A4038(ftCo_Fighter* fp, bool); /* 0A0FF8 */ static void ftCo_800B0760(ftCo_Fighter* fp); -/* 0A11B0 */ static UNK_RET ftCo_800B0918(UNK_PARAMS); +/* 0A11B0 */ static void ftCo_800B0918(ftCo_Fighter* fp0, ftCo_Fighter* fp1); /* 0A138C */ static void ftCo_800B0AF4(ftCo_Fighter* fp); -/* 0A1540 */ static bool ftCo_800B0CA8(ftCo_Fighter* fp); +/* 0A1540 */ static bool ftCo_800B0CA8(ftCo_Fighter* fp0, ftCo_Fighter* fp1); /* 0A1664 */ static UNK_RET ftCo_800A4768(UNK_PARAMS); /* 0A1730 */ static bool ftCo_800B0E98(ftCo_Fighter* fp0, ftCo_Fighter* fp1); /* 0A18B0 */ static void ftCo_800A49B4(ftCo_Fighter* fp); @@ -109,7 +117,7 @@ /* 0A1B04 */ static UNK_RET ftCo_800B126C(UNK_PARAMS); /* 0A1B38 */ static bool ftCo_800A1B38(enum_t); /* 0A1D10 */ static UNK_RET ftCo_800B1478(UNK_PARAMS); -/* 0A1FD0 */ static UNK_RET ftCo_800A50D4(UNK_PARAMS); +/* 0A1FD0 */ static ftCo_Fighter* ftCo_800A50D4(ftCo_Fighter* fp); /* 0A2068 */ static UNK_RET ftCo_800B17D0(UNK_PARAMS); /* 0A2190 */ static ftCo_Fighter* ftCo_800A5294(ftCo_Fighter* fp, int player_id); @@ -133,7 +141,7 @@ /* 0A6A98 */ static UNK_RET ftCo_800A6A98(UNK_PARAMS); /* 0A6D2C */ static UNK_RET ftCo_800A6D2C(UNK_PARAMS); /* 0A6FC4 */ static UNK_RET ftCo_800A6FC4(UNK_PARAMS); -/* 0A75DC */ static UNK_RET ftCo_800A75DC(UNK_PARAMS); +/* 0A75DC */ static void ftCo_800A75DC(ftCo_Fighter* fp0, ftCo_Fighter* fp1); /* 0A7AAC */ static void ftCo_800A7AAC(ftCo_Fighter* fp); /* 0A80E4 */ static void ftCo_800A80E4(ftCo_Fighter* fp); /* 0A8210 */ static UNK_RET ftCo_800A8210(UNK_PARAMS); @@ -141,7 +149,7 @@ /* 0A8940 */ static void ftCo_800A8940(ftCo_Fighter* fp); /* 0A8DE4 */ static void ftCo_800A8DE4(ftCo_Fighter* fp); /* 0A8EB0 */ static UNK_RET ftCo_800A8EB0(UNK_PARAMS); -/* 0A92CC */ static UNK_RET ftCo_800A92CC(UNK_PARAMS); +/* 0A92CC */ static void ftCo_800A92CC(ftCo_Fighter* fp); /* 0A949C */ static void ftCo_800A949C(ftCo_Fighter* fp); /* 0A963C */ static void ftCo_800A963C(ftCo_Fighter* fp); /* 0A96B8 */ static UNK_RET ftCo_800A96B8(UNK_PARAMS); diff --git a/src/melee/ft/types.h b/src/melee/ft/types.h index 86059e350a..efffee26eb 100644 --- a/src/melee/ft/types.h +++ b/src/melee/ft/types.h @@ -957,6 +957,23 @@ typedef struct FtDynamicBones { // once they're defined // } FtDynamicBones; +struct Fighter_x1A88_xFC_t { + /* +0 */ HSD_Pad x0; + /* +4 */ u8 x4; + /* +5 */ u8 x5; + /* +6 */ u8 x6; + /* +7 */ u8 x7; + /* +8 */ u8 x8; + /* +9 */ u8 x9; + /* +A */ u8 xA; + /* +B */ u8 xB; + /* +C */ Vec3 cur_pos; + /* +18 */ float facing_dir; + /* +1C */ struct Fighter_x1A88_xFC_t* x1C; + /* +20 */ u8 x20[0x348 - 0x20]; +}; +STATIC_ASSERT(sizeof(struct Fighter_x1A88_xFC_t) == 0x348); + struct Fighter_x1A88_t { /* +0 */ HSD_Pad x0; /* +4 */ u8 x4; @@ -985,7 +1002,8 @@ struct Fighter_x1A88_t { /* +54 */ Vec2 x54; /* +5C */ float x5C; /* +60 */ int x60; - /* +64 */ u8 x64[0x7C - 0x64]; + /* +64 */ Vec2 x64; + /* +64 */ u8 x6C[0x7C - 0x6C]; /* +7C */ int x7C; /* +80 */ u8 x80[0xF8 - 0x80]; /* +F8:0 */ u8 xF8_b0 : 1; @@ -1020,21 +1038,9 @@ struct Fighter_x1A88_t { /* +FB:5 */ u8 xFB_b5 : 1; /* +FB:6 */ u8 xFB_b6 : 1; /* +FB:7 */ u8 xFB_b7 : 1; - /* +80 */ u8 xFC[0x448 - 0xFC]; - /* +448 */ struct { - /* +0 */ HSD_Pad x0; - /* +4 */ u8 x4; - /* +5 */ u8 x5; - /* +6 */ u8 x6; - /* +7 */ u8 x7; - /* +8 */ u8 x8; - /* +9 */ u8 x9; - /* +A */ u8 xA; - /* +B */ u8 xB; - /* +C */ Vec2 offset; - /* +14 */ UNK_T x14; - /* +18 */ float facing_dir; - }* x448; + /* +FC */ struct Fighter_x1A88_xFC_t xFC; + /* +444 */ struct Fighter_x1A88_xFC_t* x444; + /* +448 */ struct Fighter_x1A88_xFC_t* x448; /* +44C */ UNK_T x44C; /* +450 */ UNK_T x450; /* +454 */ uint x454; @@ -1766,7 +1772,6 @@ struct Fighter { /* fp+2340 */ union ftZelda_MotionVars zd; } mv; }; - STATIC_ASSERT(sizeof(Fighter) == 0x23EC); struct gmScriptEventDefault { diff --git a/src/melee/gr/ground.c b/src/melee/gr/ground.c index c3938d7eb7..82df46cb19 100644 --- a/src/melee/gr/ground.c +++ b/src/melee/gr/ground.c @@ -267,10 +267,10 @@ void Ground_801BFFB0(void) stage_info.x694[2] = NULL; stage_info.x694[3] = NULL; stage_info.x6A4 = NULL; - stage_info.cam_info.cam_bounds_left = -170; - stage_info.cam_info.cam_bounds_right = 170; - stage_info.cam_info.cam_bounds_top = 120; - stage_info.cam_info.cam_bounds_bottom = -60; + stage_info.cam_info.cam_bounds.left = -170; + stage_info.cam_info.cam_bounds.right = 170; + stage_info.cam_info.cam_bounds.top = 120; + stage_info.cam_info.cam_bounds.bottom = -60; stage_info.cam_info.cam_x_offset = 0; stage_info.cam_info.cam_y_offset = 0; stage_info.cam_info.cam_vertical_tilt = 30; @@ -1711,22 +1711,22 @@ void Ground_801C36F4(int map_id, HSD_JObj* root, UNK_T joint) void Ground_801C3880(f32 val) { - stage_info.cam_info.cam_bounds_top = val; + stage_info.cam_info.cam_bounds.top = val; } void Ground_801C3890(f32 val) { - stage_info.cam_info.cam_bounds_bottom = val; + stage_info.cam_info.cam_bounds.bottom = val; } void Ground_801C38A0(f32 val) { - stage_info.cam_info.cam_bounds_left = val; + stage_info.cam_info.cam_bounds.left = val; } void Ground_801C38AC(f32 val) { - stage_info.cam_info.cam_bounds_right = val; + stage_info.cam_info.cam_bounds.right = val; } void Ground_801C38BC(f32 x, f32 y) @@ -1906,10 +1906,10 @@ void Ground_801C39C0(void) break; } } - stage_info.cam_info.cam_bounds_top = phi_f0; - stage_info.cam_info.cam_bounds_bottom = phi_f5; - stage_info.cam_info.cam_bounds_left = phi_f3; - stage_info.cam_info.cam_bounds_right = phi_f4; + stage_info.cam_info.cam_bounds.top = phi_f0; + stage_info.cam_info.cam_bounds.bottom = phi_f5; + stage_info.cam_info.cam_bounds.left = phi_f3; + stage_info.cam_info.cam_bounds.right = phi_f4; stage_info.cam_info.cam_x_offset = phi_f1; stage_info.cam_info.cam_y_offset = phi_f2; } diff --git a/src/melee/gr/stage.c b/src/melee/gr/stage.c index 23468ed78f..fef5526c1f 100644 --- a/src/melee/gr/stage.c +++ b/src/melee/gr/stage.c @@ -27,25 +27,25 @@ StructPairWithStageID unk_struct_804D49F0 = { 12, 2 }; f32 Stage_GetCamBoundsLeftOffset(void) { - return stage_info.cam_info.cam_bounds_left + + return stage_info.cam_info.cam_bounds.left + stage_info.cam_info.cam_x_offset; } f32 Stage_GetCamBoundsRightOffset(void) { - return stage_info.cam_info.cam_bounds_right + + return stage_info.cam_info.cam_bounds.right + stage_info.cam_info.cam_x_offset; } f32 Stage_GetCamBoundsTopOffset(void) { - return stage_info.cam_info.cam_bounds_top + + return stage_info.cam_info.cam_bounds.top + stage_info.cam_info.cam_y_offset; } f32 Stage_GetCamBoundsBottomOffset(void) { - return stage_info.cam_info.cam_bounds_bottom + + return stage_info.cam_info.cam_bounds.bottom + stage_info.cam_info.cam_y_offset; } @@ -113,18 +113,18 @@ f32 Stage_GetBlastZoneBottomOffset(void) f32 Stage_CalcUnkCamY(void) { f32 cam_y_offset = stage_info.cam_info.cam_y_offset; - f32 y_pos = stage_info.cam_info.cam_bounds_bottom + cam_y_offset + + f32 y_pos = stage_info.cam_info.cam_bounds.bottom + cam_y_offset + (stage_info.blast_zone.bottom + cam_y_offset); return 0.5F * y_pos; } f32 Stage_CalcUnkCamYBounds(void) { - f32 cam_offset = (stage_info.cam_info.cam_bounds_bottom + + f32 cam_offset = (stage_info.cam_info.cam_bounds.bottom + stage_info.cam_info.cam_y_offset); f32 y_pos_product = 0.5F * - ((stage_info.cam_info.cam_bounds_bottom + + ((stage_info.cam_info.cam_bounds.bottom + stage_info.cam_info.cam_y_offset) + (stage_info.blast_zone.bottom + stage_info.cam_info.cam_y_offset)); diff --git a/src/melee/gr/types.h b/src/melee/gr/types.h index 840cf2ee56..71855af56a 100644 --- a/src/melee/gr/types.h +++ b/src/melee/gr/types.h @@ -13,39 +13,6 @@ #include #include -/// @remarks This struct is based in part on the datasheet however the info -/// there is likely incorrect as this doesn't quite match @c -/// grGroundParam. -typedef struct StageCameraInfo { - f32 cam_bounds_left; // 0x0 - f32 cam_bounds_right; // 0x4 - f32 cam_bounds_top; // 0x8 - f32 cam_bounds_bottom; // 0xC - f32 cam_x_offset; // 0x10 - f32 cam_y_offset; // 0x14 - f32 cam_vertical_tilt; // 0x18 - f32 cam_pan_degrees; // 0x1C - f32 x20; // 0x20 - f32 x24; // 0x24 - f32 cam_track_ratio; // 0x28 - f32 cam_fixed_zoom; // 0x2C - f32 cam_track_smooth; // 0x30 - f32 cam_zoom_rate; // 0x34 - f32 cam_max_depth; // 0x38 - f32 x3C; // 0x3C - f32 pausecam_zpos_min; // 0x40 - f32 pausecam_zpos_init; // 0x44 - f32 pausecam_zpos_max; // 0x48 - f32 cam_angle_up; // 0x4C - f32 cam_angle_down; // 0x50 - f32 cam_angle_left; // 0x54 - f32 cam_angle_right; // 0x58 - Vec3 fixed_cam_pos; // 0x5C - 0x64 - f32 fixed_cam_fov; // 0x68 - f32 fixed_cam_vert_angle; // 0x6C - f32 fixed_cam_horz_angle; // 0x70 -} StageCameraInfo; - typedef struct StageBlastZone { f32 left; // 0x74 f32 right; // 0x78 @@ -53,6 +20,36 @@ typedef struct StageBlastZone { f32 bottom; // 0x80 } StageBlastZone; +/// @remarks This struct is based in part on the datasheet however the info +/// there is likely incorrect as this doesn't quite match @c +/// grGroundParam. +typedef struct StageCameraInfo { + StageBlastZone cam_bounds; // 0x00 + f32 cam_x_offset; // 0x10 + f32 cam_y_offset; // 0x14 + f32 cam_vertical_tilt; // 0x18 + f32 cam_pan_degrees; // 0x1C + f32 x20; // 0x20 + f32 x24; // 0x24 + f32 cam_track_ratio; // 0x28 + f32 cam_fixed_zoom; // 0x2C + f32 cam_track_smooth; // 0x30 + f32 cam_zoom_rate; // 0x34 + f32 cam_max_depth; // 0x38 + f32 x3C; // 0x3C + f32 pausecam_zpos_min; // 0x40 + f32 pausecam_zpos_init; // 0x44 + f32 pausecam_zpos_max; // 0x48 + f32 cam_angle_up; // 0x4C + f32 cam_angle_down; // 0x50 + f32 cam_angle_left; // 0x54 + f32 cam_angle_right; // 0x58 + Vec3 fixed_cam_pos; // 0x5C - 0x64 + f32 fixed_cam_fov; // 0x68 + f32 fixed_cam_vert_angle; // 0x6C + f32 fixed_cam_horz_angle; // 0x70 +} StageCameraInfo; + struct StageInfo { StageCameraInfo cam_info; // 0x00 - 0x70 StageBlastZone blast_zone; // 0x74 - 0x80