summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/octorok.c140
1 files changed, 140 insertions, 0 deletions
diff --git a/src/octorok.c b/src/octorok.c
new file mode 100644
index 00000000..64ceb622
--- /dev/null
+++ b/src/octorok.c
@@ -0,0 +1,140 @@
+#include "global.h"
+#include "entity.h"
+
+extern void sub_0800129E();
+extern void sub_0804A9AC();
+extern void sub_0804AA30();
+extern void sub_0804A9FC();
+extern void sub_0804A7D4();
+extern void CreateDeathFx();
+extern void sub_0801ECFC();
+extern u32 sub_0806F520();
+extern void UpdateSprite();
+extern void sub_0806F4E8();
+extern void sub_0806F3E4();
+extern void UpdateSpriteAnimation();
+extern void sub_0804A720();
+extern u32 Random();
+extern void sub_0801ED14();
+extern void sub_08004274();
+
+extern void (*gOctorok[2]);
+extern void (*gOctorokIdle[4])(Entity *);
+extern void (*gUnk_080CA158[4])(Entity *);
+
+extern u8 gUnk_080CA170[8];
+//Main
+void sub_0801EAB0(Entity *ent)
+{
+ sub_0800129E(ent, gOctorok);
+ sub_0804A9AC(ent, 0, 1, -16);
+}
+
+//Idle
+void sub_0801EAD0(Entity *ent)
+{
+ gOctorokIdle[ent->action](ent);
+}
+
+//Touch player
+void sub_0801EAE8(Entity *ent)
+{
+ if (ent->field_0x43 != 0) {
+ sub_0804A9FC(ent, 28);
+ }
+ sub_0804AA30(ent, gOctorok);
+}
+
+//Death
+void sub_0801EB0C(Entity *ent)
+{
+ if ((ent->entityType).parameter1 == 0) {
+ sub_0804A7D4(ent);
+ }
+ else {
+ CreateDeathFx(ent, 241, 0);
+ }
+}
+
+void sub_0801EB2C(Entity *ent)
+{
+ s32 iVar1;
+
+ if ((ent->previousActionFlag < 3) && (iVar1 = sub_0806F520(ent), iVar1 == 0)) {
+ sub_0801ECFC(ent);
+ UpdateSprite(ent, ent->animationState);
+ }
+ else {
+ gUnk_080CA158[ent->previousActionFlag](ent);
+ }
+}
+
+void sub_0801EB68(Entity *ent)
+{
+ ent->previousActionFlag = 1;
+ ent->filler[1] = 60;
+}
+
+void sub_0801EB74(Entity *ent)
+{
+ sub_0806F4E8(ent);
+}
+
+void sub_0801EB7C(Entity *ent)
+{
+ sub_0806F3E4(ent);
+}
+
+void sub_0801EB84(Entity *ent)
+{
+ ent->flags = ent->flags & 127;
+ UpdateSpriteAnimation(ent, 2);
+}
+
+void nullsub_3()
+{
+}
+
+void sub_0801EB9C(Entity *ent)
+{
+ if ((ent->flags & 128) != 0) {
+ ent->flags = ent->flags | 128;
+ ent->field_0x3a = ent->field_0x3a & 251;
+ }
+ else {
+ ent->currentHealth = 0;
+ }
+}
+
+//Init
+#ifdef NON_MATCHING
+void sub_0801EBC8(Entity *ent)
+{
+ sub_0804A720();
+ ent->animationState = (ent->entityType).parameter1 == 2 ? (ent->entityType).parameter1 : Random() & 3;
+ ent->filler[0] = 18;
+ sub_0801ECFC(ent);
+ UpdateSprite(ent,ent->animationState);
+}
+#else
+NAKED
+void sub_0801EBC8(Entity *ent)
+{
+ asm(".include \"asm/octorok/sub_0801EBC8.inc\"");
+}
+#endif
+
+void sub_0801EBF4(Entity *ent)
+{
+ u8 bVar1;
+ u32 uVar2;
+
+ bVar1 = ent->parameter3 -= 1;
+ if (bVar1 == 0) {
+ ent->action = 2;
+ uVar2 = Random();
+ ent->parameter3 = gUnk_080CA170[uVar2 & 3];
+ sub_0801ED14(ent);
+ }
+ sub_08004274(ent);
+} \ No newline at end of file