From 0443d4508ad21e69063594f58ee248a5a13a8ca1 Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Sun, 22 Sep 2024 18:59:03 -0400 Subject: [PATCH] Partially match `lgunbeam` (#1456) --- src/melee/it/itCommonItems.h | 4 +- src/melee/it/it_266F.h | 2 +- src/melee/it/it_2725.h | 4 +- src/melee/it/items/itlgunbeam.c | 580 ++++++++++++-------------------- 4 files changed, 215 insertions(+), 375 deletions(-) diff --git a/src/melee/it/itCommonItems.h b/src/melee/it/itCommonItems.h index fa7db6864d..61d95f9244 100644 --- a/src/melee/it/itCommonItems.h +++ b/src/melee/it/itCommonItems.h @@ -140,11 +140,11 @@ typedef struct ItLGunBeamAttr { typedef struct ItLGunBeamVars { /* +0 ip+DD4 */ Vec3 position0; /* +C ip+DE0 */ Vec3 position1; - /* +18 ip+DEC */ Vec3 position2; + /* +18 ip+DEC */ Vec3 velocity; /* +24 ip+DF8 */ f32 angle0; /* +28 ip+DFC */ f32 angle1; /* +2C ip+E00 */ f32 lifetime; - /* +30 ip+E04 */ f32 xE04; + /* +30 ip+E04 */ int xE04; } ItLGunBeamVars; typedef struct ItLGunRayAttr { diff --git a/src/melee/it/it_266F.h b/src/melee/it/it_266F.h index a901a3b48f..55554775b0 100644 --- a/src/melee/it/it_266F.h +++ b/src/melee/it/it_266F.h @@ -108,7 +108,7 @@ typedef void (*ItCallback)(HSD_GObj*); /* 272F7C */ void it_80272F7C(HSD_JObj*, f32); /* 273030 */ bool it_80273030(Item_GObj*); /* 273078 */ bool itColl_BounceOffShield(Item_GObj*); -/* 273130 */ bool it_80273130(Item_GObj*); +/* 273130 */ enum_t it_80273130(Item_GObj*); /* 273168 */ void it_80273168(HSD_GObj* gobj); /* 2731A4 */ void it_802731A4(HSD_GObj*); /* 2731E0 */ void it_802731E0(HSD_GObj*); diff --git a/src/melee/it/it_2725.h b/src/melee/it/it_2725.h index 7f7129fbc4..ed3dd4abc8 100644 --- a/src/melee/it/it_2725.h +++ b/src/melee/it/it_2725.h @@ -12,6 +12,7 @@ #include /* 272828 */ s32 it_80272828(s32); +/* 272940 */ void it_80272940(Item_GObj* gobj); /* 272980 */ void it_80272980(Item_GObj*, f32); /* 272A60 */ void it_80272A60(Item_GObj*); /* 272CC0 */ HSD_JObj* it_80272CC0(Item_GObj*, enum_t); @@ -37,7 +38,6 @@ /* 276CEC */ void it_80276CEC(HSD_GObj*); /* 276FC4 */ void it_80276FC4(HSD_GObj*); /* 277040 */ bool it_80277040(Item_GObj*); -/* 277040 */ bool it_80277040(Item_GObj*); /* 277544 */ bool it_80277544(HSD_GObj*); /* 27781C */ bool it_8027781C(Item_GObj*); /* 2787B4 */ void it_802787B4(Item_GObj*, s32); @@ -48,8 +48,8 @@ /* 27A13C */ void it_8027A13C(Item_GObj*); /* 27ADEC */ M2C_UNK it_8027ADEC(M2C_UNK, Item_GObj*, HSD_JObj*, f32); /* 27B070 */ void it_8027B070(Item_GObj* gobj, Fighter_GObj* owner_gobj); -/* 27B730 */ void it_8027B730(void); /* 27B378 */ void it_8027B378(Fighter_GObj*, Item_GObj*, float); +/* 27B730 */ void it_8027B730(void); /* 27B798 */ s32 it_8027B798(Item_GObj*, Vec3*); /* 27C56C */ void it_8027C56C(Item_GObj*, f32); /* 27C8B0 */ void it_8027C8B0(Item_GObj*); diff --git a/src/melee/it/items/itlgunbeam.c b/src/melee/it/items/itlgunbeam.c index 15b14d26aa..0ff35ada81 100644 --- a/src/melee/it/items/itlgunbeam.c +++ b/src/melee/it/items/itlgunbeam.c @@ -1,478 +1,318 @@ +#include "it/forward.h" + #include "itlgunbeam.h" #include "db/db_2253.h" #include "ef/eflib.h" #include "ef/efsync.h" +#include "it/inlines.h" #include "it/it_266F.h" #include "it/it_26B1.h" +#include "it/it_2725.h" #include "it/types.h" #include "lb/lbvector.h" #include +#include #include #include #include #include -UNK_RET it_80272940(Item_GObj*); /* extern */ -void it_802998A0(Item_GObj*, HSD_GObj*, s32); /* static */ -int it_8029999C(HSD_GObj*); /* static */ -void it_802999E4(HSD_GObj*); /* static */ -int it_80299A68(HSD_GObj*); /* static */ - -static f32 it_804DCC20 = 0.0f; -static double it_804DCC28 = 2 * M_PI; -static double it_804DCC30 = -M_PI; -static double it_804DCC38 = M_PI; -static double it_804DCC40 = M_PI_2; -static double it_804DCC48 = 0.02; -static double it_804DCC50 = 0.5; -static f32 it_804DCC58 = 1.0f; -static f32 it_804DCC5C = 3.0f; +static bool it_8029999C(Item_GObj*); +static bool it_80299A68(Item_GObj*); +static void it_802998A0(Item_GObj*, HSD_GObj*, s32); +static void it_802999E4(Item_GObj*); -ItemStateTable it_803F6630[1] = { +ItemStateTable it_803F6630[] = { { 0, it_8029999C, it_802999E4, it_80299A68 }, }; -void it_802993E0(Item_GObj* item_gobj, s32 arg1) +void it_802993E0(Item_GObj* gobj, s32 flags) { - // f32 sp1C; - // f32 sp18; - // f32 sp14; + Item* item = GET_ITEM(gobj); Vec3 pos; - Item* item; - - item = item_gobj->user_data; - pos.x = 0.0f; - pos.y = 0.0f; - pos.z = 0.0f; - // sp14 = 0.0f; - // sp18 = 0.0f; - // sp1C = 0.0f; -loop_2: - if (item->xDD4_itemVar.lgunbeam.angle0 < -3.141592653589793) { - item->xDD4_itemVar.lgunbeam.angle0 = - item->xDD4_itemVar.lgunbeam.angle0 + 6.283185307179586; - goto loop_2; - } -loop_5: - if (item->xDD4_itemVar.lgunbeam.angle0 > 3.141592653589793) { - item->xDD4_itemVar.lgunbeam.angle0 = - item->xDD4_itemVar.lgunbeam.angle0 - 6.283185307179586; - goto loop_5; + pos.x = pos.y = pos.z = 0.0f; + while (item->xDD4_itemVar.lgunbeam.angle0 < -M_PI) { + item->xDD4_itemVar.lgunbeam.angle0 += 2 * M_PI; } -#if 0 - switch (arg1) { - case 1: - pos.x += item->x378_itemColl.floor.normal.x; - pos.y += item->x378_itemColl.floor.normal.y; - case 2: - pos.x += item->x378_itemColl.ceiling.normal.x; - pos.y += item->x378_itemColl.ceiling.normal.y; - case 4: - pos.x += item->x378_itemColl.right_wall.normal.x; - pos.y += item->x378_itemColl.right_wall.normal.y; - case 8: - pos.x += item->x378_itemColl.left_wall.normal.x; - pos.y += item->x378_itemColl.left_wall.normal.y; + while (item->xDD4_itemVar.lgunbeam.angle0 > +M_PI) { + item->xDD4_itemVar.lgunbeam.angle0 -= 2 * M_PI; } - lbVector_Normalize(&pos); - item->xDD4_itemVar.lgunbeam.xDE0.x = pos.x; - item->xDD4_itemVar.lgunbeam.xDE0.y = pos.y; - item->xDD4_itemVar.lgunbeam.xDE0.z = pos.z; -#elif 1 - if (arg1 & 1) { + if (flags & (1 << 0)) { pos.x += item->x378_itemColl.floor.normal.x; pos.y += item->x378_itemColl.floor.normal.y; - // sp14 += item->x378_itemColl.floor.normal.x; - // sp18 += item->x378_itemColl.floor.normal.y; } - if (arg1 & 2) { + if (flags & (1 << 1)) { pos.x += item->x378_itemColl.ceiling.normal.x; pos.y += item->x378_itemColl.ceiling.normal.y; - // sp14 += item->x378_itemColl.ceiling.normal.x; - // sp18 += item->x378_itemColl.ceiling.normal.y; } - if (arg1 & 4) { + if (flags & (1 << 2)) { pos.x += item->x378_itemColl.right_wall.normal.x; pos.y += item->x378_itemColl.right_wall.normal.y; - // sp14 += item->x378_itemColl.right_wall.normal.x; - // sp18 += item->x378_itemColl.right_wall.normal.y; } - if (arg1 & 8) { + if (flags & (1 << 3)) { pos.x += item->x378_itemColl.left_wall.normal.x; pos.y += item->x378_itemColl.left_wall.normal.y; - // sp14 += item->x378_itemColl.left_wall.normal.x; - // sp18 += item->x378_itemColl.left_wall.normal.y; } lbVector_Normalize(&pos); - item->xDD4_itemVar.lgunbeam.position1.x = pos.x; - item->xDD4_itemVar.lgunbeam.position1.y = pos.y; - item->xDD4_itemVar.lgunbeam.position1.z = pos.z; -#else - if (arg1 & 1) { - sp14 += item->x378_itemColl.floor.normal.x; - sp18 += item->x378_itemColl.floor.normal.y; - } - if (arg1 & 2) { - sp14 += item->x378_itemColl.ceiling.normal.x; - sp18 += item->x378_itemColl.ceiling.normal.y; - } - if (arg1 & 4) { - sp14 += item->x378_itemColl.right_wall.normal.x; - sp18 += item->x378_itemColl.right_wall.normal.y; - } - if (arg1 & 8) { - sp14 += item->x378_itemColl.left_wall.normal.x; - sp18 += item->x378_itemColl.left_wall.normal.y; - } - lbVector_Normalize((Vec3*) &sp14); - item->xDD4_itemVar.lgunbeam.xDE0.x = sp14; - item->xDD4_itemVar.lgunbeam.xDE0.y = sp18; - item->xDD4_itemVar.lgunbeam.xDE0.z = sp1C; -#endif + item->xDD4_itemVar.lgunbeam.position1 = pos; } -void it_80299528(Item_GObj* item_gobj, s32 arg1) +void it_80299528(Item_GObj* gobj, s32 arg1) { - Item* item; - f32 temp_f1; - f32 temp_f31; - f32 var_f0; - f32 var_f1; - f32 var_f2; - f32 var_f2_2; - f32 var_f31; - f32 var_f3; - f32 var_f3_2; + Item* ip = GET_ITEM(gobj); - item = item_gobj->user_data; if (arg1 != 0) { - temp_f31 = atan2f(item->xDD4_itemVar.lgunbeam.position1.x, - item->xDD4_itemVar.lgunbeam.position1.y); - var_f31 = atan2f(item->xDD4_itemVar.lgunbeam.position2.x, - item->xDD4_itemVar.lgunbeam.position2.y) - - temp_f31; - loop_3: - if (var_f31 > 3.141592653589793) { - var_f31 = var_f31 - 6.283185307179586; - goto loop_3; + float angle1 = atan2f(ip->xDD4_itemVar.lgunbeam.position1.x, + ip->xDD4_itemVar.lgunbeam.position1.y); + float angle2 = atan2f(ip->xDD4_itemVar.lgunbeam.velocity.x, + ip->xDD4_itemVar.lgunbeam.velocity.y) - + angle1; + while (angle2 > M_PI) { + angle2 -= 2 * M_PI; } - loop_6: - if (var_f31 < -3.141592653589793) { - var_f31 = var_f31 + 6.283185307179586; - goto loop_6; + while (angle2 < -M_PI) { + angle2 += 2 * M_PI; } - if (var_f31 == 0.0f) { - var_f1 = 0.0f; - } else { - temp_f1 = lbVector_Angle(&item->xDD4_itemVar.lgunbeam.position1, - &item->xDD4_itemVar.lgunbeam.position2); - if (var_f31 < 0.0f) { - var_f2 = -var_f31; - } else { - var_f2 = var_f31; - } - if (var_f2 < 1.5707963267948966) { - if (var_f31 < 0.0f) { - var_f3 = -var_f31; - } else { - var_f3 = var_f31; - } - var_f2_2 = - (0.019999999552965164 * (var_f3 / 3.141592653589793)); + { + float var_f1; + if (angle2 == 0.0f) { + var_f1 = 0.0f; } else { - if (var_f31 < 0.0f) { - var_f3_2 = -var_f31; - } else { - var_f3_2 = var_f31; + float temp_f1 = + lbVector_Angle(&ip->xDD4_itemVar.lgunbeam.position1, + &ip->xDD4_itemVar.lgunbeam.velocity); + { + float var_f2_2; + if (ABS(angle2) < M_PI_2) { + var_f2_2 = 0.02f * (ABS(angle2) / M_PI); + } else { + var_f2_2 = 0.5 * (ABS(angle2) / M_PI); + } + { + float var_f0; + if (angle2 < 0.0f) { + var_f0 = -var_f2_2; + } else { + var_f0 = var_f2_2; + } + var_f1 = temp_f1 * var_f0; + } } - var_f2_2 = (0.5 * (var_f3_2 / 3.141592653589793)); - } - if (var_f31 < 0.0f) { - var_f0 = -var_f2_2; - } else { - var_f0 = var_f2_2; } - var_f1 = temp_f1 * var_f0; + ip->xDD4_itemVar.lgunbeam.angle0 -= var_f1; } - item->xDD4_itemVar.lgunbeam.angle0 -= var_f1; - loop_27: - if (item->xDD4_itemVar.lgunbeam.angle0 < -3.141592653589793) { - item->xDD4_itemVar.lgunbeam.angle0 = - item->xDD4_itemVar.lgunbeam.angle0 + 6.283185307179586; - goto loop_27; + while (ip->xDD4_itemVar.lgunbeam.angle0 < -M_PI) { + ip->xDD4_itemVar.lgunbeam.angle0 += 2 * M_PI; } - loop_30: - if (item->xDD4_itemVar.lgunbeam.angle0 > 3.141592653589793) { - item->xDD4_itemVar.lgunbeam.angle0 = - item->xDD4_itemVar.lgunbeam.angle0 - 6.283185307179586; - goto loop_30; + while (ip->xDD4_itemVar.lgunbeam.angle0 > +M_PI) { + ip->xDD4_itemVar.lgunbeam.angle0 -= 2 * M_PI; } } } -void it_802996D0(HSD_GObj* owner_gobj, Vec3* pos, u32 arg2, f32 dir) +void it_802996D0(HSD_GObj* owner_gobj, Vec3* pos, u32 arg2, f32 facing_dir) { - // u8 sp64; - // u32 sp60; - // s16 sp5C; - // f32 sp58; - // f32 sp54; - // f32 sp50; - // f32 sp4C; - // f32 sp48; - // s32 sp44; - // s32 sp40; - // Vec3 sp34; - // s32 sp28; - // HSD_GObj* sp24; - // HSD_GObj* sp20; - Item* item; - Item_GObj* item_gobj; SpawnItem spawn; - f32 unused1; - f32 unused2; - // f32 temp_f2_2; - f32 var_f0; - ItLGunBeamAttr* item_spec_attr; + PAD_STACK(4); - spawn.kind = 0x27; + spawn.kind = It_Kind_L_Gun_Beam; spawn.prev_pos = *pos; - // spawn.prev_pos.x = pos->x; - // spawn.prev_pos.y = pos->y; - // spawn.prev_pos.z = pos->z; spawn.prev_pos.z = 0.0f; - it_8026BB68((Item_GObj*) owner_gobj, &spawn.pos); - spawn.facing_dir = dir; + it_8026BB68(owner_gobj, &spawn.pos); + spawn.facing_dir = facing_dir; spawn.x3C_damage = 0; - spawn.vel.z = 0.0f; - spawn.vel.y = 0.0f; - spawn.vel.x = 0.0f; + spawn.vel.x = spawn.vel.y = spawn.vel.z = 0.0f; spawn.x0_parent_gobj = owner_gobj; spawn.x4_parent_gobj2 = spawn.x0_parent_gobj; spawn.x44_flag.bits.b0 = true; - // sp64 |= 0x80; spawn.x40 = arg2; - item_gobj = Item_80268B18(&spawn); - if (item_gobj != NULL) { - item = item_gobj->user_data; - item_spec_attr = item->xC4_article_data->x4_specialAttributes; - item->xDB8_itcmd_var3 = 0; - item->xDB4_itcmd_var2 = 0; - item->xDB0_itcmd_var1 = 0; - item->xDAC_itcmd_var0 = 0; - item->xDD4_itemVar.lgunbeam.lifetime = item_spec_attr->x0; - it_80275158((HSD_GObj*) item_gobj, item_spec_attr->x0); - item->xDD4_itemVar.lgunbeam.position0 = *pos; - item->xDD4_itemVar.lgunbeam.angle1 = - ((item_spec_attr->x8 - item_spec_attr->x4) * HSD_Randf()) + - item_spec_attr->x4; - item->xDD4_itemVar.lgunbeam.angle0 = - ((item_spec_attr->x10 - item_spec_attr->xC) * HSD_Randf()) + - item_spec_attr->xC; - // var_f0 = item->xDD4_itemVar.lgunbeam.xDF8; - if (item->facing_dir == 1.0f) { - var_f0 = item->xDD4_itemVar.lgunbeam.angle0; - } else { - var_f0 = -item->xDD4_itemVar.lgunbeam.angle0; - } - item->xDD4_itemVar.lgunbeam.angle0 = var_f0; - loop_6: - if (item->xDD4_itemVar.lgunbeam.angle0 < -3.141592653589793) { - item->xDD4_itemVar.lgunbeam.angle0 = - item->xDD4_itemVar.lgunbeam.angle0 + 6.283185307179586; - goto loop_6; - } - loop_9: - if (item->xDD4_itemVar.lgunbeam.angle0 > 3.141592653589793) { - item->xDD4_itemVar.lgunbeam.angle0 = - item->xDD4_itemVar.lgunbeam.angle0 - 6.283185307179586; - goto loop_9; - } - item->xDD4_itemVar.lgunbeam.xE04 = 0.0f; - // item->xDCC_flag = (u8) (item->xDCC_flag & ~0x10); - item->xDCC_flag.b1 = 1; - it_802998A0(item_gobj, owner_gobj, HSD_Randi(4)); + { + Item_GObj* gobj = Item_80268B18(&spawn); + if (gobj != NULL) { + Item* item = GET_ITEM(gobj); + ItLGunBeamAttr* item_spec_attr = + item->xC4_article_data->x4_specialAttributes; + item->xDAC_itcmd_var0 = item->xDB0_itcmd_var1 = + item->xDB4_itcmd_var2 = item->xDB8_itcmd_var3 = 0; + item->xDD4_itemVar.lgunbeam.lifetime = item_spec_attr->x0; + it_80275158(gobj, item_spec_attr->x0); + item->xDD4_itemVar.lgunbeam.position0 = *pos; + { + float temp = item_spec_attr->x4; + item->xDD4_itemVar.lgunbeam.angle1 = + ((item_spec_attr->x8 - temp) * HSD_Randf()) + temp; + } + { + float temp = item_spec_attr->xC; + item->xDD4_itemVar.lgunbeam.angle0 = + (item_spec_attr->x10 - temp) * HSD_Randf() + temp; + } + { + f32 angle; + if (item->facing_dir == +1) { + angle = +item->xDD4_itemVar.lgunbeam.angle0; + } else { + angle = -item->xDD4_itemVar.lgunbeam.angle0; + } + item->xDD4_itemVar.lgunbeam.angle0 = angle; + } + while (item->xDD4_itemVar.lgunbeam.angle0 < -M_PI) { + item->xDD4_itemVar.lgunbeam.angle0 += 2 * M_PI; + } + while (item->xDD4_itemVar.lgunbeam.angle0 > M_PI) { + item->xDD4_itemVar.lgunbeam.angle0 -= 2 * M_PI; + } + item->xDD4_itemVar.lgunbeam.xE04 = 0.0f; + item->xDCC_flag.b3 = false; + + it_802998A0(gobj, owner_gobj, HSD_Randi(4)); + } } } -void it_802998A0(Item_GObj* item_gobj, HSD_GObj* fighter_gobj, s32 arg2) +void it_802998A0(Item_GObj* gobj, HSD_GObj* fighter_gobj, s32 arg2) { - f32 sp2C; + Item* ip = GET_ITEM(gobj); + HSD_JObj* jobj = GET_JOBJ(gobj); + f32 sp2C = 1.0f; Vec3 pos; - HSD_JObj* item_jobj; - Item* item; - f32 temp_f1; - f32 unused1; - f32 unused2; - f32 unused3; - - item = item_gobj->user_data; - item_jobj = item_gobj->hsd_obj; - sp2C = 1.0f; - it_8026B3A8(item_gobj); + it_8026B3A8(gobj); // item->unkDCA = item->unkDCA & ~0x10; - item->xDC8_word.flags.x3 = 0; - it_80272940(item_gobj); - Item_80268E5C((HSD_GObj*) item_gobj, 0, ITEM_ANIM_UPDATE); - pos = item->pos; - Item_802694CC((HSD_GObj*) item_gobj); - it_802999E4((HSD_GObj*) item_gobj); - item->pos.x -= item->x40_vel.x; - item->pos.y -= item->x40_vel.y; - temp_f1 = it_8026D9A0(item_gobj); - // item->pos = pos; - // item->pos.x = sp30; - // item->pos.y = temp_r0; - // item->pos.z = temp_r0_2; - // efSync_Spawn(arg2 + 0x44E, item_gobj, item_jobj, item->0x2C, &sp2C, - // temp_f1); efSync_Spawn(arg2 + 0x44E, item_gobj, item_jobj, - // item->facing_dir, pos, &sp2C); - efSync_Spawn(arg2 + 0x44E, item_gobj, item_jobj, item->facing_dir, - item->pos, &sp2C); - db_80225DD8(item_gobj, (Fighter_GObj*) fighter_gobj); + { + PAD_STACK(8); + ip->xDC8_word.flags.x3 = 0; + it_80272940(gobj); + Item_80268E5C(gobj, 0, ITEM_ANIM_UPDATE); + pos = ip->pos; + Item_802694CC(gobj); + it_802999E4(gobj); + ip->pos.x -= ip->x40_vel.x; + ip->pos.y -= ip->x40_vel.y; + it_8026D9A0(gobj); + ip->pos = pos; + // item->pos.x = sp30; + // item->pos.y = temp_r0; + // item->pos.z = temp_r0_2; + // efSync_Spawn(arg2 + 0x44E, gobj, item_jobj, item->0x2C, &sp2C, + // temp_f1); efSync_Spawn(arg2 + 0x44E, gobj, item_jobj, + // item->facing_dir, pos, &sp2C); + efSync_Spawn(arg2 + 0x44E, gobj, jobj, ip->facing_dir, ip->pos, &sp2C); + db_80225DD8(gobj, fighter_gobj); + } } -int it_8029999C(HSD_GObj* item_gobj) +bool it_8029999C(HSD_GObj* gobj) { - f32 unused1; - f32 unused2; - f32 unused3; - f32 unused4; - - if (it_80273130((Item_GObj*) item_gobj) == 1) { - efLib_DestroyAll((HSD_GObj*) item_gobj); - return 1; + PAD_STACK(4 * 4); + if (it_80273130(gobj) == 1) { + efLib_DestroyAll(gobj); + return true; } - return 0; + return false; } -void it_802999E4(HSD_GObj* item_gobj) +void it_802999E4(HSD_GObj* gobj) { - Item* item; - f32 temp_f0; - f32 temp_f0_2; - f32 unused1; - f32 unused2; + Item* ip = GET_ITEM(gobj); + PAD_STACK(4); + + ip->xDD4_itemVar.lgunbeam.position0 = ip->pos; + + ip->xDD4_itemVar.lgunbeam.velocity.x = ip->x40_vel.x = + ip->xDD4_itemVar.lgunbeam.angle1 * + sinf(ip->xDD4_itemVar.lgunbeam.angle0); + + ip->xDD4_itemVar.lgunbeam.velocity.y = ip->x40_vel.y = + ip->xDD4_itemVar.lgunbeam.angle1 * + cosf(ip->xDD4_itemVar.lgunbeam.angle0); - item = item_gobj->user_data; - item->xDD4_itemVar.lgunbeam.position0 = item->pos; - temp_f0 = item->xDD4_itemVar.lgunbeam.angle1 * - sinf(item->xDD4_itemVar.lgunbeam.angle0); - item->x40_vel.x = temp_f0; - // item->xDD4_itemVar.lgunbeam.xDEC = temp_f0; - item->xDD4_itemVar.lgunbeam.position2.x = temp_f0; - temp_f0_2 = item->xDD4_itemVar.lgunbeam.angle1 * - cosf(item->xDD4_itemVar.lgunbeam.angle0); - item->x40_vel.y = temp_f0_2; - item->xDD4_itemVar.lgunbeam.position2.y = temp_f0_2; - item->x40_vel.z = 0.0f; - item->xDD4_itemVar.lgunbeam.position2.z = 0.0f; - lbVector_Normalize(&item->xDD4_itemVar.lgunbeam.position2); + ip->xDD4_itemVar.lgunbeam.velocity.z = ip->x40_vel.z = 0.0f; + + lbVector_Normalize(&ip->xDD4_itemVar.lgunbeam.velocity); } -int it_80299A68(HSD_GObj* item_gobj) +bool it_80299A68(HSD_GObj* gobj) { - Item* item; - s32 temp_r3; - s32 var_r31; - - item = item_gobj->user_data; -loop_2: - if (item->xDD4_itemVar.lgunbeam.angle0 < -3.141592653589793) { - item->xDD4_itemVar.lgunbeam.angle0 = - item->xDD4_itemVar.lgunbeam.angle0 + 6.283185307179586; - goto loop_2; - } -loop_5: - if (item->xDD4_itemVar.lgunbeam.angle0 > 3.141592653589793) { - item->xDD4_itemVar.lgunbeam.angle0 = - item->xDD4_itemVar.lgunbeam.angle0 - 6.283185307179586; - goto loop_5; - } - var_r31 = 0; - // item->x378_itemColl.x108_joint = 3.0f; - // item->x378_itemColl.x10C_joint[0] = 3.0f; - // item->x378_itemColl.x10C_joint[1] = 3.0f; - // item->x378_itemColl.x10C_joint[2] = 3.0f; - item->x378_itemColl.x108_f32 = 3.0f; - item->x378_itemColl.x10C_f32 = 3.0f; - item->x378_itemColl.x110_f32 = 3.0f; - item->x378_itemColl.x114_f32 = 3.0f; - it_8026D9A0((Item_GObj*) item_gobj); - temp_r3 = item->x378_itemColl.env_flags; - if (temp_r3 & 0x18000) { - var_r31 = 1; + s32 flags = 0; + Item* ip = GET_ITEM(gobj); + while (ip->xDD4_itemVar.lgunbeam.angle0 < -M_PI) { + ip->xDD4_itemVar.lgunbeam.angle0 += 2 * M_PI; } - if (temp_r3 & 0x6000) { - var_r31 |= 2; + while (ip->xDD4_itemVar.lgunbeam.angle0 > +M_PI) { + ip->xDD4_itemVar.lgunbeam.angle0 -= 2 * M_PI; } - if (temp_r3 & 0x3F) { - var_r31 |= 4; - } - if (temp_r3 & 0xFC0) { - var_r31 |= 8; - } - if (var_r31 != 0) { - it_802993E0((Item_GObj*) item_gobj, var_r31); - it_80299528((Item_GObj*) item_gobj, var_r31); + { + ip->x378_itemColl.x108_f32 = 3.0f; + ip->x378_itemColl.x10C_f32 = 3.0f; + ip->x378_itemColl.x110_f32 = 3.0f; + ip->x378_itemColl.x114_f32 = 3.0f; + it_8026D9A0(gobj); + + if (ip->x378_itemColl.env_flags & 0x18000) { + flags |= 1; + } + if (ip->x378_itemColl.env_flags & 0x6000) { + flags |= 2; + } + if (ip->x378_itemColl.env_flags & 0x3F) { + flags |= 4; + } + if (ip->x378_itemColl.env_flags & 0xFC0) { + flags |= 8; + } + if (flags) { + it_802993E0(gobj, flags); + it_80299528(gobj, flags); + } } - return 0; + return false; } -int it_80299B6C(Item_GObj* item_gobj) +bool it_80299B6C(Item_GObj* gobj) { - return 0; + return false; } -int it_80299B74(Item_GObj* item_gobj) +bool it_80299B74(Item_GObj* gobj) { - Item* item; - - item = item_gobj->user_data; - item->xDD4_itemVar.lgunbeam.angle0 = - item->xDD4_itemVar.lgunbeam.angle0 + 3.141592653589793; -loop_2: - if (item->xDD4_itemVar.lgunbeam.angle0 < -3.141592653589793) { - item->xDD4_itemVar.lgunbeam.angle0 = - item->xDD4_itemVar.lgunbeam.angle0 + 6.283185307179586; - goto loop_2; + Item* ip = GET_ITEM(gobj); + ip->xDD4_itemVar.lgunbeam.angle0 += M_PI; + while (ip->xDD4_itemVar.lgunbeam.angle0 < -M_PI) { + ip->xDD4_itemVar.lgunbeam.angle0 += 2 * M_PI; } -loop_5: - if (item->xDD4_itemVar.lgunbeam.angle0 > 3.141592653589793) { - item->xDD4_itemVar.lgunbeam.angle0 = - item->xDD4_itemVar.lgunbeam.angle0 - 6.283185307179586; - goto loop_5; + while (ip->xDD4_itemVar.lgunbeam.angle0 > +M_PI) { + ip->xDD4_itemVar.lgunbeam.angle0 -= 2 * M_PI; } - item->facing_dir = -item->facing_dir; - item->x40_vel.x = -item->x40_vel.x; - item->x40_vel.y = -item->x40_vel.y; - return 0; + ip->facing_dir = -ip->facing_dir; + ip->x40_vel.x = -ip->x40_vel.x; + ip->x40_vel.y = -ip->x40_vel.y; + return false; } -int it_80299C08(Item_GObj* item_gobj) +bool it_80299C08(Item_GObj* gobj) { - return 1; + return true; } -int it_80299C10(Item_GObj* item_gobj) +bool it_80299C10(Item_GObj* gobj) { - return 0; + return false; } -int it_80299C18(Item_GObj* item_gobj) +bool it_80299C18(Item_GObj* gobj) { - return 1; + return true; } -int it_80299C20(Item_GObj* item_gobj) +bool it_80299C20(Item_GObj* gobj) { - return 1; + return true; } -void it_80299C28(Item_GObj* item_gobj, HSD_GObj* ref_gobj) +void it_80299C28(Item_GObj* gobj, HSD_GObj* ref_gobj) { - it_8026B894(item_gobj, ref_gobj); + it_8026B894(gobj, ref_gobj); }