diff --git a/include/entity.h b/include/entity.h index 09903fb3..c963f7f2 100644 --- a/include/entity.h +++ b/include/entity.h @@ -2,6 +2,7 @@ #define ENTITY_H #include "global.h" +#include "sprite.h" typedef struct { void* entity1; @@ -73,8 +74,8 @@ typedef struct Entity { u8 b2 : 3; } PACKED spriteOrientation; u8 filler[2]; - u8 animationList; - u8 field_1f; + u8 frameIndex; + u8 lastFrameIndex; s32 field_0x20; s16 nonPlanarMovement; u8 spriteAnimation[3]; @@ -109,8 +110,8 @@ typedef struct Entity { u8 field_0x4f; struct Entity* parent; struct Entity* attachedEntity; - u8 field_0x58; - u8 animTime; + u8 animIndex; + u8 frameDuration; union { u8 all; struct { @@ -120,11 +121,8 @@ typedef struct Entity { u8 f3 : 1; } PACKED b; } PACKED frames; - u8 gfx; - u8 field_0x5c; - u8 field_0x5d; - u8 field_0x5e; - u8 field_0x5f; + u8 frameSpriteSettings; + Frame* animPtr; u16 spriteVramOffset; u8 spriteOffsetX; u8 spriteOffsetY; diff --git a/include/sprite.h b/include/sprite.h index e69de29b..0a172203 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -0,0 +1,26 @@ +#ifndef SPRITE_H +#define SPRITE_H + +#include "global.h" + +typedef struct { + u8 index; + u8 duration; + union { + u8 raw; + struct { + u8 unk : 6; + u8 hFlip : 1; + u8 vFlip : 1; + } PACKED b; + } PACKED spriteSettings; + union { + u8 raw; + struct { + u8 extraFrameIndex : 6; + u8 unk : 1; + u8 endOfAnimation : 1; + } PACKED b; + } PACKED frameSettings; +} Frame; +#endif \ No newline at end of file diff --git a/src/bladeBrothers.c b/src/bladeBrothers.c index 5d8be642..fedaef0f 100644 --- a/src/bladeBrothers.c +++ b/src/bladeBrothers.c @@ -86,7 +86,7 @@ void sub_08068A4C(Entity* this) { this->field_0xf = 0x10; } else { this->field_0xf--; - uVar1 = (u32)this->field_0x58; + uVar1 = (u32)this->animIndex; } } iVar2 = sub_0806F078(this, uVar1); diff --git a/src/giantLeaf.c b/src/giantLeaf.c index c43a20af..d34c1605 100644 --- a/src/giantLeaf.c +++ b/src/giantLeaf.c @@ -15,7 +15,7 @@ void GiantLeaf(Entity* ent) { ent->spriteSettings.b.ss0 = 1; ent->spriteOrder.b3 = 3; ent->ticks.b0 = 7; - ent->animationList = ent->entityType.form; + ent->frameIndex = ent->entityType.form; sub_0808D618(ent); } } diff --git a/src/goron.c b/src/goron.c index cacf9dfc..42124144 100644 --- a/src/goron.c +++ b/src/goron.c @@ -32,7 +32,7 @@ void sub_08069328(Entity* this) { this->animationState = action; } } - if (this->field_0x58 != this->animationState) { + if (this->animIndex != this->animationState) { InitAnimationForceUpdate(this, this->animationState); } if (this->interactType != 0) { @@ -62,7 +62,7 @@ void sub_08069428(Entity* this, s32 offsetX, bool32 createFx65); void sub_080693D0(Entity* this) { sub_0807DD94(this, 0); - if (this->field_0x58 == 8) { + if (this->animIndex == 8) { u32 var0 = this->field_0x82 & 0xF; bool32 createFx65 = ((-var0) | var0) >> 0x1F; // = !var0 diff --git a/src/mailbox.c b/src/mailbox.c index 24380832..e290f2be 100644 --- a/src/mailbox.c +++ b/src/mailbox.c @@ -33,7 +33,7 @@ void sub_08063220(Entity* this) { bVar1 = 0; } - if (this->field_0x58 != bVar1) { + if (this->animIndex != bVar1) { InitAnimationForceUpdate(this); } else { sub_08063280(this, bVar1); diff --git a/src/rem.c b/src/rem.c index 6266104f..93180c5e 100644 --- a/src/rem.c +++ b/src/rem.c @@ -28,7 +28,7 @@ void sub_0806a370(Entity* this) { sub_0807DDE4(this); UpdateAnimationSingleFrame(this); sub_0806ED78(this); - if (this->field_0x58 == 0xf) { + if (this->animIndex == 0xf) { pbVar1 = &this->frames.all; if (*pbVar1 == 1) { *pbVar1 = 0; diff --git a/src/talon.c b/src/talon.c index 10cec011..5e1561ab 100644 --- a/src/talon.c +++ b/src/talon.c @@ -47,10 +47,10 @@ void sub_0806559C(Entity* this) { offset = result; } } else { - offset = this->field_0x58; + offset = this->animIndex; } - if (this->field_0x58 != offset) { + if (this->animIndex != offset) { InitializeAnimation(this, offset); } else { GetNextFrame(this); @@ -128,11 +128,11 @@ void sub_080656D4(Entity* this) { void sub_0806574C(Entity* this) { u32 j; - j = (this->field_0x58 & ~3) + sub_0806F5A4(sub_080045C4(this, &gLinkEntity)); - if (this->field_0x58 != j) { + j = (this->animIndex & ~3) + sub_0806F5A4(sub_080045C4(this, &gLinkEntity)); + if (this->animIndex != j) { InitAnimationForceUpdate(this, j); } - this->field_0x6a.HALF.LO = this->field_0x58; + this->field_0x6a.HALF.LO = this->animIndex; } void sub_08065780(Entity* this, u16* param_2) { @@ -145,7 +145,7 @@ void sub_08065780(Entity* this, u16* param_2) { void Talon_Head(Entity* this) { sub_0806FF60(this, 0, ((this->frames.all & 7) + 0xB)); - sub_0806FF60(this, 1, this->animationList); + sub_0806FF60(this, 1, this->frameIndex); sub_0806FF88(this, 1, 0); sub_0807000C(this); } diff --git a/src/windTribeFlag.c b/src/windTribeFlag.c index 6ef01fb3..b8257ff5 100644 --- a/src/windTribeFlag.c +++ b/src/windTribeFlag.c @@ -19,7 +19,7 @@ void WindTribeFlag(Entity *this) else { GetNextFrame(this); } - if (this->animTime == 0xff) { - this->animTime = (Random() & 0xf) + 0x10; + if (this->frameDuration == 0xff) { + this->frameDuration = (Random() & 0xf) + 0x10; } } \ No newline at end of file diff --git a/src/windcrest.c b/src/windcrest.c index 38151a80..0429a658 100644 --- a/src/windcrest.c +++ b/src/windcrest.c @@ -21,7 +21,7 @@ void Windcrest(Entity *this) { if (this->action == 0) { this->action++; - this->animationList = 0; + this->frameIndex = 0; sub_0807DD64(this); } sub_0807DDAC(this, 0); diff --git a/src/zelda.c b/src/zelda.c index 57f0e034..830bbf3e 100644 --- a/src/zelda.c +++ b/src/zelda.c @@ -112,27 +112,27 @@ void sub_08066DE4(Entity* ent) { void sub_08066E08(Entity* ent) { InitAnimationForceUpdate(ent, 0x50); - ent->field_0x80 = ent->field_0x58; + ent->field_0x80 = ent->animIndex; } void sub_08066E20(Entity* ent) { InitAnimationForceUpdate(ent, 0x44); - ent->field_0x80 = ent->field_0x58; + ent->field_0x80 = ent->animIndex; } void sub_08066E38(Entity* ent) { InitAnimationForceUpdate(ent, 0x48); - ent->field_0x80 = ent->field_0x58; + ent->field_0x80 = ent->animIndex; } void sub_08066E50(Entity* ent) { InitAnimationForceUpdate(ent, 0x4C); - ent->field_0x80 = ent->field_0x58; + ent->field_0x80 = ent->animIndex; } void sub_08066E68(Entity* ent) { InitAnimationForceUpdate(ent, 0x54); - ent->field_0x80 = ent->field_0x58; + ent->field_0x80 = ent->animIndex; } void sub_08066E80(Entity* ent, u8* param_2) { @@ -175,7 +175,7 @@ void sub_08066E80(Entity* ent, u8* param_2) { return; } } - ent->field_0x80 = ent->field_0x58; + ent->field_0x80 = ent->animIndex; gUnk_02033280[6] = 0; }