mirror of
https://github.com/zeldaret/tmc
synced 2026-06-09 04:40:07 -04:00
finish decompile octorok
This commit is contained in:
+139
-57
@@ -1,119 +1,201 @@
|
||||
#include "global.h"
|
||||
#include "entity.h"
|
||||
#include "functions.h"
|
||||
|
||||
extern void EnemyFunctionHandler();
|
||||
extern void SetChildOffset();
|
||||
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 sub_0806F4E8();
|
||||
extern void sub_0806F3E4();
|
||||
extern void UpdateAnimationVariableFrames();
|
||||
extern void sub_0804A720();
|
||||
extern u32 Random();
|
||||
extern void sub_0801ED14();
|
||||
extern u32 sub_0801EDEC();
|
||||
extern Entity *sub_08049DF4(u32);
|
||||
|
||||
extern void(*gOctorok[2]);
|
||||
extern void (*gOctorokIdle[4])(Entity*);
|
||||
extern void (*gUnk_080CA158[4])(Entity*);
|
||||
extern void (*const gOctorok[6])(Entity*);
|
||||
extern void (*const gOctorokIdle[4])(Entity*);
|
||||
extern void (*const gUnk_080CA158[4])(Entity*);
|
||||
|
||||
extern Entity* gUnk_020000B0;
|
||||
extern s8 gUnk_080CA17E[2];
|
||||
extern u8 gUnk_080CA170[8];
|
||||
extern u8 gUnk_080CA174[2];
|
||||
extern u8 gUnk_080CA176[8];
|
||||
// Main
|
||||
void Octorok(Entity* ent) {
|
||||
EnemyFunctionHandler(ent, gOctorok);
|
||||
SetChildOffset(ent, 0, 1, -16);
|
||||
void Octorok(Entity* this) {
|
||||
EnemyFunctionHandler(this, gOctorok);
|
||||
SetChildOffset(this, 0, 1, -16);
|
||||
}
|
||||
|
||||
// Idle
|
||||
void sub_0801EAD0(Entity* ent) {
|
||||
gOctorokIdle[ent->action](ent);
|
||||
void sub_0801EAD0(Entity* this) {
|
||||
gOctorokIdle[this->action](this);
|
||||
}
|
||||
|
||||
// Touch player
|
||||
void sub_0801EAE8(Entity* ent) {
|
||||
if (ent->field_0x43 != 0) {
|
||||
sub_0804A9FC(ent, 28);
|
||||
void sub_0801EAE8(Entity* this) {
|
||||
if (this->field_0x43 != 0) {
|
||||
sub_0804A9FC(this, 28);
|
||||
}
|
||||
sub_0804AA30(ent, gOctorok);
|
||||
sub_0804AA30(this, gOctorok);
|
||||
}
|
||||
|
||||
// Death
|
||||
void sub_0801EB0C(Entity* ent) {
|
||||
if ((ent->entityType).form == 0) {
|
||||
sub_0804A7D4(ent);
|
||||
void sub_0801EB0C(Entity* this) {
|
||||
if ((this->entityType).form == 0) {
|
||||
sub_0804A7D4(this);
|
||||
} else {
|
||||
CreateDeathFx(ent, 241, 0);
|
||||
CreateDeathFx(this, 241, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0801EB2C(Entity* ent) {
|
||||
void sub_0801EB2C(Entity* this) {
|
||||
s32 iVar1;
|
||||
|
||||
if ((ent->previousActionFlag < 3) && (iVar1 = sub_0806F520(ent), iVar1 == 0)) {
|
||||
sub_0801ECFC(ent);
|
||||
InitializeAnimation(ent, ent->animationState);
|
||||
if ((this->previousActionFlag < 3) && (iVar1 = sub_0806F520(this), iVar1 == 0)) {
|
||||
sub_0801ECFC(this);
|
||||
InitializeAnimation(this, this->animationState);
|
||||
} else {
|
||||
gUnk_080CA158[ent->previousActionFlag](ent);
|
||||
gUnk_080CA158[this->previousActionFlag](this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0801EB68(Entity* ent) {
|
||||
ent->previousActionFlag = 1;
|
||||
ent->field_0x1d = 60;
|
||||
void sub_0801EB68(Entity* this) {
|
||||
this->previousActionFlag = 1;
|
||||
this->field_0x1d = 60;
|
||||
}
|
||||
|
||||
void sub_0801EB74(Entity* ent) {
|
||||
sub_0806F4E8(ent);
|
||||
void sub_0801EB74(Entity* this) {
|
||||
sub_0806F4E8(this);
|
||||
}
|
||||
|
||||
void sub_0801EB7C(Entity* ent) {
|
||||
sub_0806F3E4(ent);
|
||||
void sub_0801EB7C(Entity* this) {
|
||||
sub_0806F3E4(this);
|
||||
}
|
||||
|
||||
void sub_0801EB84(Entity* ent) {
|
||||
ent->flags = ent->flags & 127;
|
||||
UpdateAnimationVariableFrames(ent, 2);
|
||||
void sub_0801EB84(Entity* this) {
|
||||
this->flags &= 0x7f;
|
||||
UpdateAnimationVariableFrames(this, 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;
|
||||
void sub_0801EB9C(Entity* this) {
|
||||
if (this->flags & 0x80) {
|
||||
this->flags |= 0x80;
|
||||
this->field_0x3a &= 0xfb;
|
||||
} else {
|
||||
ent->currentHealth = 0;
|
||||
this->currentHealth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Init
|
||||
#ifdef NON_MATCHING
|
||||
void sub_0801EBC8(Entity* ent) {
|
||||
sub_0804A720();
|
||||
ent->animationState = (ent->entityType).form == 2 ? (ent->entityType).form : Random() & 3;
|
||||
ent->filler[0] = 18;
|
||||
sub_0801ECFC(ent);
|
||||
InitializeAnimation(ent, ent->animationState);
|
||||
void sub_0801EBC8(Entity* this) {
|
||||
sub_0804A720(this);
|
||||
if (this->entityType.form == 2) {
|
||||
this->animationState = this->entityType.form;
|
||||
} else {
|
||||
this->animationState = Random() & 3;
|
||||
}
|
||||
this->field_0x1c = 18;
|
||||
sub_0801ECFC(this);
|
||||
InitializeAnimation(this, this->animationState);
|
||||
}
|
||||
#else
|
||||
NAKED
|
||||
void sub_0801EBC8(Entity* ent) {
|
||||
asm(".include \"asm/octorok/sub_0801EBC8.inc\"");
|
||||
}
|
||||
#endif
|
||||
|
||||
void sub_0801EBF4(Entity* ent) {
|
||||
void sub_0801EBF4(Entity* this) {
|
||||
u32 uVar2;
|
||||
|
||||
if (--ent->actionDelay == 0) {
|
||||
ent->action = 2;
|
||||
if (--this->actionDelay == 0) {
|
||||
this->action = 2;
|
||||
uVar2 = Random();
|
||||
ent->actionDelay = gUnk_080CA170[uVar2 & 3];
|
||||
sub_0801ED14(ent);
|
||||
this->actionDelay = gUnk_080CA170[uVar2 & 3];
|
||||
sub_0801ED14(this);
|
||||
}
|
||||
GetNextFrame(ent);
|
||||
GetNextFrame(this);
|
||||
}
|
||||
|
||||
void sub_0801EC2C(Entity* this) {
|
||||
sub_080AEF88(this);
|
||||
GetNextFrame(this);
|
||||
if (--this->actionDelay == 0) {
|
||||
if (sub_0801EDEC(this) && gUnk_080CA174[this->entityType.form] <= (Random() & 3)) {
|
||||
this->action = 3;
|
||||
InitializeAnimation(this, this->animationState + 4);
|
||||
} else {
|
||||
sub_0801ECFC(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0801EC80(Entity* this) {
|
||||
GetNextFrame(this);
|
||||
if (this->frames.all & 1) {
|
||||
Entity* ent = sub_0804A98C(this, 1, 0);
|
||||
if (ent) {
|
||||
s8* off;
|
||||
ent->direction = this->direction;
|
||||
off = &gUnk_080CA176[this->direction / 4];
|
||||
ent->x.HALF.HI += off[0];
|
||||
ent->y.HALF.HI += off[1];
|
||||
ent->height.HALF.HI = -3;
|
||||
this->frames.all &= 0xfe;
|
||||
sub_08004488(0x18d);
|
||||
}
|
||||
}
|
||||
|
||||
if (this->frames.all & 0x80)
|
||||
sub_0801ECFC(this);
|
||||
}
|
||||
|
||||
void sub_0801ECFC(Entity* this) {
|
||||
this->action = 1;
|
||||
this->actionDelay = (Random() & 0x38) + 0x18;
|
||||
}
|
||||
|
||||
void sub_0801ED14(Entity* this) {
|
||||
if (this->entityType.form != 2) {
|
||||
if (sub_08049FA0(this)) {
|
||||
if (this->entityType.form == 1 && (Random() & 3) == 0 && sub_08049FDC(this, 1)) {
|
||||
this->direction = (GetFacingDirection(this, gUnk_020000B0) + 4) & 0x18;
|
||||
} else {
|
||||
this->direction = Random() & 0x18;
|
||||
}
|
||||
} else if ((Random() & 3)) {
|
||||
this->direction = (sub_08049EE4(this) + gUnk_080CA17E[Random() & 1]) & 0x18;
|
||||
} else {
|
||||
this->direction = Random() & 0x18;
|
||||
}
|
||||
} else {
|
||||
if (sub_08049FDC(this, 1) == 0) {
|
||||
if (sub_08049FA0(this)) {
|
||||
this->direction = Random() & 0x18;
|
||||
} else if (Random() & 3) {
|
||||
this->direction = (sub_08049EE4(this) + gUnk_080CA17E[Random() & 1]) & 0x18;
|
||||
} else {
|
||||
this->direction = (GetFacingDirection(this, gUnk_020000B0) + 4) & 0x18;
|
||||
}
|
||||
} else {
|
||||
this->direction = (GetFacingDirection(this, gUnk_020000B0) + 4) & 0x18;
|
||||
}
|
||||
}
|
||||
this->animationState = this->direction >> 3;
|
||||
InitializeAnimation(this, this->animationState);
|
||||
}
|
||||
|
||||
u32 sub_0801EDEC(Entity *this) {
|
||||
Entity* ent = sub_08049DF4(1);
|
||||
|
||||
if (ent == NULL)
|
||||
return 0;
|
||||
|
||||
if (((GetFacingDirection(this, ent) + 4) & 0x18) != this->direction)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user