Skip to content

Commit

Permalink
missing assert, format
Browse files Browse the repository at this point in the history
  • Loading branch information
hohle committed Sep 10, 2024
1 parent c9a4f5c commit ce59234
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
41 changes: 21 additions & 20 deletions include/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
17 changes: 9 additions & 8 deletions src/weapon/w_044.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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--;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit ce59234

Please sign in to comment.