mirror of https://github.com/zeldaret/tmc.git
decompile moldworm
This commit is contained in:
parent
269d8970f3
commit
a56b6a2041
1523
asm/moldworm.s
1523
asm/moldworm.s
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,83 @@
|
|||
|
||||
.syntax unified
|
||||
|
||||
.text
|
||||
|
||||
|
||||
push {r4, r5, r6, lr}
|
||||
adds r4, r0, #0
|
||||
ldrh r5, [r4, #0x2e]
|
||||
ldrh r6, [r4, #0x32]
|
||||
ldrb r1, [r4, #0xa]
|
||||
cmp r1, #0
|
||||
bne _0802306C
|
||||
ldrb r0, [r4, #0xc]
|
||||
cmp r0, #0
|
||||
beq _08023052
|
||||
adds r0, r4, #0
|
||||
bl sub_0802390C
|
||||
_08023052:
|
||||
adds r0, r4, #0
|
||||
adds r0, #0x7c
|
||||
ldrb r0, [r0]
|
||||
adds r1, r4, #0
|
||||
adds r1, #0x7d
|
||||
strb r0, [r1]
|
||||
ldr r1, _08023068 @ =gUnk_080CBC38
|
||||
adds r0, r4, #0
|
||||
bl EnemyFunctionHandler
|
||||
b _08023090
|
||||
.align 2, 0
|
||||
_08023068: .4byte gUnk_080CBC38
|
||||
_0802306C:
|
||||
ldr r0, [r4, #0x50]
|
||||
ldr r0, [r0, #4]
|
||||
cmp r0, #0
|
||||
beq _08023088
|
||||
cmp r1, #8
|
||||
beq _08023080
|
||||
adds r0, r4, #0
|
||||
bl sub_080235BC
|
||||
b _08023090
|
||||
_08023080:
|
||||
adds r0, r4, #0
|
||||
bl sub_08023730
|
||||
b _08023090
|
||||
_08023088:
|
||||
adds r0, r4, #0
|
||||
bl DeleteEntity
|
||||
b _080230CA
|
||||
_08023090:
|
||||
ldr r0, [r4, #0x50]
|
||||
adds r2, r0, #0
|
||||
adds r2, #0x7c
|
||||
adds r0, #0x7d
|
||||
ldrb r1, [r2]
|
||||
ldrb r0, [r0]
|
||||
cmp r1, r0
|
||||
beq _080230CA
|
||||
ldr r1, [r4, #0x54]
|
||||
cmp r1, #0
|
||||
beq _080230CA
|
||||
ldrb r2, [r2]
|
||||
subs r2, #1
|
||||
movs r0, #0xf
|
||||
ands r2, r0
|
||||
adds r2, #0x78
|
||||
adds r2, r1, r2
|
||||
ldrh r1, [r4, #0x2e]
|
||||
subs r1, r1, r5
|
||||
adds r1, #8
|
||||
movs r3, #0xf
|
||||
ands r1, r3
|
||||
lsls r1, r1, #4
|
||||
ldrh r0, [r4, #0x32]
|
||||
subs r0, r0, r6
|
||||
adds r0, #8
|
||||
ands r0, r3
|
||||
orrs r1, r0
|
||||
strb r1, [r2]
|
||||
_080230CA:
|
||||
pop {r4, r5, r6, pc}
|
||||
|
||||
.syntax divided
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
.syntax unified
|
||||
|
||||
.text
|
||||
|
||||
adds r2, r0, #0
|
||||
adds r1, r2, #0
|
||||
adds r1, #0x78
|
||||
movs r0, #0x88
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
adds r1, #1
|
||||
strb r0, [r1]
|
||||
bx lr
|
||||
|
||||
.syntax divided
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
.syntax unified
|
||||
|
||||
.text
|
||||
|
||||
push {r4, r5, r6, lr}
|
||||
adds r4, r0, #0
|
||||
movs r0, #1
|
||||
bl sub_08049DF4
|
||||
adds r5, r0, #0
|
||||
cmp r5, #0
|
||||
bne _08023B4C
|
||||
movs r0, #0
|
||||
b _08023B8E
|
||||
_08023B4C:
|
||||
movs r0, #0x2e
|
||||
ldrsh r2, [r4, r0]
|
||||
ldr r3, _08023B90 @ =gUnk_080CBCB8
|
||||
ldrb r0, [r4, #0x14]
|
||||
lsls r0, r0, #1
|
||||
adds r1, r0, r3
|
||||
ldrb r1, [r1]
|
||||
lsls r1, r1, #0x18
|
||||
asrs r1, r1, #0x18
|
||||
adds r2, r2, r1
|
||||
movs r6, #0x32
|
||||
ldrsh r1, [r4, r6]
|
||||
adds r0, #1
|
||||
adds r0, r0, r3
|
||||
ldrb r0, [r0]
|
||||
lsls r0, r0, #0x18
|
||||
asrs r0, r0, #0x18
|
||||
adds r1, r1, r0
|
||||
movs r3, #0
|
||||
movs r4, #0x2e
|
||||
ldrsh r0, [r5, r4]
|
||||
subs r0, r0, r2
|
||||
adds r0, #0x14
|
||||
cmp r0, #0x28
|
||||
bhi _08023B8C
|
||||
movs r6, #0x32
|
||||
ldrsh r0, [r5, r6]
|
||||
subs r0, r0, r1
|
||||
adds r0, #0x14
|
||||
cmp r0, #0x28
|
||||
bhi _08023B8C
|
||||
movs r3, #1
|
||||
_08023B8C:
|
||||
adds r0, r3, #0
|
||||
_08023B8E:
|
||||
pop {r4, r5, r6, pc}
|
||||
.align 2, 0
|
||||
_08023B90: .4byte gUnk_080CBCB8
|
||||
|
||||
.syntax divided
|
|
@ -0,0 +1,79 @@
|
|||
.include "asm/macros.inc"
|
||||
.include "constants/constants.inc"
|
||||
|
||||
.section .rodata
|
||||
|
||||
gUnk_080CBCC8:: @ 080CBCC8
|
||||
.incbin "baserom.gba", 0x0CBCC8, 0x0000004
|
||||
|
||||
gUnk_080CBCCC:: @ 080CBCCC
|
||||
.incbin "baserom.gba", 0x0CBCCC, 0x0000004
|
||||
|
||||
gUnk_080CBCD0:: @ 080CBCD0
|
||||
.incbin "baserom.gba", 0x0CBCD0, 0x0000004
|
||||
|
||||
gUnk_080CBCD4:: @ 080CBCD4
|
||||
.incbin "baserom.gba", 0x0CBCD4, 0x0000004
|
||||
|
||||
gUnk_080CBCD8:: @ 080CBCD8
|
||||
.incbin "baserom.gba", 0x0CBCD8, 0x0000004
|
||||
|
||||
gUnk_080CBCDC:: @ 080CBCDC
|
||||
.incbin "baserom.gba", 0x0CBCDC, 0x0000004
|
||||
|
||||
gUnk_080CBCE0:: @ 080CBCE0
|
||||
.incbin "baserom.gba", 0x0CBCE0, 0x0000004
|
||||
|
||||
gUnk_080CBCE4:: @ 080CBCE4
|
||||
.incbin "baserom.gba", 0x0CBCE4, 0x0000004
|
||||
|
||||
gUnk_080CBCE8:: @ 080CBCE8
|
||||
.incbin "baserom.gba", 0x0CBCE8, 0x0000004
|
||||
|
||||
gUnk_080CBCEC:: @ 080CBCEC
|
||||
.incbin "baserom.gba", 0x0CBCEC, 0x0000004
|
||||
|
||||
gUnk_080CBCF0:: @ 080CBCF0
|
||||
.incbin "baserom.gba", 0x0CBCF0, 0x0000004
|
||||
|
||||
gUnk_080CBCF4:: @ 080CBCF4
|
||||
.incbin "baserom.gba", 0x0CBCF4, 0x0000004
|
||||
|
||||
gUnk_080CBCF8:: @ 080CBCF8
|
||||
.incbin "baserom.gba", 0x0CBCF8, 0x0000004
|
||||
|
||||
gUnk_080CBCFC:: @ 080CBCFC
|
||||
.incbin "baserom.gba", 0x0CBCFC, 0x0000004
|
||||
|
||||
gUnk_080CBD00:: @ 080CBD00
|
||||
.incbin "baserom.gba", 0x0CBD00, 0x0000004
|
||||
|
||||
gUnk_080CBD04:: @ 080CBD04
|
||||
.incbin "baserom.gba", 0x0CBD04, 0x0000004
|
||||
|
||||
gUnk_080CBD08:: @ 080CBD08
|
||||
.incbin "baserom.gba", 0x0CBD08, 0x0000004
|
||||
|
||||
gUnk_080CBD0C:: @ 080CBD0C
|
||||
.incbin "baserom.gba", 0x0CBD0C, 0x0000004
|
||||
|
||||
gUnk_080CBD10:: @ 080CBD10
|
||||
.incbin "baserom.gba", 0x0CBD10, 0x0000004
|
||||
|
||||
gUnk_080CBD14:: @ 080CBD14
|
||||
.incbin "baserom.gba", 0x0CBD14, 0x0000004
|
||||
|
||||
gUnk_080CBD18:: @ 080CBD18
|
||||
.incbin "baserom.gba", 0x0CBD18, 0x0000004
|
||||
|
||||
gUnk_080CBD1C:: @ 080CBD1C
|
||||
.incbin "baserom.gba", 0x0CBD1C, 0x0000004
|
||||
|
||||
gUnk_080CBD20:: @ 080CBD20
|
||||
.incbin "baserom.gba", 0x0CBD20, 0x000002C
|
||||
|
||||
gUnk_080CBD4C:: @ 080CBD4C
|
||||
.incbin "baserom.gba", 0x0CBD4C, 0x000000C
|
||||
|
||||
gUnk_080CBD58:: @ 080CBD58
|
||||
.incbin "baserom.gba", 0x0CBD58, 0x0000064
|
|
@ -3,102 +3,6 @@
|
|||
|
||||
.section .rodata
|
||||
|
||||
gUnk_080CBC38:: @ 080CBC38
|
||||
.incbin "baserom.gba", 0x0CBC38, 0x0000018
|
||||
|
||||
gUnk_080CBC50:: @ 080CBC50
|
||||
.incbin "baserom.gba", 0x0CBC50, 0x0000020
|
||||
|
||||
gUnk_080CBC70:: @ 080CBC70
|
||||
.incbin "baserom.gba", 0x0CBC70, 0x0000020
|
||||
|
||||
gUnk_080CBC90:: @ 080CBC90
|
||||
.incbin "baserom.gba", 0x0CBC90, 0x0000008
|
||||
|
||||
gUnk_080CBC98:: @ 080CBC98
|
||||
.incbin "baserom.gba", 0x0CBC98, 0x0000010
|
||||
|
||||
gUnk_080CBCA8:: @ 080CBCA8
|
||||
.incbin "baserom.gba", 0x0CBCA8, 0x0000010
|
||||
|
||||
gUnk_080CBCB8:: @ 080CBCB8
|
||||
.incbin "baserom.gba", 0x0CBCB8, 0x0000010
|
||||
|
||||
gUnk_080CBCC8:: @ 080CBCC8
|
||||
.incbin "baserom.gba", 0x0CBCC8, 0x0000004
|
||||
|
||||
gUnk_080CBCCC:: @ 080CBCCC
|
||||
.incbin "baserom.gba", 0x0CBCCC, 0x0000004
|
||||
|
||||
gUnk_080CBCD0:: @ 080CBCD0
|
||||
.incbin "baserom.gba", 0x0CBCD0, 0x0000004
|
||||
|
||||
gUnk_080CBCD4:: @ 080CBCD4
|
||||
.incbin "baserom.gba", 0x0CBCD4, 0x0000004
|
||||
|
||||
gUnk_080CBCD8:: @ 080CBCD8
|
||||
.incbin "baserom.gba", 0x0CBCD8, 0x0000004
|
||||
|
||||
gUnk_080CBCDC:: @ 080CBCDC
|
||||
.incbin "baserom.gba", 0x0CBCDC, 0x0000004
|
||||
|
||||
gUnk_080CBCE0:: @ 080CBCE0
|
||||
.incbin "baserom.gba", 0x0CBCE0, 0x0000004
|
||||
|
||||
gUnk_080CBCE4:: @ 080CBCE4
|
||||
.incbin "baserom.gba", 0x0CBCE4, 0x0000004
|
||||
|
||||
gUnk_080CBCE8:: @ 080CBCE8
|
||||
.incbin "baserom.gba", 0x0CBCE8, 0x0000004
|
||||
|
||||
gUnk_080CBCEC:: @ 080CBCEC
|
||||
.incbin "baserom.gba", 0x0CBCEC, 0x0000004
|
||||
|
||||
gUnk_080CBCF0:: @ 080CBCF0
|
||||
.incbin "baserom.gba", 0x0CBCF0, 0x0000004
|
||||
|
||||
gUnk_080CBCF4:: @ 080CBCF4
|
||||
.incbin "baserom.gba", 0x0CBCF4, 0x0000004
|
||||
|
||||
gUnk_080CBCF8:: @ 080CBCF8
|
||||
.incbin "baserom.gba", 0x0CBCF8, 0x0000004
|
||||
|
||||
gUnk_080CBCFC:: @ 080CBCFC
|
||||
.incbin "baserom.gba", 0x0CBCFC, 0x0000004
|
||||
|
||||
gUnk_080CBD00:: @ 080CBD00
|
||||
.incbin "baserom.gba", 0x0CBD00, 0x0000004
|
||||
|
||||
gUnk_080CBD04:: @ 080CBD04
|
||||
.incbin "baserom.gba", 0x0CBD04, 0x0000004
|
||||
|
||||
gUnk_080CBD08:: @ 080CBD08
|
||||
.incbin "baserom.gba", 0x0CBD08, 0x0000004
|
||||
|
||||
gUnk_080CBD0C:: @ 080CBD0C
|
||||
.incbin "baserom.gba", 0x0CBD0C, 0x0000004
|
||||
|
||||
gUnk_080CBD10:: @ 080CBD10
|
||||
.incbin "baserom.gba", 0x0CBD10, 0x0000004
|
||||
|
||||
gUnk_080CBD14:: @ 080CBD14
|
||||
.incbin "baserom.gba", 0x0CBD14, 0x0000004
|
||||
|
||||
gUnk_080CBD18:: @ 080CBD18
|
||||
.incbin "baserom.gba", 0x0CBD18, 0x0000004
|
||||
|
||||
gUnk_080CBD1C:: @ 080CBD1C
|
||||
.incbin "baserom.gba", 0x0CBD1C, 0x0000004
|
||||
|
||||
gUnk_080CBD20:: @ 080CBD20
|
||||
.incbin "baserom.gba", 0x0CBD20, 0x000002C
|
||||
|
||||
gUnk_080CBD4C:: @ 080CBD4C
|
||||
.incbin "baserom.gba", 0x0CBD4C, 0x000000C
|
||||
|
||||
gUnk_080CBD58:: @ 080CBD58
|
||||
.incbin "baserom.gba", 0x0CBD58, 0x0000064
|
||||
|
||||
gUnk_080CBDBC:: @ 080CBDBC
|
||||
.incbin "baserom.gba", 0x0CBDBC, 0x0000018
|
||||
|
||||
|
|
|
@ -177,6 +177,12 @@ extern void PositionRelative(Entity*, Entity*, s32, s32);
|
|||
#define DirectionToAnimationState(expr) (DirectionRoundUp(expr) >> 3)
|
||||
#define DirectionFromAnimationState(expr) (expr << 3)
|
||||
|
||||
#define Direction8Round(expr) ((expr) & 0x1c)
|
||||
#define Direction8RoundUp(expr) Direction8Round((expr) + 2)
|
||||
#define Direction8TurnAround(expr) (Direction8RoundUp(expr) ^ 0x10)
|
||||
#define Direction8ToAnimationState(expr) (Direction8RoundUp(expr) >> 2)
|
||||
#define Direction8FromAnimationState(expr) (expr << 2)
|
||||
|
||||
extern Entity gUnk_03003DA0;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -340,7 +340,7 @@ SECTIONS {
|
|||
src/enemy/cuccoChickAggr.o(.text);
|
||||
src/enemy/moldorm.o(.text);
|
||||
src/enemy/enemyE.o(.text);
|
||||
asm/moldworm.o(.text);
|
||||
src/enemy/moldworm.o(.text);
|
||||
asm/sluggula.o(.text);
|
||||
asm/pesto.o(.text);
|
||||
asm/puffstool.o(.text);
|
||||
|
@ -932,6 +932,8 @@ SECTIONS {
|
|||
src/enemy/moldorm.o(.rodata);
|
||||
src/enemy/enemyE.o(.rodata);
|
||||
data/animations/enemyE.o(.rodata);
|
||||
src/enemy/moldworm.o(.rodata);
|
||||
data/animations/moldworm.o(.rodata);
|
||||
data/data_080CBC38.o(.rodata);
|
||||
src/enemy.o(.rodata);
|
||||
data/data_080D3D94.o(.rodata);
|
||||
|
|
|
@ -0,0 +1,586 @@
|
|||
#include "enemy.h"
|
||||
#include "entity.h"
|
||||
#include "functions.h"
|
||||
|
||||
extern void sub_0800449C(Entity*, u32);
|
||||
extern bool32 sub_08023A38(u32);
|
||||
extern void sub_08023990(Entity*, u32, u32);
|
||||
extern void sub_08023A88(Entity*, u32);
|
||||
|
||||
void sub_080235BC(Entity*);
|
||||
void sub_08023644(Entity*);
|
||||
void sub_08023730(Entity*);
|
||||
void sub_080237D8(Entity*);
|
||||
void sub_0802390C(Entity*);
|
||||
void sub_080239F0(Entity*);
|
||||
bool32 sub_08023B38(Entity*);
|
||||
|
||||
extern u8 gEntCount;
|
||||
extern const u8 gUnk_080B37A0[];
|
||||
|
||||
extern void (*const gUnk_080CBC38[])(Entity*);
|
||||
extern void (*const gUnk_080CBC50[])(Entity*);
|
||||
extern const s8 gUnk_080CBC70[];
|
||||
extern const s8 gUnk_080CBC90[];
|
||||
extern void (*const gUnk_080CBC98[])(Entity*);
|
||||
extern void (*const gUnk_080CBCA8[])(Entity*);
|
||||
extern const s8 gUnk_080CBCB8[];
|
||||
|
||||
#if NON_MATCHING
|
||||
void Moldworm(Entity* this) {
|
||||
u16 prevX = this->x.HALF.HI;
|
||||
u16 prevY = this->y.HALF.HI;
|
||||
|
||||
if (this->entityType.form == 0) {
|
||||
if (this->action != 0) {
|
||||
sub_0802390C(this);
|
||||
}
|
||||
this->field_0x7c.BYTES.byte1 = this->field_0x7c.BYTES.byte0;
|
||||
EnemyFunctionHandler(this, gUnk_080CBC38);
|
||||
} else {
|
||||
if (this->parent->next) {
|
||||
if (this->entityType.form != 8) {
|
||||
sub_080235BC(this);
|
||||
} else {
|
||||
sub_08023730(this);
|
||||
}
|
||||
} else {
|
||||
DeleteEntity(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->parent->field_0x7c.BYTES.byte0 != this->parent->field_0x7c.BYTES.byte1 && this->attachedEntity) {
|
||||
((u8*)&this->attachedEntity->field_0x78)[(this->parent->field_0x7c.BYTES.byte0 - 1) & 0xf] =
|
||||
(((this->x.HALF.HI - prevX + 8) & 0xf) << 4) | ((this->y.HALF.HI - prevY + 8U) & 0xf);
|
||||
}
|
||||
}
|
||||
#else
|
||||
NAKED
|
||||
void Moldworm(Entity* this) {
|
||||
asm(".include \"asm/non_matching/moldworm/moldworm.inc\"");
|
||||
}
|
||||
#endif
|
||||
|
||||
void sub_080230CC(Entity* this) {
|
||||
gUnk_080CBC50[this->action](this);
|
||||
}
|
||||
|
||||
void sub_080230E4(Entity* this) {
|
||||
if (this->previousActionFlag == 0xff) {
|
||||
this->action = 7;
|
||||
this->actionDelay = 1;
|
||||
this->previousActionFlag = 0;
|
||||
this->damageType = 0x85;
|
||||
this->hurtBlinkTime = -8;
|
||||
this->field_0x7c.BYTES.byte3 = 0;
|
||||
this->field_0x7a.HALF.HI = 0;
|
||||
if (this->bitfield == 0x80 || this->bitfield == 0x9e) {
|
||||
this->entityType.parameter = 0;
|
||||
this->field_0x80.HALF.LO = 0x14;
|
||||
} else {
|
||||
this->entityType.parameter = 1;
|
||||
this->field_0x80.HALF.LO = 8;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->currentHealth == 0 && this->field_0x7c.BYTES.byte3 == 0 && this->action == 7) {
|
||||
CopyPosition(this, &gPlayerEntity);
|
||||
gPlayerEntity.flags = gPlayerEntity.flags | 0x80;
|
||||
gPlayerEntity.spriteSettings.b.draw = 1;
|
||||
gPlayerEntity.field_0x20 = 0x18000;
|
||||
gPlayerEntity.direction = 0xff;
|
||||
gPlayerEntity.hurtBlinkTime = -0x14;
|
||||
gPlayerState.jumpStatus = 0x41;
|
||||
gPlayerState.flags.all &= 0xfff7ffff;
|
||||
}
|
||||
|
||||
sub_0804AA30(this, gUnk_080CBC38);
|
||||
}
|
||||
|
||||
void sub_080231A4(Entity* this) {
|
||||
this->field_0x7c.BYTES.byte0++;
|
||||
sub_08001324(this);
|
||||
}
|
||||
|
||||
void nullsub_135(Entity* this) {
|
||||
}
|
||||
|
||||
void sub_080231BC(Entity* this) {
|
||||
if (gEntCount < 0x40) {
|
||||
Entity* ent;
|
||||
|
||||
ent = this->attachedEntity = CreateEnemy(0xf, 1);
|
||||
ent->parent = this;
|
||||
|
||||
ent = ent->attachedEntity = CreateEnemy(0xf, 2);
|
||||
ent->parent = this;
|
||||
|
||||
ent = ent->attachedEntity = CreateEnemy(0xf, 3);
|
||||
ent->parent = this;
|
||||
|
||||
ent = ent->attachedEntity = CreateEnemy(0xf, 4);
|
||||
ent->parent = this;
|
||||
|
||||
ent = ent->attachedEntity = CreateEnemy(0xf, 5);
|
||||
ent->parent = this;
|
||||
|
||||
ent = ent->attachedEntity = CreateEnemy(0xf, 6);
|
||||
ent->parent = this;
|
||||
|
||||
ent = ent->attachedEntity = CreateEnemy(0xf, 7);
|
||||
ent->parent = this;
|
||||
|
||||
ent->attachedEntity = CreateEnemy(0xf, 8);
|
||||
*(Entity**)&ent->attachedEntity->field_0x74 = ent;
|
||||
ent = ent->attachedEntity;
|
||||
ent->parent = this;
|
||||
ent->attachedEntity = NULL;
|
||||
sub_0804A720(this);
|
||||
this->action = 6;
|
||||
this->actionDelay = 0x1e;
|
||||
this->parent = this;
|
||||
this->field_0x78.HWORD = 0x1e;
|
||||
this->palette.b.b0 = 5;
|
||||
this->direction = Random() & 0x1f;
|
||||
this->animationState = Direction8ToAnimationState(this->direction);
|
||||
InitializeAnimation(this, this->animationState);
|
||||
}
|
||||
}
|
||||
|
||||
void nullsub_136(Entity* this) {
|
||||
}
|
||||
|
||||
void sub_08023288(Entity* this) {
|
||||
if (sub_08049FDC(this, 1) && (this->actionDelay++ & 0xf) == 0) {
|
||||
u32 idx = Random() & 0x1e;
|
||||
u32 i;
|
||||
|
||||
for (i = 0; i < 0x10; i++) {
|
||||
u32 x = gPlayerEntity.x.HALF.HI + gUnk_080CBC70[idx + 0];
|
||||
u32 y = gPlayerEntity.y.HALF.HI + gUnk_080CBC70[idx + 1];
|
||||
if (sub_08023A38(GetTileTypeByPos(x, y, gPlayerEntity.collisionLayer))) {
|
||||
sub_08023990(this, x, y);
|
||||
return;
|
||||
}
|
||||
idx += 2;
|
||||
idx &= 0x1e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08023330(Entity* this) {
|
||||
GetNextFrame(this);
|
||||
if (this->frames.all & 0x80) {
|
||||
this->action = 4;
|
||||
this->actionDelay = 0x19;
|
||||
this->flags |= 0x80;
|
||||
this->field_0x78.HWORD = 600;
|
||||
this->direction = Random() & 0x1c;
|
||||
this->animationState = this->direction >> 2;
|
||||
this->field_0x7a.HALF.HI = 0;
|
||||
this->field_0x7c.BYTES.byte3 = 0;
|
||||
sub_08023A88(this, this->animationState);
|
||||
CopyPosition(this, this->attachedEntity);
|
||||
CreateFx(this, 4, 0);
|
||||
}
|
||||
}
|
||||
|
||||
extern u32 GetTileTypeByEntity(Entity*);
|
||||
void sub_08023A68(Entity*);
|
||||
void sub_08023AB0(Entity*);
|
||||
|
||||
void sub_08023398(Entity* this) {
|
||||
this->field_0x7c.BYTES.byte0++;
|
||||
|
||||
if (this->field_0x7c.BYTES.byte3 && sub_08049FDC(this, 1) == 0) {
|
||||
this->field_0x78.HWORD = 1;
|
||||
}
|
||||
|
||||
if (--this->field_0x78.HWORD == 0) {
|
||||
if (sub_08023A38(GetTileTypeByEntity(this))) {
|
||||
this->action = 5;
|
||||
this->field_0x7c.BYTES.byte3 = 0;
|
||||
this->flags = this->flags & 0x7f;
|
||||
this->damageType = 0x85;
|
||||
this->attachedEntity->actionDelay = 1;
|
||||
sub_08023A68(this);
|
||||
CreateFx(this, 4, 0);
|
||||
return;
|
||||
}
|
||||
this->field_0x78.HWORD = 0x28;
|
||||
}
|
||||
|
||||
if (this->field_0x7c.BYTES.byte3) {
|
||||
sub_08023AB0(this);
|
||||
}
|
||||
|
||||
if (--this->actionDelay < 3) {
|
||||
if (this->actionDelay == 0)
|
||||
this->actionDelay = 25;
|
||||
} else {
|
||||
int prevX = this->x.WORD;
|
||||
int prevY = this->y.WORD;
|
||||
ProcessMovement(this);
|
||||
if (this->x.WORD == prevX && this->y.WORD == prevY) {
|
||||
this->field_0x7c.BYTES.byte0--;
|
||||
}
|
||||
|
||||
if ((gScreenTransition.frameCount & 7) == 0) {
|
||||
u32 uVar4;
|
||||
|
||||
sub_08004596(this, sub_08049F84(this, 1));
|
||||
uVar4 = Direction8ToAnimationState(this->direction);
|
||||
if (uVar4 != this->animationState) {
|
||||
this->animationState = uVar4;
|
||||
InitializeAnimation(this, uVar4 + this->field_0x7a.HALF.HI);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_080234A4(Entity* this) {
|
||||
this->field_0x7c.BYTES.byte0++;
|
||||
GetNextFrame(this);
|
||||
if (this->field_0x7c.BYTES.byte3) {
|
||||
this->action = 6;
|
||||
this->spriteSettings.b.draw = 0;
|
||||
this->field_0x78.HWORD = 300;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_080234D8(Entity* this) {
|
||||
if (--this->field_0x78.HWORD == 0) {
|
||||
this->action = 2;
|
||||
this->palette.b.b0 = 5;
|
||||
this->direction = Random() & 0x1f;
|
||||
this->animationState = Direction8ToAnimationState(this->direction);
|
||||
sub_08023A88(this, this->animationState);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0802351C(Entity* this) {
|
||||
if (this->actionDelay != 0 && (this->entityType.parameter == 1 || gPlayerEntity.frameIndex == 0xff)) {
|
||||
this->actionDelay = 0;
|
||||
this->attachedEntity->action = 3;
|
||||
this->attachedEntity->field_0xf = this->field_0x80.HALF.LO;
|
||||
InitializeAnimation(this->attachedEntity, this->attachedEntity->animationState + 1);
|
||||
InitializeAnimation(this, this->animationState);
|
||||
}
|
||||
|
||||
if (this->field_0x7c.BYTES.byte3 == 0) {
|
||||
if (this->entityType.parameter == 0) {
|
||||
gPlayerEntity.animationState = this->animationState & 7;
|
||||
gPlayerState.flags.all |= 0x80000;
|
||||
PositionRelative(this, &gPlayerEntity, 0, gUnk_080CBC90[this->animationState & 7] << 0x10);
|
||||
gPlayerEntity.spriteOffsetY = -gUnk_080CBC90[this->animationState & 7];
|
||||
}
|
||||
} else {
|
||||
this->action = 4;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_080235BC(Entity* this) {
|
||||
gUnk_080CBC98[this->action](this);
|
||||
}
|
||||
|
||||
void sub_080235D4(Entity* this) {
|
||||
Entity* parent;
|
||||
|
||||
this->action = 1;
|
||||
parent = this->parent;
|
||||
this->x.HALF.HI = parent->x.HALF.HI;
|
||||
this->y.HALF.HI = parent->y.HALF.HI;
|
||||
sub_080239F0(this);
|
||||
if (this->entityType.form == 1) {
|
||||
this->animationState = 0x10;
|
||||
} else {
|
||||
this->animationState = 0x12;
|
||||
}
|
||||
InitializeAnimation(this, this->animationState);
|
||||
}
|
||||
|
||||
void sub_08023604(Entity* this) {
|
||||
if (((u8*)&this->field_0x78)[this->parent->field_0x7c.BYTES.byte0 & 0xf] != 0x88) {
|
||||
this->action = 2;
|
||||
this->actionDelay = 0;
|
||||
this->flags |= 0x80;
|
||||
this->spriteSettings.b.draw = 1;
|
||||
sub_08023644(this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08023644(Entity* this) {
|
||||
Entity* parent = this->parent;
|
||||
|
||||
if (parent->animIndex == 0x17 && this->actionDelay != 0 && this->x.HALF.HI == parent->x.HALF.HI &&
|
||||
this->y.HALF.HI == parent->y.HALF.HI) {
|
||||
this->action = 1;
|
||||
this->flags &= ~0x80;
|
||||
this->spriteSettings.b.draw = 0;
|
||||
this->attachedEntity->actionDelay = 1;
|
||||
sub_080239F0(this);
|
||||
}
|
||||
|
||||
if (parent->field_0x7c.BYTES.byte0 != parent->field_0x7c.BYTES.byte1) {
|
||||
u8* tmp = &((u8*)&this->field_0x78)[parent->field_0x7c.BYTES.byte0 & 0xf];
|
||||
this->x.HALF.HI += (*tmp >> 4) - 8;
|
||||
this->y.HALF.HI += (*tmp & 0xf) - 8;
|
||||
this->spriteOrientation.flipY = parent->spriteOrientation.flipY;
|
||||
this->spriteRendering.b3 = parent->spriteRendering.b3;
|
||||
this->collisionLayer = parent->collisionLayer;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_080236F8(Entity* parent) {
|
||||
if (--parent->field_0xf == 0) {
|
||||
parent->action = 2;
|
||||
parent->attachedEntity->action = 3;
|
||||
parent->attachedEntity->field_0xf = parent->parent->field_0x80.HALF.LO;
|
||||
InitializeAnimation(parent->attachedEntity, parent->attachedEntity->animationState + 1);
|
||||
InitializeAnimation(parent, parent->animationState);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08023730(Entity* this) {
|
||||
gUnk_080CBCA8[this->action](this);
|
||||
}
|
||||
|
||||
void sub_08023748(Entity* this) {
|
||||
Entity* parent;
|
||||
|
||||
this->action = 1;
|
||||
this->animationState = 20;
|
||||
parent = this->parent;
|
||||
this->x.HALF.HI = parent->x.HALF.HI;
|
||||
this->y.HALF.HI = parent->y.HALF.HI;
|
||||
sub_080239F0(this);
|
||||
sub_08023A68(this);
|
||||
}
|
||||
|
||||
void sub_0802376C(Entity* this) {
|
||||
Entity* parent = this->parent;
|
||||
|
||||
if (parent->spriteSettings.b.draw == 1 && parent->animIndex < 0x10) {
|
||||
this->spriteSettings.b.draw = 1;
|
||||
GetNextFrame(this);
|
||||
}
|
||||
|
||||
if (((u8*)&this->field_0x78)[parent->field_0x7c.BYTES.byte0 & 0xf] != 0x88) {
|
||||
this->action = 2;
|
||||
this->actionDelay = 0;
|
||||
this->flags |= 0x80;
|
||||
this->parent->field_0x7c.BYTES.byte3 = 1;
|
||||
sub_08023A88(this, 20);
|
||||
sub_080237D8(this);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_080237D8(Entity* this) {
|
||||
Entity* parent = this->parent;
|
||||
|
||||
if (parent->animIndex == 0x17 && this->actionDelay != 0 && this->x.HALF.HI == parent->x.HALF.HI &&
|
||||
this->y.HALF.HI == parent->y.HALF.HI) {
|
||||
this->action = 1;
|
||||
this->flags &= ~0x80;
|
||||
this->spriteSettings.b.draw = 0;
|
||||
parent->field_0x7c.BYTES.byte3 = 1;
|
||||
sub_080239F0(this);
|
||||
sub_08023A68(this);
|
||||
}
|
||||
|
||||
if (parent->field_0x7c.BYTES.byte0 != parent->field_0x7c.BYTES.byte1) {
|
||||
u8* tmp = &((u8*)&this->field_0x78)[parent->field_0x7c.BYTES.byte0 & 0xf];
|
||||
this->x.HALF.HI += (*tmp >> 4) - 8;
|
||||
this->y.HALF.HI += (*tmp & 0xf) - 8;
|
||||
|
||||
this->spriteOrientation.flipY = parent->spriteOrientation.flipY;
|
||||
this->spriteRendering.b3 = parent->spriteRendering.b3;
|
||||
this->collisionLayer = parent->collisionLayer;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08023894(Entity* this) {
|
||||
if (--this->field_0xf == 0) {
|
||||
this->action = 2;
|
||||
this->parent->field_0x7c.BYTES.byte3 = 1;
|
||||
InitializeAnimation(this, this->animationState);
|
||||
if ((this->parent->entityType).parameter == 0) {
|
||||
gPlayerState.flags.all |= 0x200000;
|
||||
gPlayerEntity.x.HALF.HI = this->x.HALF.HI;
|
||||
gPlayerEntity.y.HALF.HI = this->y.HALF.HI;
|
||||
gPlayerEntity.direction = DirectionRoundUp(GetFacingDirection(*(Entity**)&this->field_0x74, this));
|
||||
gPlayerEntity.animationState = gPlayerEntity.direction >> 2;
|
||||
gPlayerEntity.hurtBlinkTime = 12;
|
||||
ModHealth(-0x10);
|
||||
sub_0800449C(&gPlayerEntity, 0x7a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0802390C(Entity* this) {
|
||||
if (this->bitfield & 0x80) {
|
||||
Entity* ent = this->attachedEntity;
|
||||
do {
|
||||
ent->hurtBlinkTime = this->hurtBlinkTime;
|
||||
} while (ent = ent->attachedEntity, ent != NULL);
|
||||
} else {
|
||||
Entity* ent = this->attachedEntity;
|
||||
do {
|
||||
if (ent->bitfield & 0x80) {
|
||||
u8 bVar2 = 0xff - ent->currentHealth;
|
||||
if (bVar2 != 0) {
|
||||
u32 tmp;
|
||||
ent->currentHealth = 0xff;
|
||||
tmp = (u8)ent->hurtBlinkTime;
|
||||
if (this->currentHealth >= bVar2) {
|
||||
this->currentHealth -= bVar2;
|
||||
} else {
|
||||
this->currentHealth = 0;
|
||||
}
|
||||
|
||||
ent = this;
|
||||
do {
|
||||
ent->hurtBlinkTime = tmp;
|
||||
} while (ent = ent->attachedEntity, ent != NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (ent = ent->attachedEntity, ent != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08023990(Entity* this, u32 param_2, u32 param_3) {
|
||||
Entity* ent;
|
||||
|
||||
this->action = 3;
|
||||
this->spriteSettings.b.draw = 1;
|
||||
this->palette.b.b0 = 0x5;
|
||||
this->palette.b.b4 = 0x5;
|
||||
this->spritePriority.b0 = 7;
|
||||
this->x.HALF.HI = param_2;
|
||||
this->y.HALF.HI = param_3;
|
||||
this->collisionLayer = gPlayerEntity.collisionLayer;
|
||||
UpdateSpriteForCollisionLayer(this);
|
||||
InitializeAnimation(this, 0x16);
|
||||
|
||||
ent = this->attachedEntity;
|
||||
do {
|
||||
sub_080239F0(ent);
|
||||
CopyPosition(this, ent);
|
||||
} while (ent = ent->attachedEntity, ent != NULL);
|
||||
}
|
||||
|
||||
/* TODO: fix struct */
|
||||
NAKED
|
||||
void sub_080239F0(Entity* this) {
|
||||
asm(".include \"asm/non_matching/moldworm/sub_080239F0.inc\"");
|
||||
}
|
||||
|
||||
bool32 sub_08023A38(u32 unk) {
|
||||
if (unk == 0x1a || unk == 0x29) {
|
||||
return TRUE;
|
||||
} else {
|
||||
unk = gUnk_080B37A0[unk];
|
||||
if (unk == 9 || unk == 11 || unk == 10 || unk == 12) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08023A68(Entity* this) {
|
||||
sub_0801D2B4(this, 5);
|
||||
this->spritePriority.b0 = 7;
|
||||
InitializeAnimation(this, 0x17);
|
||||
}
|
||||
|
||||
void sub_08023A88(Entity* this, u32 unk) {
|
||||
sub_0801D2B4(this, 0x22);
|
||||
this->spritePriority.b0 = 4;
|
||||
InitializeAnimation(this, unk);
|
||||
}
|
||||
|
||||
void sub_08023AB0(Entity* this) {
|
||||
if (this->field_0x7a.HALF.HI == 8) {
|
||||
if (this->field_0x7c.BYTES.byte2) {
|
||||
this->field_0x7c.BYTES.byte2--;
|
||||
} else if (!sub_08023B38(this) || 0x1d >= this->field_0x78.HWORD) {
|
||||
this->damageType = 0x85;
|
||||
this->field_0x7a.HALF.HI = 0;
|
||||
this->field_0x7c.BYTES.byte2 = 30;
|
||||
InitializeAnimation(this, this->animationState);
|
||||
}
|
||||
} else if (this->field_0x7c.BYTES.byte2) {
|
||||
this->field_0x7c.BYTES.byte2--;
|
||||
} else if (this->field_0x78.HWORD >= 90 && sub_08023B38(this)) {
|
||||
this->damageType = 0x87;
|
||||
this->field_0x7a.HALF.HI = 8;
|
||||
this->field_0x7c.BYTES.byte2 = 10;
|
||||
InitializeAnimation(this, this->animationState + 8);
|
||||
}
|
||||
}
|
||||
|
||||
NAKED
|
||||
bool32 sub_08023B38(Entity* this) {
|
||||
asm(".include \"asm/non_matching/moldworm/sub_08023B38.inc\"");
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
void (*const gUnk_080CBC38[])(Entity*) = {
|
||||
sub_080230CC,
|
||||
sub_080230E4,
|
||||
sub_080231A4,
|
||||
sub_0804A7D4,
|
||||
sub_08001242,
|
||||
nullsub_135,
|
||||
};
|
||||
|
||||
void (*const gUnk_080CBC50[])(Entity*) = {
|
||||
sub_080231BC,
|
||||
nullsub_136,
|
||||
sub_08023288,
|
||||
sub_08023330,
|
||||
sub_08023398,
|
||||
sub_080234A4,
|
||||
sub_080234D8,
|
||||
sub_0802351C,
|
||||
};
|
||||
|
||||
const s8 gUnk_080CBC70[] = {
|
||||
0x00, 0xd0, 0x00, 0x30,
|
||||
0xd0, 0x00, 0x30, 0x00,
|
||||
0xe0, 0xe0, 0xe0, 0x20,
|
||||
0x20, 0xe0, 0x20, 0x20,
|
||||
0xf0, 0xe0, 0x10, 0xe0,
|
||||
0xf0, 0x20, 0x10, 0x20,
|
||||
0xe0, 0xf0, 0x20, 0xf0,
|
||||
0xe0, 0x10, 0x20, 0x10,
|
||||
};
|
||||
|
||||
const s8 gUnk_080CBC90[] = {
|
||||
0xff, 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff,
|
||||
};
|
||||
|
||||
void (*const gUnk_080CBC98[])(Entity*) = {
|
||||
sub_080235D4,
|
||||
sub_08023604,
|
||||
sub_08023644,
|
||||
sub_080236F8,
|
||||
};
|
||||
|
||||
void (*const gUnk_080CBCA8[])(Entity*) = {
|
||||
sub_08023748,
|
||||
sub_0802376C,
|
||||
sub_080237D8,
|
||||
sub_08023894,
|
||||
};
|
||||
|
||||
const s8 gUnk_080CBCB8[] = {
|
||||
0x00, 0xe4, 0x14, 0xec,
|
||||
0x1c, 0x00, 0x14, 0x14,
|
||||
0x00, 0x1c, 0xec, 0x14,
|
||||
0xe4, 0x00, 0xec, 0xec,
|
||||
};
|
||||
// clang-format on
|
Loading…
Reference in New Issue