summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBehemoth <Luisscheurenbrand@gmail.com>2020-09-21 23:08:16 +0200
committerBehemoth <Luisscheurenbrand@gmail.com>2020-09-21 23:08:16 +0200
commit0df7cfe8d9941a25cf7e8f8ed0dcfd13fdec73bf (patch)
tree28b4193104040ec712db946e41aa4d666fcc6eb8 /src
parent5b454deef60e3db1e739e8be8152cbe76ac9bc84 (diff)
decompile Bobomb
Diffstat (limited to 'src')
-rw-r--r--src/enemy/bobomb.c331
1 files changed, 331 insertions, 0 deletions
diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c
new file mode 100644
index 00000000..bf4b4372
--- /dev/null
+++ b/src/enemy/bobomb.c
@@ -0,0 +1,331 @@
+#include "enemy.h"
+#include "functions.h"
+
+extern void CreateDustSmall(Entity*);
+extern void sub_08078930(Entity*);
+extern void sub_08078954(Entity*);
+
+void sub_0802CB68(Entity*);
+void sub_0802CBC4(Entity*);
+void sub_0802CC18(Entity*);
+
+extern void (*const gUnk_080CD5D4[])(Entity*);
+extern void (*const gUnk_080CD5EC[])(Entity*);
+extern void (*const gUnk_080CD600[])(Entity*);
+extern void (*const gUnk_080CD618[])(Entity*);
+
+void Bobomb(Entity* this) {
+ EnemyFunctionHandler(this, gUnk_080CD5D4);
+}
+
+void sub_0802C670(Entity* this) {
+ gUnk_080CD5EC[this->action](this);
+}
+
+void sub_0802C688(Entity* this) {
+ if (this->bitfield & 0x80) {
+ switch (this->bitfield & 0x7f) {
+ case 0:
+ case 1:
+ if (this->field_0x82.HALF.LO) {
+ this->field_0x42 = 0;
+ gPlayerEntity.field_0x42 = 4;
+ }
+ return;
+ case 0xe:
+ case 0x14:
+ case 0x15:
+ case 0x16:
+ this->action = 3;
+ this->field_0x42 = 0;
+ sub_0802CBC4(this);
+ return;
+ }
+ this->field_0x82.HALF.LO++;
+ this->field_0x80.HALF.LO = 28;
+ switch (this->field_0x82.HALF.LO) {
+ case 1:
+ sub_0802CB68(this);
+ EnqueueSFX(0x14d);
+ break;
+ case 2:
+ this->action = 3;
+ this->damageType = 0x6e;
+ this->field_0xf = 1;
+ this->field_0x20 = 0x18000;
+ this->nonPlanarMovement = 0;
+ this->field_0x80.HALF.HI = 1;
+ InitializeAnimation(this, this->direction >> 4 | 6);
+ break;
+ }
+ }
+ sub_0804AA30(this, gUnk_080CD5D4);
+}
+
+void sub_0802C7AC(Entity* this) {
+ if (this->previousActionFlag < 3 && !sub_0806F520(this)) {
+ this->previousActionFlag = 0;
+ this->field_0xf = 1;
+ this->height.HALF.HI = 0;
+ if (this->field_0x82.HALF.LO != 2) {
+ this->nonPlanarMovement = this->field_0x82.HALF.LO ? 0x200 : 0x80;
+ }
+ this->field_0x20 = 0x18000;
+ this->field_0x82.HALF.HI = 0;
+ this->field_0x80.HALF.HI = 0;
+ } else {
+ this->height.HALF.HI = -1;
+ gUnk_080CD600[this->previousActionFlag](this);
+ if (this->actionDelay != 0) {
+ GetNextFrame(this);
+ }
+ }
+}
+
+void sub_0802C820(Entity* this) {
+ this->previousActionFlag = 1;
+ this->field_0x1d = 60;
+}
+
+void sub_0802C82C(Entity* this) {
+ sub_0806F4E8(this);
+}
+
+void sub_0802C834(Entity* this) {
+ sub_0806F3E4(this);
+}
+
+void sub_0802C83C(Entity* this) {
+ if (this->field_0x82.HALF.LO) {
+ if (--this->actionDelay == 0) {
+ this->action = 3;
+ switch (gPlayerEntity.animationState & 6) {
+ case 2:
+ this->x.HALF.HI -= 6;
+ break;
+ case 6:
+ this->x.HALF.HI += 6;
+ break;
+ }
+ sub_0802CBC4(this);
+ } else {
+ sub_0802CC18(this);
+ this->flags &= ~0x80;
+ this->damageType = 0x6e;
+ }
+ } else {
+ this->field_0x82.HALF.LO = 2;
+ this->actionDelay = 120;
+ InitializeAnimation(this, (this->direction >> 4) | 6);
+ this->flags &= ~0x80;
+ this->damageType = 0x6e;
+ }
+}
+
+void nullsub_149(Entity* this) {
+ /* ... */
+}
+
+void sub_0802C8B8(Entity* this) {
+ this->action = 3;
+ sub_0802CBC4(this);
+}
+
+void sub_0802C8C4(Entity* this) {
+ sub_0804A7D4(this);
+ this->spriteSettings.b.draw = 0;
+}
+
+void sub_0802C8D8(Entity* this) {
+ this->action = 1;
+ this->actionDelay = 0x3c;
+ this->field_0xf = 0;
+ this->direction = (Random() & 0x18) | 4;
+ this->field_0x16 = 0;
+ this->field_0x1c = 0x12;
+ this->field_0x82.HALF.LO = 0;
+ this->field_0x82.HALF.HI = 0;
+ this->field_0x80.HALF.LO = 0;
+ this->field_0x80.HALF.HI = 0;
+ InitializeAnimation(this, this->direction >> 4);
+}
+
+void sub_0802C91C(Entity* this) {
+ GetNextFrame(this);
+ ProcessMovement(this);
+ if (this->field_0x82.HALF.LO) {
+ if (this->collisions) {
+ sub_0800417E(this, this->collisions);
+ InitializeAnimation(this, (this->direction >> 4) | 2);
+ }
+ if (--this->actionDelay == 0) {
+ sub_0802CBC4(this);
+ } else {
+ if ((this->actionDelay & 0xf) == 8) {
+ CreateDustSmall(this);
+ }
+ sub_0802CC18(this);
+ }
+ } else {
+ if (this->collisions) {
+ sub_0800417E(this, this->collisions);
+ InitializeAnimation(this, this->direction >> 4);
+ }
+ if (--this->actionDelay == 0) {
+ this->actionDelay = 60;
+ this->direction = (this->direction + 8) & 0x1c;
+ InitializeAnimation(this, this->direction >> 4);
+ }
+ }
+}
+
+void sub_0802C9B8(Entity* this) {
+ gUnk_080CD618[this->previousActionFlag](this);
+}
+
+void sub_0802C9D0(Entity* this) {
+ this->previousActionFlag = 1;
+ this->flags &= ~0x80;
+ this->spritePriority.b1 = 0;
+ this->field_0x82.HALF.HI = 1;
+ sub_0802CC18(this);
+ InitializeAnimation(this, (this->direction >> 4) | 6);
+ GetNextFrame(this);
+}
+
+void sub_0802CA10(Entity* this) {
+ if (gPlayerState.heldObject != 5) {
+ if (--this->actionDelay == 0) {
+ sub_0802CBC4(this);
+ } else {
+ sub_0802CC18(this);
+ GetNextFrame(this);
+ }
+ } else {
+ this->field_0x82.HALF.HI = 2;
+ this->direction = (((gPlayerEntity.animationState) << 2) | 4) & 0x1c;
+ sub_0802CC18(this);
+ GetNextFrame(this);
+ }
+}
+
+void sub_0802CA6C(Entity* this) {
+ if (--this->actionDelay == 0) {
+ sub_0802CBC4(this);
+ } else {
+ sub_0802CC18(this);
+ GetNextFrame(this);
+ }
+}
+
+void sub_0802CA94(Entity* this) {
+ this->action = 3;
+ this->flags &= ~0x80;
+ this->field_0xf = 1;
+ this->spritePriority.b1 = 1;
+ this->field_0x20 = 0x18000;
+ this->nonPlanarMovement = 0;
+ this->field_0x82.HALF.HI = 0;
+ this->field_0x80.HALF.HI = 0;
+ this->direction = ((gPlayerEntity.animationState << 2) | 4) & 0x1c;
+ InitializeAnimation(this, (this->direction >> 4) | 6);
+}
+
+void sub_0802CAF8(Entity* this) {
+ if (--this->actionDelay == 0) {
+ sub_0802CBC4(this);
+ } else {
+ if (this->field_0x80.HALF.HI && sub_080044EC(this, 0x2800) == 1) {
+ EnqueueSFX(0x104);
+ }
+ sub_0802CC18(this);
+ sub_08078930(this);
+ if (this->field_0xf && this->height.HALF.HI == 0) {
+ this->field_0xf = 0;
+ this->flags = this->flags | 0x80;
+ this->damageType = 0x6e;
+ }
+ GetNextFrame(this);
+ }
+}
+
+void nullsub_150(Entity* this) {
+ /* ... */
+}
+
+void sub_0802CB68(Entity* this) {
+ this->action = 1;
+ this->previousActionFlag = 0;
+ this->direction = Random() & 0x18;
+ this->direction |= 4;
+ this->flags |= 0x80;
+ if (this->field_0x82.HALF.LO) {
+ this->actionDelay = 200;
+ this->nonPlanarMovement = 0x200;
+ InitializeAnimation(this, (this->direction >> 4) | 2);
+ } else {
+ this->actionDelay = 0x3c;
+ this->nonPlanarMovement = 0x80;
+ InitializeAnimation(this, this->direction >> 4);
+ }
+}
+
+void sub_0802CBC4(Entity* this) {
+ Entity* ent;
+
+ this->action = 4;
+ this->spriteSettings.b.draw = 0;
+ this->flags &= ~0x80;
+ this->currentHealth = 0;
+ if (this->field_0x82.HALF.HI) {
+ sub_08079184();
+ }
+ sub_08078954(this);
+
+ ent = CreateObjectWithParent(this, 0x20, 0, 0);
+ if (ent) {
+ ent->collisionLayer = this->collisionLayer;
+ }
+}
+
+void sub_0802CC18(Entity* this) {
+ if (--this->field_0x80.HALF.LO == 0) {
+ this->field_0x80.HALF.LO = 28;
+ EnqueueSFX(0x14d);
+ }
+}
+
+// clang-format off
+void (*const gUnk_080CD5D4[])(Entity*) = {
+ sub_0802C670,
+ sub_0802C688,
+ sub_08001324,
+ sub_0802C8C4,
+ sub_08001242,
+ sub_0802C7AC,
+};
+
+void (*const gUnk_080CD5EC[])(Entity*) = {
+ sub_0802C8D8,
+ sub_0802C91C,
+ sub_0802C9B8,
+ sub_0802CAF8,
+ nullsub_150,
+};
+
+void (*const gUnk_080CD600[])(Entity*) = {
+ sub_0802C820,
+ sub_0802C82C,
+ sub_0802C834,
+ sub_0802C83C,
+ nullsub_149,
+ sub_0802C8B8,
+};
+
+void (*const gUnk_080CD618[])(Entity*) = {
+ sub_0802C9D0,
+ sub_0802CA10,
+ sub_0802CA6C,
+ sub_0802CA94,
+};
+// clang-format on