summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornotyouraveragehooman <65437533+notyouraveragehooman@users.noreply.github.com>2020-08-29 17:54:59 -0700
committerGitHub <noreply@github.com>2020-08-29 17:54:59 -0700
commit550ca4177be3558bfceab66d4236bcef8aafcbce (patch)
treec6a419fc9fb7c2a523ba1e918b8cde61858f203e /src
parentae7968e0067118a4d1d40fc7ca42c74e90b996d1 (diff)
parentdba975b15b1ae95d7537137a0a9b714382c38abe (diff)
Merge pull request #80 from HookedBehemoth:beetle
decompile Beetle, DoorMimic and RockChuchu
Diffstat (limited to 'src')
-rw-r--r--src/enemy/beetle.c360
-rw-r--r--src/enemy/cuccoChickAggr.c167
-rw-r--r--src/enemy/doorMimic.c271
-rw-r--r--src/enemy/enemyE.c69
-rw-r--r--src/enemy/hangingSeed.c62
-rw-r--r--src/enemy/keese.c199
-rw-r--r--src/enemy/moldorm.c211
-rw-r--r--src/enemy/rockChuchu.c122
-rw-r--r--src/enemy/spinyChuchu.c285
-rw-r--r--src/object/mineralWaterSource.c4
-rw-r--r--src/object/object49.c8
11 files changed, 1638 insertions, 120 deletions
diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c
new file mode 100644
index 00000000..3bdbfdad
--- /dev/null
+++ b/src/enemy/beetle.c
@@ -0,0 +1,360 @@
+#include "entity.h"
+#include "functions.h"
+#include "player.h"
+
+extern u32 sub_08049F64(Entity*, u32, u32);
+
+u32 sub_08021D00();
+void sub_08021D44(Entity* this, u32 param_2);
+
+extern void (*const gUnk_080CB590[])(Entity*);
+extern void (*const gUnk_080CB5A8[])(Entity*);
+extern void (*const gUnk_080CB5C8[])(Entity*);
+extern void (*const gUnk_080CB5D4[])(Entity*);
+
+extern const s8 gUnk_080CB5DC[];
+extern const s8 gUnk_080CB5E4[];
+
+void Beetle(Entity* this) {
+ EnemyFunctionHandler(this, gUnk_080CB590);
+}
+
+void sub_08021768(Entity* this) {
+ gUnk_080CB5A8[this->action](this);
+}
+
+void sub_08021780(Entity* this) {
+ switch (this->bitfield) {
+ case 0x80:
+ if (gPlayerState.field_0xa8 == 24) {
+ sub_08021768(this);
+ } else {
+ this->action = 5;
+ this->actionDelay = 0xb4;
+ this->field_0xf = 0;
+ this->flags &= ~0x80;
+ this->spritePriority.b0 = 3;
+ CopyPositionAndSpriteOffset(&gPlayerEntity, this);
+ this->height.HALF.HI = -1;
+ ((u8*)&this->field_0x86)[1] = 1;
+ InitializeAnimation(this, 6);
+ }
+ break;
+ case 0x93:
+ sub_08021768(this);
+ break;
+ }
+
+ if (this->currentHealth == 0)
+ this->field_0x42 = 0;
+
+ sub_0804AA30(this, gUnk_080CB590);
+}
+
+void sub_08021818(Entity* this) {
+ if (this->entityType.form == 0) {
+ sub_0804A7D4(this);
+ } else {
+ Entity* ent = this->parent;
+ if (ent) {
+ ent->field_0xf--;
+ this->parent = NULL;
+ }
+ CreateDeathFx(this, 0xf0, 0);
+ }
+}
+
+void sub_08021848(Entity* this) {
+ if (sub_0806F520(this)) {
+ gUnk_080CB5C8[this->previousActionFlag](this);
+ } else {
+ this->action = 3;
+ this->height.HALF.HI = 0;
+ InitializeAnimation(this, 2);
+ }
+}
+
+void sub_0802187C(Entity* this) {
+ this->previousActionFlag = 2;
+}
+
+void nullsub_130(Entity* this) {
+}
+
+void sub_08021888(Entity* this) {
+ if (sub_0806F3E4(this))
+ sub_08021818(this);
+}
+
+void sub_0802189C(Entity* this) {
+ sub_0804A720(this);
+ this->action = 1;
+ this->field_0x1c = 1;
+ InitializeAnimation(this, 3);
+}
+
+void sub_080218B4(Entity* this) {
+ gUnk_080CB5D4[this->entityType.parameter](this);
+}
+
+void sub_080218CC(Entity* this) {
+ if (this->previousActionFlag == 0) {
+ this->previousActionFlag = 1;
+ this->spriteSettings.b.draw = 1;
+ this->direction = ((sub_08049F84(this, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & 0x1f;
+ this->nonPlanarMovement = 0x100;
+ this->field_0x20 = 0x12000;
+ }
+
+ GetNextFrame(this);
+ if (this->frames.all & 1) {
+ sub_080AEFE0(this);
+ if (sub_080044EC(this, 0x1c00) == 0)
+ this->frameDuration = 1;
+ }
+
+ if (this->frames.all & 0x80) {
+ this->action = 2;
+ this->actionDelay = (Random() & 0x38) + 8;
+ this->field_0xf = 1;
+ this->flags |= 0x80;
+ this->nonPlanarMovement = 0x180;
+ InitializeAnimation(this, 0);
+ }
+}
+
+void sub_08021984(Entity* this) {
+ if (this->previousActionFlag == 0) {
+ this->previousActionFlag = 1;
+ this->flags |= 0x80;
+ this->spriteSettings.b.draw = 3;
+ this->height.HALF.HI = -0x80;
+ this->spriteRendering.b3 = 1;
+ this->spriteOrientation.flipY = 1;
+ sub_08004488(0x12d);
+ }
+
+ if (sub_08003FC4(this, 0x1800) == 0) {
+ this->action = 2;
+ this->actionDelay = 16;
+ this->field_0xf = 1;
+ this->spriteSettings.b.draw = 1;
+ this->nonPlanarMovement = 0x180;
+ ((u8*)&this->field_0x86)[0] = 60;
+ InitializeAnimation(this, 0);
+ UpdateSpriteForCollisionLayer(this);
+ }
+}
+
+void sub_08021A10(Entity* this) {
+ GetNextFrame(this);
+ if (sub_080041A0(this, &gPlayerEntity, 120, 80) && sub_08021D00(this) == 0) {
+ if (--this->actionDelay == 0) {
+ this->action = 3;
+ this->actionDelay = (Random() & 0x3f) + 30;
+ sub_08021D44(this, this->direction);
+ InitializeAnimation(this, 2);
+ }
+ }
+}
+
+void sub_08021A64(Entity* this) {
+ if (!sub_08021D00(this)) {
+ if (--this->actionDelay == 0) {
+ this->action = 2;
+ this->actionDelay = (Random() & 0x1f) + 0x1e;
+ InitializeAnimation(this, 0);
+ }
+
+ if (--this->field_0xf == 0) {
+ u32 tmp;
+
+ this->field_0xf = 8;
+ tmp = sub_08049F84(this, 1);
+ if (tmp == 0xff) {
+ this->action = 7;
+ InitializeAnimation(this, 1);
+ return;
+ }
+ sub_08021D44(this, tmp);
+ }
+ sub_080AEF88(this);
+ GetNextFrame(this);
+ }
+}
+
+void sub_08021AD8(Entity* this) {
+ GetNextFrame(this);
+ if (this->frames.all & 1) {
+ if (this->actionDelay) {
+ u32 tmp;
+
+ this->actionDelay = 0;
+ tmp = sub_08049F84(this, 1);
+ if (tmp == 0xff) {
+ this->action = 2;
+ this->actionDelay = '\b';
+ InitializeAnimation(this, 0);
+ return;
+ }
+ this->direction = (u8)tmp;
+ sub_08004488(0x7c);
+ }
+ sub_080AEFE0(this);
+ if (!sub_08003FC4(this, 0x1800))
+ this->frameDuration = 1;
+ }
+
+ if (this->frames.all & 0x80) {
+ this->action = 2;
+ this->actionDelay = 20;
+ ((u8*)&this->field_0x86)[0] = 60;
+ InitializeAnimation(this, 0);
+ }
+}
+
+void sub_08021B64(Entity* this) {
+ if (gPlayerState.flags.all & 4) {
+ this->action = 3;
+ this->height.WORD = 0;
+ InitializeAnimation(this, 2);
+ } else {
+ int iVar4 = 1;
+ if (gPlayerState.field_0xa8 != 11 && gPlayerState.field_0xa8 != 20) {
+ if (sub_0807953C())
+ iVar4 = this->entityType.form * 3 + 8;
+
+ iVar4 = this->actionDelay - iVar4;
+ if (iVar4 < 0)
+ iVar4 = 0;
+
+ this->actionDelay = (u8)iVar4;
+ }
+
+ if (gPlayerState.flags.all & 0x110)
+ iVar4 = 0;
+
+ if (iVar4 == 0) {
+ this->action = 6;
+ this->field_0x20 = 0x10000;
+ ((u8*)&this->field_0x86)[1] = 0;
+ if (gPlayerEntity.direction != 0xff) {
+ this->direction = 0x10 ^ gPlayerEntity.direction;
+ } else {
+ this->direction = (gPlayerEntity.animationState << 2) ^ 0x10;
+ }
+ InitializeAnimation(this, 5);
+ } else {
+ gPlayerState.field_0x1a[0] |= 0x80;
+ gPlayerState.field_0x80 -= 0x50;
+ gPlayerState.field_0xaa++;
+ CopyPositionAndSpriteOffset(&gPlayerEntity, this);
+ this->x.HALF.HI += gUnk_080CB5E4[(this->field_0xf++ & 0xe) >> 1];
+ this->height.HALF.HI--;
+ GetNextFrame(this);
+ }
+ }
+}
+
+void sub_08021C58(Entity* this) {
+ GetNextFrame(this);
+ if (this->frames.all & 1) {
+ sub_080AEFE0(this);
+ if (sub_08003FC4(this, 0x1800) == 0)
+ this->frameDuration = 1;
+ }
+
+ if (this->frames.all & 0x80) {
+ this->action = 2;
+ this->actionDelay = 60;
+ this->field_0xf = 1;
+ this->flags |= 0x80;
+ this->spritePriority.b0 = 4;
+ ((u8*)&this->field_0x86)[0] = 60;
+ InitializeAnimation(this, 0);
+ }
+}
+
+void sub_08021CD0(Entity* this) {
+ if ((this->frames.all & 0x80) == 0)
+ GetNextFrame(this);
+
+ if (sub_08049F84(this, 1) == 0xff)
+ return;
+
+ this->action = 3;
+ InitializeAnimation(this, 2);
+}
+
+u32 sub_08021D00(Entity* this) {
+ u32 ret;
+
+ if (((u8*)&this->field_0x86)[0]) {
+ ((u8*)&this->field_0x86)[0]--;
+ ret = 0;
+ } else if (sub_08049F64(this, 1, 0x10) == 0) {
+ ret = 0;
+ } else {
+ this->action = 4;
+ this->actionDelay = 1;
+ this->field_0x20 = 0x18000;
+ InitializeAnimation(this, 4);
+ ret = 1;
+ }
+
+ return ret;
+}
+
+void sub_08021D44(Entity* this, u32 param_2) {
+ param_2 += 4;
+ param_2 &= 0x18;
+ this->direction = param_2;
+ if (param_2 & 8) {
+ this->nonPlanarMovement = 0x180;
+ } else {
+ this->nonPlanarMovement = 0xc0;
+ }
+}
+
+
+// clang-format off
+void (*const gUnk_080CB590[])(Entity*) = {
+ sub_08021768,
+ sub_08021780,
+ sub_08001324,
+ sub_08021818,
+ sub_08001242,
+ sub_08021848,
+};
+
+void (*const gUnk_080CB5A8[])(Entity*) = {
+ sub_0802189C,
+ sub_080218B4,
+ sub_08021A10,
+ sub_08021A64,
+ sub_08021AD8,
+ sub_08021B64,
+ sub_08021C58,
+ sub_08021CD0,
+};
+
+void (*const gUnk_080CB5C8[])(Entity*) = {
+ sub_0802187C,
+ nullsub_130,
+ sub_08021888,
+};
+
+void (*const gUnk_080CB5D4[])(Entity*) = {
+ sub_080218CC,
+ sub_08021984,
+};
+
+const s8 gUnk_080CB5DC[] = {
+ -1, -2, 1, 2, -3, 3, -4, 4,
+};
+
+const s8 gUnk_080CB5E4[] = {
+ -1, -2, -1, 0, 1, 2, 1, 0,
+};
+// clang-format on
+
diff --git a/src/enemy/cuccoChickAggr.c b/src/enemy/cuccoChickAggr.c
new file mode 100644
index 00000000..2fcfcc89
--- /dev/null
+++ b/src/enemy/cuccoChickAggr.c
@@ -0,0 +1,167 @@
+#include "enemy.h"
+#include "entity.h"
+#include "functions.h"
+
+extern Entity* sub_08049DF4(u32);
+
+void sub_08022A88(Entity*);
+void sub_08022AA4(Entity*);
+void sub_08022B0C(Entity*);
+u32 sub_08022B20(Entity*);
+void sub_08022B44(Entity*);
+
+extern void (*const gUnk_080CBB64[])(Entity*);
+extern void (*const gUnk_080CBB7C[])(Entity*);
+
+void CuccoChickAggr(Entity* this) {
+ gUnk_080CBB64[GetNextFunction(this)](this);
+}
+
+void sub_08022934(Entity* this) {
+ gUnk_080CBB7C[this->action](this);
+}
+
+void sub_0802294C(Entity* this) {
+ sub_0804AA30(this, gUnk_080CBB64);
+}
+
+void nullsub_132(Entity* this) {
+}
+
+void sub_08022960(Entity* this) {
+ sub_0804A720(this);
+ sub_08022A88(this);
+}
+
+void sub_08022970(Entity* this) {
+ if (--this->actionDelay == 0) {
+ sub_08022AA4(this);
+ }
+}
+
+void sub_08022988(Entity* this) {
+ if (this->height.HALF.HI == 0 && sub_08022B20(this)) {
+ sub_08022B0C(this);
+ } else {
+ if (this->field_0xf) {
+ if (--this->field_0xf)
+ return;
+
+ this->frameIndex = 1;
+ this->field_0x20 = 0x10000;
+ sub_08004488(0xd6);
+ }
+
+ sub_080AEF88(this);
+ if (sub_08003FC4(this, 0x2000) == 0) {
+ if (--this->actionDelay == 0) {
+ sub_08022A88(this);
+ } else {
+ this->field_0xf = 4;
+ this->frameIndex = 0;
+ }
+ }
+ }
+}
+
+void sub_080229F8(Entity* this) {
+ if (sub_08003FC4(this, 0x2800) == 0) {
+ if (--this->actionDelay == 0) {
+ this->action = 4;
+ this->actionDelay = 6;
+ this->field_0xf = 8;
+ this->frameIndex = 0;
+ this->nonPlanarMovement = 0xc0;
+ sub_08022B44(this);
+ } else {
+ this->field_0x20 = 0x10000;
+ sub_08004488(0xd6);
+ }
+ }
+}
+
+void sub_08022A40(Entity* this) {
+ if (this->field_0xf) {
+ if (--this->field_0xf)
+ return;
+
+ this->frameIndex = 1;
+ }
+
+ sub_080AEF88(this);
+ if (sub_08003FC4(this, 0x2000) == 0) {
+ if (--this->actionDelay == 0) {
+ sub_08022A88(this);
+ } else {
+ sub_08022B44(this);
+ }
+ }
+}
+
+void sub_08022A88(Entity* this) {
+ this->action = 1;
+ this->actionDelay = (Random() & 0xf) + 8;
+ this->frameIndex = 0;
+}
+
+void sub_08022AA4(Entity* this) {
+ u32 rand = Random();
+
+ this->action = 2;
+ this->actionDelay = (rand & 3) + 1;
+ this->field_0xf = 1;
+ this->nonPlanarMovement = 0x80;
+
+ if (!sub_08049FA0(this) && (rand >> 8) & 3) {
+ this->direction = sub_08049EE4(this);
+ } else {
+ this->direction = (rand >> 0x10) & 0x1f;
+ }
+
+ if (this->direction & 0xf)
+ this->spriteSettings.b.flipX = (this->direction >> 4) ^ 1;
+}
+
+void sub_08022B0C(Entity* this) {
+ this->action = 3;
+ this->actionDelay = 3;
+ this->field_0xf = 8;
+ sub_08022B44(this);
+}
+
+u32 sub_08022B20(Entity* this) {
+ if (!sub_08049DF4(2))
+ return 0;
+
+ return sub_080041A0(this, &gPlayerEntity, 0x24, 0x24);
+}
+
+void sub_08022B44(Entity *this){
+ this->field_0x20 = 0xc000;
+ this->direction = GetFacingDirection(this,&gPlayerEntity);
+
+ if (this->direction & 0xf)
+ this->spriteSettings.b.flipX = (this->direction >> 4)^1;
+
+ sub_08004488(0xd6);
+}
+
+
+// clang-format off
+void (*const gUnk_080CBB64[])(Entity*) = {
+ sub_08022934,
+ sub_0802294C,
+ sub_08001324,
+ sub_0804A7D4,
+ sub_08001242,
+ nullsub_132,
+};
+
+void (*const gUnk_080CBB7C[])(Entity*) = {
+ sub_08022960,
+ sub_08022970,
+ sub_08022988,
+ sub_080229F8,
+ sub_08022A40,
+};
+// clang-format on
diff --git a/src/enemy/doorMimic.c b/src/enemy/doorMimic.c
new file mode 100644
index 00000000..587ce521
--- /dev/null
+++ b/src/enemy/doorMimic.c
@@ -0,0 +1,271 @@
+#include "enemy.h"
+#include "entity.h"
+#include "functions.h"
+
+extern s16 sub_080001DA(u32, u32); // ?
+extern void sub_08049CF4();
+extern u32 sub_0806FBFC(u32, u32, u32, u32);
+void sub_080221C0();
+
+typedef struct {
+ s8 h;
+ s8 v;
+} PACKED PosOffset;
+
+extern void (*const gUnk_080CB734[])(Entity*);
+extern void (*const gUnk_080CB74C[])(Entity*);
+
+#if NON_MATCHING
+extern const PosOffset gUnk_080CB764[];
+#else
+extern const s8 gUnk_080CB764[];
+#endif
+extern const PosOffset gUnk_080CB76C[4][6];
+extern const u16 gUnk_080CB79C[];
+extern const BoundingBox* const* const gUnk_080CB8A4[];
+
+extern s16 gUnk_080B4488[];
+
+void DoorMimic(Entity* this) {
+ gUnk_080CB734[GetNextFunction(this)](this);
+ this->boundingBox = (BoundingBox*)gUnk_080CB8A4[this->entityType.parameter][this->frameIndex];
+}
+
+void sub_08021FDC(Entity* this) {
+ gUnk_080CB74C[this->action](this);
+}
+
+void sub_08021FF4(Entity* this) {
+ sub_0804AA30(this, gUnk_080CB734);
+}
+
+void sub_08022004(Entity* this) {
+ SetTile((u16)this->field_0x7c.HALF.LO, (u16)this->field_0x7c.HALF.HI, this->collisionLayer);
+ CreateFx(this, 5, 0);
+ sub_08049CF4(this);
+ DeleteThisEntity();
+}
+
+#if NON_MATCHING
+void sub_08022034(Entity* this) {
+ this->action = 1;
+ this->entityType.parameter = this->entityType.form & 3;
+ this->spritePriority.b0 = 5;
+ this->field_0x78.HWORD = gUnk_080CB764[this->entityType.parameter].h + this->x.HALF.HI;
+ this->field_0x7a.HWORD = gUnk_080CB764[this->entityType.parameter].v + this->y.HALF.HI;
+ InitializeAnimation(this, this->entityType.parameter);
+ sub_080221C0(this);
+}
+#else
+void sub_08022034(Entity* this) {
+ this->action = 1;
+ this->entityType.parameter = this->entityType.form & 3;
+ this->spritePriority.b0 = 5;
+ this->field_0x78.HWORD = gUnk_080CB764[this->entityType.parameter * 2] + this->x.HALF.HI;
+ this->field_0x7a.HWORD = gUnk_080CB764[this->entityType.parameter * 2 + 1] + this->y.HALF.HI;
+ InitializeAnimation(this, this->entityType.parameter);
+ sub_080221C0(this);
+}
+#endif
+
+void sub_0802209C(Entity* this) {
+ if (this->actionDelay == 0) {
+ if (sub_0806FBFC(this->field_0x78.HWORD, this->field_0x7a.HWORD, 0x10, 0x10)) {
+ this->action = 2;
+ this->actionDelay = 0x12;
+ InitializeAnimation(this, this->entityType.parameter + 4);
+ }
+ } else {
+ this->actionDelay = this->actionDelay - 1;
+ }
+}
+
+void sub_080220D8(Entity* this) {
+ if (--this->actionDelay == 0)
+ this->action = 3;
+}
+
+void sub_080220F0(Entity* this) {
+ GetNextFrame(this);
+ if (this->frames.all & 0x80) {
+ const PosOffset* off;
+ u32 i;
+
+ this->action = 4;
+ this->actionDelay = 0x78;
+ this->field_0x44 = 0;
+ off = gUnk_080CB76C[this->entityType.parameter];
+ for (i = 0; i < 6; i++, off++) {
+ Entity* fx = CreateFx(this, 0x11, 0);
+ if (fx) {
+ fx->x.HALF.HI += off->h;
+ fx->y.HALF.HI += off->v;
+ }
+ }
+ sub_08004488(260);
+ } else if (this->frames.all & 1) {
+ this->field_0x44 = 4;
+ }
+}
+
+void sub_08022174(Entity* this) {
+ sub_0800445C(this);
+ if (--this->actionDelay == 0) {
+ this->action = 5;
+ InitializeAnimation(this, this->entityType.parameter + 8);
+ }
+}
+
+void sub_08022198(Entity* this) {
+ sub_0800445C(this);
+ GetNextFrame(this);
+ if (this->frames.all & 0x80) {
+ this->action = 1;
+ this->actionDelay = 0x5a;
+ }
+}
+
+void sub_080221C0(Entity* this) {
+ u32 tile = COORD_TO_TILE(this) + gUnk_080B4488[this->entityType.parameter];
+ this->field_0x7c.HALF.HI = tile;
+ this->field_0x7c.HALF.LO = sub_080001DA(tile, this->collisionLayer);
+ SetTile(gUnk_080CB79C[this->entityType.parameter], tile, this->collisionLayer);
+}
+
+// clang-format off
+void (*const gUnk_080CB734[])(Entity*) = {
+ sub_08021FDC,
+ sub_08021FF4,
+ sub_08001324,
+ sub_08022004,
+ sub_08001242,
+ sub_08021FDC,
+};
+
+void (*const gUnk_080CB74C[])(Entity*) = {
+ sub_08022034,
+ sub_0802209C,
+ sub_080220D8,
+ sub_080220F0,
+ sub_08022174,
+ sub_08022198,
+};
+
+#if NON_MATCHING
+const PosOffset gUnk_080CB764[] = {
+ {-0x08, 0x00},
+ {-0x10, -0x08},
+ {-0x08, -0x10},
+ { 0x00, -0x08},
+};
+#else
+const s8 gUnk_080CB764[] = {
+ -0x08, 0x00,
+ -0x10, -0x08,
+ -0x08, -0x10,
+ 0x00, -0x08,
+};
+#endif
+
+const PosOffset gUnk_080CB76C[][6] = {
+ {
+ {-0x04, 0x1a},
+ { 0x04, 0x1a},
+ {-0x0c, 0x10},
+ { 0x0c, 0x10},
+ {-0x0c, 0x08},
+ { 0x0c, 0x08},
+ },
+ {
+ {-0x1a, -0x04},
+ {-0x1a, 0x04},
+ {-0x10, -0x0c},
+ {-0x10, 0x0c},
+ {-0x08, -0x0c},
+ {-0x08, 0x0c},
+ },
+ {
+ {-0x04, -0x1a},
+ { 0x04, -0x1a},
+ {-0x0c, -0x10},
+ { 0x0c, -0x10},
+ {-0x0c, -0x08},
+ { 0x0c, -0x08},
+ },
+ {
+ { 0x1a, -0x04},
+ { 0x1a, 0x04},
+ { 0x10, -0x0c},
+ { 0x10, 0x0c},
+ { 0x08, -0x0c},
+ { 0x08, 0x0c},
+ },
+};
+
+const u16 gUnk_080CB79C[] = {
+ 0x4023,
+ 0x4025,
+ 0x4026,
+ 0x4024,
+};
+
+
+const BoundingBox gUnk_080CB7A4 = { 0x00, 0xf7, 0x00, 0x00, 0x00, 0x00, 0x08, 0x06 };
+const BoundingBox gUnk_080CB7AC = { 0x00, 0xfb, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04 };
+const BoundingBox gUnk_080CB7B4 = { 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04 };
+const BoundingBox gUnk_080CB7BC = { 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x06, 0x08 };
+const BoundingBox gUnk_080CB7C4 = { 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0c };
+const BoundingBox gUnk_080CB7CC = { 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08 };
+const BoundingBox gUnk_080CB7D4 = { 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04 };
+const BoundingBox gUnk_080CB7DC = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04 };
+const BoundingBox gUnk_080CB7E4 = { 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08 };
+const BoundingBox gUnk_080CB7EC = { 0x00, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0c };
+
+const BoundingBox *const gUnk_080CB7F4[] = {
+ &gUnk_080CB7A4,
+ &gUnk_080CB7AC,
+ &gUnk_080CB7B4,
+ &gUnk_080CB7BC,
+ &gUnk_080CB7C4,
+ &gUnk_080CB7C4,
+ &gUnk_080CB7CC,
+ &gUnk_080CB7D4,
+ &gUnk_080CB7DC,
+ &gUnk_080CB7E4,
+ &gUnk_080CB7EC,
+ &gUnk_080CB7EC,
+};
+
+const BoundingBox gUnk_080CB824 = { 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08 };
+const BoundingBox gUnk_080CB82C = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08 };
+const BoundingBox gUnk_080CB834 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08 };
+const BoundingBox gUnk_080CB83C = { 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08 };
+const BoundingBox gUnk_080CB844 = { 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x08 };
+const BoundingBox gUnk_080CB84C = { 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08 };
+const BoundingBox gUnk_080CB854 = { 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08 };
+const BoundingBox gUnk_080CB85C = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08 };
+const BoundingBox gUnk_080CB864 = { 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08 };
+const BoundingBox gUnk_080CB86C = { 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x08 };
+
+const BoundingBox *const gUnk_080CB874[] = {
+ &gUnk_080CB84C,
+ &gUnk_080CB854,
+ &gUnk_080CB85C,
+ &gUnk_080CB864,
+ &gUnk_080CB86C,
+ &gUnk_080CB86C,
+ &gUnk_080CB824,
+ &gUnk_080CB82C,
+ &gUnk_080CB834,
+ &gUnk_080CB83C,
+ &gUnk_080CB844,
+ &gUnk_080CB844,
+};
+
+const BoundingBox *const *const gUnk_080CB8A4[] = {
+ gUnk_080CB7F4,
+ gUnk_080CB874,
+ gUnk_080CB7F4,
+ gUnk_080CB874,
+};
+// clang-format on
diff --git a/src/enemy/enemyE.c b/src/enemy/enemyE.c
new file mode 100644
index 00000000..9f6a0b6d
--- /dev/null
+++ b/src/enemy/enemyE.c
@@ -0,0 +1,69 @@
+#include "enemy.h"
+#include "entity.h"
+#include "functions.h"
+
+void sub_08023000(Entity*, int);
+
+extern void (*const gUnk_080CBBC8[])(Entity*);
+extern void (*const gUnk_080CBBDC[])(Entity*);
+
+void EnemyE(Entity* this) {
+ EnemyFunctionHandler(this, gUnk_080CBBC8);
+}
+
+void sub_08022FB4(Entity* this) {
+ gUnk_080CBBDC[this->action](this);
+}
+
+void nullsub_133(Entity* this) {
+}
+
+void sub_08022FD0(Entity* this) {
+ this->action = 1;
+ this->spriteSettings.b.draw = 1;
+ sub_08023000(this, 0);
+}
+
+void sub_08022FEC(Entity* this) {
+ sub_08023000(this, 0x80);
+}
+
+void sub_08022FF8(Entity* this) {
+}
+
+void sub_08022FFC(Entity* this) {
+}
+
+void sub_08023000(Entity* this, int frames) {
+ int tmp;
+
+ if (frames == 0x80) {
+ UpdateAnimationSingleFrame(this);
+ } else {
+ InitAnimationForceUpdate(this, frames);
+ }
+
+ tmp = 0x80;
+ if (this->frameSpriteSettings == 0x40)
+ tmp *= -1;
+
+ this->spriteRendering.b0 = 3;
+ sub_0805EC9C(this, tmp, 0x80, 0);
+}
+
+// clang-format off
+void (*const gUnk_080CBBC8[])(Entity*) = {
+ sub_08022FB4,
+ nullsub_133,
+ sub_08001324,
+ sub_0804A7D4,
+ sub_08001242,
+};
+
+void (*const gUnk_080CBBDC[])(Entity*) = {
+ sub_08022FD0,
+ sub_08022FEC,
+ sub_08022FF8,
+ sub_08022FFC,
+};
+// clang-format on
diff --git a/src/enemy/hangingSeed.c b/src/enemy/hangingSeed.c
index 7f0ba1dc..cd204a6e 100644
--- a/src/enemy/hangingSeed.c
+++ b/src/enemy/hangingSeed.c
@@ -1,39 +1,51 @@
-#include "global.h"
#include "entity.h"
-
-extern void EnemyFunctionHandler(Entity*, void (*const funcs[])(Entity*));
-extern void DeleteThisEntity();
+#include "functions.h"
extern void (*const gUnk_080CB570[])(Entity*);
extern void (*const gUnk_080CB588[])(Entity*);
-void HangingSeed(Entity *this)
-{
- EnemyFunctionHandler(this, gUnk_080CB570);
+void HangingSeed(Entity* this) {
+ EnemyFunctionHandler(this, gUnk_080CB570);
}
-void sub_080216E4(Entity *this)
-{
- gUnk_080CB588[this->action](this);
+void sub_080216E4(Entity* this) {
+ gUnk_080CB588[this->action](this);
}
-void sub_080216FC(Entity *this)
-{
- if ((this->bitfield & 0x80) != 0) {
- CreateFx(this, 3, 0x80);
- DeleteThisEntity();
- }
+void sub_080216FC(Entity* this) {
+ if (this->bitfield & 0x80) {
+ CreateFx(this, 3, 0x80);
+ DeleteThisEntity();
+ }
}
-void nullsub_7(Entity* this){}
+void nullsub_7(Entity* this) {
+}
-void sub_08021720(Entity *this)
-{
- this->action = 1;
- this->spriteSettings.b.draw = 1;
- this->frameIndex = (this->entityType).form;
- this->spriteRendering.b3 = 1;
- this->spritePriority.b0 = 3;
+void sub_08021720(Entity* this) {
+ this->action = 1;
+ this->spriteSettings.b.draw = 1;
+ this->frameIndex = this->entityType.form;
+ this->spriteRendering.b3 = 1;
+ this->spritePriority.b0 = 3;
}
-void nullsub_08(Entity* this){} \ No newline at end of file
+void nullsub_08(Entity* this) {
+}
+
+// clang-format off
+void (*const gUnk_080CB570[])(Entity*) = {
+ sub_080216E4,
+ sub_080216FC,
+ sub_08001324,
+ sub_0804A7D4,
+ sub_08001242,
+ nullsub_7,
+};
+
+void (*const gUnk_080CB588[])(Entity*) = {
+ sub_08021720,
+ nullsub_08,
+};
+// clang-format on
+
diff --git a/src/enemy/keese.c b/src/enemy/keese.c
index 0083bbf3..14f5c520 100644
--- a/src/enemy/keese.c
+++ b/src/enemy/keese.c
@@ -2,14 +2,14 @@
#include "entity.h"
#include "enemy.h"
#include "player.h"
+#include "functions.h"
-extern void sub_0804AA30(Entity*, void *);
+extern void sub_08001328(Entity*);
extern u32 sub_0806F520(Entity*);
extern void sub_0806F4E8(Entity*);
extern u32 sub_0806F3E4(Entity*);
extern void sub_0804A7D4(Entity*);
extern void sub_0804A720(Entity*);
-extern u32 Random();
extern void sub_08021EF0(Entity*);
extern void sub_080AEFB4(Entity*);
extern void sub_08021F24(Entity*);
@@ -17,102 +17,89 @@ extern u32 sub_0806FCB8(Entity*, s32, s32, u32);
extern u32 sub_08049FA0(Entity*);
extern u32 sub_08049EE4(Entity*);
-extern void (*gUnk_080CB69C[])(Entity*);
-extern void (*gUnk_080CB6B4[])(Entity*);
-extern void (*gUnk_080CB6C4[])(Entity*);
+extern void (*const gUnk_080CB69C[])(Entity*);
+extern void (*const gUnk_080CB6B4[])(Entity*);
+extern void (*const gUnk_080CB6C4[])(Entity*);
-extern u8 gUnk_080CB6D0[];
-extern u16 gUnk_080CB6D6[];
-extern u8 gUnk_080CB6F6[];
+extern const s8 gUnk_080CB6D0[];
+extern const u16 gUnk_080CB6D6[];
+extern const u8 gUnk_080CB6F6[];
-void Keese(Entity *this)
-{
+void Keese(Entity* this) {
gUnk_080CB69C[GetNextFunction(this)](this);
}
-void sub_08021D80(Entity *this)
-{
+void sub_08021D80(Entity* this) {
gUnk_080CB6B4[this->action](this);
}
-void sub_08021d98(Entity *this)
-{
- sub_0804AA30(this, &gUnk_080CB69C);
+void sub_08021d98(Entity* this) {
+ sub_0804AA30(this, gUnk_080CB69C);
}
-void sub_08021DA8(Entity *this)
-{
- if (sub_0806F520(this)) {
- gUnk_080CB6C4[this->previousActionFlag](this);
- }
+void sub_08021DA8(Entity* this) {
+ if (sub_0806F520(this)) {
+ gUnk_080CB6C4[this->previousActionFlag](this);
+ }
}
-void sub_08021DCC(Entity *this)
-{
- this->previousActionFlag = 2;
+void sub_08021DCC(Entity* this) {
+ this->previousActionFlag = 2;
}
-void sub_08021DD4(Entity *this)
-{
- sub_0806F4E8(this);
+void sub_08021DD4(Entity* this) {
+ sub_0806F4E8(this);
}
-void sub_08021DDC(Entity *this)
-{
- if (sub_0806F3E4(this)) {
- sub_0804A7D4(this);
- }
+void sub_08021DDC(Entity* this) {
+ if (sub_0806F3E4(this)) {
+ sub_0804A7D4(this);
+ }
}
-void sub_08021DF0(Entity *this)
-{
-
- sub_0804A720(this);
- if ((this->entityType).form != 0) {
- this->spritePriority.b1 = 1;
- this->height.HALF.HI = -0x10;
- }
- this->direction = Random() & 0x1f;
- this->field_0x1c = 1;
- this->spritePriority.b0 = 3;
- this->collisionLayer = 3;
- UpdateSpriteForCollisionLayer(this);
- sub_08021EF0(this);
+void sub_08021DF0(Entity* this) {
+
+ sub_0804A720(this);
+ if ((this->entityType).form != 0) {
+ this->spritePriority.b1 = 1;
+ this->height.HALF.HI = -0x10;
+ }
+ this->direction = Random() & 0x1f;
+ this->field_0x1c = 1;
+ this->spritePriority.b0 = 3;
+ this->collisionLayer = 3;
+ UpdateSpriteForCollisionLayer(this);
+ sub_08021EF0(this);
}
-void sub_08021E4C(Entity *this)
-{
- if (this->field_0x78.HWORD != 0) {
- this->field_0x78.HWORD--;
- }
- if (this->field_0x7a.HWORD != 0) {
- (this->field_0x7a.HWORD)--;
- }
- GetNextFrame(this);
- if ((this->frames.b.f3) != 0) {
- sub_08021F24(this);
- }
- else {
- sub_080AEFB4(this);
- }
- this->spriteOffsetY = gUnk_080CB6D0[this->frames.all];
+void sub_08021E4C(Entity* this) {
+ if (this->field_0x78.HWORD != 0) {
+ this->field_0x78.HWORD--;
+ }
+ if (this->field_0x7a.HWORD != 0) {
+ (this->field_0x7a.HWORD)--;
+ }
+ GetNextFrame(this);
+ if ((this->frames.b.f3) != 0) {
+ sub_08021F24(this);
+ } else {
+ sub_080AEFB4(this);
+ }
+ this->spriteOffsetY = gUnk_080CB6D0[this->frames.all];
}
-void sub_08021EA4(Entity *this)
-{
- if (--this->actionDelay == 0) {
- sub_08021EF0(this);
- }
+void sub_08021EA4(Entity* this) {
+ if (--this->actionDelay == 0) {
+ sub_08021EF0(this);
+ }
}
-void sub_08021EBC(Entity *this)
-{
+void sub_08021EBC(Entity* this) {
s32 iVar1;
-
+
if (this->actionDelay != 0) {
this->actionDelay--;
- }
- else {
+ } else {
iVar1 = sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x70);
if (iVar1 != 0) {
sub_08021EF0(this);
@@ -120,37 +107,71 @@ void sub_08021EBC(Entity *this)
}
}
-void sub_08021EF0(Entity *this)
-{
- u32 uVar1;
-
- this->action = 1;
- this->field_0x78.HWORD = gUnk_080CB6D6[Random() & 0xf];
- this->field_0x7a.HWORD = 0x3c;
- InitializeAnimation(this, 0);
+void sub_08021EF0(Entity* this) {
+ u32 uVar1;
+
+ this->action = 1;
+ this->field_0x78.HWORD = gUnk_080CB6D6[Random() & 0xf];
+ this->field_0x7a.HWORD = 0x3c;
+ InitializeAnimation(this, 0);
}
-void sub_08021F24(Entity *this)
-{
+void sub_08021F24(Entity* this) {
u32 bVar1;
-
+
if (this->field_0x78.HWORD == 0) {
this->action = 2;
this->actionDelay = gUnk_080CB6F6[Random() & 0xf];
InitializeAnimation(this, 1);
- }
- else if (!this->field_0x7a.HWORD && !(sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x70))) {
+ } else if (!this->field_0x7a.HWORD &&
+ !(sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x70))) {
this->action = 3;
this->actionDelay = 0x1e;
InitializeAnimation(this, 1);
- }
- else {
+ } else {
if (sub_08049FA0(this) != 0) {
this->direction = Random() & 0x1f;
- }
- else {
+ } else {
this->direction = sub_08049EE4(this);
}
InitializeAnimation(this, 0);
}
-} \ No newline at end of file
+}
+
+// clang-format off
+void (*const gUnk_080CB69C[])(Entity*) = {
+ sub_08021D80,
+ sub_08021d98,
+ sub_08001328,
+ sub_0804A7D4,
+ sub_08001242,
+ sub_08021DA8,
+};
+
+void (*const gUnk_080CB6B4[])(Entity*) = {
+ sub_08021DF0,
+ sub_08021E4C,
+ sub_08021EA4,
+ sub_08021EBC,
+};
+
+void (*const gUnk_080CB6C4[])(Entity*) = {
+ sub_08021DCC,
+ sub_08021DD4,
+ sub_08021DDC,
+};
+
+const s8 gUnk_080CB6D0[] = {
+ 1, -2, -5, -2, 1, 0,
+};
+
+const u16 gUnk_080CB6D6[] = {
+ 180, 180, 300, 300, 300, 300, 300, 300,
+ 480, 480, 480, 480, 480, 480, 720, 720,
+};
+
+const u8 gUnk_080CB6F6[] = {
+ 30, 30, 45, 45, 45, 45, 45, 45,
+ 60, 60, 60, 60, 60, 60, 75, 75,
+};
+// clang-format on
diff --git a/src/enemy/moldorm.c b/src/enemy/moldorm.c
new file mode 100644
index 00000000..530eeae1
--- /dev/null
+++ b/src/enemy/moldorm.c
@@ -0,0 +1,211 @@
+#include "enemy.h"
+#include "entity.h"
+#include "functions.h"
+
+void sub_08022EAC(Entity*);
+void sub_08022F14(Entity*);
+
+extern void (*const gUnk_080CBB90[])(Entity*);
+extern void (*const gUnk_080CBBA0[])(Entity*);
+extern void (*const gUnk_080CBBB4[])(Entity*);
+extern void (*const gUnk_080CBBBC[])(Entity*);
+
+extern u8 gEntCount;
+extern const s8 gUnk_080CBBC4[];
+
+void Moldorm(Entity* this) {
+ gUnk_080CBB90[this->entityType.form](this);
+}
+
+void sub_08022BA0(Entity* this) {
+ this->field_0x78.HALF.HI++;
+ this->field_0x74.HWORD = this->x.HALF.HI;
+ this->field_0x76.HWORD = this->y.HALF.HI;
+ EnemyFunctionHandler(this, gUnk_080CBBA0);
+ sub_08022EAC(this);
+}
+
+void sub_08022BD4(Entity* this) {
+ gUnk_080CBBB4[this->action](this);
+}
+
+void sub_08022BEC(Entity* this) {
+ if (this->field_0x7a.HALF.LO != this->currentHealth)
+ this->field_0x7a.HALF.HI = 30;
+
+ this->field_0x7a.HALF.LO = this->currentHealth;
+ this->actionDelay = 1;
+ this->direction = this->field_0x3e;
+
+ this->animationState = ((this->direction + 2) & 0x1c) >> 2;
+ this->frameIndex = this->animationState;
+
+ this->attachedEntity->hurtBlinkTime = this->hurtBlinkTime;
+ (*(Entity**)&this->field_0x7c)->hurtBlinkTime = this->hurtBlinkTime;
+ (*(Entity**)&this->field_0x80)->hurtBlinkTime = this->hurtBlinkTime;
+ sub_0804AA30(this, gUnk_080CBBA0);
+}
+
+void sub_08022C58(Entity* this) {
+ Entity *tail0, *tail1, *tail2;
+
+ this->flags &= ~0x80;
+
+ if (gEntCount >= 0x45)
+ return;
+
+ tail0 = CreateEnemy(0xd, 1);
+ this->attachedEntity = tail0;
+ tail0->spritePriority.b0 = 5;
+ tail0->parent = this;
+ CopyPosition(this, tail0);
+
+ tail1 = CreateEnemy(0xd, 2);
+ tail0->attachedEntity = tail1;
+ tail1->spritePriority.b0 = 5;
+ tail1->parent = this;
+ CopyPosition(this, tail1);
+
+ tail2 = CreateEnemy(0xd, 3);
+ tail1->attachedEntity = tail2;
+ tail2->spritePriority.b0 = 5;
+ tail2->parent = this;
+ CopyPosition(this, tail2);
+
+ sub_0804A720(this);
+ this->action = 1;
+ this->actionDelay = 1;
+ this->field_0xf = 1;
+ this->flags = this->flags | 0x80;
+ this->parent = this;
+ this->attachedEntity = tail0;
+ *(Entity**)&this->field_0x7c = tail1;
+ *(Entity**)&this->field_0x80 = tail2;
+
+ this->direction = Random() & 0x1f;
+ this->animationState = ((this->direction + 2) & 0x1c) >> 2;
+ this->frameIndex = this->animationState;
+ this->field_0x7a.HALF.LO = this->currentHealth;
+}
+
+void sub_08022D40(Entity* this) {
+ if (this->field_0x7a.HALF.HI) {
+ if (this->field_0x7a.HALF.HI-- & 1) {
+ this->animationState = (this->animationState + 1) & 7;
+ this->frameIndex = this->animationState;
+ }
+ } else {
+ sub_08022F14(this);
+ sub_080AEF88(this);
+
+ if (this->collisions) {
+ sub_0800417E(this, this->collisions);
+ this->animationState = ((this->direction + 2) & 0x1c) >> 2;
+ this->frameIndex = this->animationState;
+ }
+ }
+}
+
+void sub_08022D90(Entity* this) {
+ if (this->parent->next) {
+ Entity* parent;
+
+ gUnk_080CBBBC[this->action](this);
+ parent = this->parent;
+ this->spriteOrientation.flipY = parent->spriteOrientation.flipY;
+ this->spriteRendering.b3 = parent->spriteRendering.b3;
+ this->collisionLayer = parent->collisionLayer;
+ } else {
+ DeleteEntity(this);
+ }
+}
+
+void sub_08022DE8(Entity* this) {
+ this->action = 1;
+ this->field_0x7c.BYTES.byte0 = 0x88;
+ this->field_0x7c.BYTES.byte1 = 0x88;
+ this->field_0x7c.BYTES.byte2 = 0x88;
+ this->field_0x7c.BYTES.byte3 = 0x88;
+ this->field_0x80.HALF.LO = 0x88;
+ this->field_0x80.HALF.HI = 0x88;
+ this->field_0x82.HALF.LO = 0x88;
+ this->field_0x82.HALF.HI = 0x88;
+ this->animationState = this->parent->animationState;
+ *(u32*)&this->cutsceneBeh = this->animationState * 0x11111111;
+
+ if (this->entityType.form != 3) {
+ this->frameIndex = this->entityType.form + 7;
+ } else {
+ this->frameIndex = this->animationState + 10;
+ }
+}
+
+NAKED
+void sub_08022E40(Entity* this) {
+ asm(".include \"asm/non_matching/moldorm/sub_08022E40.inc\"");
+}
+
+NAKED
+void sub_08022EAC(Entity* this) {
+ asm(".include \"asm/non_matching/moldorm/sub_08022EAC.inc\"");
+}
+
+void sub_08022F14(Entity* this) {
+ if (sub_08049FA0(this) == 0) {
+ u32 bVar6 = (sub_08049EE4(this) - this->direction) & 0x1f;
+ if (8 < ((bVar6 + 4) & 0x1f)) {
+ this->field_0xf = 8;
+ if (bVar6 < 0x10) {
+ this->field_0x78.HALF.LO = 1;
+ } else {
+ this->field_0x78.HALF.LO = -1;
+ }
+ }
+ }
+
+ if (--this->actionDelay == 0) {
+ this->actionDelay = 4;
+
+ if (--this->field_0xf == 0) {
+ this->field_0xf = 8;
+ this->field_0x78.HALF.LO = gUnk_080CBBC4[Random() & 1];
+ }
+
+ this->direction += this->field_0x78.HALF.LO;
+ this->direction &= 0x1f;
+
+ this->animationState = ((this->direction + 2) & 0x1c) >> 2;
+ this->frameIndex = this->animationState;
+ }
+}
+
+// clang-format off
+void (*const gUnk_080CBB90[])(Entity*) = {
+ sub_08022BA0,
+ sub_08022D90,
+ sub_08022D90,
+ sub_08022D90,
+};
+
+void (*const gUnk_080CBBA0[])(Entity*) = {
+ sub_08022BD4,
+ sub_08022BEC,
+ sub_08001324,
+ sub_0804A7D4,
+ sub_08001242,
+};
+
+void (*const gUnk_080CBBB4[])(Entity*) = {
+ sub_08022C58,
+ sub_08022D40,
+};
+
+void (*const gUnk_080CBBBC[])(Entity*) = {
+ sub_08022DE8,
+ sub_08022E40,
+};
+
+const s8 gUnk_080CBBC4[] = {
+ 1, -1, 0, 0,
+};
+// clang-format off
diff --git a/src/enemy/rockChuchu.c b/src/enemy/rockChuchu.c
new file mode 100644
index 00000000..337e21dc
--- /dev/null
+++ b/src/enemy/rockChuchu.c
@@ -0,0 +1,122 @@
+#include "enemy.h"
+#include "entity.h"
+#include "functions.h"
+
+extern void sub_0804A4E4(Entity*, Entity*);
+
+extern void (*const gUnk_080CB948[])(Entity*);
+extern void (*const gUnk_080CB960[])(Entity*);
+
+void RockChuchu(Entity* this) {
+ EnemyFunctionHandler(this, gUnk_080CB948);
+}
+
+void sub_0802223C(Entity* this) {
+ gUnk_080CB960[this->action](this);
+}
+
+void sub_08022254(Entity* this) {
+ Entity* ent;
+
+ if (this->currentHealth) {
+ switch (this->bitfield & 0x7f) {
+ case 4:
+ case 5:
+ case 6:
+ case 8:
+ case 9:
+ case 10:
+ case 0xb:
+ case 0xc:
+ case 0xd:
+ case 0x10:
+ case 0x11:
+ case 0x12:
+ case 0x18:
+ case 0x19:
+ case 0x1a:
+ if ((gPlayerState.field_0xac & 8) == 0)
+ break;
+ case 0x16:
+ case 0x1c:
+ CreateFx(this, 4, 0);
+ ent = CreateEnemy(1, 1);
+ if (ent) {
+ ent->entityType.parameter = 1;
+ ent->hurtBlinkTime = -8;
+ sub_0804A4E4(this, ent);
+ this->action = 2;
+ this->flags &= ~0x80;
+ this->spriteSettings.b.draw = 0;
+ this->direction = this->field_0x3e;
+ this->attachedEntity = ent;
+ }
+ }
+ } else {
+ if (this->damageType != 0x94)
+ InitializeAnimation(this, 2);
+ }
+
+ sub_0804AA30(this, gUnk_080CB948);
+}
+
+void nullsub_131(Entity* this) {
+}
+
+void sub_08022368(Entity* this) {
+ sub_0804A720(this);
+ this->action = 1;
+ this->actionDelay = Random();
+ this->direction = sub_08049F84(this, 1);
+ InitializeAnimation(this, 0);
+}
+
+void sub_08022390(Entity* this) {
+ if (sub_08049FDC(this, 1)) {
+ if ((this->actionDelay++ & 0xf) == 0) {
+ this->direction = sub_08049F84(this, 1);
+ this->field_0xf = Random() & 4;
+ }
+
+ if (this->field_0xf == 0) {
+ sub_080AEF88(this);
+ } else {
+ this->field_0xf = this->field_0xf - 1;
+ }
+ } else {
+ this->actionDelay = Random();
+ }
+
+ GetNextFrame(this);
+}
+
+void sub_080223E4(Entity* this) {
+ Entity* ent;
+
+ ent = this->attachedEntity;
+ if (ent) {
+ ent->bitfield = 0x94;
+ ent->hurtBlinkTime = 0x10;
+ ent->field_0x42 = 0xc;
+ ent->field_0x3e = this->direction;
+ }
+
+ DeleteEntity(this);
+}
+
+// clang-format off
+void (*const gUnk_080CB948[])(Entity*) = {
+ sub_0802223C,
+ sub_08022254,
+ sub_08001324,
+ sub_0804A7D4,
+ sub_08001242,
+ nullsub_131,
+};
+
+void (*const gUnk_080CB960[])(Entity*) = {
+ sub_08022368,
+ sub_08022390,
+ sub_080223E4,
+};
+// clang-format on
diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c
new file mode 100644
index 00000000..a3d41a1b
--- /dev/null
+++ b/src/enemy/spinyChuchu.c
@@ -0,0 +1,285 @@
+#include "enemy.h"
+#include "entity.h"
+#include "functions.h"
+
+extern void sub_08001318(Entity*);
+extern u32 sub_08049F64(Entity*, u32, u32);
+extern void sub_0804A4E4(Entity*, Entity*);
+extern void sub_0804AA1C(Entity*);
+
+u32 sub_080228CC(Entity*);
+u32 sub_080228F0(Entity*);
+
+extern void (*const gUnk_080CBA28[])(Entity*);
+extern void (*const gUnk_080CBA40[])(Entity*);
+
+extern const u8 gUnk_080CBA60[];
+
+extern BoundingBox gUnk_080FD468;
+extern BoundingBox gUnk_080FD470;
+
+extern Entity* gUnk_020000B0;
+
+void SpinyChuchu(Entity* this) {
+ EnemyFunctionHandler(this, gUnk_080CBA28);
+ SetChildOffset(this, 0, 1, -0x10);
+}
+
+void sub_08022434(Entity* this) {
+ gUnk_080CBA40[this->action](this);
+}
+
+void sub_0802244C(Entity* this) {
+ if (this->currentHealth) {
+ if (this->damageType == 0x65) {
+ switch (this->bitfield & 0x7f) {
+ case 2:
+ case 3:
+ this->action = 2;
+ this->field_0xf = 0x3c;
+ this->damageType = 0x5c;
+ this->boundingBox = &gUnk_080FD468;
+ InitializeAnimation(this, 0);
+ break;
+ case 8:
+ case 9:
+ case 10:
+ case 0xb:
+ case 0xc:
+ case 0x16:
+ case 0x18:
+ case 0x19:
+ case 0x1a:
+ sub_0804A9FC(this, 0x1c);
+ this->action = 5;
+ this->damageType = 0x5c;
+ InitializeAnimation(this, 1);
+ }
+ } else if (this->bitfield == 0x94) {
+ sub_0804A9FC(this, 0x1c);
+ this->action = 5;
+ InitializeAnimation(this, 1);
+ }
+
+ if (this->field_0x80.HALF.LO != this->currentHealth) {
+ this->action = 5;
+ this->damageType = 0x5c;
+ InitializeAnimation(this, 1);
+ } else {
+ if (this->action == 3) {
+ this->action = 4;
+ InitializeAnimation(this, 3);
+ sub_08004488(0x194);
+ }
+ }
+ } else {
+ InitializeAnimation(this, 1);
+ }
+
+ this->field_0x80.HALF.LO = this->currentHealth;
+ sub_0804AA30(this, gUnk_080CBA28);
+}
+
+void sub_080225A0(Entity* this) {
+ if (this->animIndex == 1)
+ GetNextFrame(this);
+ sub_08001318(this);
+}
+
+void sub_080225BC(Entity* this) {
+ sub_08003FC4(this, 0x1800);
+ if (this->frames.all & 1) {
+ sub_0804A7D4(this);
+ } else {
+ GetNextFrame(this);
+ }
+}
+
+void nullsub_9(Entity* this) {
+}
+
+void sub_080225EC(Entity* this) {
+ sub_0804A720(this);
+ this->field_0x80.HALF.LO = this->currentHealth;
+ this->field_0x80.HALF.HI = 0x5a;
+ if (this->actionDelay == 0) {
+ this->action = 2;
+ InitializeAnimation(this, 0);
+ } else {
+ this->action = 1;
+ this->field_0xf = 0x3c;
+ this->spriteSettings.b.draw = 3;
+ this->spriteRendering.b3 = 1;
+ this->spriteOrientation.flipY = 1;
+ this->height.HALF.HI = -0x80;
+ InitializeAnimation(this, 6);
+ }
+}
+
+void sub_08022654(Entity* this) {
+ switch (this->previousActionFlag) {
+ case 0:
+ if (--this->field_0xf)
+ return;
+ this->previousActionFlag = 1;
+ PlaySFX(0x12d);
+ InitializeAnimation(this, 0);
+ /* fallthrough */
+ case 1:
+ if (sub_08003FC4(this, 0x1800))
+ return;
+
+ this->previousActionFlag = 2;
+ this->spriteSettings.b.draw = 1;
+ InitializeAnimation(this, 5);
+ sub_08004488(0x7d);
+ UpdateSpriteForCollisionLayer(this);
+ /* fallthrough */
+ case 2:
+ GetNextFrame(this);
+ if (--this->actionDelay == 0) {
+ this->action = 3;
+ this->damageType = 0x65;
+ InitializeAnimation(this, 2);
+ }
+ break;
+ }
+}
+
+void sub_080226EC(Entity* this) {
+ if (sub_08049FDC(this, 1)) {
+ if (sub_080228CC(this)) {
+ this->action = 3;
+ this->damageType = 0x65;
+ InitializeAnimation(this, 2);
+ return;
+ }
+
+ if (sub_080228F0(this)) {
+ this->action = 6;
+ this->field_0x20 = 0x12000;
+ this->nonPlanarMovement = 0x140;
+ this->direction = GetFacingDirection(this, gUnk_020000B0);
+ this->damageType = 0x5a;
+ InitializeAnimation(this, 4);
+ return;
+ }
+
+ if ((this->actionDelay++ & 7) == 0) {
+ this->direction = sub_08049F84(this, 1);
+ }
+
+ sub_080AEF88(this);
+ }
+
+ GetNextFrame(this);
+}
+
+void sub_08022780(Entity* this) {
+ GetNextFrame(this);
+ if (this->frames.all & 0x80) {
+ this->action = 4;
+ InitializeAnimation(this, 3);
+ sub_08004488(0x194);
+ }
+}
+
+void sub_080227AC(Entity* this) {
+ GetNextFrame(this);
+ if (this->frames.all & 1) {
+ this->boundingBox = &gUnk_080FD470;
+ } else {
+ this->boundingBox = &gUnk_080FD468;
+ }
+
+ if (this->frames.all & 2) {
+ this->frames.all &= ~2;
+ this->damageType = 0x5c;
+ }
+
+ if (this->frames.all & 0x80) {
+ this->action = 2;
+ this->field_0xf = gUnk_080CBA60[Random() & 3];
+ InitializeAnimation(this, 0);
+ }
+}
+
+void sub_0802281C(Entity* this) {
+ sub_08003FC4(this, 0x1800);
+ GetNextFrame(this);
+ if (this->frames.all & 0x80) {
+ this->action = 2;
+ this->nonPlanarMovement = 0x20;
+ InitializeAnimation(this, 0);
+ sub_0804AA1C(this);
+ }
+}
+
+void sub_08022854(Entity* this) {
+ GetNextFrame(this);
+ if (this->frames.all & 1) {
+ sub_080AEFE0(this);
+ if (sub_08003FC4(this, 0x1800) == 0) {
+ this->action = 7;
+ this->damageType = 0x5c;
+ InitializeAnimation(this, 5);
+ sub_08004488(0x7d);
+ }
+ }
+}
+
+void sub_0802289C(Entity* this) {
+ GetNextFrame(this);
+ if (this->frames.all & 0x80) {
+ this->action = 2;
+ this->nonPlanarMovement = 0x20;
+ this->field_0x80.HALF.HI = 0x78;
+ InitializeAnimation(this, 0);
+ }
+}
+
+u32 sub_080228CC(Entity* this) {
+ if (this->field_0xf == 0) {
+ if (sub_08049F64(this, 1, 0x28))
+ return 1;
+ } else {
+ this->field_0xf--;
+ }
+ return 0;
+}
+
+u32 sub_080228F0(Entity* this) {
+ if (this->field_0x80.HALF.HI == 0) {
+ if (sub_08049F64(this, 1, 0x40))
+ return 1;
+ } else {
+ this->field_0x80.HALF.HI--;
+ }
+ return 0;
+}
+
+// clang-format off
+void (*const gUnk_080CBA28[])(Entity*) = {
+ sub_08022434,
+ sub_0802244C,
+ sub_080225A0,
+ sub_080225BC,
+ sub_08001242,
+ nullsub_9,
+};
+
+void (*const gUnk_080CBA40[])(Entity*) = {
+ sub_080225EC,
+ sub_08022654,
+ sub_080226EC,
+ sub_08022780,
+ sub_080227AC,
+ sub_0802281C,
+ sub_08022854,
+ sub_0802289C,
+};
+
+const u8 gUnk_080CBA60[] = {
+ 10, 20, 30, 20,
+};
+// clang-format on
diff --git a/src/object/mineralWaterSource.c b/src/object/mineralWaterSource.c
index c874530b..cc1f45d7 100644
--- a/src/object/mineralWaterSource.c
+++ b/src/object/mineralWaterSource.c
@@ -30,8 +30,8 @@ void MineralWaterSource_Init(Entity *this) {
this->entityType.parameter = unknownParameters->field_0x00;
this->field_0x40 = unknownParameters->field_0x03;
- this->boundingBox->field_0x6 = unknownParameters->field_0x01;
- this->boundingBox->field_0x7 = unknownParameters->field_0x02;
+ this->boundingBox->unknown[6] = unknownParameters->field_0x01;
+ this->boundingBox->unknown[7] = unknownParameters->field_0x02;
this->flags |= 0x80;
diff --git a/src/object/object49.c b/src/object/object49.c
index e3fa37dd..0617aad2 100644
--- a/src/object/object49.c
+++ b/src/object/object49.c
@@ -243,10 +243,10 @@ void sub_0808F498(Entity* this) {
this->action = 1;
this->actionDelay = 64;
var0 = this->entityType.parameter != 0 ? 44 : 43;
- this->x.HALF.HI -= this->parent->boundingBox->field_0x6;
- this->x.HALF.HI += (s32)Random() % (this->parent->boundingBox->field_0x6 * 2);
- this->y.HALF.HI -= this->parent->boundingBox->field_0x7;
- this->y.HALF.HI += (s32)Random() % (this->parent->boundingBox->field_0x7 * 2);
+ this->x.HALF.HI -= this->parent->boundingBox->unknown[6];
+ this->x.HALF.HI += (s32)Random() % (this->parent->boundingBox->unknown[6] * 2);
+ this->y.HALF.HI -= this->parent->boundingBox->unknown[7];
+ this->y.HALF.HI += (s32)Random() % (this->parent->boundingBox->unknown[7] * 2);
sub_0801D2B4(this, var0);
InitializeAnimation(this, 4);
}