From ce59234289c9218832aba1f02ddd892a2d9a8291 Mon Sep 17 00:00:00 2001 From: Jonathan Hohle Date: Tue, 10 Sep 2024 15:02:10 -0700 Subject: [PATCH] missing assert, format --- include/entity.h | 41 +++++++++++++++++++++-------------------- src/weapon/w_044.c | 17 +++++++++-------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/include/entity.h b/include/entity.h index bf6d78ba67..8069602a67 100644 --- a/include/entity.h +++ b/include/entity.h @@ -241,26 +241,26 @@ typedef struct PACKED { } ET_WeaponUnk030; typedef struct { - /* 0x7C */ s16 lifetime; - /* 0x7E */ s16 unk7E; - /* 0x80 */ s16 unk80; - /* 0x82 */ s16 unk82; - /* 0x84 */ struct Entity* some_ent; - /* 0x88 */ s16 childPalette; - /* 0x8A */ s16 unk8A; - /* 0x8C */ s32 : 32; - /* 0x90 */ s16 unk90; - /* 0x92 */ s16:16; - /* 0x94 */ s16 unk94; - /* 0x96 */ s16 : 16; - /* 0x98 */ s32 unk98; - /* 0x9C */ s32 accelerationX; - /* 0xA0 */ s32 accelerationY; - /* 0xA4 */ s32 unkA4; - /* 0xA8 */ s32 unkA8; - /* 0xAC */ u8 anim; - /* 0xAD */ u8 unkAD; - /* 0xAE */ s16 equipId; + /* 0x7C */ s16 lifetime; + /* 0x7E */ s16 unk7E; + /* 0x80 */ s16 unk80; + /* 0x82 */ s16 unk82; + /* 0x84 */ struct Entity* some_ent; + /* 0x88 */ s16 childPalette; + /* 0x8A */ s16 unk8A; + /* 0x8C */ s32 : 32; + /* 0x90 */ s16 unk90; + /* 0x92 */ s16 : 16; + /* 0x94 */ s16 unk94; + /* 0x96 */ s16 : 16; + /* 0x98 */ s32 unk98; + /* 0x9C */ s32 accelerationX; + /* 0xA0 */ s32 accelerationY; + /* 0xA4 */ s32 unkA4; + /* 0xA8 */ s32 unkA8; + /* 0xAC */ u8 anim; + /* 0xAD */ u8 unkAD; + /* 0xAE */ s16 equipId; } ET_WeaponUnk044; typedef struct PACKED { @@ -1905,6 +1905,7 @@ SYNC_FIELD(ET_Player, ET_WeaponUnk006, anim); SYNC_FIELD(ET_Player, ET_WeaponUnk012, anim); SYNC_FIELD(ET_Player, ET_WeaponUnk014, anim); SYNC_FIELD(ET_Player, ET_WeaponUnk030, anim); +SYNC_FIELD(ET_Player, ET_WeaponUnk044, anim); SYNC_FIELD(ET_Player, ET_WeaponUnk046, anim); SYNC_FIELD(ET_Player, ET_WeaponUnk047, anim); SYNC_FIELD(ET_Player, ET_KarmaCoin, anim); diff --git a/src/weapon/w_044.c b/src/weapon/w_044.c index d5091e5674..34e16869c1 100644 --- a/src/weapon/w_044.c +++ b/src/weapon/w_044.c @@ -114,6 +114,7 @@ extern s32 D_80097420; extern s32 D_138000_8017A260[]; void EntityWeaponAttack(Entity* self) { + const int PrimCount = 17; bool doLastblock; Primitive* prim; s16 selfY; @@ -137,15 +138,14 @@ void EntityWeaponAttack(Entity* self) { doLastblock = false; switch (self->step) { case 0: - self->primIndex = g_api.AllocPrimitives( - PRIM_GT4, 17); // bug? loops iterate over 16 prims + self->primIndex = g_api.AllocPrimitives(PRIM_GT4, PrimCount); if (self->primIndex == -1) { DestroyEntity(self); return; } prim = &g_PrimBuf[self->primIndex]; - for (i = 0; i < 16; i++) { + for (i = 0; i < (PrimCount - 1); i++) { if (i < 8) { prim->u1 = prim->u3 = (7 - i) * 8 + 0x40; prim->u0 = prim->u2 = prim->u1 + 7; @@ -212,7 +212,7 @@ void EntityWeaponAttack(Entity* self) { g_api.func_80118C28(2); prim = &g_PrimBuf[self->primIndex]; - for (i = 0; i < 16; i++) { + for (i = 0; i < (PrimCount - 1); i++) { prim->u0 = prim->u2 = i * 8; prim->u1 = prim->u3 = prim->u0 + 8; prim->v0 = prim->v1 = vCoord + 0; @@ -221,7 +221,8 @@ void EntityWeaponAttack(Entity* self) { prim = prim->next; } - if (i == 0xF) { // ??? + // BUG? this will always fail + if (i == 15) { prim->u1--; prim->u3--; } @@ -266,7 +267,7 @@ void EntityWeaponAttack(Entity* self) { } prim = &g_PrimBuf[self->primIndex]; - for (i = 0; i < 16; i++) { + for (i = 0; i < (PrimCount - 1); i++) { prim->drawMode = DRAW_TPAGE2 | DRAW_TPAGE | DRAW_COLORS | DRAW_TRANSP; prim = prim->next; @@ -288,7 +289,7 @@ void EntityWeaponAttack(Entity* self) { offset = 64; base = 192; prim = &g_PrimBuf[self->primIndex]; - for (i = 0; i < 16; i++) { + for (i = 0; i < (PrimCount - 1); i++) { angle = D_138000_8017A260[i]; sine = (rsin(angle) >> 5) * self->ext.weapon_044.unk94 / 256; prim->y0 = selfY + sine; @@ -329,7 +330,7 @@ void EntityWeaponAttack(Entity* self) { prim->y3 = -(((rsin(0xE00) >> 8) * self->rotX) >> 8) + lastBlockYShift; prim->r0 = prim->g0 = prim->b0 = prim->r1 = prim->g1 = prim->b1 = prim->r2 = prim->g2 = prim->b2 = prim->r3 = prim->g3 = prim->b3 = - self->rotY; // ??? + self->rotY; prim->drawMode &= ~DRAW_HIDE; } }