mirror of https://github.com/zeldaret/tmc.git
finish decompile octorok
This commit is contained in:
parent
264cce346a
commit
1c65cda79d
246
asm/octorok.s
246
asm/octorok.s
|
|
@ -1,246 +0,0 @@
|
|||
.include "asm/macros.inc"
|
||||
|
||||
.include "constants/constants.inc"
|
||||
|
||||
.syntax unified
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_0801EC2C
|
||||
sub_0801EC2C: @ 0x0801EC2C
|
||||
push {r4, r5, lr}
|
||||
adds r5, r0, #0
|
||||
bl sub_080AEF88
|
||||
adds r0, r5, #0
|
||||
bl GetNextFrame
|
||||
ldrb r0, [r5, #0xe]
|
||||
subs r0, #1
|
||||
strb r0, [r5, #0xe]
|
||||
lsls r0, r0, #0x18
|
||||
cmp r0, #0
|
||||
bne _0801EC7E
|
||||
adds r0, r5, #0
|
||||
bl sub_0801EDEC
|
||||
cmp r0, #0
|
||||
beq _0801EC78
|
||||
ldr r1, _0801EC74 @ =gUnk_080CA174
|
||||
ldrb r0, [r5, #0xa]
|
||||
adds r0, r0, r1
|
||||
ldrb r4, [r0]
|
||||
bl Random
|
||||
movs r1, #3
|
||||
ands r0, r1
|
||||
cmp r4, r0
|
||||
bhi _0801EC78
|
||||
strb r1, [r5, #0xc]
|
||||
ldrb r1, [r5, #0x14]
|
||||
adds r1, #4
|
||||
adds r0, r5, #0
|
||||
bl InitializeAnimation
|
||||
b _0801EC7E
|
||||
.align 2, 0
|
||||
_0801EC74: .4byte gUnk_080CA174
|
||||
_0801EC78:
|
||||
adds r0, r5, #0
|
||||
bl sub_0801ECFC
|
||||
_0801EC7E:
|
||||
pop {r4, r5, pc}
|
||||
|
||||
thumb_func_start sub_0801EC80
|
||||
sub_0801EC80: @ 0x0801EC80
|
||||
push {r4, r5, lr}
|
||||
adds r4, r0, #0
|
||||
bl GetNextFrame
|
||||
adds r5, r4, #0
|
||||
adds r5, #0x5a
|
||||
ldrb r1, [r5]
|
||||
movs r0, #1
|
||||
ands r0, r1
|
||||
cmp r0, #0
|
||||
beq _0801ECD8
|
||||
adds r0, r4, #0
|
||||
movs r1, #1
|
||||
movs r2, #0
|
||||
bl sub_0804A98C
|
||||
adds r2, r0, #0
|
||||
cmp r2, #0
|
||||
beq _0801ECD8
|
||||
ldrb r0, [r4, #0x15]
|
||||
strb r0, [r2, #0x15]
|
||||
ldrb r1, [r4, #0x15]
|
||||
lsrs r1, r1, #2
|
||||
ldr r0, _0801ECF0 @ =gUnk_080CA176
|
||||
adds r1, r1, r0
|
||||
movs r0, #0
|
||||
ldrsb r0, [r1, r0]
|
||||
ldrh r3, [r2, #0x2e]
|
||||
adds r0, r0, r3
|
||||
strh r0, [r2, #0x2e]
|
||||
movs r0, #1
|
||||
ldrsb r0, [r1, r0]
|
||||
ldrh r1, [r2, #0x32]
|
||||
adds r0, r0, r1
|
||||
strh r0, [r2, #0x32]
|
||||
ldr r0, _0801ECF4 @ =0x0000FFFD
|
||||
strh r0, [r2, #0x36]
|
||||
ldrb r1, [r5]
|
||||
movs r0, #0xfe
|
||||
ands r0, r1
|
||||
strb r0, [r5]
|
||||
ldr r0, _0801ECF8 @ =0x0000018D
|
||||
bl sub_08004488
|
||||
_0801ECD8:
|
||||
adds r0, r4, #0
|
||||
adds r0, #0x5a
|
||||
ldrb r1, [r0]
|
||||
movs r0, #0x80
|
||||
ands r0, r1
|
||||
cmp r0, #0
|
||||
beq _0801ECEC
|
||||
adds r0, r4, #0
|
||||
bl sub_0801ECFC
|
||||
_0801ECEC:
|
||||
pop {r4, r5, pc}
|
||||
.align 2, 0
|
||||
_0801ECF0: .4byte gUnk_080CA176
|
||||
_0801ECF4: .4byte 0x0000FFFD
|
||||
_0801ECF8: .4byte 0x0000018D
|
||||
|
||||
thumb_func_start sub_0801ECFC
|
||||
sub_0801ECFC: @ 0x0801ECFC
|
||||
push {r4, lr}
|
||||
adds r4, r0, #0
|
||||
movs r0, #1
|
||||
strb r0, [r4, #0xc]
|
||||
bl Random
|
||||
movs r1, #0x38
|
||||
ands r0, r1
|
||||
adds r0, #0x18
|
||||
strb r0, [r4, #0xe]
|
||||
pop {r4, pc}
|
||||
.align 2, 0
|
||||
|
||||
thumb_func_start sub_0801ED14
|
||||
sub_0801ED14: @ 0x0801ED14
|
||||
push {r4, r5, lr}
|
||||
adds r5, r0, #0
|
||||
ldrb r0, [r5, #0xa]
|
||||
cmp r0, #2
|
||||
beq _0801ED7E
|
||||
adds r0, r5, #0
|
||||
bl sub_08049FA0
|
||||
cmp r0, #0
|
||||
beq _0801ED4C
|
||||
ldrb r0, [r5, #0xa]
|
||||
cmp r0, #1
|
||||
bne _0801ED46
|
||||
bl Random
|
||||
movs r1, #3
|
||||
ands r1, r0
|
||||
cmp r1, #0
|
||||
bne _0801ED46
|
||||
adds r0, r5, #0
|
||||
movs r1, #1
|
||||
bl sub_08049FDC
|
||||
cmp r0, #0
|
||||
bne _0801EDC4
|
||||
_0801ED46:
|
||||
bl Random
|
||||
b _0801EDD0
|
||||
_0801ED4C:
|
||||
bl Random
|
||||
movs r1, #3
|
||||
ands r1, r0
|
||||
cmp r1, #0
|
||||
beq _0801ED78
|
||||
adds r0, r5, #0
|
||||
bl sub_08049EE4
|
||||
adds r4, r0, #0
|
||||
bl Random
|
||||
ldr r2, _0801ED74 @ =gUnk_080CA17E
|
||||
movs r1, #1
|
||||
ands r1, r0
|
||||
adds r1, r1, r2
|
||||
ldrb r0, [r1]
|
||||
adds r0, r0, r4
|
||||
b _0801EDD0
|
||||
.align 2, 0
|
||||
_0801ED74: .4byte gUnk_080CA17E
|
||||
_0801ED78:
|
||||
bl Random
|
||||
b _0801EDD0
|
||||
_0801ED7E:
|
||||
adds r0, r5, #0
|
||||
movs r1, #1
|
||||
bl sub_08049FDC
|
||||
cmp r0, #0
|
||||
bne _0801EDC4
|
||||
adds r0, r5, #0
|
||||
bl sub_08049FA0
|
||||
cmp r0, #0
|
||||
beq _0801ED9A
|
||||
bl Random
|
||||
b _0801EDD0
|
||||
_0801ED9A:
|
||||
bl Random
|
||||
movs r1, #3
|
||||
ands r1, r0
|
||||
cmp r1, #0
|
||||
beq _0801EDC4
|
||||
adds r0, r5, #0
|
||||
bl sub_08049EE4
|
||||
adds r4, r0, #0
|
||||
bl Random
|
||||
ldr r2, _0801EDC0 @ =gUnk_080CA17E
|
||||
movs r1, #1
|
||||
ands r1, r0
|
||||
adds r1, r1, r2
|
||||
ldrb r0, [r1]
|
||||
adds r0, r0, r4
|
||||
b _0801EDD0
|
||||
.align 2, 0
|
||||
_0801EDC0: .4byte gUnk_080CA17E
|
||||
_0801EDC4:
|
||||
ldr r0, _0801EDE8 @ =gUnk_020000B0
|
||||
ldr r1, [r0]
|
||||
adds r0, r5, #0
|
||||
bl GetFacingDirection
|
||||
adds r0, #4
|
||||
_0801EDD0:
|
||||
movs r1, #0x18
|
||||
ands r0, r1
|
||||
strb r0, [r5, #0x15]
|
||||
ldrb r0, [r5, #0x15]
|
||||
lsrs r0, r0, #3
|
||||
strb r0, [r5, #0x14]
|
||||
ldrb r1, [r5, #0x14]
|
||||
adds r0, r5, #0
|
||||
bl InitializeAnimation
|
||||
pop {r4, r5, pc}
|
||||
.align 2, 0
|
||||
_0801EDE8: .4byte gUnk_020000B0
|
||||
|
||||
thumb_func_start sub_0801EDEC
|
||||
sub_0801EDEC: @ 0x0801EDEC
|
||||
push {r4, lr}
|
||||
adds r4, r0, #0
|
||||
movs r0, #1
|
||||
bl sub_08049DF4
|
||||
adds r1, r0, #0
|
||||
cmp r1, #0
|
||||
beq _0801EE12
|
||||
adds r0, r4, #0
|
||||
bl GetFacingDirection
|
||||
adds r0, #4
|
||||
movs r1, #0x18
|
||||
ands r0, r1
|
||||
ldrb r4, [r4, #0x15]
|
||||
cmp r0, r4
|
||||
bne _0801EE12
|
||||
movs r0, #1
|
||||
b _0801EE14
|
||||
_0801EE12:
|
||||
movs r0, #0
|
||||
_0801EE14:
|
||||
pop {r4, pc}
|
||||
.align 2, 0
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
.include "asm/macros.inc"
|
||||
|
||||
.include "constants/constants.inc"
|
||||
|
||||
.text
|
||||
|
||||
.syntax unified
|
||||
push {r4, lr}
|
||||
adds r4, r0, #0
|
||||
bl sub_0804A720
|
||||
ldrb r0, [r4, #0xa]
|
||||
cmp r0, #2
|
||||
beq _0801EBDE
|
||||
bl Random
|
||||
movs r1, #3
|
||||
ands r0, r1
|
||||
_0801EBDE:
|
||||
strb r0, [r4, #0x14]
|
||||
movs r0, #0x12
|
||||
strb r0, [r4, #0x1c]
|
||||
adds r0, r4, #0
|
||||
bl sub_0801ECFC
|
||||
ldrb r1, [r4, #0x14]
|
||||
adds r0, r4, #0
|
||||
bl InitializeAnimation
|
||||
pop {r4, pc}
|
||||
.syntax divided
|
||||
|
||||
|
|
@ -326,7 +326,6 @@ SECTIONS {
|
|||
asm/code_0801D79C.o(.text);
|
||||
/* enemies */
|
||||
src/enemy/octorok.o(.text);
|
||||
asm/octorok.o(.text);
|
||||
asm/chuchu.o(.text);
|
||||
src/enemy/leever.o(.text);
|
||||
asm/peahat.o(.text);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue