summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenny022p <info@henny022.de>2021-10-21 10:36:44 +0200
committerHenny022p <info@henny022.de>2021-10-21 10:36:44 +0200
commit00a57e3b368c98ccf5f2f45f89b1353523445940 (patch)
tree22d579b8ac553c5b480f15f710664ff5a8f37e43 /src
parente1759fa99cac28ae50c24a18c89092f0704ad685 (diff)
decompiled Enemy5A
Diffstat (limited to 'src')
-rw-r--r--src/enemy/enemy5A.c327
1 files changed, 327 insertions, 0 deletions
diff --git a/src/enemy/enemy5A.c b/src/enemy/enemy5A.c
new file mode 100644
index 00000000..058f6afb
--- /dev/null
+++ b/src/enemy/enemy5A.c
@@ -0,0 +1,327 @@
+#include "entity.h"
+#include "enemy.h"
+#include "audio.h"
+#include "textbox.h"
+#include "coord.h"
+#include "functions.h"
+
+void sub_08045A00(Entity*);
+void sub_08045A28(Entity*);
+
+void sub_080456E8(Entity*);
+void sub_08045700(Entity*);
+void nullsub_173(Entity*);
+void sub_080457E4(Entity*);
+void sub_0804586C(Entity*);
+void sub_080458C4(Entity*);
+void sub_08045938(Entity*);
+void sub_08045984(Entity*);
+
+void (*const gUnk_080D1888[])(Entity*) = {
+ sub_080456E8, sub_08045700, sub_080456E8, sub_0804A7D4, sub_08001242, nullsub_173,
+};
+
+void (*const gUnk_080D18A0[])(Entity*) = {
+ sub_080457E4, sub_0804586C, sub_080458C4, sub_08045938, sub_08045984,
+};
+
+struct xy {
+ s8 x;
+ s8 y;
+} PACKED;
+
+const struct xy gUnk_080D18B4[] = { { 0xe8, 0xf6 }, { 0xf6, 0xe8 }, { 0x0a, 0xe8 }, { 0x18, 0xf6 },
+ { 0x18, 0x0a }, { 0x0a, 0x18 }, { 0xf6, 0x18 }, { 0xe8, 0x0a } };
+
+void Enemy5A(Entity* this) {
+ EnemyFunctionHandler(this, gUnk_080D1888);
+}
+
+void sub_080456E8(Entity* this) {
+ gUnk_080D18A0[this->action](this);
+}
+
+void sub_08045700(Entity* this) {
+ u8 bVar1;
+ Entity* pEVar4;
+
+ if (this->type != 0) {
+ pEVar4 = this->parent->parent;
+ if ((this->bitfield & 0x80) != 0) {
+ bVar1 = this->bitfield & 0x3f;
+ if ((bVar1 == 0xe) || (bVar1 == 0x15)) {
+
+ if (this->field_0x80.HALF.HI == 0) {
+ this->action = 3;
+ this->field_0x80.HALF.HI += 1;
+ InitializeAnimation(this, (this->type << 3) | (this->actionDelay + 2));
+ InitializeAnimation(this->parent, (this->parent->type << 3) | (this->actionDelay + 2));
+ }
+ if (this->actionDelay != 0) {
+ SoundReq(SFX_17A);
+ } else {
+ SoundReq(SFX_ITEM_GLOVES_KNOCKBACK);
+ }
+ } else {
+ if (this->currentHealth != 0xff) {
+ this->currentHealth = 0xff;
+ if (this->actionDelay != 0 && (pEVar4->field_0x80.HALF.HI != 0)) {
+ pEVar4->field_0x76.HALF.LO |= (1 << this->type2);
+ if (this->cutsceneBeh.HALF.HI == 0) {
+ this->cutsceneBeh.HALF.HI += 1;
+ InitializeAnimation(this, this->type << 3 | 6);
+ InitializeAnimation(this->parent, this->parent->type << 3 | 6);
+ }
+ }
+ }
+ }
+ }
+ }
+ sub_0804AA30(this, gUnk_080D1888);
+}
+
+void nullsub_173(Entity* this) {
+}
+
+void sub_080457E4(Entity* this) {
+ Entity* child;
+ u8 bVar2;
+
+ bVar2 = gTextBox.doTextBox & 0x7f;
+ if ((gTextBox.doTextBox & 0x7f) == 0) {
+ this->action = 1;
+ this->spriteSettings.b.draw = 0;
+ this->field_0x80.HALF.LO = bVar2;
+ this->field_0x80.HALF.HI = bVar2;
+ this->cutsceneBeh.HALF.HI = bVar2;
+ this->field_0xf = bVar2;
+ this->field_0x82.HALF.LO = 0x30;
+ this->field_0x82.HALF.HI = bVar2;
+ if (this->type == 0) {
+ sub_08045A00(this);
+ child = CreateEnemy(ENEMY_5A, 1);
+ if (child != NULL) {
+ child->parent = this;
+ this->attachedEntity = child;
+ child->actionDelay = this->actionDelay;
+ child->type2 = this->type2;
+ CopyPosition(this, child);
+ }
+ } else {
+ this->spriteOffsetY = 1;
+ }
+ InitializeAnimation(this, (u32)this->type << 3 | 1);
+ }
+}
+
+void sub_0804586C(Entity* this) {
+ sub_08045A28(this);
+ if (this->field_0x82.HALF.LO == 0) {
+ if ((this->frames.all & 0x80) != 0) {
+ if (this->type != 0) {
+ this->flags |= 0x80;
+ }
+ this->action = 2;
+ InitializeAnimation(this, (u32)this->type << 3);
+ }
+ } else {
+ if (--this->field_0x82.HALF.LO == 0) {
+ this->spriteSettings.b.draw = 1;
+ }
+ }
+}
+
+void sub_080458C4(Entity* this) {
+ Entity* parent;
+
+ sub_08045A28(this);
+ parent = this->parent;
+ if (this->type != 0) {
+ parent = parent->parent;
+ }
+ if ((parent->action == 3) && (parent->field_0x80.HALF.LO == 1)) {
+ this->action = 4;
+ this->field_0xf = 0;
+ if (this->type != 0) {
+ this->flags &= 0x7f;
+ if (this->actionDelay != 0) {
+ InitializeAnimation(this, this->type << 3 | 5);
+ InitializeAnimation(this->parent, this->parent->type << 3 | 5);
+ } else {
+ InitializeAnimation(this, this->type << 3 | 4);
+ InitializeAnimation(this->parent, this->parent->type << 3 | 4);
+ }
+ }
+ }
+}
+
+void sub_08045938(Entity* this) {
+ sub_08045A28(this);
+ if ((this->frames.all & 0x80) != 0) {
+ this->action = 2;
+ if (this->type != 0) {
+ if (this->actionDelay == 0) {
+ this->damageType = 0x32;
+ } else {
+ this->parent->parent->field_0x76.HALF.LO |= (1 << this->type2);
+ this->damageType = 0x31;
+ }
+ }
+ }
+}
+
+void sub_08045984(Entity* this) {
+ Entity* parent;
+
+ sub_08045A28(this);
+ if (this->field_0xf == 0) {
+ if ((this->frames.all & 0x80) != 0) {
+ this->field_0xf = 0x20;
+ }
+ } else {
+ parent = this->parent;
+ if (this->type != 0) {
+ parent = parent->parent;
+ }
+ if ((parent->animationState < 3) && (parent->action != 3)) {
+ this->action = 1;
+ this->field_0xf = 0;
+ this->field_0x80.HALF.HI = 0;
+ this->cutsceneBeh.HALF.HI = 0;
+ if (this->type != 0) {
+ this->damageType = 0x33;
+ }
+ if ((parent->field_0x74.HALF.HI >> this->type2 & 1U) != 0) {
+ this->actionDelay = 1;
+ } else {
+ this->actionDelay = 0;
+ }
+ InitializeAnimation(this, this->type << 3 | 1);
+ }
+ }
+}
+
+void sub_08045A00(Entity* this) {
+ const struct xy* t = &gUnk_080D18B4[this->type2];
+ PositionRelative(this->parent, this, t->x << 0x10, (t->y + 3) * 0x10000);
+}
+
+void sub_08045A28(Entity* this) {
+ u32 frames;
+ u32 type;
+
+ if (this->field_0x82.HALF.LO == 0) {
+ GetNextFrame(this);
+ }
+ frames = this->frames.all & 0x70;
+ type = this->type;
+ if (type == 0) {
+ sub_08045A00(this);
+ switch (this->field_0x82.HALF.HI) {
+ case 0:
+ switch (frames) {
+ case 0x20:
+ this->field_0x82.HALF.HI = 1;
+ sub_0801D2B4(this, 0x13e);
+ break;
+ case 0x00:
+ case 0x40:
+ this->field_0x82.HALF.HI = 2;
+ sub_0801D2B4(this, 0x13f);
+ break;
+ default:
+ break;
+ }
+ break;
+ case 1:
+ switch (frames) {
+ case 0x10:
+ this->field_0x82.HALF.HI = type;
+ sub_0801D2B4(this, 0x13b);
+ break;
+ case 0:
+ this->field_0x82.HALF.HI = 2;
+ sub_0801D2B4(this, 0x13f);
+ break;
+ default:
+ break;
+ }
+ break;
+ case 2:
+ switch (frames) {
+ case 0x20:
+ this->field_0x82.HALF.HI = 1;
+ sub_0801D2B4(this, 0x13e);
+ break;
+ case 0x10:
+ this->field_0x82.HALF.HI = 0;
+ sub_0801D2B4(this, 0x13b);
+ break;
+ case 0x40:
+ this->field_0x82.HALF.HI = 2;
+ sub_0801D2B4(this, 0x13f);
+ break;
+ default:
+ break;
+ }
+ break;
+ case 3:
+ switch (frames) {
+ case 0:
+ this->field_0x82.HALF.HI = 2;
+ sub_0801D2B4(this, 0x13f);
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ } else {
+ PositionRelative(this->parent, this, 0, -0x10000);
+ switch (this->field_0x82.HALF.HI) {
+ case 0:
+ switch (this->frames.all & 0x70) {
+ case 0x10:
+ this->field_0x82.HALF.HI = 2;
+ sub_0801D2B4(this, 0x13b);
+ break;
+ case 0x20:
+ this->field_0x82.HALF.HI = 1;
+ sub_0801D2B4(this, 0x13e);
+ break;
+ default:
+ break;
+ }
+ break;
+ case 1: {
+ u32 temp = this->frames.all & 0x70;
+ switch (temp) {
+ case 0:
+ this->field_0x82.HALF.HI = temp;
+ sub_0801D2B4(this, 0x13f);
+ break;
+ case 0x10:
+ this->field_0x82.HALF.HI = 2;
+ sub_0801D2B4(this, 0x13b);
+ break;
+ default:
+ break;
+ }
+ } break;
+ case 2:
+ switch (this->frames.all & 0x70) {
+ case 0:
+ this->field_0x82.HALF.HI = this->frames.all & 0x70;
+ sub_0801D2B4(this, 0x13f);
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+}