This commit is contained in:
theo3
2020-09-28 21:26:20 -07:00
93 changed files with 6070 additions and 10802 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ Entity* sub_080A2A3C(Entity* parent, u32 form, u32 subtype, u32 param_4) {
ent = CreateObjectWithParent(parent, 0, form, subtype);
if (ent != NULL) {
ent->actionDelay = 5;
ent->field_0x86 = param_4;
ent->field_0x86.HWORD = param_4;
}
return ent;
}
-1
View File
@@ -16,7 +16,6 @@ extern void sub_0804AA30(Entity*, void (*const funcs[])(Entity*));
extern u32 sub_0806FCB8(Entity*, u32, u32, u32);
extern u32 GetNextFunction(Entity*);
extern void SetChildOffset(Entity*, s32, s32, s32);
extern u32 Random(void);
extern Entity* gUnk_020000B0;
extern u8 gEntCount;
+331
View File
@@ -0,0 +1,331 @@
#include "enemy.h"
#include "functions.h"
extern void CreateDustSmall(Entity*);
extern void sub_08078930(Entity*);
extern void sub_08078954(Entity*);
void sub_0802CB68(Entity*);
void sub_0802CBC4(Entity*);
void sub_0802CC18(Entity*);
extern void (*const gUnk_080CD5D4[])(Entity*);
extern void (*const gUnk_080CD5EC[])(Entity*);
extern void (*const gUnk_080CD600[])(Entity*);
extern void (*const gUnk_080CD618[])(Entity*);
void Bobomb(Entity* this) {
EnemyFunctionHandler(this, gUnk_080CD5D4);
}
void sub_0802C670(Entity* this) {
gUnk_080CD5EC[this->action](this);
}
void sub_0802C688(Entity* this) {
if (this->bitfield & 0x80) {
switch (this->bitfield & 0x7f) {
case 0:
case 1:
if (this->field_0x82.HALF.LO) {
this->field_0x42 = 0;
gPlayerEntity.field_0x42 = 4;
}
return;
case 0xe:
case 0x14:
case 0x15:
case 0x16:
this->action = 3;
this->field_0x42 = 0;
sub_0802CBC4(this);
return;
}
this->field_0x82.HALF.LO++;
this->field_0x80.HALF.LO = 28;
switch (this->field_0x82.HALF.LO) {
case 1:
sub_0802CB68(this);
EnqueueSFX(0x14d);
break;
case 2:
this->action = 3;
this->damageType = 0x6e;
this->field_0xf = 1;
this->field_0x20 = 0x18000;
this->nonPlanarMovement = 0;
this->field_0x80.HALF.HI = 1;
InitializeAnimation(this, this->direction >> 4 | 6);
break;
}
}
sub_0804AA30(this, gUnk_080CD5D4);
}
void sub_0802C7AC(Entity* this) {
if (this->previousActionFlag < 3 && !sub_0806F520(this)) {
this->previousActionFlag = 0;
this->field_0xf = 1;
this->height.HALF.HI = 0;
if (this->field_0x82.HALF.LO != 2) {
this->nonPlanarMovement = this->field_0x82.HALF.LO ? 0x200 : 0x80;
}
this->field_0x20 = 0x18000;
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.HI = 0;
} else {
this->height.HALF.HI = -1;
gUnk_080CD600[this->previousActionFlag](this);
if (this->actionDelay != 0) {
GetNextFrame(this);
}
}
}
void sub_0802C820(Entity* this) {
this->previousActionFlag = 1;
this->field_0x1d = 60;
}
void sub_0802C82C(Entity* this) {
sub_0806F4E8(this);
}
void sub_0802C834(Entity* this) {
sub_0806F3E4(this);
}
void sub_0802C83C(Entity* this) {
if (this->field_0x82.HALF.LO) {
if (--this->actionDelay == 0) {
this->action = 3;
switch (gPlayerEntity.animationState & 6) {
case 2:
this->x.HALF.HI -= 6;
break;
case 6:
this->x.HALF.HI += 6;
break;
}
sub_0802CBC4(this);
} else {
sub_0802CC18(this);
this->flags &= ~0x80;
this->damageType = 0x6e;
}
} else {
this->field_0x82.HALF.LO = 2;
this->actionDelay = 120;
InitializeAnimation(this, (this->direction >> 4) | 6);
this->flags &= ~0x80;
this->damageType = 0x6e;
}
}
void nullsub_149(Entity* this) {
/* ... */
}
void sub_0802C8B8(Entity* this) {
this->action = 3;
sub_0802CBC4(this);
}
void sub_0802C8C4(Entity* this) {
sub_0804A7D4(this);
this->spriteSettings.b.draw = 0;
}
void sub_0802C8D8(Entity* this) {
this->action = 1;
this->actionDelay = 0x3c;
this->field_0xf = 0;
this->direction = (Random() & 0x18) | 4;
this->field_0x16 = 0;
this->field_0x1c = 0x12;
this->field_0x82.HALF.LO = 0;
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.LO = 0;
this->field_0x80.HALF.HI = 0;
InitializeAnimation(this, this->direction >> 4);
}
void sub_0802C91C(Entity* this) {
GetNextFrame(this);
ProcessMovement(this);
if (this->field_0x82.HALF.LO) {
if (this->collisions) {
sub_0800417E(this, this->collisions);
InitializeAnimation(this, (this->direction >> 4) | 2);
}
if (--this->actionDelay == 0) {
sub_0802CBC4(this);
} else {
if ((this->actionDelay & 0xf) == 8) {
CreateDustSmall(this);
}
sub_0802CC18(this);
}
} else {
if (this->collisions) {
sub_0800417E(this, this->collisions);
InitializeAnimation(this, this->direction >> 4);
}
if (--this->actionDelay == 0) {
this->actionDelay = 60;
this->direction = (this->direction + 8) & 0x1c;
InitializeAnimation(this, this->direction >> 4);
}
}
}
void sub_0802C9B8(Entity* this) {
gUnk_080CD618[this->previousActionFlag](this);
}
void sub_0802C9D0(Entity* this) {
this->previousActionFlag = 1;
this->flags &= ~0x80;
this->spritePriority.b1 = 0;
this->field_0x82.HALF.HI = 1;
sub_0802CC18(this);
InitializeAnimation(this, (this->direction >> 4) | 6);
GetNextFrame(this);
}
void sub_0802CA10(Entity* this) {
if (gPlayerState.heldObject != 5) {
if (--this->actionDelay == 0) {
sub_0802CBC4(this);
} else {
sub_0802CC18(this);
GetNextFrame(this);
}
} else {
this->field_0x82.HALF.HI = 2;
this->direction = (((gPlayerEntity.animationState) << 2) | 4) & 0x1c;
sub_0802CC18(this);
GetNextFrame(this);
}
}
void sub_0802CA6C(Entity* this) {
if (--this->actionDelay == 0) {
sub_0802CBC4(this);
} else {
sub_0802CC18(this);
GetNextFrame(this);
}
}
void sub_0802CA94(Entity* this) {
this->action = 3;
this->flags &= ~0x80;
this->field_0xf = 1;
this->spritePriority.b1 = 1;
this->field_0x20 = 0x18000;
this->nonPlanarMovement = 0;
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.HI = 0;
this->direction = ((gPlayerEntity.animationState << 2) | 4) & 0x1c;
InitializeAnimation(this, (this->direction >> 4) | 6);
}
void sub_0802CAF8(Entity* this) {
if (--this->actionDelay == 0) {
sub_0802CBC4(this);
} else {
if (this->field_0x80.HALF.HI && sub_080044EC(this, 0x2800) == 1) {
EnqueueSFX(0x104);
}
sub_0802CC18(this);
sub_08078930(this);
if (this->field_0xf && this->height.HALF.HI == 0) {
this->field_0xf = 0;
this->flags = this->flags | 0x80;
this->damageType = 0x6e;
}
GetNextFrame(this);
}
}
void nullsub_150(Entity* this) {
/* ... */
}
void sub_0802CB68(Entity* this) {
this->action = 1;
this->previousActionFlag = 0;
this->direction = Random() & 0x18;
this->direction |= 4;
this->flags |= 0x80;
if (this->field_0x82.HALF.LO) {
this->actionDelay = 200;
this->nonPlanarMovement = 0x200;
InitializeAnimation(this, (this->direction >> 4) | 2);
} else {
this->actionDelay = 0x3c;
this->nonPlanarMovement = 0x80;
InitializeAnimation(this, this->direction >> 4);
}
}
void sub_0802CBC4(Entity* this) {
Entity* ent;
this->action = 4;
this->spriteSettings.b.draw = 0;
this->flags &= ~0x80;
this->currentHealth = 0;
if (this->field_0x82.HALF.HI) {
sub_08079184();
}
sub_08078954(this);
ent = CreateObjectWithParent(this, 0x20, 0, 0);
if (ent) {
ent->collisionLayer = this->collisionLayer;
}
}
void sub_0802CC18(Entity* this) {
if (--this->field_0x80.HALF.LO == 0) {
this->field_0x80.HALF.LO = 28;
EnqueueSFX(0x14d);
}
}
// clang-format off
void (*const gUnk_080CD5D4[])(Entity*) = {
sub_0802C670,
sub_0802C688,
sub_08001324,
sub_0802C8C4,
sub_08001242,
sub_0802C7AC,
};
void (*const gUnk_080CD5EC[])(Entity*) = {
sub_0802C8D8,
sub_0802C91C,
sub_0802C9B8,
sub_0802CAF8,
nullsub_150,
};
void (*const gUnk_080CD600[])(Entity*) = {
sub_0802C820,
sub_0802C82C,
sub_0802C834,
sub_0802C83C,
nullsub_149,
sub_0802C8B8,
};
void (*const gUnk_080CD618[])(Entity*) = {
sub_0802C9D0,
sub_0802CA10,
sub_0802CA6C,
sub_0802CA94,
};
// clang-format on
+612 -29
View File
@@ -3,24 +3,43 @@
#include "functions.h"
#include "player.h"
extern void sub_08078954(Entity*);
extern u32 sub_0800442E(Entity*);
extern void sub_08078930(Entity*);
extern s32 sub_080012DC(Entity*);
extern u32 GetNextFunction(Entity*);
extern void sub_0802AD54(Entity*);
extern void sub_0802B048(Entity*);
extern void sub_0806F4E8(Entity*);
extern Entity* sub_08049DF4(u32);
extern void sub_08079BD8(Entity*);
extern u32 GetTileTypeByEntity(Entity*);
void sub_0802AD1C(Entity*, u32);
void sub_0802AD54(Entity*);
void sub_0802B048(Entity*);
void sub_0802ACDC(Entity*, u32);
void sub_0802ADDC(Entity*);
void sub_0802AC40(Entity*);
bool32 sub_0802B234(Entity*);
Entity* sub_0802B250(Entity*);
void sub_0802B264(Entity*);
extern void (*const gUnk_080012C8[])(Entity*);
extern void (*const gUnk_080CD0F0[])(Entity*);
extern void (*const gUnk_080CD108[])(Entity*);
extern void (*const gUnk_080CD120[])(Entity*);
extern void (*const gUnk_080CD134[])(Entity*);
extern void (*const gUnk_080CD108[])(Entity*);
extern void (*const gUnk_080CD140[])(Entity*);
extern void (*const gUnk_080CD158[])(Entity*);
extern const BoundingBox gUnk_080CD16C;
extern const BoundingBox gUnk_080CD174;
extern const BoundingBox gUnk_080CD17C;
void BombPeahat(Entity* this) {
s32 iVar1;
u32 uVar2;
if (((this->entityType).form == 2) && (iVar1 = sub_080012DC(this), iVar1)) {
if ((this->entityType.form == 2) && (iVar1 = sub_080012DC(this), iVar1)) {
gUnk_080012C8[iVar1](this);
} else {
gUnk_080CD0F0[GetNextFunction(this)](this);
@@ -32,54 +51,618 @@ void sub_0802A84C(Entity* this) {
default:
gUnk_080CD108[this->action](this);
sub_0802AD54(this);
return;
break;
case 2:
gUnk_080CD120[this->action](this);
sub_0802B048(this);
return;
break;
case 3:
gUnk_080CD134[this->action](this);
break;
}
}
void sub_0802A8AC(Entity *this) {
void sub_0802A8AC(Entity* this) {
this->field_0x80.HALF.HI = 0;
if (this->entityType.form < 2) {
InitializeAnimation(this, 0);
}
}
void sub_0802A8C8(Entity* this)
{
gUnk_080CD140[this->previousActionFlag](this);
void sub_0802A8C8(Entity* this) {
gUnk_080CD140[this->previousActionFlag](this);
}
void sub_0802A8E0(Entity *this)
{
this->previousActionFlag = 1;
this->field_0x1d = 0x3c;
void sub_0802A8E0(Entity* this) {
this->previousActionFlag = 1;
this->field_0x1d = 60;
}
void sub_0802A8EC(Entity *this)
{
void sub_0802A8EC(Entity* this) {
sub_0806F4E8(this);
}
void sub_0802A8F4(Entity *this)
{
void sub_0802A8F4(Entity* this) {
sub_0806F3E4(this);
}
void sub_0802A8FC(Entity *this)
{
if ((gPlayerState.field_0x1c & 0xf) == 0) {
this->currentHealth = gPlayerState.field_0x1c & 0xf;
}
void sub_0802A8FC(Entity* this) {
if ((gPlayerState.field_0x1c & 0xf) == 0) {
this->currentHealth = gPlayerState.field_0x1c & 0xf;
}
}
void nullsub_143(Entity* this){}
void sub_0802A91C(Entity *this)
{
this->currentHealth = 0;
void nullsub_143(Entity* this) {
/* ... */
}
void sub_0802A91C(Entity* this) {
this->currentHealth = 0;
}
void sub_0802A924(Entity* this) {
this->action = 1;
this->previousActionFlag = 0;
this->actionDelay = 0;
this->field_0xf = 0;
this->boundingBox = (BoundingBox*)&gUnk_080CD16C;
this->height.HALF.HI = -0x30;
this->field_0x80.HALF.LO = Random() & 1;
this->field_0x82.HWORD = 0;
this->field_0x7a.HALF.HI = 0;
this->field_0x80.HALF.HI = 0;
this->field_0x7a.HALF.LO = 0;
this->field_0x78.HALF.LO = 0;
this->field_0x78.HALF.HI = 0;
this->collisionLayer = 3;
this->spriteOrientation.flipY = 1;
this->spriteRendering.b3 = 1;
this->spritePriority.b0 = 1;
InitializeAnimation(this, this->entityType.form + 1);
}
void sub_0802A9A8(Entity* this) {
if (this->field_0xf) {
this->field_0xf--;
} else {
if (this->actionDelay) {
if (--this->actionDelay == 0) {
this->action = 2;
this->previousActionFlag = 0;
this->actionDelay = 0x40;
sub_0802ACDC(this, 8);
}
} else {
if (gRoomControls.unk2 != 0) {
return;
}
this->spriteSettings.b.draw = 1;
this->field_0x82.HWORD = 1;
if (this->field_0x80.HALF.LO) {
this->x.HALF.HI = gRoomControls.roomScrollX - 0x10;
this->direction = 8;
} else {
this->x.HALF.HI = gRoomControls.roomScrollX + 0x100;
this->direction = 0x18;
}
this->y.HALF.HI = gRoomControls.roomScrollY + 0x40;
this->actionDelay = 0x80;
sub_0802ADDC(this);
}
sub_0802AC40(this);
}
}
void sub_0802AA40(Entity* this) {
sub_0802AC40(this);
if (--this->field_0xf == 0) {
sub_0802ACDC(this, 8);
this->field_0x7a.HALF.HI++;
}
if (this->actionDelay) {
this->actionDelay--;
} else {
Entity* ent = this->attachedEntity;
if (ent) {
if (ent->next == NULL) {
this->attachedEntity = NULL;
} else {
u32 direction = DirectionRound(this->field_0x80.HALF.LO * 0x10 + 0x18);
if (0x20 < this->field_0x7a.HALF.HI) {
this->direction = direction;
}
if (this->direction == direction) {
this->action = 3;
this->nonPlanarMovement = 0x180;
this->field_0x7a.HALF.HI = 0;
ent->field_0x80.HALF.LO = 1;
ent->actionDelay = 0x96;
}
}
}
}
}
void sub_0802AAC0(Entity* this) {
sub_0802AC40(this);
if (--this->field_0xf == 0) {
sub_0802AD1C(this, 4);
}
if (this->field_0x80.HALF.HI) {
Entity* ent = this->attachedEntity;
if (ent == NULL) {
this->field_0x80.HALF.HI = 0;
} else if (ent->next == NULL) {
this->field_0x80.HALF.HI = 0;
this->attachedEntity = NULL;
} else if (ent->actionDelay == 0 && ent->field_0xf < 0x51) {
this->field_0x80.HALF.HI = 0;
}
} else {
this->action = 4;
this->actionDelay = 0xc0;
this->field_0xf = 4;
this->field_0x80.HALF.LO ^= 1;
this->field_0x78.HALF.LO = 0;
this->field_0x78.HALF.HI = 4;
this->direction = 0xff;
InitializeAnimation(this, 0);
}
}
void sub_0802AB40(Entity* this) {
sub_0802AC40(this);
switch (this->field_0x78.HALF.LO) {
case 0:
if (this->height.HALF.HI) {
if (--this->field_0x78.HALF.HI == 0) {
this->field_0x78.HALF.HI = 4;
this->height.HALF.HI++;
}
} else {
this->field_0x78.HALF.LO = 1;
this->field_0x78.HALF.HI = 0x30;
this->direction = sub_08049F84(this, 0);
}
break;
case 1:
if (--this->field_0x78.HALF.HI == 0) {
this->field_0x78.HALF.LO = 2;
this->field_0x78.HALF.HI = 4;
} else if ((this->field_0x78.HALF.HI & 7) == 0) {
this->direction = sub_08049F84(this, 0);
}
break;
case 2:
if (-0x30 < this->height.HALF.HI) {
if (--this->field_0x78.HALF.HI == 0) {
this->field_0x78.HALF.HI = 4;
this->height.HALF.HI--;
sub_0802ACDC(this, 4);
}
} else {
this->action = 5;
this->nonPlanarMovement = 0;
InitializeAnimation(this, this->entityType.form + 1);
}
break;
}
}
void sub_0802AC08(Entity* this) {
if (this->frames.all & 0x80) {
this->action = 2;
this->previousActionFlag = 0;
this->actionDelay = 0x40;
this->nonPlanarMovement = 0xc0;
sub_0802ACDC(this, 8);
sub_0802ADDC(this);
}
GetNextFrame(this);
}
void sub_0802AC40(Entity* this) {
GetNextFrame(this);
sub_0806F69C(this);
if (this->field_0x7a.HALF.LO) {
if (sub_0802B234(this) == 0) {
this->field_0x7a.HALF.LO = 0;
this->spritePriority.b1 = 0;
} else {
if (this->height.HALF.HI == 0) {
if (this->spritePriority.b1 != 1) {
this->spritePriority.b1 = 1;
}
} else {
if (this->spritePriority.b1 != 3) {
this->spritePriority.b1 = 3;
}
}
}
} else {
if (sub_0802B234(this)) {
this->field_0x7a.HALF.LO = 1;
if (this->height.HALF.HI == 0) {
this->spritePriority.b1 = 1;
} else {
this->spritePriority.b1 = 3;
}
}
}
}
void sub_0802ACDC(Entity* this, u32 param_2) {
u32 x;
if (this->field_0x80.HALF.LO) {
x = sub_080045B4(this, gRoomControls.roomScrollX + 0x20, gRoomControls.roomScrollY + 0x60);
} else {
x = sub_080045B4(this, gRoomControls.roomScrollX + 0xd0, gRoomControls.roomScrollY + 0x60);
}
sub_08004596(this, x);
this->field_0xf = param_2;
}
void sub_0802AD1C(Entity* this, u32 param_2) {
Entity* ent = sub_08049DF4(1);
if (ent) {
u32 y = ent->y.HALF.HI - 0x18;
u32 x = ent->x.HALF.HI;
sub_08004596(this, sub_080045B4(this, x, y));
this->field_0xf = param_2;
} else {
sub_0802ACDC(this, param_2);
}
}
void sub_0802AD54(Entity* this) {
if (this->field_0x82.HWORD != 0) {
if (gRoomControls.unk2 != 0) {
this->spriteSettings.b.draw = 0;
DeleteEntity(this);
return;
}
if (gRoomControls.roomOriginY > this->y.HALF.HI ||
(gRoomControls.roomOriginY + gRoomControls.height + 0x20) < this->y.HALF.HI) {
this->spriteSettings.b.draw = 0;
} else {
this->spriteSettings.b.draw = 1;
}
}
if (this->field_0x80.HALF.HI) {
if (this->attachedEntity == NULL || this->attachedEntity->next == NULL) {
this->action = 4;
this->actionDelay = 0xc0;
this->field_0xf = 4;
this->field_0x80.HALF.LO ^= 1;
}
}
}
void sub_0802ADDC(Entity* this) {
Entity* ent = CreateEnemy(0x1b, this->entityType.form + 2);
if (ent != NULL) {
ent->entityType.parameter = !!sub_0802B234(this);
ent->parent = this;
this->attachedEntity = ent;
CopyPosition(this, ent);
this->field_0x80.HALF.HI = 1;
if (this->entityType.form == 0) {
this->field_0x7a.HALF.LO++;
}
}
}
void sub_0802AE24(Entity* this) {
this->action = 1;
this->actionDelay = 0xf0;
this->field_0x20 = 0x8000;
this->boundingBox = (BoundingBox*)&gUnk_080CD174;
this->field_0x3c = 3;
this->field_0x16 = 0;
this->field_0x1c = 2;
this->field_0x80.HALF.HI = 0;
this->field_0x7a.HALF.HI = 1;
InitializeAnimation(this, 3);
}
void sub_0802AE68(Entity* this) {
Entity* ent = sub_0802B250(this);
if (ent == 0) {
this->action = 3;
this->field_0x80.HALF.LO = 1;
sub_0802B264(this);
} else {
if (ent->field_0x80.HALF.HI) {
CopyPosition(ent, this);
this->spriteSettings.b.draw = 0;
} else {
this->action = 3;
this->field_0x80.HALF.LO = 1;
sub_0802B264(this);
}
}
}
void sub_0802AEBC(Entity* this) {
gUnk_080CD158[this->previousActionFlag](this);
}
void sub_0802AED4(Entity* this) {
GetNextFrame(this);
if (this->field_0x80.HALF.HI < 2) {
if (sub_080044EC(this, 0x2800) == 1) {
this->field_0x80.HALF.HI++;
}
} else {
if (!sub_0800442E(this)) {
sub_08078930(this);
}
}
if (this->entityType.parameter != 0 && this->field_0x80.HALF.HI) {
this->actionDelay = 0;
this->field_0xf = 1;
}
}
void sub_0802AF28(Entity* this) {
this->previousActionFlag = 1;
sub_08079BD8(this);
this->spritePriority.b1 = 2;
GetNextFrame(this);
}
void sub_0802AF50(Entity* this) {
GetNextFrame(this);
}
void sub_0802AF58(Entity* this) {
GetNextFrame(this);
this->spritePriority.b1 = 3;
}
void sub_0802AF74(Entity* this) {
this->action = 3;
this->previousActionFlag = 0;
if (this->actionDelay > 60) {
this->actionDelay = 60;
}
GetNextFrame(this);
}
void sub_0802AF94(Entity* this) {
DeleteEntity(this);
}
void sub_0802AF9C(Entity* this) {
GetNextFrame(this);
if (--this->actionDelay == 0) {
if (this->parent->field_0x7a.HALF.LO) {
this->parent->field_0x7a.HALF.LO--;
}
DeleteEntity(this);
}
}
#if NON_MATCHING
void sub_0802AFC8(Entity* this) {
u32 flag = 8;
if (this->field_0xf < 0x29) {
u32 tmp;
flag = 4;
if (this->field_0x82.HWORD & 0x8000) {
this->field_0x82.HWORD -= 0x10;
} else {
this->field_0x82.HWORD += 0x10;
}
if (0x7f < (this->field_0x82.HWORD & 0xf0) - 1) {
this->field_0x82.HWORD ^= 0x8000;
}
tmp = 0x130 - (this->field_0x82.HWORD & 0xf0);
sub_0805EC9C(this, tmp, tmp, 0);
}
if (this->field_0xf & flag) {
this->palette.b.b0 = 0;
} else {
this->palette.b.b0 = this->palette.b.b4;
}
}
#else
NAKED
void sub_0802AFC8(Entity* this) {
asm(".include \"asm/non_matching/bombPeahat/sub_0802AFC8.inc\"");
}
#endif
void sub_0802B048(Entity* this) {
Entity* ent;
u32 action;
if (this->field_0x7a.HALF.HI) {
if (gRoomControls.roomOriginY > this->y.HALF.HI ||
(gRoomControls.roomOriginY + gRoomControls.height + 0x20) < this->y.HALF.HI) {
this->flags &= ~0x80;
} else {
this->flags |= 0x80;
}
}
ent = this->parent;
if (ent && this->action == 1) {
this->spriteRendering.b3 = ent->spriteRendering.b3;
this->spritePriority.b0 = ent->spritePriority.b0;
this->spriteOrientation.flipY = ent->spriteOrientation.flipY;
}
action = this->action;
if (action != 4 && this->field_0x80.HALF.LO) {
if (this->actionDelay) {
if (--this->actionDelay == 0) {
this->field_0xf = 0x50;
this->field_0x82.HWORD = 0;
this->spriteRendering.b0 = 3;
sub_0805EC9C(this, 0x100, 0x100, 0);
}
} else {
if (this->field_0xf) {
if (--this->field_0xf == 0) {
if (action == 2 && this->previousActionFlag == 1) {
gPlayerState.heldObject = 0;
}
sub_0805EC60(this);
this->action = 4;
this->boundingBox = (BoundingBox*)&gUnk_080CD17C;
this->actionDelay = 0xf;
this->spriteSettings.b.draw = 0;
this->flags |= 0x80;
this->field_0x7a.HALF.HI = 0;
sub_08078954(this);
if (this->parent->next) {
this->parent->field_0x80.HALF.HI = 0;
}
ent = CreateObjectWithParent(this, 0x20, 0, 0);
if (ent != NULL) {
this->collisionLayer = 1;
} else {
DeleteEntity(this);
}
} else {
sub_0802AFC8(this);
}
}
}
}
}
void sub_0802B1A0(Entity* this) {
this->action = 1;
this->actionDelay = 0;
this->field_0xf = 0x4f;
this->field_0x80.HALF.HI = 1;
InitializeAnimation(this, 0);
}
void sub_0802B1BC(Entity* this) {
Entity* ent;
if (this->actionDelay) {
this->actionDelay--;
}
ent = sub_0802B250(this);
if (ent == 0) {
this->action = 2;
sub_0802B264(this);
} else {
if (ent->field_0x80.HALF.HI) {
CopyPosition(ent, this);
} else {
this->action = 2;
sub_0802B264(this);
}
}
}
void sub_0802B204(Entity* this) {
if (sub_080044EC(this, 0x2800) == 1) {
Entity* ent = CreateEnemy(0x22, 1);
if (ent) {
CopyPosition(this, ent);
ent->parent = this->parent;
}
DeleteThisEntity();
}
}
bool32 sub_0802B234(Entity* this) {
bool32 ret = FALSE;
if (GetTileTypeByEntity(this) - 0x1c4 > 1)
ret = TRUE;
return ret;
}
Entity* sub_0802B250(Entity* this) {
Entity* parent = this->parent;
if (parent && parent->next == NULL) {
parent = NULL;
}
return parent;
}
void sub_0802B264(Entity* this) {
this->spriteSettings.b.draw = 1;
if (sub_0802B234(this)) {
this->spritePriority.b1 = 3;
} else {
this->spritePriority.b1 = 0;
}
GetNextFrame(this);
}
// clang-format off
void (*const gUnk_080CD0F0[])(Entity*) = {
sub_0802A84C,
sub_0802A8AC,
sub_08001324,
sub_0804A7D4,
sub_08001242,
sub_0802A8C8,
};
void (*const gUnk_080CD108[])(Entity*) = {
sub_0802A924,
sub_0802A9A8,
sub_0802AA40,
sub_0802AAC0,
sub_0802AB40,
sub_0802AC08,
};
void (*const gUnk_080CD120[])(Entity*) = {
sub_0802AE24,
sub_0802AE68,
sub_0802AEBC,
sub_0802AED4,
sub_0802AF9C,
};
void (*const gUnk_080CD134[])(Entity*) = {
sub_0802B1A0,
sub_0802B1BC,
sub_0802B204,
};
void (*const gUnk_080CD140[])(Entity*) = {
sub_0802A8E0,
sub_0802A8EC,
sub_0802A8F4,
sub_0802A8FC,
nullsub_143,
sub_0802A91C,
};
void (*const gUnk_080CD158[])(Entity*) = {
sub_0802AF28,
sub_0802AF50,
sub_0802AF58,
sub_0802AF74,
sub_0802AF94,
};
const BoundingBox gUnk_080CD16C = {
0x00, 0xFB, 0x05, 0x03, 0x03, 0x05, 0x06, 0x06,
};
const BoundingBox gUnk_080CD174 = {
0x00, 0x00, 0x06, 0x00, 0x00, 0x06, 0x04, 0x04,
};
const BoundingBox gUnk_080CD17C = {
0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x16, 0x16,
};
// clang-format on
+608
View File
@@ -0,0 +1,608 @@
#include "enemy.h"
#include "entity.h"
#include "flags.h"
#include "functions.h"
#include "textbox.h"
extern void sub_0801D040(Entity*, u32);
extern Entity* sub_08049DF4(u32);
extern bool32 sub_08056338(void);
extern void UnloadOBJPalette(Entity*);
bool32 sub_0802915C(Entity*);
bool32 sub_080291DC(Entity*);
void sub_0802922C(Entity*);
void sub_08028E9C(Entity*);
u32 sub_080001DA(u32, u32);
void sub_08028FFC(Entity*);
void sub_0802925C(Entity*);
void sub_080290E0(Entity*, u32);
bool32 sub_08028F98(Entity*, u32);
void sub_08029078(Entity*);
bool32 sub_08028FDC(Entity*);
void sub_080290FC(Entity*);
void sub_08028EDC(Entity*);
extern const struct SalesOffering gUnk_080CC954[];
extern const u8 gUnk_080CC9C0[];
extern void (*const gUnk_080CC9C8[])(Entity*);
extern void (*const gUnk_080CC9E0[])(Entity*);
extern const u8 gUnk_080CCA04[];
struct SalesOffering {
u8 field_0x0;
u8 field_0x1;
u16 price;
u16 field_0x4;
u16 field_0x6;
u8 field_0x8;
u8 field_0x9;
u16 field_0xa;
};
void BusinessScrub(Entity* this) {
EnemyFunctionHandler(this, gUnk_080CC9C8);
}
void sub_0802891C(Entity* this) {
gUnk_080CC9E0[this->action](this);
}
void sub_08028934(Entity* this) {
Entity* pEVar1;
if (this->damageType == 1 && (this->bitfield & 0x7f) == 0x42) {
this->action = 3;
this->previousActionFlag = 0;
this->actionDelay = 0x28;
this->flags &= ~0x80;
sub_080290E0(this, 4);
pEVar1 = CreateFx(this, 3, 0);
if (pEVar1 != NULL) {
pEVar1->height.HALF.HI -= 8;
}
EnqueueSFX(0x1bb);
}
}
void nullsub_140(Entity* this) {
/* ... */
}
void sub_08028994(Entity* this) {
this->field_0xf = 0;
this->field_0x78.HWORD = this->x.HALF.HI;
this->field_0x7a.HWORD = this->y.HALF.HI;
this->animationState = 0;
this->direction = 0x10;
sub_08028E9C(this);
if ((*(u8*)this->field_0x7c.WORD & 1) || CheckFlags(this->field_0x86.HWORD)) {
this->action = 4;
this->actionDelay = 0x78;
this->spritePriority.b1 = 1;
sub_0802925C(this);
sub_080290E0(this, 0);
} else {
this->actionDelay = 0;
this->field_0x76.HWORD = COORD_TO_TILE(this);
this->field_0x74.HWORD = sub_080001DA(this->field_0x76.HWORD, this->collisionLayer);
this->field_0x40 = 0x41;
sub_08028FFC(this);
}
}
void sub_08028A48(Entity* this) {
if (this->actionDelay) {
this->actionDelay--;
} else if (sub_08028F98(this, 0)) {
sub_08029078(this);
this->previousActionFlag = 0;
this->field_0xf = 1;
}
}
void sub_08028A74(Entity* this) {
u32 unk;
GetNextFrame(this);
switch (this->previousActionFlag) {
case 0:
unk = 1;
if (this->frames.all & 0x80) {
this->previousActionFlag = 1;
this->actionDelay = 0x3c;
this->field_0xf = 0x10;
sub_08028FDC(this);
sub_080290E0(this, 1);
}
break;
case 1:
unk = 1;
if (--this->actionDelay == 0) {
this->previousActionFlag = 2;
this->actionDelay = 0x20;
this->field_0xf = 0;
sub_08028FDC(this);
sub_080290E0(this, 2);
} else if (--this->field_0xf == 0) {
if (sub_08028FDC(this)) {
sub_080290E0(this, 1);
}
this->field_0xf = 0x10;
}
break;
case 2:
unk = 1;
sub_080290FC(this);
if (this->frames.all & 1) {
Entity* ent = sub_0804A98C(this, 4, 0);
if (ent != NULL) {
ent->parent = this;
ent->direction = this->direction;
this->frames.all &= ~1;
this->previousActionFlag = 3;
}
}
break;
case 3:
unk = 2;
if (this->frames.all & 0x80) {
this->previousActionFlag = 4;
this->actionDelay = 0x50;
sub_080290E0(this, 1);
}
break;
case 4:
unk = 2;
if (--this->actionDelay == 0) {
if (sub_08028F98(this, 0)) {
this->previousActionFlag = 1;
this->actionDelay = 0x3c;
this->field_0xf = 0x10;
sub_08028FDC(this);
} else {
sub_08028FFC(this);
this->previousActionFlag = 0;
this->actionDelay = 0x50;
this->field_0xf = 0;
}
return;
}
break;
}
if (!sub_08028F98(this, unk)) {
sub_08028FFC(this);
this->previousActionFlag = 0;
this->actionDelay = 0x50;
this->field_0xf = 0;
}
}
void sub_08028BC4(Entity* this) {
Entity* iVar1;
switch (this->previousActionFlag) {
case 0:
if (this->actionDelay == 0) {
if (this->frames.all & 0x80) {
this->previousActionFlag = 1;
sub_08028FDC(this);
sub_080290E0(this, 5);
this->spritePriority.b1 = 1;
}
} else {
this->actionDelay--;
}
break;
case 1:
if (this->frames.all & 0x80) {
this->action = 4;
this->previousActionFlag = 0;
this->actionDelay = 0x1e;
this->field_0xf = 5;
sub_080290E0(this, 0);
iVar1 = sub_0804A9FC(this, 0x1c);
if (iVar1 != NULL) {
iVar1->spritePriority.b0 = 3;
iVar1->height.HALF.HI -= 12;
sub_0805E3A0(iVar1, 2);
}
SetFlag(this->field_0x86.HWORD);
sub_0802925C(this);
}
break;
}
GetNextFrame(this);
sub_0800445C(this);
}
extern void sub_0804AA1C(Entity*);
void sub_08028F0C(Entity*);
void sub_08028C84(Entity* this) {
if (--this->actionDelay == 0) {
this->actionDelay = 0x30;
if (this->field_0xf) {
if (--this->field_0xf == 0) {
sub_0804AA1C(this);
}
} else if (sub_08028FDC(this) || this->field_0x80.HALF.LO) {
this->field_0x80.HALF.LO = 0;
sub_080290E0(this, 0);
}
}
GetNextFrame(this);
sub_0800445C(this);
sub_08028F0C(this);
}
void sub_08028CE8(Entity* this) {
struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD;
u32 subtype;
if ((gTextBox.doTextBox & 0x7f) == 0 && sub_0802915C(this) && !sub_08056338()) {
if (offer->price <= gUnk_02002A40.stats.rupees) {
if (sub_080291DC(this)) {
/* Bag full. */
TextboxNoOverlapFollow(0x2904);
sub_08078A90(0);
} else {
ModRupees(-offer->price);
switch (offer->field_0x0 >> 2) {
case 0:
subtype = offer->field_0x9;
if (subtype == 0xff) {
subtype = gUnk_080CC9C0[Random() & 7];
}
CreateItemEntity(offer->field_0x8, subtype, 0);
this->action = 6;
this->actionDelay = 4;
this->field_0x80.HALF.HI = 0;
sub_080290E0(this, 3);
SetLocalFlag(0x87);
return;
case 1:
CreateItemEntity(offer->field_0x8, offer->field_0x9, 0);
this->actionDelay = 4;
sub_0802922C(this);
return;
case 2:
CreateItemEntity(offer->field_0x8, offer->field_0x9, 0);
this->actionDelay = 8;
sub_0802922C(this);
return;
}
}
} else {
/* Not enough money. */
TextboxNoOverlapFollow(0x2903);
sub_08078A90(0);
}
}
sub_0800445C(this);
this->action = 4;
this->actionDelay = 0x30;
sub_080290E0(this, 0);
}
void sub_08028DE8(Entity* this) {
if (gPlayerEntity.action == 8) {
if (this->field_0x80.HALF.HI == 0) {
sub_08078A90(1);
this->field_0x80.HALF.HI = 1;
}
} else {
TextboxNoOverlapFollow(0x2902);
this->action = 4;
this->field_0x80.HALF.HI = 0;
this->actionDelay = 1;
sub_08028EDC(this);
sub_08078A90(0);
sub_0800445C(this);
GetNextFrame(this);
}
}
void sub_08028E40(Entity* this) {
if ((gTextBox.doTextBox & 0x7f) == 0) {
struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD;
this->action = 4;
this->previousActionFlag = gTextBox.doTextBox & 0x7f;
this->actionDelay = 1;
if (CheckLocalFlag(offer->field_0xa) == 0) {
SetLocalFlag(offer->field_0xa);
}
sub_08078A90(0);
}
sub_0800445C(this);
GetNextFrame(this);
}
void sub_08028E84(Entity* this) {
if (UpdateFuseInteraction()) {
this->action = 4;
this->actionDelay = 1;
}
}
bool32 sub_08029198(const struct SalesOffering*);
void sub_08028E9C(Entity* this) {
const struct SalesOffering* offer = &gUnk_080CC954[this->entityType.form];
if (sub_08029198(offer) && (offer->field_0x0 & 2)) {
offer = &gUnk_080CC954[offer->field_0xa];
}
this->field_0x7c.WORD = (u32)offer;
this->field_0x80.HALF.LO = 0;
}
void sub_08028EDC(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
if (sub_08029198(offer) && (offer->field_0x0 & 2)) {
offer = &gUnk_080CC954[offer->field_0xa];
this->field_0x7c.WORD = (u32)offer;
}
}
void sub_08028F0C(Entity* this) {
if (this->interactType == 2) {
this->action = 8;
this->interactType = 0;
sub_0806F118(this);
} else if (this->interactType != 0) {
u16 dialog;
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
this->interactType = 0;
sub_0804AA1C(this);
this->direction = (GetAnimationState(this) << 3);
sub_080290E0(this, 3);
this->field_0x80.HALF.LO = 1;
this->actionDelay = 0x20;
this->field_0xf = 0;
if (sub_08029198(offer)) {
dialog = offer->field_0x6;
} else {
if ((offer->field_0x0 & 0xfc) != 0xc) {
this->action = 5;
} else {
this->action = 7;
}
dialog = offer->field_0x4;
sub_08078A90(1);
}
TextboxNoOverlapFollow(dialog);
gTextBox.field_0x10 = offer->price;
}
}
bool32 sub_08028F98(Entity* this, u32 param_2) {
Entity* ent = sub_08049DF4(1);
if (ent == NULL || sub_080041A0(this, ent, 0x28, 0x28)) {
return FALSE;
}
if (param_2 != 2) {
u32 distance = param_2 ? 0x58 : 0x50;
if (!sub_080041A0(this, ent, distance, distance)) {
return FALSE;
}
}
return TRUE;
}
bool32 sub_08028FDC(Entity* this) {
u32 direction = DirectionRoundUp(sub_08049F84(this, 1));
if (direction == this->direction) {
return FALSE;
} else {
this->direction = direction;
return TRUE;
}
}
void sub_08028FFC(Entity* this) {
this->action = 1;
this->flags &= ~0x80;
this->spritePriority.b1 = 0;
sub_080AE068(this);
UnloadOBJPalette(this);
this->spriteVramOffset = 0xe8;
this->palette.b.b0 = 2;
this->palette.b.b4 = 2;
this->spriteIndex = 0xa7;
this->x.HALF.HI = this->field_0x78.HWORD;
this->y.HALF.HI = this->field_0x7a.HWORD;
InitializeAnimation(this, 0);
SetTile(0x4022, this->field_0x76.HWORD, this->collisionLayer);
}
void sub_08029078(Entity* this) {
this->action = 2;
this->flags = this->flags | 0x80;
this->spritePriority.b1 = 1;
if (LoadFixedGFX(this, 0x72) == 0) {
DeleteEntity(this);
} else {
sub_0801D040(this, 0x6e);
this->spriteIndex = 0xd0;
sub_08028FDC(this);
sub_080290E0(this, 1);
SetTile(this->field_0x74.HWORD, this->field_0x76.HWORD, this->collisionLayer);
}
}
void sub_080290E0(Entity* this, u32 param_2) {
InitializeAnimation(this, this->direction >> 3 | gUnk_080CCA04[param_2]);
}
void sub_080290FC(Entity* this) {
if (this->actionDelay != 0) {
if (--this->actionDelay < 0x10 && (this->actionDelay & 1) == 0) {
s32 sVar3 = (this->direction & 0x10) ? -1 : 1;
if ((this->direction & 8)) {
this->x.HALF.HI += (this->actionDelay & 8) ? -sVar3 : sVar3;
} else {
this->y.HALF.HI += (this->actionDelay & 8) ? sVar3 : -sVar3;
}
}
}
}
bool32 sub_0802915C(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
switch (offer->field_0x8) {
case 0x44:
if (GetInventoryValue(0x44) == 0)
return TRUE;
break;
case 0x1c:
if (CheckGlobalFlag(0x5a) == 0)
return TRUE;
break;
case 0x5c:
case 0x6c:
case 0x6f:
return TRUE;
}
return FALSE;
}
bool32 sub_08029198(const struct SalesOffering* offer) {
u32 tmp;
if ((offer->field_0x0 & 0xfc) != 0xc) {
switch (offer->field_0x8) {
case 0x1c:
tmp = CheckGlobalFlag(0x5a);
break;
case 0x9:
case 0x44:
tmp = GetInventoryValue(offer->field_0x8);
break;
default:
return 0;
}
} else {
tmp = CheckLocalFlag(offer->field_0xa);
}
if (tmp == 0) {
return FALSE;
}
return TRUE;
}
bool32 sub_080291DC(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
switch (offer->field_0x8) {
case 0x6c:
if (gBombBagSizes[gUnk_02002A40.stats.bombBagType] <= gUnk_02002A40.stats.bombCount)
return TRUE;
break;
case 0x6f:
if (gQuiverSizes[gUnk_02002A40.stats.quiverType] <= gUnk_02002A40.stats.arrowCount)
return TRUE;
break;
}
return FALSE;
}
#if NON_MATCHING
void sub_0802922C(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
this->action = 6;
this->field_0x80.HALF.HI = 0;
switch (offer->field_0x8) {
case 0x1c:
SetGlobalFlag(0x5a);
break;
}
sub_080290E0(this, 3);
}
#else
NAKED
void sub_0802922C(Entity* this) {
asm(".include \"asm/non_matching/businessScrub/sub_0802925C.inc\"");
}
#endif
void sub_0802925C(Entity* this) {
sub_08078784(this, sub_0801E99C(this));
}
void sub_08029270(Entity* this) {
if (this->action == 0) {
this->action++;
this->spriteSettings.b.draw = 1;
InitializeAnimation(this, 0xe);
} else {
GetNextFrame(this);
}
}
// clang-format off
const struct SalesOffering gUnk_080CC954[] = {
{0x06, 0x00, 0xffff, 0x290f, 0x2902, 0x09, 0xff, 0x0001},
{0x04, 0x00, 0x001e, 0x290e, 0x2902, 0x6f, 0xff, 0xffff},
{0x04, 0x00, 0x001e, 0x290b, 0x2902, 0x6c, 0xff, 0xffff},
{0x08, 0x00, 0x0028, 0x290c, 0x2911, 0x44, 0xff, 0xffff},
{0x00, 0x00, 0x0064, 0x290d, 0x2902, 0x5c, 0xff, 0xffff},
{0x04, 0x00, 0x0014, 0x2910, 0x2911, 0x1c, 0xff, 0xffff},
{0x0c, 0x00, 0xffff, 0x2912, 0x2913, 0xff, 0xff, 0x0046},
{0x04, 0x00, 0x0064, 0x2913, 0x2902, 0x5c, 0x75, 0xffff},
{0x00, 0x00, 0x00C8, 0x290d, 0x2902, 0x5c, 0xff, 0xffff},
};
const u8 gUnk_080CC9C0[] = {
0x6e,
0x6f,
0x70,
0x71,
0x72,
0x73,
0x74,
0x75,
};
void (*const gUnk_080CC9C8[])(Entity*) = {
sub_0802891C,
sub_08028934,
sub_08001324,
sub_0804A7D4,
sub_08001242,
nullsub_140,
};
void (*const gUnk_080CC9E0[])(Entity*) = {
sub_08028994,
sub_08028A48,
sub_08028A74,
sub_08028BC4,
sub_08028C84,
sub_08028CE8,
sub_08028DE8,
sub_08028E40,
sub_08028E84,
};
const u8 gUnk_080CCA04[] = {
0, 4, 8, 12, 16, 20,
};
// clang-format on
+91
View File
@@ -0,0 +1,91 @@
#include "enemy.h"
#include "entity.h"
#include "functions.h"
extern s32 sub_080012DC(Entity*);
extern u32 sub_0804A024(Entity*, u32, u32);
extern bool32 sub_080AF038(Entity*);
extern void (*const gUnk_080012C8[])(Entity*);
extern void (*const gUnk_080CD27C[])(Entity*);
extern void (*const gUnk_080CD298[])(Entity*);
void Chaser(Entity* this) {
u32 idx = sub_080012DC(this);
if (idx) {
gUnk_080012C8[idx](this);
} else {
gUnk_080CD27C[GetNextFunction(this)](this);
}
}
void sub_0802B518(Entity* this) {
gUnk_080CD298[this->action](this);
}
void sub_0802B530(Entity* this) {
this->action = 1;
InitializeAnimation(this, 0);
}
void sub_0802B540(Entity* this) {
if (this->actionDelay) {
this->actionDelay--;
} else {
u32 direction = sub_0804A024(this, 1, 0xc);
if (direction != 0xff) {
this->action = 2;
this->nonPlanarMovement = 0x40;
this->direction = direction;
}
}
}
void sub_0802B56C(Entity* this) {
GetNextFrame(this);
if (this->bitfield & 0x80) {
this->nonPlanarMovement = 0x40;
}
if (sub_080AF038(this)) {
if (this->animIndex != 1) {
InitializeAnimation(this, 1);
}
if (this->nonPlanarMovement < 0x220) {
this->nonPlanarMovement += 4;
}
} else {
this->action = 3;
InitializeAnimation(this, 2);
}
}
void sub_0802B5C8(Entity *this) {
GetNextFrame(this);
if (this->frames.all & 0x80) {
this->action = 1;
this->actionDelay = 30;
InitializeAnimation(this,0);
}
}
// clang-format off
void (*const gUnk_080CD27C[])(Entity*) = {
sub_0802B518,
sub_0802B518,
sub_08001324,
sub_0804A7D4,
sub_08001242,
sub_0802B518,
sub_0802B518,
};
void (*const gUnk_080CD298[])(Entity*) = {
sub_0802B530,
sub_0802B540,
sub_0802B56C,
sub_0802B5C8,
};
// clang-format on
+190
View File
@@ -0,0 +1,190 @@
#include "enemy.h"
#include "entity.h"
#include "functions.h"
extern void sub_08078B48(void);
void sub_08027870(Entity*);
extern void (*const gUnk_080CC19C[])(Entity*);
extern void (*const gUnk_080CC1B0[])(Entity*);
extern const u8 gUnk_080CC1B8[];
extern void (*const gUnk_080CC1C8[])(Entity*);
extern void (*const gUnk_080CC1DC[])(Entity*);
extern void (*const gUnk_080CC20C[])(Entity*);
extern const u8 gUnk_080CC234[];
extern const u8 gUnk_080CC24F[];
extern void (*const gUnk_080CC258[])(Entity*);
extern void (*const gUnk_080CC264[])(Entity*);
extern void (*const gUnk_080CC26C[])(Entity*);
extern const u8 gUnk_080CC278[];
extern const u16 gUnk_080CC27C[];
extern const u16 gUnk_080CC29C[];
extern const u16 gUnk_080CC2BC[];
extern const s8 gUnk_080CC2DC[];
void sub_08025DC0(Entity*);
void sub_08025CBC(Entity*);
void sub_08025CD4(Entity*);
void sub_08001242(Entity*);
void sub_08025DD8(Entity*);
void sub_08026060(Entity*);
void sub_08026110(Entity*);
void sub_080272D4(Entity*);
void sub_0802720C(Entity*);
void sub_0802720C(Entity*);
void sub_08026090(Entity*);
void sub_0802626C(Entity*);
void sub_08026580(Entity*);
void sub_08026634(Entity*);
void sub_08026750(Entity*);
void sub_0802686C(Entity*);
void sub_080268C8(Entity*);
void sub_0802694C(Entity*);
void sub_08026C40(Entity*);
void sub_08026E1C(Entity*);
void sub_08026FA4(Entity*);
void sub_08027064(Entity*);
void sub_08026F1C(Entity*);
void sub_080262A8(Entity*);
void sub_08026328(Entity*);
void sub_08026358(Entity*);
void sub_080263B4(Entity*);
void sub_08026414(Entity*);
void sub_0802647C(Entity*);
void sub_080264AC(Entity*);
void sub_080264D4(Entity*);
void sub_0802650C(Entity*);
void sub_0802653C(Entity*);
void sub_08026774(Entity*);
void sub_080267D0(Entity*);
void sub_08026808(Entity*);
void sub_080268EC(Entity*);
void sub_08026914(Entity*);
void sub_08026968(Entity*);
void sub_080269CC(Entity*);
void sub_08026BE8(Entity*);
// clang-format off
void (*const gUnk_080CC19C[])(Entity*) = {
sub_08025DC0,
sub_08025DC0,
sub_08025CBC,
sub_08025CD4,
sub_08001242,
};
void (*const gUnk_080CC1B0[])(Entity*) = {
sub_08025DD8,
sub_08026060,
};
const u8 gUnk_080CC1B8[] = {
0, 4,
0, 0,
0, 4,
0, 0,
1, 4,
0, 0,
2, 4,
0, 0,
};
void (*const gUnk_080CC1C8[])(Entity*) = {
sub_08026110,
sub_080272D4,
sub_0802720C,
sub_0802720C,
sub_08026090,
};
void (*const gUnk_080CC1DC[])(Entity*) = {
sub_0802626C,
sub_08026580,
sub_08026634,
sub_08026750,
sub_0802686C,
sub_080268C8,
sub_0802694C,
sub_08026C40,
sub_08026E1C,
sub_08026FA4,
sub_08027064,
sub_08026F1C,
};
void (*const gUnk_080CC20C[])(Entity*) = {
sub_080262A8,
sub_08026328,
sub_08026358,
sub_080263B4,
sub_08026414,
sub_0802647C,
sub_080264AC,
sub_080264D4,
sub_0802650C,
sub_0802653C,
};
const u8 gUnk_080CC234[] = {
0x3C, 0x1E, 0x1E, 0x1E,
0x1E, 0x0F, 0x0F, 0x0F,
0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x0A, 0x0A,
0x0A, 0x0F, 0x0F, 0x0F,
0x1E, 0x1E, 0x2D, 0x0A,
0x5A, 0x1E, 0xFF,
};
const u8 gUnk_080CC24F[] = {
2, 2, 4, 4,
4, 6, 6, 8,
};
void (*const gUnk_080CC258[])(Entity*) = {
sub_08026774,
sub_080267D0,
sub_08026808,
};
void (*const gUnk_080CC264[])(Entity*) = {
sub_080268EC,
sub_08026914,
};
void (*const gUnk_080CC26C[])(Entity*) = {
sub_08026968,
sub_080269CC,
sub_08026BE8,
};
const u8 gUnk_080CC278[] = {
150, 180, 210, 250,
};
const u16 gUnk_080CC27C[] = {
0x80, 0x8, 0x100, 0x6,
0x80, 0x18, 0x100, 0x8,
0x180, 0x6, 0x100, 0x10,
0x0, 0x0, 0xA0, 0x18,
};
const u16 gUnk_080CC29C[] = {
0x80, 0x8, 0x100, 0x4,
0x80, 0xC, 0x80, 0x6,
0x200, 0x6, 0x100, 0xC,
0x0, 0x0, 0xA0, 0x14,
};
const u16 gUnk_080CC2BC[] = {
0x80, 0x8, 0x100, 0x0,
0x60, 0x2, 0x80, 0x2,
0x200, 0x6, 0x100, 0x8,
0x0, 0x0, 0xA0, 0x10,
};
const s8 gUnk_080CC2DC[] = {
-7, -9, -7,
};
// clang-format on
+1 -26
View File
@@ -15,11 +15,7 @@ typedef struct {
extern void (*const gUnk_080CB734[])(Entity*);
extern void (*const gUnk_080CB74C[])(Entity*);
#if NON_MATCHING
extern const PosOffset gUnk_080CB764[];
#else
extern const s8 gUnk_080CB764[];
#endif
extern const PosOffset gUnk_080CB76C[4][6];
extern const u16 gUnk_080CB79C[];
extern const BoundingBox* const* const gUnk_080CB8A4[];
@@ -46,27 +42,15 @@ void sub_08022004(Entity* this) {
DeleteThisEntity();
}
#if NON_MATCHING
void sub_08022034(Entity* this) {
this->action = 1;
this->entityType.parameter = this->entityType.form & 3;
this->spritePriority.b0 = 5;
this->field_0x78.HWORD = gUnk_080CB764[this->entityType.parameter].h + this->x.HALF.HI;
this->field_0x7a.HWORD = gUnk_080CB764[this->entityType.parameter].v + this->y.HALF.HI;
InitializeAnimation(this, this->entityType.parameter);
sub_080221C0(this);
}
#else
void sub_08022034(Entity* this) {
this->action = 1;
this->entityType.parameter = this->entityType.form & 3;
this->spritePriority.b0 = 5;
this->field_0x78.HWORD = gUnk_080CB764[this->entityType.parameter * 2] + this->x.HALF.HI;
this->field_0x78.HWORD = gUnk_080CB764[this->entityType.parameter * 2 + 0] + this->x.HALF.HI;
this->field_0x7a.HWORD = gUnk_080CB764[this->entityType.parameter * 2 + 1] + this->y.HALF.HI;
InitializeAnimation(this, this->entityType.parameter);
sub_080221C0(this);
}
#endif
void sub_0802209C(Entity* this) {
if (this->actionDelay == 0) {
@@ -151,21 +135,12 @@ void (*const gUnk_080CB74C[])(Entity*) = {
sub_08022198,
};
#if NON_MATCHING
const PosOffset gUnk_080CB764[] = {
{-0x08, 0x00},
{-0x10, -0x08},
{-0x08, -0x10},
{ 0x00, -0x08},
};
#else
const s8 gUnk_080CB764[] = {
-0x08, 0x00,
-0x10, -0x08,
-0x08, -0x10,
0x00, -0x08,
};
#endif
const PosOffset gUnk_080CB76C[][6] = {
{
+254
View File
@@ -0,0 +1,254 @@
#include "enemy.h"
#include "functions.h"
void sub_0802C4B0(Entity*);
void sub_0802C62C(Entity*);
extern void (*const gUnk_080CD540[])(Entity*);
extern void (*const gUnk_080CD558[])(Entity*);
extern const u16 gUnk_080CD568[];
extern const u8 gUnk_080CD580[];
extern const s16 gUnk_080CD58C[];
void FallingBoulder(Entity* this) {
EnemyFunctionHandler(this, gUnk_080CD540);
}
void sub_0802C238(Entity* this) {
gUnk_080CD558[this->action](this);
}
void sub_0802C250(Entity* this) {
/* ... */
}
void sub_0802C254(Entity* this) {
/* ... */
}
void sub_0802C258(Entity* this) {
sub_0804A720(this);
this->field_0x20 = 0x20000;
this->actionDelay = 2;
this->field_0x7a.HWORD = Random() & 0x70;
switch (this->entityType.form) {
case 1:
this->field_0x7a.HWORD |= 0x100;
break;
case 2:
this->field_0x7a.HWORD |= 0x200;
break;
}
this->field_0x80.HWORD = this->x.HALF.HI;
this->field_0x82.HWORD = this->y.HALF.HI;
this->height.HALF.HI = -0x10;
this->collisionLayer = 3;
this->spriteRendering.b3 = 1;
this->spritePriority.b0 = 2;
this->field_0x7c.HALF.LO = 0;
this->field_0x7c.HALF.HI = COORD_TO_TILE(this);
sub_0802C62C(this);
sub_0802C4B0(this);
}
void sub_0802C318(Entity* this) {
if (--this->field_0x7a.HWORD == 0) {
this->action = 2;
}
}
#if NON_MATCHING
void sub_0802C334(Entity* this) {
if ((u16)this->field_0x7c.HALF.LO == 0) {
u32 tmp = gRoomControls.roomOriginY;
if (&gPlayerEntity == NULL)
return;
if (tmp - gPlayerEntity.y.HALF.HI <= 0x38) {
return;
}
this->field_0x7c.HALF.LO = 1;
this->spriteSettings.b.draw = 1;
}
GetNextFrame(this);
this->field_0x7c.HALF.HI = COORD_TO_TILE(this);
if (sub_080044EC(this, *(u32*)&this->cutsceneBeh) == 1) {
EnqueueSFX(0x14c);
this->flags = this->flags | 0x80;
this->field_0x7a.HWORD = 0xc;
sub_0802C4B0(this);
} else {
s32 y;
if (this->field_0x7a.HWORD) {
u16 tmp = --this->field_0x7a.HWORD;
switch (tmp) {
case 0:
this->flags &= ~0x80;
break;
case 8:
if (this->entityType.parameter != 0 && !sub_08049FA0(this)) {
u32 diff = 0;
s32 i;
for (i = 1; i > -1; i--) {
Entity* ent = CreateFx(this, 0x15, 0);
if (ent) {
ent->x.HALF.HI += 12;
ent->x.HALF.HI -= diff;
}
diff += 0x18;
}
sub_0802C62C(this);
this->field_0x7a.HWORD = Random() & 0xff | 0x100;
return;
}
break;
}
}
y = gRoomControls.roomOriginY + gRoomControls.height - this->y.HALF.HI;
if (y >= 5) {
sub_080AEFB4(this);
} else {
sub_0806F69C(this);
if (this->height.HALF.HI - y > 0x38) {
sub_0802C62C(this);
this->field_0x7a.HWORD = (Random() & 0x7f) | 0x80;
if (this->entityType.form == 3) {
this->action = 3;
}
}
}
}
this->collisionLayer = 3;
this->spritePriority.b0 = 1;
UpdateSpriteForCollisionLayer(this);
}
#else
NAKED
void sub_0802C334(Entity* this) {
asm(".include \"asm/non_matching/fallingBoulder/sub_0802C334.inc\"");
}
#endif
void nullsub_148(Entity* this) {
/* ... */
}
extern u32 sub_080001DA(u32, u32);
void sub_0802C4B0(Entity* this) {
u32 offset;
u32 index;
u32 rand;
switch (sub_080001DA(this->field_0x7c.HALF_U.HI, this->collisionLayer)) {
case 0x1ab ... 0x1af:
offset = 8;
break;
case 0x1c4:
offset = 4;
break;
default:
offset = 0;
break;
}
rand = Random() & 7;
if (rand & 4) {
if (rand & 3) {
this->nonPlanarMovement = gUnk_080CD568[offset | 2];
} else {
this->nonPlanarMovement = gUnk_080CD568[offset | 0];
}
} else {
if (rand & 3) {
this->nonPlanarMovement = gUnk_080CD568[offset | 1];
} else {
this->nonPlanarMovement = gUnk_080CD568[offset | 3];
}
}
rand = Random() & 7;
if (rand & 4) {
if (this->actionDelay != 0) {
this->actionDelay = 0;
InitializeAnimation(this, 0);
}
if (rand & 3) {
this->direction = gUnk_080CD580[offset | 1];
} else {
this->direction = gUnk_080CD580[offset | 0];
}
} else {
if (this->actionDelay != 1) {
this->actionDelay = 1;
InitializeAnimation(this, 1);
}
if (rand & 3) {
this->direction = gUnk_080CD580[offset | 2];
} else {
this->direction = gUnk_080CD580[offset | 3];
}
}
rand = Random() & 7;
this->field_0x20 = 0x20000;
if (rand & 4) {
if (rand & 3) {
*(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 1];
} else {
*(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 3];
}
} else {
if (rand & 3) {
*(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 2];
} else {
*(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 0];
}
}
}
void sub_0802C62C(Entity *this) {
this->action = 1;
this->y.HALF.HI = this->field_0x82.HWORD;
this->x.HALF.HI = this->field_0x80.HWORD;
this->spriteSettings.b.draw = 0;
this->flags &= ~0x80;
this->field_0x7c.HALF.LO = 0;
}
// clang-format off
void (*const gUnk_080CD540[])(Entity*) = {
sub_0802C238,
sub_0802C250,
sub_08001324,
sub_0804A7D4,
sub_08001242,
sub_0802C254,
};
void (*const gUnk_080CD558[])(Entity*) = {
sub_0802C258,
sub_0802C318,
sub_0802C334,
nullsub_148,
};
const u16 gUnk_080CD568[] = {
0x80, 0x100, 0x180, 0x200,
0x80, 0x100, 0x180, 0x200,
0x100, 0x200, 0x300, 0x400,
};
const u8 gUnk_080CD580[] = {
10, 14, 18, 22,
10, 14, 18, 22,
10, 14, 18, 22,
};
const s16 gUnk_080CD58C[] = {
0x1800, 0x2000, 0x2800, 0x3000,
0x1800, 0x2000, 0x2800, 0x3000,
0x1800, 0x2000, 0x2800, 0x3000,
};
// clang-format on
+436
View File
@@ -0,0 +1,436 @@
#include "enemy.h"
#include "functions.h"
extern void sub_08008796(Entity*, u32, u32, u32);
extern u32 sub_0804A024(Entity*, u32, u32);
extern bool32 sub_080AE4CC(Entity*, u32, u32, u32);
extern Entity gUnk_0200D654;
extern Entity gUnk_02027EB4;
void sub_0802C18C(Entity*);
void sub_0802C218(Entity*);
void sub_0802C1C0(Entity*);
u32 sub_0802C020(Entity*);
void sub_0802C058(Entity*, u32);
bool32 sub_0802C06C(Entity*);
void sub_08080964(u32, u32);
void sub_0802C1CC(Entity*);
bool32 sub_0802C0E8(Entity*);
extern void (*const gUnk_080CD3E4[])(Entity*);
extern void (*const gUnk_080CD3FC[])(Entity*);
extern void (*const gUnk_080CD408[])(Entity*);
extern void (*const gUnk_080CD42C[])(Entity*);
extern void (*const gUnk_080CD438[])(Entity*);
extern void (*const gUnk_080CD450[])(Entity*);
extern const s8 gUnk_080CD45C[];
extern const s8 gUnk_080CD464[];
void Helmasaur(Entity* this) {
if (this->entityType.form == 0) {
EnemyFunctionHandler(this, gUnk_080CD3E4);
SetChildOffset(this, 0, 1, -0x10);
} else {
gUnk_080CD3FC[this->action](this);
}
}
void sub_0802BBAC(Entity* this) {
gUnk_080CD408[this->action](this);
}
void sub_0802BBC4(Entity* this) {
if (this->damageType != 0x19) {
switch (this->bitfield & 0x7f) {
case 0:
case 2:
case 3:
if (this->action == 4) {
this->field_0x42 = 0;
sub_0802C218(this);
}
break;
}
}
if (this->field_0x43 != 0) {
sub_0804A9FC(this, 0x1c);
}
sub_0804AA30(this, gUnk_080CD3E4);
}
void sub_0802BC20(Entity* this) {
if (this->damageType != 0x19) {
if (sub_0806F520(this)) {
gUnk_080CD42C[this->previousActionFlag](this);
}
} else if (2 < this->previousActionFlag || sub_0806F520(this)) {
gUnk_080CD438[this->previousActionFlag](this);
}
}
void sub_0802BC74(Entity* this) {
sub_0802C1C0(this);
this->previousActionFlag = 1;
this->field_0x1d = 60;
this->animationState = (gPlayerEntity.animationState >> 1) ^ 2;
InitializeAnimation(this, this->animationState);
}
void sub_0802BCA0(Entity* this) {
sub_0806F4E8(this);
}
void sub_0802BCA8(Entity* this) {
if (this->damageType != 0x19) {
Entity* ent;
this->action = 7;
this->actionDelay = 0x5a;
this->field_0x20 = 0x18000;
this->damageType = 0x19;
this->field_0x3a = this->field_0x3a & 0xfb;
this->field_0x1c = 0x12;
ent = CreateEnemy(0x20, 1);
if (ent) {
ent->animationState = this->animationState;
CopyPosition(this, ent);
}
InitializeAnimation(this, this->animationState + 4);
}
}
void sub_0802BCFC(Entity* this) {
this->previousActionFlag = 1;
this->field_0x1d = 60;
}
void sub_0802BD08(Entity* this) {
sub_0806F3E4(this);
}
void sub_0802BD10(Entity* this) {
this->flags &= ~0x80;
UpdateAnimationVariableFrames(this, 2);
}
void nullsub_145(Entity* this) {
/* ... */
}
void sub_0802BD28(Entity* this) {
if (this->flags & 0x80) {
this->flags |= 0x80;
this->field_0x3a &= ~0x4;
} else {
this->currentHealth = 0;
}
}
void sub_0802BD54(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->field_0x78.HALF.LO = Random();
this->field_0x1d = 60;
this->field_0x78.HALF.HI = 0xff;
this->direction = DirectionRound(Random());
this->animationState = this->direction >> 3;
InitializeAnimation(this, this->animationState);
}
void sub_0802BD8C(Entity* this) {
if (this->actionDelay) {
this->actionDelay--;
} else {
u32 direction;
if (sub_08049FDC(this, 1)) {
direction = sub_0804A024(this, 1, 0x10);
if (direction != 0xff && direction != this->field_0x78.HALF.HI) {
sub_0802C058(this, direction);
return;
}
}
direction = sub_0802C020(this);
if (direction != this->direction) {
sub_0802C058(this, direction);
}
}
}
void sub_0802BDE0(Entity* this) {
if (sub_0802C06C(this)) {
this->action = 3;
this->actionDelay = 60;
this->field_0x78.HALF.HI = 0xff;
} else {
this->action = 1;
this->actionDelay = (Random() & 0xf) + 0xf;
this->field_0x78.HALF.HI = this->direction;
}
}
void sub_0802BE18(Entity* this) {
UpdateAnimationVariableFrames(this, 2);
if (--this->actionDelay == 0) {
this->action = 4;
this->actionDelay = 0x1e;
this->nonPlanarMovement = 0x300;
} else {
sub_0802C18C(this);
}
}
void sub_0802BE48(Entity* this) {
if (!sub_080AEFE0(this)) {
sub_0802C218(this);
sub_08080964(8, 0);
} else {
GetNextFrame(this);
sub_0802C1CC(this);
if (sub_0802C0E8(this)) {
this->action = 5;
}
}
}
void sub_0802BE80(Entity* this) {
this->nonPlanarMovement -= 0x20;
if (0xff < this->nonPlanarMovement) {
sub_0802C1CC(this);
}
if (this->nonPlanarMovement > 0) {
sub_080AEFE0(this);
sub_0802C18C(this);
} else {
sub_0802C1C0(this);
this->actionDelay += 30;
}
}
void sub_0802BEBC(Entity* this) {
this->direction ^= 0x10;
sub_080AEFE0(this);
this->direction ^= 0x10;
if (!sub_080044EC(this, 0x2000)) {
sub_0802C1C0(this);
}
}
void sub_0802BEEC(Entity* this) {
if (this->actionDelay) {
if ((--this->actionDelay & 0x1f) == 0) {
this->animationState ^= 2;
this->direction = this->animationState << 3;
InitializeAnimation(this, this->animationState + 4);
}
} else if (!sub_08003FC4(this, 0x1c00)) {
this->action = 8;
this->actionDelay = 30;
this->nonPlanarMovement = 0x120;
}
}
void sub_0802BF3C(Entity* this) {
ProcessMovement(this);
GetNextFrame(this);
if (--this->actionDelay == 0) {
u32 sprite;
this->actionDelay = 30;
this->direction = sub_0802C020(this);
sprite = this->direction >> 3;
if (sprite != this->animationState) {
this->animationState = sprite;
InitializeAnimation(this, sprite + 4);
}
}
}
void sub_0802BF78(Entity* this) {
this->action = 1;
this->flags2 = 4;
this->field_0x1c = 1;
this->direction = this->animationState << 3;
InitializeAnimation(this, this->animationState + 8);
}
void sub_0802BF98(Entity* this) {
if (sub_0806F520(this)) {
gUnk_080CD450[this->previousActionFlag](this);
} else {
this->action = 2;
this->actionDelay = 30;
this->flags &= ~0x80;
}
}
void sub_0802BFD0(Entity* this) {
this->previousActionFlag = 2;
}
void sub_0802BFD8(Entity* this) {
sub_0806F4E8(this);
}
void sub_0802BFE0(Entity* this) {
if (sub_0806F3E4(this)) {
DeleteEntity(this);
}
}
void sub_0802BFF4(Entity* this) {
this->spriteSettings.b.draw ^= 1;
if (--this->actionDelay == 0) {
DeleteEntity(this);
}
}
u32 sub_0802C020(Entity* this) {
u32 uVar1 = Random();
if (sub_08049FA0(this) || (uVar1 & 1))
return DirectionRound(uVar1);
return (sub_08049EE4(this) + (uVar1 >> 0x10 & 1) * 4) & 0x18;
}
void sub_0802C058(Entity* this, u32 param_2) {
this->action = 2;
this->direction = param_2;
this->animationState = param_2 >> 3;
InitializeAnimation(this, this->animationState);
}
bool32 sub_0802C06C(Entity* this) {
u32 x = this->x.HALF.HI + (s8)this->boundingBox->unknown[0];
u32 y = this->y.HALF.HI + (s8)this->boundingBox->unknown[1];
u32 xdiff = gUnk_080CD45C[(this->direction >> 2) + 0];
u32 ydiff = gUnk_080CD45C[(this->direction >> 2) + 1];
Entity* ent = this->collisionLayer == 2 ? &gUnk_0200D654 : &gUnk_02027EB4;
u32 i;
for (i = 0; i < 8; i++) {
x += xdiff;
y += ydiff;
if (sub_080AE4CC(ent, x, y, 0))
return FALSE;
}
return TRUE;
}
bool32 sub_0806FC24(u32, u32);
bool32 sub_0802C0E8(Entity* this) {
if (--this->actionDelay == 0) {
return TRUE;
} else {
const s8* ptr = &gUnk_080CD45C[this->direction >> 2];
s32 x = this->x.HALF.HI + (s8)this->boundingBox->unknown[0] + ptr[0] * 6;
s32 y = this->y.HALF.HI + (s8)this->boundingBox->unknown[1] + ptr[1] * 6;
Entity* ent = this->collisionLayer == 2 ? &gUnk_0200D654 : &gUnk_02027EB4;
u32 ret = FALSE;
if (!sub_0806FC24(TILE(x, y), 9)) {
u32 tmp = sub_080AE4CC(ent, x, y, 0);
ret = (-tmp | tmp) >> 0x1f;
}
return ret;
}
}
void sub_0802C18C(Entity* this) {
this->field_0x78.HALF.LO--;
if ((this->field_0x78.HALF.LO & 7) == 0) {
Entity* ent = CreateObject(0xf, 0x11, 0x40);
if (ent) {
PositionRelative(this, ent, 0, 0x10000);
}
}
}
void sub_0802C1C0(Entity* this) {
this->action = 1;
this->actionDelay = 30;
}
void sub_0802C1CC(Entity* this) {
const s8* ptr = &gUnk_080CD464[this->animationState << 2];
sub_08008796(this, 9, this->x.HALF.HI + ptr[0], this->y.HALF.HI + ptr[1]);
sub_08008796(this, 9, this->x.HALF.HI + ptr[2], this->y.HALF.HI + ptr[3]);
}
void sub_0802C218(Entity* this) {
this->action = 6;
this->nonPlanarMovement = 0xe0;
this->field_0x20 = 0x18000;
}
// clang-format off
void (*const gUnk_080CD3E4[])(Entity*) = {
sub_0802BBAC,
sub_0802BBC4,
sub_08001324,
sub_0804A7D4,
sub_08001242,
sub_0802BC20,
};
void (*const gUnk_080CD3FC[])(Entity*) = {
sub_0802BF78,
sub_0802BF98,
sub_0802BFF4,
};
void (*const gUnk_080CD408[])(Entity*) = {
sub_0802BD54,
sub_0802BD8C,
sub_0802BDE0,
sub_0802BE18,
sub_0802BE48,
sub_0802BE80,
sub_0802BEBC,
sub_0802BEEC,
sub_0802BF3C,
};
void (*const gUnk_080CD42C[])(Entity*) = {
sub_0802BC74,
sub_0802BCA0,
sub_0802BCA8,
};
void (*const gUnk_080CD438[])(Entity*) = {
sub_0802BCFC,
sub_0802BCA0,
sub_0802BD08,
sub_0802BD10,
nullsub_145,
sub_0802BD28,
};
void (*const gUnk_080CD450[])(Entity*) = {
sub_0802BFD0,
sub_0802BFD8,
sub_0802BFE0,
};
const s8 gUnk_080CD45C[] = {
0, -8,
8, 0,
0, 8,
-8, 0,
};
const s8 gUnk_080CD464[] = {
-3, -8, 3, -8,
8, -3, 8, 3,
-3, 8, 3, 8,
-8, -3, -8, 3,
};
// clang-format on
+287
View File
@@ -0,0 +1,287 @@
#include "enemy.h"
#include "entity.h"
#include "functions.h"
#include "textbox.h"
extern bool32 sub_080544B4(u32);
extern void sub_0807CAA0(u32, u32);
void sub_0802810C(Entity*);
void sub_080281A0(Entity*);
bool32 sub_080281E0(u32);
void sub_08028224(u32);
extern void (*const gUnk_080CC6FC[])(Entity*);
extern void (*const gUnk_080CC714[])(Entity*);
void LikeLike(Entity* this) {
EnemyFunctionHandler(this, gUnk_080CC6FC);
SetChildOffset(this, 0, 1, -0x10);
}
void sub_08027D8C(Entity* this) {
gUnk_080CC714[this->action](this);
}
void sub_08027DA4(Entity* this) {
if (this->damageType == 1) {
this->action = 3;
this->flags &= ~0x80;
this->damageType = 0x8c;
} else {
if (this->action == 7) {
sub_0802810C(this);
} else if (this->bitfield & 0x80) {
u8 tmp = this->bitfield & ~0x80;
if (!tmp) {
this->action = 7;
this->actionDelay = 0x5f;
this->field_0xf = tmp;
this->flags2 &= 0xfc;
this->field_0x82.HALF.HI = gPlayerEntity.spritePriority.b1;
}
}
}
if (this->currentHealth == 0) {
this->actionDelay = 0x20;
}
if (this->field_0x43) {
sub_0804A9FC(this, 0x1c);
}
sub_0804AA30(this, gUnk_080CC6FC);
}
void sub_08027E40(Entity* this) {
if (this->actionDelay == 2 && this->field_0x80.HALF.LO != 0xff) {
sub_0805E3A0(this, 3);
sub_08028224(this->field_0x80.HALF.LO);
}
sub_0804A7D4(this);
}
void nullsub_139(Entity* this) {
/* ... */
}
void sub_08027E70(Entity* this) {
sub_0804A720(this);
switch (this->entityType.form) {
case 0:
this->action = 3;
this->spriteSettings.b.draw = 0;
this->flags = this->flags & 0x7f;
this->actionDelay = 0;
break;
case 1:
this->action = 1;
this->spriteSettings.b.draw = 1;
this->actionDelay = 8;
InitializeAnimation(this, 1);
break;
case 2:
this->action = 1;
this->spriteSettings.b.draw = 0;
this->actionDelay = 0;
this->damageType = 1;
InitializeAnimation(this, 0);
break;
}
this->direction = 0;
this->field_0x82.HALF.LO = 0;
this->animationState = 0;
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.LO = 0xff;
}
void sub_08027EFC(Entity* this) {
if (this->damageType == 1)
return;
if (sub_08049FDC(this, 1)) {
if (!sub_08049FA0(this) && (Random() & 0x30)) {
this->direction = sub_08049EE4(this);
} else {
this->direction = this->field_0x82.HALF.LO;
}
if (--this->actionDelay == 0) {
this->direction = sub_08049F84(this, 1);
this->field_0x82.HALF.LO = this->direction;
this->actionDelay = 8;
}
ProcessMovement(this);
GetNextFrame(this);
} else {
this->action = 6;
this->flags &= ~0x80;
InitializeAnimation(this, 2);
}
}
void nullsub_12(Entity* this) {
/* ... */
}
void sub_08027F84(Entity* this) {
if (sub_08049FDC(this, 1)) {
this->action = 5;
this->spriteSettings.b.draw = 1;
InitializeAnimation(this, 0);
CreateDust(this);
}
}
void sub_08027FB4(Entity* this) {
if (--this->actionDelay == 0) {
this->action = 1;
this->actionDelay = 1;
this->flags2 |= 1;
}
GetNextFrame(this);
}
void sub_08027FE0(Entity* this) {
GetNextFrame(this);
if (this->frames.all & 1) {
this->action = 1;
this->flags |= 0x80;
this->direction = sub_08049F84(this, 1);
this->actionDelay = 8;
this->spritePriority.b1 = 1;
InitializeAnimation(this, 1);
}
}
void sub_0802802C(Entity* this) {
GetNextFrame(this);
if (this->frames.all & 1) {
this->action = 3;
this->spriteSettings.b.draw = 0;
this->direction = 0;
this->actionDelay = 0;
CreateDust(this);
}
}
void sub_0802805C(Entity* this) {
u8* tmp;
UpdateAnimationVariableFrames(this, 2);
if (sub_0807953C()) {
u32 tmp2 = Random();
u32 tmp3 = this->field_0xf + 1;
tmp3 += (tmp2 & 1);
this->field_0xf = tmp3;
}
if (this->field_0xf >= 0x19 || gUnk_02002A40.stats.health == 0) {
sub_0802810C(this);
} else {
ResetPlayer();
gPlayerState.field_0x1a[0] |= 0x80;
PositionRelative(this, &gPlayerEntity, 0, 0x10000);
tmp = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex);
gPlayerEntity.spriteOffsetX = tmp[0];
gPlayerEntity.spriteOffsetY = tmp[1];
gPlayerEntity.spritePriority.b1 = 0;
if (--this->actionDelay == 0) {
sub_080281A0(this);
}
if ((this->actionDelay & 3) == 0) {
EnqueueSFX(0x104);
}
}
}
#if NON_MATCHING
void sub_0802810C(Entity* this) {
gPlayerState.jumpStatus = 0x41;
gPlayerState.field_0xa = 0;
gPlayerState.flags.all &= 0xffffffef;
gPlayerEntity.flags |= 0x80;
gPlayerEntity.field_0x20 = 0x18000;
gPlayerEntity.hurtBlinkTime = -60;
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
gPlayerEntity.spritePriority.b1 = this->field_0x82.HALF.HI;
gPlayerEntity.height.HALF.HI = gPlayerEntity.spriteOffsetY;
gPlayerEntity.spriteOffsetY = 0;
this->action = 4;
this->actionDelay = 0x50;
this->field_0xf = 0;
this->flags2 |= 2;
if (this->hurtBlinkTime == 0) {
this->hurtBlinkTime = -18;
}
}
#else
NAKED
void sub_0802810C(Entity* this) {
asm(".include \"asm/non_matching/likeLike/sub_0802810C.inc\"");
}
#endif
void sub_080281A0(Entity* this) {
this->field_0xf = 0x19;
if (sub_080281E0(0xe)) {
this->field_0x80.HALF.LO = 0xe;
TextboxNoOverlapFollow(0x578);
} else if (sub_080281E0(0xd)) {
this->field_0x80.HALF.LO = 0xd;
TextboxNoOverlapFollow(0x578);
} else {
ModHealth(-1);
}
}
bool32 sub_080281E0(u32 param_1) {
bool32 ret = FALSE;
if (GetInventoryValue(param_1) == 1) {
if (sub_080544B4(gUnk_02002A40.stats.itemOnA)) {
gUnk_02002A40.stats.itemOnA = 0;
}
if (sub_080544B4(gUnk_02002A40.stats.itemOnB)) {
gUnk_02002A40.stats.itemOnB = 0;
}
sub_0807CAA0(param_1, 0);
ret = TRUE;
}
return ret;
}
void sub_08028224(u32 param_1) {
sub_080A7C18(param_1, 0, 1);
TextboxNoOverlapFollow(0x579);
}
void (*const gUnk_080CC6FC[])(Entity *) = {
sub_08027D8C,
sub_08027DA4,
sub_08001324,
sub_08027E40,
sub_08001242,
nullsub_139,
};
void (*const gUnk_080CC714[])(Entity *) = {
sub_08027E70,
sub_08027EFC,
nullsub_12,
sub_08027F84,
sub_08027FB4,
sub_08027FE0,
sub_0802802C,
sub_0802805C,
};
+582
View File
@@ -0,0 +1,582 @@
#include "enemy.h"
#include "entity.h"
#include "functions.h"
extern u8 gEntCount;
extern BoundingBox gUnk_080FD298;
extern BoundingBox gUnk_080FD2A0;
void sub_08029E0C(Entity*);
void sub_08029EEC(Entity*);
void sub_0802A098(Entity*);
void sub_0802A16C(Entity*);
void sub_0802A058(Entity*);
bool32 sub_0802A14C(Entity*);
void sub_0802A18C(Entity*);
bool32 sub_08029FE4(Entity*);
void sub_08029FB4(Entity*, u32, u32);
void sub_0802A0F8(Entity*);
extern void (*const gUnk_080CCD44[])(Entity*);
extern void (*const gUnk_080CCD60[])(Entity*);
extern void (*const gUnk_080CCD78[])(Entity*);
extern void (*const gUnk_080CCD88[])(Entity*);
extern const u8 gUnk_080CCDA0[];
extern void (*const gUnk_080CCDA8[])(Entity*);
extern const u8 gUnk_080CCDC8[];
extern const u16 gUnk_080CCDD4[];
void Madderpillar(Entity* this) {
gUnk_080CCD44[this->entityType.form](this);
}
void sub_08029870(Entity* this) {
gUnk_080CCD60[GetNextFunction(this)](this);
}
void sub_0802988C(Entity* this) {
gUnk_080CCD78[this->action](this);
}
void sub_080298A4(Entity* this) {
if (this->action == 1) {
switch (this->bitfield & 0x7f) {
case 0:
case 1:
case 2:
case 3:
case 0xf:
case 0x13:
case 0x1b:
case 0x1e:
break;
default:
this->action = 2;
this->actionDelay = 0;
this->damageType = 0x6b;
this->field_0x76.HALF.HI = 0;
sub_0801D2B4(this, 0x7f);
EnqueueSFX(0xfe);
this->attachedEntity->action = 2;
break;
}
}
sub_0804AA30(this, gUnk_080CCD60);
}
void sub_08029980(Entity* this) {
if (this->field_0xf) {
this->field_0xf--;
} else {
sub_0804A7D4(this);
}
}
void nullsub_14(Entity* this) {
/* ... */
}
void sub_0802999C(Entity* this) {
if (gEntCount < 0x44) {
Entity *ent1, *ent2, *ent3, *ent4, *ent5, *ent6;
ent1 = CreateEnemy(0x18, 1);
ent1->parent = this;
PositionRelative(this, ent1, 0, 5);
this->attachedEntity = ent1;
ent2 = CreateEnemy(0x18, 2);
ent2->parent = this;
PositionRelative(this, ent2, 0, 4);
ent1->attachedEntity = ent2;
ent3 = CreateEnemy(0x18, 3);
ent3->parent = this;
PositionRelative(this, ent3, 0, 3);
ent2->attachedEntity = ent3;
ent4 = CreateEnemy(0x18, 4);
ent4->parent = this;
PositionRelative(this, ent4, 0, 2);
ent3->attachedEntity = ent4;
ent5 = CreateEnemy(0x18, 5);
ent5->parent = this;
PositionRelative(this, ent5, 0, 1);
ent4->attachedEntity = ent5;
ent6 = CreateEnemy(0x18, 6);
ent6->attachedEntity = this;
ent6->parent = this;
PositionRelative(this, ent6, 0, 0);
ent5->attachedEntity = ent6;
this->action = 1;
this->flags |= 0x80;
this->direction = DirectionRound(Random());
this->nonPlanarMovement = 0xa0;
this->animationState = 0xff;
this->y.WORD += 6;
this->parent = this;
this->field_0x74.HALF.LO = 0xff;
this->field_0x74.HALF.HI = 0;
this->field_0x76.HALF.HI = 1;
sub_08029E0C(this);
sub_08029EEC(this);
}
}
void sub_08029A94(Entity* this) {
UpdateAnimationSingleFrame(this);
sub_0802A098(this);
}
void sub_08029AA4(Entity* this) {
if (this->field_0x76.HALF.HI != 0) {
this->action = 3;
this->nonPlanarMovement = 0x108;
this->damageType = 0x6a;
this->field_0x7a.HWORD = 0x168;
this->field_0x74.HALF.HI = 4;
sub_08029EEC(this);
EnqueueSFX(0x19d);
}
}
void sub_08029AE0(Entity* this) {
UpdateAnimationSingleFrame(this);
sub_0802A16C(this);
sub_0802A098(this);
if (--this->field_0x7a.HWORD == 0) {
this->action = 1;
this->nonPlanarMovement = 0xa0;
this->field_0x74.HALF.HI = 0;
sub_08029EEC(this);
sub_0801D2B4(this, 0x77);
EnqueueSFX(0x182);
}
}
void sub_08029B2C(Entity* this) {
if (sub_0802A14C(this)) {
if (this->field_0x86.HALF.LO) {
if (--this->actionDelay == 0) {
CreateFx(this, 0x48, 0);
DeleteEntity(this);
}
} else {
this->flags &= ~0x80;
this->actionDelay = -(this->entityType.form * 15 - 90);
this->field_0x86.HALF.LO = 1;
}
} else {
gUnk_080CCD88[this->action](this);
}
}
void sub_08029B90(Entity* this) {
this->action = 1;
this->spriteSettings.b.draw = 1;
sub_0802A058(this);
if (this->entityType.form < 2) {
InitializeAnimation(this, 0);
} else {
InitializeAnimation(this, 4);
}
}
void sub_08029BC4(Entity* this) {
u32 uVar1;
u32 uVar2;
sub_0802A18C(this);
uVar1 = this->x.HALF.HI;
uVar2 = this->y.HALF.HI;
if (sub_08029FE4(this)) {
u32 index;
if (this->entityType.form < 2) {
index = 0;
} else {
index = 4;
}
InitializeAnimation(this, this->animationState + index);
}
sub_08029FB4(this, this->x.HALF.HI - uVar1, this->y.HALF.HI - uVar2);
}
void sub_08029C08(Entity* this) {
this->action = 3;
this->actionDelay = gUnk_080CCDA0[this->entityType.form];
this->damageType = 0x6b;
this->attachedEntity->action = 2;
}
void sub_08029C2C(Entity* this) {
if (--this->actionDelay == 0) {
this->action = 4;
sub_0801D2B4(this, 0x7f);
EnqueueSFX(0x6c);
}
}
void sub_08029C50(Entity* this) {
if (this->parent->field_0x76.HALF.HI != 0) {
this->action = 5;
this->damageType = 0x6a;
}
}
void sub_08029C6C(Entity* this) {
sub_0802A18C(this);
sub_08029BC4(this);
if (this->parent->action != 3) {
this->action = 1;
sub_0801D2B4(this, 0x77);
} else {
sub_0802A16C(this);
}
}
void sub_08029C98(Entity* this) {
if (sub_0802A14C(this)) {
CreateFx(this, 0x48, 0);
DeleteEntity(this);
} else {
gUnk_080CCDA8[this->action](this);
}
}
void sub_08029CCC(Entity* this) {
this->action = 1;
this->spriteSettings.b.draw = 1;
sub_0802A058(this);
InitializeAnimation(this, 8);
}
void sub_08029CF0(Entity* this) {
if (sub_08029FE4(this)) {
InitializeAnimation(this, this->animationState + 8);
}
}
void sub_08029D08(Entity* this) {
this->action = 3;
this->actionDelay = 0x47;
}
void sub_08029D14(Entity* this) {
if (this->actionDelay) {
if (--this->actionDelay == 0) {
InitializeAnimation(this, this->animationState + 0xc);
sub_0801D2B4(this, 0x7f);
EnqueueSFX(0x6c);
}
} else {
GetNextFrame(this);
if (this->frames.all & 0x80) {
this->action = 4;
this->actionDelay = 0x78;
this->damageType = 0x6c;
this->boundingBox = &gUnk_080FD298;
EnqueueSFX(0x6b);
}
}
}
void sub_08029D78(Entity* this) {
sub_0802A0F8(this);
if (--this->actionDelay == 0) {
this->action = 5;
this->damageType = 0x6a;
this->boundingBox = (BoundingBox*)&gUnk_080FD2A0;
InitializeAnimation(this, this->animationState + 0x10);
}
}
void sub_08029DAC(Entity* this) {
GetNextFrame(this);
if (this->frames.all & 0x80) {
this->action = 6;
this->parent->field_0x76.HALF.HI = 1;
InitializeAnimation(this, this->animationState + 8);
}
}
void sub_08029DDC(Entity* this) {
this->action = 7;
}
void sub_08029DE4(Entity* this) {
sub_08029CF0(this);
if (this->parent->action != 3) {
this->action = 1;
sub_0801D2B4(this, 0x77);
} else {
sub_0802A16C(this);
}
}
NAKED
void sub_08029E0C(Entity* this) {
asm(".include \"asm/non_matching/madderpillar/sub_08029E0C.inc\"");
}
void sub_08029EEC(Entity* this) {
u32 uVar1 = (this->direction >> 3) + this->field_0x74.HALF.HI;
if (uVar1 != this->animationState) {
this->animationState = uVar1;
InitAnimationForceUpdate(this, uVar1);
}
}
void sub_08029F0C(Entity* this) {
switch (this->direction >> 3) {
case 0:
this->field_0x78.HWORD = this->y.HALF.HI - 0x10;
break;
case 1:
this->field_0x78.HWORD = this->x.HALF.HI + 0x10;
break;
case 2:
this->field_0x78.HWORD = this->y.HALF.HI + 0x10;
break;
case 3:
this->field_0x78.HWORD = this->x.HALF.HI - 0x10;
break;
}
}
bool32 sub_08029F48(Entity* this) {
switch (this->direction >> 3) {
case 0:
if (this->y.HALF.HI <= this->field_0x78.HWORD) {
this->y.HALF.HI = this->field_0x78.HWORD;
return TRUE;
}
break;
case 1:
if (this->x.HALF.HI >= this->field_0x78.HWORD) {
this->x.HALF.HI = this->field_0x78.HWORD;
return TRUE;
}
break;
case 2:
if (this->y.HALF.HI >= this->field_0x78.HWORD) {
this->y.HALF.HI = this->field_0x78.HWORD;
return TRUE;
}
break;
case 3:
if (this->x.HALF.HI <= this->field_0x78.HWORD) {
this->x.HALF.HI = this->field_0x78.HWORD;
return TRUE;
}
break;
}
return FALSE;
}
void sub_08029FB4(Entity* this, u32 x, u32 y) {
u8* dst = (u8*)&this->attachedEntity->field_0x78;
s32 unk = this->parent->field_0x7c.BYTES.byte2;
u8 idx = unk % 0xe;
dst[idx] = ((x + 8) & 0xf) | (((y + 8) & 0xf) << 4);
}
/* The optimizer is strong within you. */
bool32 sub_08029FE4(Entity* this) {
u8 state;
u8* dst = (u8*)&this->field_0x78;
s32 unk = this->parent->field_0x7c.BYTES.byte2 + 1;
s8 iVar6 = (dst[unk % 0xe] & 0xf) - 8;
s8 iVar5 = (dst[unk % 0xe] >> 4) - 8;
this->x.HALF.HI += iVar6;
this->y.HALF.HI += iVar5;
GetNextFrame(this);
state = 0xff;
if (iVar6 != 0) {
if (0 < iVar6) {
state = 1;
} else {
state = 3;
}
}
if (iVar5 != 0) {
if (0 < iVar5) {
state = 2;
} else {
state = 0;
}
}
if (state != 0xff && state != this->animationState) {
this->animationState = state;
return TRUE;
} else {
return FALSE;
}
}
void sub_0802A058(Entity* this) {
this->field_0x78.HALF.LO = 0x88;
this->field_0x78.HALF.HI = 0x88;
this->field_0x7a.HALF.LO = 0x88;
this->field_0x7a.HALF.HI = 0x88;
this->field_0x7c.BYTES.byte0 = 0x88;
this->field_0x7c.BYTES.byte1 = 0x88;
this->field_0x7c.BYTES.byte2 = 0x88;
this->field_0x7c.BYTES.byte3 = 0x88;
this->field_0x80.HALF.LO = 0x88;
this->field_0x80.HALF.HI = 0x88;
this->field_0x82.HALF.LO = 0x88;
this->field_0x82.HALF.HI = 0x88;
this->cutsceneBeh.HALF.LO = 0x88;
this->cutsceneBeh.HALF.HI = 0x88;
}
void sub_0802A098(Entity* this) {
u32 uVar1;
u32 uVar2;
s32 unk = (++this->field_0x7c.BYTES.byte2, this->field_0x7c.BYTES.byte2);
u8 idx = unk % 0xe;
if (idx == 0) {
this->field_0x7c.BYTES.byte2 = 0;
}
uVar1 = this->x.HALF.HI;
uVar2 = this->y.HALF.HI;
ProcessMovement(this);
if (sub_08029F48(this)) {
sub_08029E0C(this);
sub_08029EEC(this);
EnqueueSFX(0x104);
}
sub_08029FB4(this, this->x.HALF.HI - uVar1, this->y.HALF.HI - uVar2);
}
void sub_0802A0F8(Entity* this) {
if (this->currentHealth != 0) {
if ((this->bitfield & 0x80) && this->hurtBlinkTime != 0) {
Entity* ent = this;
u32 i;
for (i = 0; i < 6; i++) {
ent = ent->attachedEntity;
ent->hurtBlinkTime = this->hurtBlinkTime;
}
}
} else {
this->parent->flags &= ~0x80;
this->parent->currentHealth = 0;
this->parent->field_0xf = 0x69;
}
}
bool32 sub_0802A14C(Entity* this) {
u32 ret = FALSE;
if (this->parent->currentHealth == 0 || this->field_0x86.HALF.LO) {
ret = TRUE;
} else {
ret = FALSE;
}
return ret;
}
void sub_0802A16C(Entity* this) {
sub_0801D2B4(this, gUnk_080CCDD4[this->parent->field_0x7a.HWORD >> 2 & 3]);
}
void sub_0802A18C(Entity* this) {
if (this->bitfield & 0x80) {
switch (this->bitfield & 0x7f) {
case 0:
case 1:
case 2:
case 3:
case 0xf:
case 0x13:
case 0x1b:
case 0x1e:
break;
default:
EnqueueSFX(0x12e);
break;
}
}
}
// clang-format off
void (*const gUnk_080CCD44[])(Entity*) = {
sub_08029870,
sub_08029B2C,
sub_08029B2C,
sub_08029B2C,
sub_08029B2C,
sub_08029B2C,
sub_08029C98,
};
void (*const gUnk_080CCD60[])(Entity*) = {
sub_0802988C,
sub_080298A4,
sub_0802988C,
sub_08029980,
sub_08001242,
nullsub_14,
};
void (*const gUnk_080CCD78[])(Entity*) = {
sub_0802999C,
sub_08029A94,
sub_08029AA4,
sub_08029AE0,
};
void (*const gUnk_080CCD88[])(Entity*) = {
sub_08029B90,
sub_08029BC4,
sub_08029C08,
sub_08029C2C,
sub_08029C50,
sub_08029C6C,
};
const u8 gUnk_080CCDA0[] = {
0x00, 0x24,
0x30,
0x3A,
0x41,
0x45,
0x00,
0x00,
};
void (*const gUnk_080CCDA8[])(Entity*) = {
sub_08029CCC,
sub_08029CF0,
sub_08029D08,
sub_08029D14,
sub_08029D78,
sub_08029DAC,
sub_08029DDC,
sub_08029DE4,
};
const u8 gUnk_080CCDC8[] = {
0x08, 0x00,
0x18, 0x00,
0x10, 0x08,
0x10, 0x08,
0x18, 0x00,
0x18, 0x10,
};
const u16 gUnk_080CCDD4[] = {
0x80, 0x81,
0x82, 0x81,
};
// clang-format on
+4 -2
View File
@@ -10,7 +10,6 @@ extern u32 sub_0806F520();
extern void sub_0806F4E8();
extern void UpdateAnimationVariableFrames();
extern void sub_0804A720();
extern u32 Random();
extern Entity* sub_08049DF4(u32);
void Octorok_Pause();
@@ -233,7 +232,10 @@ const u8 gOctorokSpitChanceModifier[] = {
};
const u8 gOctorokNutOffset[] = {
0, -3, 4, 0, 0, 2, -4, 0,
0, -3,
4, 0,
0, 2,
-4, 0,
};
const s8 gUnk_080CA17E[] = {
+11 -11
View File
@@ -49,7 +49,7 @@ void sub_08023F44(Entity* this) {
void sub_08023F5C(Entity* this) {
if (this->damageType != 0x6e) {
if (this->bitfield == 0x80) {
*(u8*)&this->field_0x86 = 0x30;
this->field_0x86.HALF.LO = 0x30;
if ((this->field_0x82.HALF.HI & 0xf) == 3 && this->action == 6) {
switch (this->field_0x80.HALF.LO) {
@@ -155,8 +155,8 @@ void sub_080240B8(Entity* this) {
this->field_0x80.HALF.HI = Random() & 0x40;
this->field_0x82.HALF.LO = 0;
this->field_0x82.HALF.HI = 0x80;
*((u8*)&this->field_0x86 + 0) = 0;
*((u8*)&this->field_0x86 + 1) = 0;
this->field_0x86.HALF.LO = 0;
this->field_0x86.HALF.HI = 0;
this->actionDelay = 0;
this->field_0xf = 0x20;
this->field_0x3c |= 0x10;
@@ -727,19 +727,19 @@ void sub_08024C94(Entity* this) {
bool32 sub_08024CC0(Entity* this) {
bool32 uVar2;
uVar2 = 1;
uVar2 = TRUE;
if (!sub_08024C48(this, 1)) {
uVar2 = 0;
uVar2 = FALSE;
} else if (!sub_08049F1C(this, gUnk_020000B0, 0x50) || !sub_08049FDC(this, 3)) {
uVar2 = 0;
uVar2 = FALSE;
sub_08024C7C(this);
}
return uVar2;
}
void sub_08024D00(Entity* this) {
if (*(u8*)&this->field_0x86) {
(*(u8*)&this->field_0x86)--;
if (this->field_0x86.HALF.LO) {
this->field_0x86.HALF.LO--;
GetNextFrame(this);
} else {
sub_08024940(this);
@@ -804,9 +804,9 @@ void sub_08024E4C(Entity* this) {
this->cutsceneBeh.HALF.LO += 1 + (Random() & 1);
}
if (gUnk_02002A40.stats.health == 0 || *((u8*)&this->field_0x86 + 1) == 4) {
if (gUnk_02002A40.stats.health == 0 || this->field_0x86.HALF.HI == 4) {
this->cutsceneBeh.HALF.LO = 0x30;
*((u8*)&this->field_0x86 + 1) = 0;
this->field_0x86.HALF.HI = 0;
sub_08024F50(this);
this->field_0x80.HALF.LO = 0;
this->nonPlanarMovement = 0x40;
@@ -828,7 +828,7 @@ void sub_08024E4C(Entity* this) {
player->animationState = 4;
player->spritePriority.b1 = 0;
if (this->field_0xf == 0) {
(*((u8*)&this->field_0x86 + 1))++;
(this->field_0x86.HALF.HI++;
player->hurtBlinkTime = 8;
ModHealth(-2);
sub_0800449C(player, 0x7a);
+3 -3
View File
@@ -169,7 +169,7 @@ void sub_08025230(Entity* this) {
if (sub_0802571C(this)) {
this->action = 2;
this->actionDelay = 240;
this->field_0x86 = COORD_TO_TILE(this);
this->field_0x86.HWORD = COORD_TO_TILE(this);
}
} else {
this->field_0x78.HWORD--;
@@ -186,12 +186,12 @@ void sub_080252E0(Entity* this) {
GetNextFrame(this);
tile = COORD_TO_TILE(this);
if (tile == this->field_0x86) {
if (tile == this->field_0x86.HWORD) {
if (--this->actionDelay == 0) {
sub_080256B4(this);
}
} else {
this->field_0x86 = tile;
this->field_0x86.HWORD = tile;
this->actionDelay = 240;
}
+44 -5
View File
@@ -17,8 +17,9 @@ extern void (*const gUnk_080CCC00[])(Entity*);
extern void (*const gUnk_080CCC18[])(Entity*);
extern void (*const gUnk_080CCC3C[])(Entity*);
extern u8 gUnk_080CCC34[];
extern u8 gUnk_080CCC47[];
extern const u8 gUnk_080CCC34[];
extern const s8 gUnk_080CCC44[];
extern const u8 gUnk_080CCC47[];
extern BoundingBox gUnk_080FD260;
void RupeeLike(Entity* this) {
@@ -146,8 +147,6 @@ void sub_080294D4(Entity* this) {
}
}
extern s8 gUnk_080CCC44[];
void sub_0802953C(Entity* this) {
u8* pbVar3;
@@ -279,4 +278,44 @@ void sub_080297F0(Entity* this) {
this->palette.b.b0 = temp;
this->spriteVramOffset = 9;
InitializeAnimation(this, 0x54);
}
}
// clang-format off
void (*const gUnk_080CCC00[])(Entity*) = {
sub_08029300,
sub_08029318,
sub_08001324,
sub_080293B4,
sub_08001242,
nullsub_141,
};
void (*const gUnk_080CCC18[])(Entity*) = {
sub_0802940C,
sub_0802944C,
sub_08029474,
sub_080294D4,
sub_0802953C,
sub_08029610,
sub_08029630,
};
const u8 gUnk_080CCC34[] = {
0x54, 0x55,
0x56, 0x55,
0x56, 0x57,
};
void (*const gUnk_080CCC3C[])(Entity*) = {
sub_08029660,
sub_08029688,
};
const s8 gUnk_080CCC44[] = {
-1, -5, -20,
};
const u8 gUnk_080CCC47[] = {
2, 1, 0,
};
// clang-format on
+120
View File
@@ -0,0 +1,120 @@
#include "enemy.h"
#include "functions.h"
extern u32 sub_0804A024(Entity*, u32, u32);
extern bool32 sub_080AE4CC(Entity*, u32, u32, u32);
extern bool32 sub_080AF038(Entity*);
extern Entity gUnk_02027EB4;
extern Entity gUnk_0200D654;
void sub_0802BB10(Entity*);
bool32 sub_0802BB2C(Entity*, u32);
extern void (*const gUnk_080CD3C4[])(Entity*);
extern const u16 gUnk_080CD3D4[];
extern const s8 gUnk_080CD3DC[];
void SensorBladeTrap(Entity* this) {
gUnk_080CD3C4[this->action](this);
}
void sub_0802B9EC(Entity* this) {
this->action = 1;
this->field_0x78.HWORD = gUnk_080CD3D4[this->entityType.form];
this->field_0x7c.HALF.LO = this->cutsceneBeh.HWORD;
this->field_0x7c.HALF.HI = this->field_0x86.HWORD;
}
void sub_0802BA18(Entity* this) {
u32 direction = sub_0804A024(this, 1, 0xe);
if (direction == 0xff)
return;
if (sub_0802BB2C(this, direction))
return;
this->action = 2;
this->nonPlanarMovement = this->field_0x78.HWORD;
this->direction = direction;
switch (direction >> 3) {
case 0:
this->field_0x7a.HWORD = this->y.HALF.HI - this->field_0x7c.HALF.HI;
break;
case 1:
this->field_0x7a.HWORD = this->x.HALF.HI + this->field_0x7c.HALF.LO;
break;
case 2:
this->field_0x7a.HWORD = this->y.HALF.HI + this->field_0x7c.HALF.HI;
break;
case 3:
this->field_0x7a.HWORD = this->x.HALF.HI - this->field_0x7c.HALF.LO;
break;
}
}
void sub_0802BA8C(Entity* this) {
if (!sub_080AF038(this)) {
sub_0802BB10(this);
} else {
switch (this->direction >> 3) {
case 0:
if (this->field_0x7a.HWORD >= this->y.HALF.HI)
sub_0802BB10(this);
break;
case 1:
if (this->field_0x7a.HWORD <= this->x.HALF.HI)
sub_0802BB10(this);
break;
case 2:
if (this->field_0x7a.HWORD <= this->y.HALF.HI)
sub_0802BB10(this);
break;
case 3:
if (this->field_0x7a.HWORD >= this->x.HALF.HI)
sub_0802BB10(this);
break;
}
}
}
void sub_0802BAFC(Entity* this) {
if (!sub_080AF038(this)) {
this->action = 1;
}
}
void sub_0802BB10(Entity* this) {
this->action = 3;
this->nonPlanarMovement = 0xc0;
this->direction = this->direction ^ 0x10;
EnqueueSFX(0x74);
}
bool32 sub_0802BB2C(Entity* this, u32 param_2) {
Entity* ent = this->collisionLayer == 2 ? &gUnk_0200D654 : &gUnk_02027EB4;
const s8* ptr = &gUnk_080CD3DC[param_2 >> 2];
return sub_080AE4CC(ent, this->x.HALF.HI + ptr[0], this->y.HALF.HI + ptr[1], 0);
}
// clang-format off
void (*const gUnk_080CD3C4[])(Entity*) = {
sub_0802B9EC,
sub_0802BA18,
sub_0802BA8C,
sub_0802BAFC,
};
const u16 gUnk_080CD3D4[] = {
0x100, 0x180,
0x200, 0x280,
};
const s8 gUnk_080CD3DC[] = {
0, -12,
12, 0,
0, 12,
-12, 0,
};
// clang-format on
+140
View File
@@ -0,0 +1,140 @@
#include "enemy.h"
#include "entity.h"
#include "functions.h"
extern void (*const gUnk_080CD234[])(Entity*);
extern void (*const gUnk_080CD24C[])(Entity*);
void Spark(Entity* this) {
gUnk_080CD234[GetNextFunction(this)](this);
}
void sub_0802B2C8(Entity* this) {
gUnk_080CD24C[this->action](this);
}
void sub_0802B2E0(Entity* this) {
Entity* ent;
if (this->bitfield & 0x80) {
if ((this->bitfield & 0x7f) == 0x14) {
this->flags &= ~0x80;
this->hurtBlinkTime = 0;
this->spriteSettings.b.draw = 0;
this->action = 2;
ent = CreateFx(this, 2, 0);
if (ent) {
this->attachedEntity = ent;
this->actionDelay = 14;
CopyPosition(this, ent);
}
}
}
}
void nullsub_15(Entity* this) {
/* ... */
}
void sub_0802B33C(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->direction = (this->entityType).parameter;
this->field_0xf = 0x78;
InitializeAnimation(this, 0);
}
void sub_0802B35C(Entity* this) {
bool32 is_head;
GetNextFrame(this);
ProcessMovement(this);
is_head = this->entityType.form == 0;
if (this->collisions == 0) {
if (--this->field_0xf == 0) {
this->field_0xf = 0x78;
this->direction += is_head ? 0x08 : 0x18;
this->direction = DirectionRound(this->direction);
}
} else {
this->field_0xf = 0x78;
switch (DirectionRound(this->direction)) {
case DirectionNorth:
if (this->collisions & 0xe) {
this->direction = is_head ? DirectionWest : DirectionEast;
} else {
if ((this->collisions & 0xe000) == 0x4000 && is_head) {
this->direction = DirectionEast;
}
if ((this->collisions & 0xe00) == 0x400 && !is_head) {
this->direction = DirectionWest;
}
}
break;
case DirectionSouth:
if (this->collisions & 0xe0) {
this->direction = is_head ? DirectionEast : DirectionWest;
} else {
if ((this->collisions & 0xe000) == 0x2000 && !is_head) {
this->direction = DirectionEast;
}
if ((this->collisions & 0xe00) == 0x200 && is_head) {
this->direction = DirectionWest;
}
}
break;
case DirectionWest:
if (this->collisions & 0xe00) {
this->direction = is_head ? DirectionSouth : DirectionNorth;
} else {
if ((this->collisions & 0xe) == 4 && is_head) {
this->direction = DirectionNorth;
}
if ((this->collisions & 0xe0) == 0x40 && !is_head) {
this->direction = DirectionSouth;
}
}
break;
case DirectionEast:
if (this->collisions & 0xe000) {
this->direction = is_head ? DirectionNorth : DirectionSouth;
} else {
if ((this->collisions & 0xe) == 2 && !is_head) {
this->direction = DirectionNorth;
}
if ((this->collisions & 0xe0) == 0x20 && is_head) {
this->direction = DirectionSouth;
}
}
break;
}
}
}
void sub_0802B4A8(Entity* this) {
if (--this->actionDelay == 0) {
Entity* ent = CreateObjectWithParent(this, 0, 0x60, 0);
if (ent) {
ent->y.HALF.HI -= 4;
}
DeleteEntity(this);
}
}
// clang-format off
void (*const gUnk_080CD234[])(Entity*) = {
sub_0802B2C8,
sub_0802B2E0,
sub_08001324,
sub_0804A7D4,
sub_08001242,
nullsub_15,
};
void (*const gUnk_080CD24C[])(Entity*) = {
sub_0802B33C,
sub_0802B35C,
sub_0802B4A8,
};
// clang-format on
+439
View File
@@ -0,0 +1,439 @@
#include "enemy.h"
#include "entity.h"
#include "functions.h"
extern bool32 sub_0806FC80(Entity*, Entity*, u32);
extern Entity* sub_080A7EE0(u32);
extern Entity* sub_08049DF4(u32);
void sub_08028604(Entity*);
void sub_08028754(Entity*);
void sub_08028784(Entity*);
void sub_080287E0(Entity*);
void sub_08028728(Entity*);
bool32 sub_080286CC(Entity*);
bool32 sub_080288A4(Entity*);
void sub_08028858(Entity*);
void sub_080288C0(Entity*);
bool32 sub_08028828(u32, u32);
void sub_080287B4(Entity*);
extern void (*const gUnk_080CC790[])(Entity*);
extern void (*const gUnk_080CC7A8[])(Entity*);
extern const u8 gUnk_080CC7BC[];
extern const s8 gUnk_080CC7C0[];
extern const u8 gUnk_080CC7D0[];
extern const u16 gUnk_080CC7D8[];
extern const BoundingBox* const gUnk_080CC944[];
void SpearMoblin(Entity* this) {
EnemyFunctionHandler(this, gUnk_080CC790);
SetChildOffset(this, 0, 1, -0x20);
if (this->attachedEntity && this->attachedEntity->next) {
CopyPosition(this, this->attachedEntity);
}
}
void sub_0802826C(Entity* this) {
gUnk_080CC7A8[this->action](this);
}
void sub_08028284(Entity* this) {
if (this->field_0x43 != 0)
sub_0804A9FC(this, 0x1c);
sub_0804AA30(this, gUnk_080CC790);
if (this->bitfield & 0x80) {
if (this->action != 4) {
sub_08028754(this);
} else {
if ((this->bitfield & 0x3f) == 0) {
this->field_0x7a.HALF.LO++;
this->field_0x80.HALF.HI = 0x16;
sub_08028784(this);
}
}
}
this->attachedEntity->hurtBlinkTime = this->hurtBlinkTime;
if (this->currentHealth == 0) {
this->nonPlanarMovement = 0;
this->field_0x82.HALF.LO = 0;
sub_080287E0(this);
DeleteEntity(this->attachedEntity);
this->attachedEntity = NULL;
}
}
void nullsub_13(Entity* this) {
/* ... */
}
void sub_08028314(Entity* this) {
Entity* pEVar2;
sub_0804A720(this);
this->action = 1;
this->animationState = 0;
this->field_0x7a.HALF.HI = 0;
this->field_0x80.HALF.LO = 0;
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.HI = 0;
this->field_0x7a.HALF.LO = 0;
this->field_0x82.HALF.LO = 1;
if (this->actionDelay) {
this->animationState = this->entityType.parameter << 1;
this->actionDelay = 0x1e;
this->nonPlanarMovement = 0x80;
this->direction = this->animationState << 2;
sub_080287E0(this);
} else {
this->animationState = 0x10;
sub_08028604(this);
}
pEVar2 = sub_080A7EE0(3);
if (pEVar2 != NULL) {
pEVar2->parent = this;
this->attachedEntity = pEVar2;
}
}
void sub_08028378(Entity* this) {
if (this->field_0x80.HALF.HI != 0) {
this->field_0x80.HALF.HI--;
}
if (--this->actionDelay == 0) {
if (++this->field_0x80.HALF.LO >= 0x10) {
sub_08028728(this);
} else {
sub_08028604(this);
}
} else {
if (sub_080286CC(this)) {
this->field_0x7a.HALF.HI |= 1;
}
if (sub_080288A4(this)) {
sub_0800417E(this, this->collisions);
this->animationState = DirectionRoundUp(this->direction) >> 2;
this->field_0x82.HALF.HI++;
sub_080287E0(this);
}
}
if (this->field_0xf >= 0xc) {
if (this->field_0x7a.HALF.HI != 0) {
sub_08028754(this);
}
} else {
this->field_0xf++;
}
sub_08028858(this);
}
void sub_08028420(Entity* this) {
if (--this->actionDelay == 0) {
this->action = 3;
this->field_0x82.HALF.LO = 0;
this->field_0x80.HALF.LO = 0;
this->animationState = 0x10;
sub_08028604(this);
} else {
if (sub_080286CC(this)) {
this->field_0x7a.HALF.HI |= 1;
}
}
if (this->field_0xf >= 0xc) {
if (this->field_0x7a.HALF.HI != 0) {
sub_08028754(this);
}
} else {
this->field_0xf++;
}
sub_08028858(this);
}
void sub_08028488(Entity* this) {
if (--this->actionDelay == 0) {
switch (this->field_0x82.HALF.LO) {
case 3:
this->action = 4;
this->nonPlanarMovement = 0x180;
this->direction = sub_08049F84(this, 1);
EnqueueSFX(0x11e);
break;
case 2:
this->action = 2;
this->nonPlanarMovement = 0;
this->actionDelay = (Random() & 7) * 3 + 0x40;
break;
case 4:
this->direction = (this->direction + 0x10) & 0x18;
/* fallthrough */
case 1:
default:
this->action = 1;
this->field_0x82.HALF.LO = 1;
this->nonPlanarMovement = 0x80;
this->actionDelay = (Random() & 7) * 3 + 0x22;
break;
}
this->field_0xf = 0;
this->animationState = DirectionRoundUp(this->direction) >> 2;
sub_080287E0(this);
}
sub_08028858(this);
}
void sub_08028528(Entity* this) {
Entity* ent = sub_08049DF4(1);
const BoundingBox* box;
if (ent == NULL) {
this->field_0xf = 0;
sub_08028728(this);
} else {
sub_080288C0(this);
box = gUnk_080CC944[this->animationState >> 1];
this->boundingBox->unknown[0] = box->unknown[0];
this->boundingBox->unknown[1] = box->unknown[1];
this->boundingBox->unknown[6] = box->unknown[6];
this->boundingBox->unknown[7] = box->unknown[7];
if (this->field_0x7a.HALF.LO != 0) {
this->field_0x7a.HALF.LO = 0;
this->field_0x80.HALF.HI = 0x16;
sub_08028784(this);
} else {
if (++this->actionDelay == 0x20) {
u32 direction;
this->actionDelay = 0;
direction = GetFacingDirection(this, ent);
if (sub_08028828(this->direction, direction)) {
this->direction = direction;
}
}
if ((this->actionDelay & 7) == 0) {
EnqueueSFX(0xf0);
CreateFx(this, 2, 0x40);
}
if (++this->field_0x7a.HALF.HI == 0x80) {
this->field_0x7a.HALF.LO++;
}
}
if (0x20 < this->field_0x7a.HALF.HI) {
ProcessMovement(this);
}
GetNextFrame(this);
}
}
#if NON_MATCHING
void sub_08028604(Entity* this) {
this->field_0xf = 0;
if (this->field_0x82.HALF.LO == 1) {
this->actionDelay = gUnk_080CC7BC[Random() & 3];
this->nonPlanarMovement = 0x80;
if (sub_08049FA0(this) != 0) {
this->direction = gUnk_080CC7D0[Random() & 7] + 0x18 + this->direction & 0x18;
} else {
u32 iVar3 = sub_08049EE4(this);
u32 uVar1;
if (this->field_0x82.HALF.HI == '\0') {
uVar1 = gUnk_080CC7C0[Random() & 0xf];
} else {
uVar1 = gUnk_080CC7C0[Random() & 7];
this->actionDelay = this->actionDelay + 0x10;
this->field_0x82.HALF.HI--;
}
this->direction = iVar3 + uVar1 + 4U & 0x18;
}
} else {
this->actionDelay = 0xc;
this->nonPlanarMovement = 0;
}
if (this->direction >> 2 != this->animationState) {
this->animationState = this->direction >> 2;
sub_080287E0(this);
}
}
#else
NAKED
void sub_08028604(Entity* this) {
asm(".include \"asm/non_matching/spearMoblin/sub_08028604.inc\"");
}
#endif
bool32 sub_080286CC(Entity* this) {
if (this->field_0x80.HALF.HI == 0) {
Entity* ent = sub_08049DF4(1);
if (ent != NULL) {
if (this->field_0x82.HALF.LO == 2 && sub_0806FC80(this, ent, 0x30))
return TRUE;
if (sub_0806FC80(this, ent, 0x40) &&
DirectionRoundUp(GetFacingDirection(this, ent)) >> 2 == this->animationState)
return TRUE;
}
}
return FALSE;
}
void sub_08028728(Entity* this) {
this->animationState = DirectionRoundUp(this->direction) >> 2;
this->direction = this->animationState << 2;
this->field_0x82.HALF.HI >>= 1;
sub_080287B4(this);
this->field_0x82.HALF.LO = 2;
}
void sub_08028754(Entity* this) {
this->direction = sub_08049F84(this, 1);
this->animationState = DirectionRoundUp(this->direction) >> 2;
this->field_0x82.HALF.HI = 0;
sub_080287B4(this);
this->field_0x82.HALF.LO = 3;
}
void sub_08028784(Entity* this) {
this->animationState = DirectionRoundUp(this->direction) >> 2;
this->direction = this->animationState << 2;
this->field_0x82.HALF.HI = 0;
sub_080287B4(this);
this->actionDelay <<= 1;
this->field_0x82.HALF.LO = 4;
}
void sub_080287B4(Entity* this) {
this->action = 3;
this->actionDelay = 0x20;
this->field_0xf = 0;
this->field_0x80.HALF.LO = 0;
this->field_0x7a.HALF.HI = 0;
this->nonPlanarMovement = 0;
this->field_0x82.HALF.LO = 0;
sub_080287E0(this);
}
void sub_080287E0(Entity* this) {
u32 sprite = this->animationState >> 1;
switch (this->field_0x82.HALF.LO) {
case 0:
/* ... */
break;
case 1:
case 4:
sprite += 4;
break;
case 3:
sprite += 8;
break;
case 2:
sprite += 0xc;
break;
}
InitializeAnimation(this, sprite);
}
bool32 sub_08028828(u32 arg0, u32 arg1) {
if (DirectionRoundUp(arg1) == DirectionRoundUp(arg0)) {
u32 angle1 = (arg1 + 5) & 7;
u32 angle0 = (arg0 + 5) & 7;
if (angle1 < 3 && angle0 < 3)
return TRUE;
}
return FALSE;
}
void sub_08028858(Entity* this) {
const BoundingBox* box;
sub_080288C0(this);
box = gUnk_080CC944[this->animationState >> 1];
this->boundingBox->unknown[0] = box->unknown[0];
this->boundingBox->unknown[1] = box->unknown[1];
this->boundingBox->unknown[6] = box->unknown[6];
this->boundingBox->unknown[7] = box->unknown[7];
if (this->field_0x82.HALF.LO == 0) {
this->nonPlanarMovement = 0;
}
ProcessMovement(this);
GetNextFrame(this);
}
bool32 sub_080288A4(Entity* this) {
return (this->collisions & gUnk_080CC7D8[this->animationState >> 1]) != 0;
}
void sub_080288C0(Entity* this) {
Entity* ent = this->attachedEntity;
if (ent && (ent->bitfield & 0x80)) {
this->field_0x3e = ent->field_0x3e;
this->hurtBlinkTime = -ent->hurtBlinkTime;
this->field_0x46 = ent->field_0x46;
this->field_0x42 = ent->field_0x42;
ent->field_0x42 = 0;
}
}
// clang-format off
void (*const gUnk_080CC790[])(Entity*) = {
sub_0802826C,
sub_08028284,
sub_08001324,
sub_0804A7D4,
sub_08001242,
nullsub_13,
};
void (*const gUnk_080CC7A8[])(Entity*) = {
sub_08028314,
sub_08028378,
sub_08028420,
sub_08028488,
sub_08028528,
};
const u8 gUnk_080CC7BC[] = {
0x30, 0x60, 0x6C, 0x91,
};
const s8 gUnk_080CC7C0[] = {
0xF8, 0x0C,
0xF4, 0x08,
0x04, 0xFA,
0x06, 0xFC,
0x00, 0xFD,
0x01, 0x03,
0xFF, 0x02,
0x00, 0xFE,
};
const u8 gUnk_080CC7D0[] = {
0x08, 0x10,
0x08, 0x00,
0x10, 0x08,
0x10, 0x00,
};
const u16 gUnk_080CC7D8[] = {
0xE, 0xE000, 0xE0, 0xE00,
};
// clang-format on
+238
View File
@@ -0,0 +1,238 @@
#include "enemy.h"
#include "entity.h"
#include "functions.h"
extern u32 sub_0804A024(Entity*, u32, u32);
extern Entity* gUnk_020000B0;
void sub_0802B9B4(Entity*);
void sub_0802B7A4(Entity*);
void sub_0802B960(Entity*);
extern void (*const gUnk_080CD2D8[])(Entity*);
extern void (*const gUnk_080CD2F0[])(Entity*);
extern const u8 gUnk_080CD314[];
extern const s8 gUnk_080CD318[];
void SpikedBeetle(Entity* this) {
EnemyFunctionHandler(this, gUnk_080CD2D8);
SetChildOffset(this, 0, 1, -0x10);
}
void sub_0802B610(Entity* this) {
gUnk_080CD2F0[this->action](this);
}
void sub_0802B628(Entity* this) {
switch (this->bitfield & 0x7f) {
case 0:
case 4:
case 5:
case 6:
case 8:
case 9:
case 10:
case 0xb:
case 0xc:
if (this->action == 4) {
this->actionDelay = 1;
}
break;
case 2:
case 3:
case 0x16:
case 0x18:
case 0x19:
case 0x1a:
case 0x1d:
if (this->action < 6) {
this->action = 6;
this->field_0x20 = 0x18000;
this->nonPlanarMovement = 0xc0;
this->direction = this->field_0x3e;
this->field_0x42 = 0;
this->hurtBlinkTime = -8;
this->damageType = 100;
InitializeAnimation(this, 9);
}
}
if (this->field_0x43) {
sub_0804A9FC(this, 0x1c);
}
sub_0804AA30(this, gUnk_080CD2D8);
}
void nullsub_144(Entity* this) {
/* ... */
}
void sub_0802B72C(Entity* this) {
sub_0804A720(this);
this->actionDelay = 1;
this->animationState = 0xff;
sub_0802B7A4(this);
}
void sub_0802B744(Entity* this) {
u32 direction;
GetNextFrame(this);
if (sub_08049FDC(this, 1) && (direction = sub_0804A024(this, 1, 0xc), direction != 0xff)) {
this->action = 3;
this->actionDelay = 0x1e;
this->direction = DirectionRound(direction);
InitializeAnimation(this, 8);
} else {
if (--this->actionDelay == 0) {
this->action = 2;
this->actionDelay = 0x1e;
} else {
if (!ProcessMovement(this)) {
this->actionDelay = 1;
}
}
}
}
void sub_0802B7A4(Entity* this) {
if (--this->actionDelay == 0) {
this->action = 1;
this->actionDelay = gUnk_080CD314[Random() & 3];
this->nonPlanarMovement = 0x60;
sub_0802B960(this);
if (this->direction != 0xff) {
u32 animation = this->direction >> 3;
if (animation != this->animationState) {
this->animationState = animation & 3;
InitializeAnimation(this, animation);
}
}
}
}
void sub_0802B7FC(Entity* this) {
GetNextFrame(this);
if (--this->actionDelay == 0) {
this->action = 4;
this->actionDelay = 0x78;
this->nonPlanarMovement = 0x1c0;
}
}
void sub_0802B820(Entity* this) {
if (!sub_080AEFE0(this)) {
this->actionDelay = 1;
}
GetNextFrame(this);
if (--this->actionDelay == 0) {
sub_0802B9B4(this);
} else if (sub_08049FDC(this, 1)) {
if ((this->actionDelay & 0xf) == 0) {
sub_08004596(this, GetFacingDirection(this, gUnk_020000B0));
}
} else {
sub_0802B9B4(this);
}
}
void sub_0802B880(Entity* this) {
if (--this->actionDelay == 0) {
this->action = 2;
this->actionDelay = 0x3c;
this->animationState = DirectionToAnimationState(this->direction);
InitializeAnimation(this, this->animationState);
}
}
void sub_0802B8B0(Entity* this) {
sub_080AEFE0(this);
switch (sub_080044EC(this, 0x1800)) {
case 0:
this->action = 7;
this->actionDelay = 0x96;
/* fallthrough */
case 1:
EnqueueSFX(299);
break;
}
}
void sub_0802B8E0(Entity* this) {
if (--this->actionDelay) {
if (this->actionDelay < 0x3c && (this->actionDelay & 1)) {
this->spriteOffsetX += gUnk_080CD318[(this->actionDelay >> 1) & 3];
}
} else {
this->action = 8;
this->field_0x20 = 0x10000;
this->nonPlanarMovement = 0x60;
this->damageType = 99;
InitializeAnimation(this, this->animationState);
EnqueueSFX(299);
}
}
void sub_0802B948(Entity* this) {
if (!sub_08003FC4(this, 0x1800)) {
this->action = 1;
this->actionDelay = 1;
}
}
void sub_0802B960(Entity* this) {
if (sub_08049FDC(this, 1)) {
if ((Random() & 7) == 0) {
this->direction = DirectionRoundUp(sub_08049F84(this, 1));
return;
}
} else if (!sub_08049FA0(this)) {
if ((Random() & 3) == 0) {
this->direction = DirectionRoundUp(sub_08049EE4(this));
return;
}
}
this->direction = DirectionRound(Random());
}
void sub_0802B9B4(Entity* this) {
this->action = 5;
this->actionDelay = 0x3c;
this->animationState = (this->direction >> 3) & 3;
InitializeAnimation(this, this->animationState + 4);
}
// clang-format off
void (*const gUnk_080CD2D8[])(Entity*) = {
sub_0802B610,
sub_0802B628,
sub_08001324,
sub_0804A7D4,
sub_08001242,
nullsub_144,
};
void (*const gUnk_080CD2F0[])(Entity*) = {
sub_0802B72C,
sub_0802B744,
sub_0802B7A4,
sub_0802B7FC,
sub_0802B820,
sub_0802B880,
sub_0802B8B0,
sub_0802B8E0,
sub_0802B948,
};
const u8 gUnk_080CD314[] = {
0x30,
0x48,
0x60,
0x78,
};
const s8 gUnk_080CD318[] = {
1, -1, -1, 1,
};
// clang-format on
+219
View File
@@ -0,0 +1,219 @@
#include "enemy.h"
#include "entity.h"
#include "functions.h"
#include "area.h"
extern void sub_08001328(Entity*);
extern Entity* sub_08049DF4(u32);
extern void DoExitTransition(u32*);
extern u32* gUnk_0813AB1C[];
void sub_0802A78C(Entity*);
void sub_0802A7D0(Entity*);
extern void (*const gUnk_080CD07C[])(Entity*);
extern void (*const gUnk_080CD094[])(Entity*);
extern const s8 gUnk_080CD0B0[];
void WallMaster(Entity* this) {
gUnk_080CD07C[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
}
void sub_0802A434(Entity* this) {
sub_0802A78C(this);
gUnk_080CD094[this->action](this);
}
void sub_0802A454(Entity* this) {
if (this->damageType != 0x75 && ((this->bitfield & 0x7f) == 0 || (this->bitfield & 0x7f) == 0x1e)) {
this->action = 5;
this->flags &= ~0x80;
this->field_0x7c.HALF.HI = gPlayerEntity.x.HALF.HI;
this->field_0x80.HWORD = gPlayerEntity.y.HALF.HI;
this->field_0x82.HWORD = gPlayerEntity.height.HALF.HI;
if (this->action != 3) {
InitializeAnimation(this, 1);
}
}
if (this->field_0x42)
if (this->field_0x42 > 4)
this->field_0x42 -= 4;
if (this->field_0x43 != 0) {
sub_0804A9FC(this, 0x1c);
}
sub_0804AA30(this, gUnk_080CD07C);
}
void nullsub_142(Entity* this) {
/* ... */
}
void sub_0802A4E4(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->collisionLayer = 3;
this->field_0x7c.BYTES.byte1 = Random();
this->field_0x7a.HWORD = this->entityType.parameter * 0x3c;
this->field_0x7c.BYTES.byte0 = this->actionDelay;
this->field_0x78.HWORD = this->actionDelay * 0x3c;
UpdateSpriteForCollisionLayer(this);
sub_0802A7D0(this);
}
void sub_0802A534(Entity* this) {
if (this->field_0x78.HWORD) {
this->field_0x78.HWORD--;
} else if (this->field_0x7a.HWORD == 0) {
Entity* ent = sub_08049DF4(1);
if (ent != NULL) {
this->action = 2;
this->actionDelay = 0x5a;
this->flags |= 0x80;
this->spriteSettings.b.draw = 3;
this->x.HALF.HI = ent->x.HALF.HI;
this->y.HALF.HI = ent->y.HALF.HI;
this->height.HALF.HI = -0x80;
this->spritePriority.b1 = 1;
this->spriteSettings.b.shadow = 2;
InitializeAnimation(this, 2);
sub_0802A7D0(this);
}
}
}
void sub_0802A5B8(Entity* this) {
sub_0802A7D0(this);
if (this->actionDelay) {
if (--this->actionDelay == 0) {
EnqueueSFX(0x12d);
InitializeAnimation(this, 0);
}
} else {
this->height.HALF.HI += 3;
if (-1 < this->height.HALF.HI) {
this->action = 3;
this->spriteSettings.b.draw = 1;
this->height.HALF.HI = 0;
InitializeAnimation(this, 1);
}
}
}
/* Kids... don't try to optimize code like this... */
void sub_0802A610(Entity* this) {
u32 flags;
GetNextFrame(this);
sub_0802A7D0(this);
flags = this->frames.all & 0x80;
if (flags) {
this->action = 4;
this->actionDelay = 0x1e;
} else if (this->frames.all & 1) {
this->frames.all = flags;
this->damageType = 0x75;
}
}
void sub_0802A650(Entity* this) {
sub_0802A7D0(this);
this->height.HALF.HI -= 2;
if (-0xa0 > this->height.HALF.HI) {
this->action = 1;
this->flags &= ~0x80;
this->spriteSettings.b.draw = 0;
this->damageType = 0x74;
this->field_0x78.HWORD = this->field_0x7c.BYTES.byte0 * 0x3c;
}
}
void sub_0802A69C(Entity* this) {
u32 flags;
sub_0802A7D0(this);
gPlayerState.field_0xa |= 0x80;
gPlayerState.field_0x1a[0] |= 0x80;
gPlayerEntity.x.HALF.HI = this->field_0x7c.HALF.HI;
gPlayerEntity.y.HALF.HI = this->field_0x80.HWORD;
gPlayerEntity.height.HALF.HI = this->field_0x82.HWORD;
if (gPlayerEntity.height.HALF.HI != this->height.HALF.HI) {
if (gPlayerEntity.height.HALF.HI < this->height.HALF.HI) {
this->height.HALF.HI--;
} else {
this->height.HALF.HI++;
}
}
/* sigh... */
GetNextFrame(this);
flags = this->frames.all & 0x80;
if (flags) {
this->action = 6;
this->actionDelay = 0x1e;
} else if (this->frames.all & 0x1) {
this->frames.all = flags;
this->spriteOffsetY = 3;
gPlayerEntity.spriteSettings.b.draw = 0;
}
}
void sub_0802A734(Entity* this) {
sub_0802A7D0(this);
if (--this->actionDelay == 0) {
sub_0805E5A8();
DoExitTransition(gUnk_0813AB1C[gArea.regret]);
} else {
this->height.WORD -= 0x20000;
gPlayerState.field_0xa |= 0x80;
gPlayerState.field_0x1a[0] |= 0x80;
}
}
void sub_0802A78C(Entity* this) {
if (this->action != 0) {
if (sub_08049FDC(this, 1)) {
if (this->field_0x78.HWORD == 0) {
if (this->field_0x7a.HWORD) {
this->field_0x7a.HWORD--;
}
}
} else {
this->field_0x7a.HWORD = this->entityType.parameter * 0x3c + 1;
}
}
}
void sub_0802A7D0(Entity* this) {
u32 unk = gUnk_080CD0B0[(this->field_0x7c.BYTES.byte1++ >> 3) & 7] + 0x100;
sub_0805EC9C(this, unk, unk, 0);
}
// clang-format off
void (*const gUnk_080CD07C[])(Entity*) = {
sub_0802A434,
sub_0802A454,
sub_08001328,
sub_0804A7D4,
sub_08001242,
nullsub_142,
};
void (*const gUnk_080CD094[])(Entity*) = {
sub_0802A4E4,
sub_0802A534,
sub_0802A5B8,
sub_0802A610,
sub_0802A650,
sub_0802A69C,
sub_0802A734,
};
const s8 gUnk_080CD0B0[] = {
-2, -4, -2, 0, 2, 4, 2, 0,
};
// clang-format on
+99
View File
@@ -0,0 +1,99 @@
#include "enemy.h"
#include "entity.h"
#include "functions.h"
#include "screen.h"
void sub_0802A39C(Entity*);
void sub_0802A334(Entity*);
extern u16 gUnk_02001A40[];
extern void (*const gUnk_080CD030[])(Entity*);
extern const u8 gUnk_080CD03C[];
extern const s8 gUnk_080CD040[];
void WaterDrop(Entity* this) {
gUnk_080CD030[this->action](this);
}
void sub_0802A250(Entity* this) {
Entity* ent;
this->action = 1;
this->actionDelay = 0;
this->field_0x20 = -0x30000;
this->nonPlanarMovement = gUnk_080CD03C[Random() & 3];
this->direction = gUnk_080CD040[Random() & 3] + 0x18;
this->collisionLayer = 2;
InitializeAnimation(this, 0);
UpdateSpriteForCollisionLayer(this);
ent = CreateObject(0x66, 0, 0);
if (ent) {
ent->parent = this;
}
}
void sub_0802A2B4(Entity* this) {
if (!sub_08003FC4(this, 0x2800)) {
this->action = 2;
this->spritePriority.b0 = 7;
EnqueueSFX(0x84);
} else {
sub_0806F69C(this);
}
sub_0802A39C(this);
if (-8 < this->height.HALF.HI) {
sub_0802A334(this);
}
}
void sub_0802A2FC(Entity* this) {
GetNextFrame(this);
if (this->frames.all & 0x80) {
DeleteEntity(this);
} else if (this->frames.all & 1) {
this->flags &= ~0x80;
} else {
sub_0802A39C(this);
}
}
void sub_0802A334(Entity* this) {
u32 x = (this->x.HALF.HI - gRoomControls.roomScrollX + gScreen.bg.bg1yOffset) >> 3;
u32 y = (this->y.HALF.HI - gRoomControls.roomScrollY + gScreen.bg.bg2xOffset) >> 3;
if (gUnk_02001A40[(x & 0x1fU) + (y & 0x1fU) * 0x20 + 0x400]) {
this->collisionLayer = 2;
} else {
this->collisionLayer = 1;
}
UpdateSpriteForCollisionLayer(this);
}
void sub_0802A39C(Entity* this) {
u32 x = (gPlayerEntity.x.HALF.HI - gRoomControls.roomScrollX + gScreen.bg.bg1yOffset) >> 3;
u32 y = (gPlayerEntity.y.HALF.HI - gRoomControls.roomScrollY + gScreen.bg.bg2xOffset - 10) >> 3;
if (gUnk_02001A40[(x & 0x1fU) + (y & 0x1fU) * 0x20 + 0x400]) {
this->flags &= ~0x80;
} else {
this->flags |= 0x80;
}
}
// clang-format off
void (*const gUnk_080CD030[])(Entity*) = {
sub_0802A250,
sub_0802A2B4,
sub_0802A2FC,
};
const u8 gUnk_080CD03C[] = {
0x60, 0x80,
0xA0, 0xC0,
};
const s8 gUnk_080CD040[] = {
-2, -1, -1, -3,
};
// clang-format on
+1 -1
View File
@@ -22,7 +22,7 @@ extern void DeleteManager(Manager20*);
void sub_0805B7A0(Manager20* this) {
Entity* tmp = CreateObject(this->manager.unk_0e, this->manager.unk_0a, this->manager.unk_0b);
if (!tmp) return;
tmp->field_0x86 = this->unk_3e;
tmp->field_0x86.HWORD = this->unk_3e;
if (CheckFlags(this->unk_3e)) {
tmp->x.HALF.HI = this->unk_36 | (this->unk_37&0xF)<<8;//r1
tmp->y.HALF.HI = this->unk_3c & 0xFFF;
+1 -2
View File
@@ -2,16 +2,15 @@
#include "entity.h"
#include "player.h"
#include "structures.h"
#include "functions.h"
extern void (*gUnk_081140D4[])(Entity*);
extern u16 gUnk_081140CC[];
extern void sub_0805E3A0(Entity*, u32);
extern void sub_0806D0B0(Entity*);
extern void sub_0807DD64(Entity*);
extern void sub_0807DDAC(Entity*, u32);
extern void sub_0807DDE4(Entity*);
extern u32 Random(void);
extern void PlaySFX(u32);
extern void sub_0806D02C(Entity*);
extern Entity* FindEntityInListByForm(u32, u32, u32, u32, u32);
-1
View File
@@ -15,7 +15,6 @@ extern void (*gUnk_08111914[])(Entity*);
extern void (*gUnk_08111928[])(Entity*);
extern Dialog gUnk_08111938[];
extern void PlaySFX(u32);
extern u32 Random();
extern u32 UpdateFuseInteraction(Entity*);
extern PlayerState gPlayerState;
-1
View File
@@ -21,7 +21,6 @@ extern void sub_08060158(Entity*);
extern u32 CheckKinstoneFused(u32);
extern Entity* FindEntityInListBySubtype(u32, u32, u32);
extern void DeleteEntity(Entity*);
extern u32 Random(void);
extern void ModBombs(s32);
extern SpriteLoadData gUnk_0810A348;
-1
View File
@@ -6,7 +6,6 @@
extern void sub_08068780(Entity*);
extern void sub_08078778(Entity*);
extern u32 Random(void);
extern void sub_0807DD50(Entity*);
extern void sub_0806F118(Entity*);
extern void sub_0807DDAC(Entity*, u32);
-1
View File
@@ -8,7 +8,6 @@ extern u32 sub_0806F5A4(u32);
extern void sub_0806F118(Entity*);
extern Entity* CreateFx(Entity*, u32, u32);
extern void PlaySFX(u32);
extern u32 Random(void);
extern void sub_0807000C(Entity*);
extern u32 sub_0801E99C(Entity*);
extern void sub_0807DD50(Entity*);
-1
View File
@@ -35,7 +35,6 @@ extern void sub_08062048(Entity*);
extern void sub_08078784(Entity*, u32);
extern void sub_08078778(Entity*);
extern u32 sub_0806F5B0(u32);
extern u32 Random(void);
extern void ResolveEntityOnTop(Entity*, Entity*);
extern void sub_08078850(Entity*, u32, u8, u32*);
+2 -2
View File
@@ -23,7 +23,7 @@ void sub_08098D1C(Entity* this) {
this->action = 1;
this->height.HALF.HI = -0x10;
temp = this->field_0x86;
temp = this->field_0x86.HWORD;
if ((temp != 0) && !CheckFlags(temp)) {
this->action = 1;
@@ -39,7 +39,7 @@ void sub_08098D1C(Entity* this) {
void sub_08098D6C(Entity* this) {
Entity* ent;
if (CheckFlags(this->field_0x86)) {
if (CheckFlags(this->field_0x86.HWORD)) {
this->action = 2;
this->actionDelay = 0x2d;
ent = CreateFx(this, 0x43, 0);
+3 -3
View File
@@ -22,7 +22,7 @@ void sub_08081AE0(Entity* this) {
this->field_0x74.HWORD = (((this->x.HALF.HI - gRoomControls.roomOriginX)>>4) & 0x3F) |
((((this->y.HALF.HI - gRoomControls.roomOriginY)>>4) & 0x3F) << 6);
this->field_0x70.HALF.HI = GetTileType(this->field_0x74.HWORD, this->collisionLayer);
if (this->entityType.form == 0 && CheckFlags(this->field_0x86)) {
if (this->entityType.form == 0 && CheckFlags(this->field_0x86.HWORD)) {
this->action = 5;
SetTileType(0x7A, this->field_0x74.HWORD, this->collisionLayer);
} else {
@@ -92,7 +92,7 @@ void sub_08081C30(Entity* this) {
}
} else {
this->action = 2;
ClearFlag(this->field_0x86);
ClearFlag(this->field_0x86.HWORD);
SetTileType(0x77, this->field_0x74.HWORD, this->collisionLayer);
PlaySFX(0x10C);
}
@@ -257,7 +257,7 @@ u32 sub_08081F7C(Entity* this, u32 r7) {
this->attachedEntity->spriteOffsetY = 0xfc;
} else {
if (this->actionDelay == 6) {
SetFlag(this->field_0x86);
SetFlag(this->field_0x86.HWORD);
SetTileType(r7, this->field_0x74.HWORD, this->collisionLayer);
sub_08081F24(this);
PlaySFX(0x10C);
+4 -5
View File
@@ -3,6 +3,7 @@
#include "room.h"
#include "player.h"
#include "flags.h"
#include "functions.h"
extern void sub_0809F7BC(Entity*);
extern void PlaySFX(u32);
@@ -13,7 +14,6 @@ extern void DeleteThisEntity();
extern u32 CheckRoomFlag(u32);
extern void sub_08078A90(u32);
extern void sub_08078B48(void);
extern u32 Random(void);
extern void sub_0806F69C(Entity*);
extern void (*gUnk_08124798[])(Entity*);
extern void (*gUnk_081247A0[])(Entity*);
@@ -23,7 +23,6 @@ extern void PositionEntityOnTop(Entity*, Entity*);
extern void sub_0807BB68(u32*, u32, u32);
extern u8 gUnk_02034490;
extern u32 gScreenTransition;
extern void* gUnk_080DD750;
extern Entity gPlayerEntity;
extern PlayerState gPlayerState;
@@ -62,7 +61,7 @@ void sub_0809F548(Entity* this) {
sub_0809F814((((this->x.HALF.HI - gRoomControls.roomOriginX) >> 4) & 63) |
(((this->y.HALF.HI - gRoomControls.roomOriginY) >> 4) & 63) << 6);
} else {
if ((gScreenTransition & 7) == 0) {
if ((gScreenTransition.frameCount & 7) == 0) {
sub_0809F7BC(this);
}
sub_0809F7F4(this);
@@ -110,7 +109,7 @@ void sub_0809F61C(Entity* this) {
sub_0809F814((((this->x.HALF.HI - gRoomControls.roomOriginX) >> 4) & 63) |
(((this->y.HALF.HI - gRoomControls.roomOriginY) >> 4) & 63) << 6);
} else {
if ((gScreenTransition & 7) == 0) {
if ((gScreenTransition.frameCount & 7) == 0) {
sub_0809F7BC(this);
}
sub_0809F7F4(this);
@@ -145,7 +144,7 @@ void sub_0809F700(Entity* this) {
this->actionDelay = (Random() & 30) + 8;
this->flags = this->flags | 12;
}
if ((gScreenTransition & 3) == 0) {
if ((gScreenTransition.frameCount & 3) == 0) {
uVar2 = Random();
this->spriteOffsetX = gUnk_081247C0[uVar2 & 7];
this->spriteOffsetY = gUnk_081247C0[uVar2 >> 4 & 7];
+2 -2
View File
@@ -40,8 +40,8 @@ void sub_0809ED88(Entity *this)
{
sub_0809F08C();
sub_0809EE44(this);
if (this->field_0x86 != 0) {
if (this->cutsceneBeh.HWORD == this->field_0x86) {
if (this->field_0x86.HWORD != 0) {
if (this->cutsceneBeh.HWORD == this->field_0x86.HWORD) {
if (CheckFlags(this->cutsceneBeh.HWORD)) {
return;
}
+4 -4
View File
@@ -4,6 +4,7 @@
#include "screen.h"
#include "greatFairy.h"
#include "structures.h"
#include "functions.h"
enum {
BEHAVIORS,
@@ -550,14 +551,14 @@ void sub_08087424(Entity* arg0, struct_08087424* arg1) {
void sub_0808747C(u32 arg0, u32 arg1) {
u32 iVar1;
iVar1 = FindEntityInListByForm(0x6, 0xf, 0x6, 0xb, 0x0);
iVar1 = (u32)FindEntityInListByForm(0x6, 0xf, 0x6, 0xb, 0x0);
if (iVar1 != 0) {
iVar1 = 1;
}
*(u32*)(arg1 + 0x14) = iVar1;
}
//clang-format off
// clang-format off
void (*const GreatFairy_Main[])(Entity*) = {
GreatFairy_CallBehavior,
GreatFairy_WingsCallBehavior,
@@ -647,5 +648,4 @@ void (*const GreatFairy_Form2Behaviors[])(Entity*) = {
sub_08087264,
sub_0808727C
};
//clang-format on
// clang-format on
+1 -1
View File
@@ -37,7 +37,7 @@ static void sub_0808E6A0(Entity* this) {
}
static void sub_0808E6E4(Entity* this) {
if (CheckFlags(this->field_0x86)) {
if (CheckFlags(this->field_0x86.HWORD)) {
this->action = 2;
this->spriteSettings.b.draw = 1;
this->spriteRendering.b0 = 3;
+2 -2
View File
@@ -20,7 +20,7 @@ void sub_08091F14(Entity* this) {
this->animIndex = 0;
this->field_0x70.HALF.LO = COORD_TO_TILE(this);
puVar3 = &this->field_0x70.HALF.LO;
if (CheckFlags(this->field_0x86) != 0) {
if (CheckFlags(this->field_0x86.HWORD) != 0) {
this->action = 2;
this->spriteSettings.b.draw = TRUE;
SetTileType(0x1a2, *puVar3 - 0x41, this->collisionLayer);
@@ -39,6 +39,6 @@ void sub_08092000(Entity* this) {
if (GetTileType(*(u16*)&this->field_0x70.HALF.LO, this->collisionLayer) == 0x1a6) {
this->action = 2;
this->spriteSettings.b.draw = TRUE;
SetFlag(this->field_0x86);
SetFlag(this->field_0x86.HWORD);
}
}
+2 -2
View File
@@ -18,7 +18,7 @@ void JailBars(Entity *this)
void sub_080A08C4(Entity *this)
{
if (CheckFlags(this->field_0x86) == 0) {
if (CheckFlags(this->field_0x86.HWORD) == 0) {
this->action = 1;
sub_080A0960(this, 0);
}
@@ -34,7 +34,7 @@ void sub_080A08C4(Entity *this)
void sub_080A0910(Entity *this)
{
if (CheckFlags(this->field_0x86) != 0) {
if (CheckFlags(this->field_0x86.HWORD) != 0) {
this->action = 2;
sub_080A0960(this, 1);
PlaySFX(0x10b);
+6 -6
View File
@@ -45,10 +45,10 @@ void sub_0809EA34(Entity* this) {
void sub_0809EA80(Entity* this) {
if ((this->bitfield & 0x80) != 0) {
if (CheckFlags(this->field_0x86) != 0) {
ClearFlag(this->field_0x86);
if (CheckFlags(this->field_0x86.HWORD) != 0) {
ClearFlag(this->field_0x86.HWORD);
} else {
SetFlag(this->field_0x86);
SetFlag(this->field_0x86.HWORD);
}
EnqueueSFX(0x110);
}
@@ -59,7 +59,7 @@ void sub_0809EABC(Entity* this) {
bool32 anySet;
u32 f;
f = CheckFlags(this->field_0x86);
f = CheckFlags(this->field_0x86.HWORD);
anySet = (-f | f) >> 0x1F;
if (this->frameIndex != anySet) {
this->frameIndex = anySet;
@@ -122,7 +122,7 @@ void sub_0809EBD8(Entity* this) {
this->action = 2;
this->actionDelay = 0x10;
this->frameIndex = 2;
SetFlag(this->field_0x86);
SetFlag(this->field_0x86.HWORD);
EnqueueSFX(0x110);
}
}
@@ -136,7 +136,7 @@ void sub_0809EC08(Entity* this) {
if (--this->actionDelay == 0) {
this->action = 1;
this->frameIndex = 3;
ClearFlag(this->field_0x86);
ClearFlag(this->field_0x86.HWORD);
EnqueueSFX(0x110);
}
}
+3 -3
View File
@@ -31,7 +31,7 @@ void Mask(Entity *this) {
void sub_080929A4(Entity *this) {
if (this->entityType.parameter & 0xC0) {
if (CheckFlags(this->field_0x86)) {
if (CheckFlags(this->field_0x86.HWORD)) {
s32 field_0x0a;
switch (this->entityType.parameter & 0xC0) {
@@ -45,7 +45,7 @@ void sub_080929A4(Entity *this) {
goto switchEnd;
}
ClearFlag(this->field_0x86);
ClearFlag(this->field_0x86.HWORD);
break;
case 0x80:
DeleteThisEntity();
@@ -117,7 +117,7 @@ void sub_08092B0C(Entity *this) {
case 0x80:
EnqueueSFX(0x72);
case 0x40:
SetFlag(this->field_0x86);
SetFlag(this->field_0x86.HWORD);
break;
}
+1 -1
View File
@@ -77,7 +77,7 @@ void sub_080A074C(Entity *this)
void sub_080A07BC(Entity *this)
{
if (CheckFlags(this->field_0x86)) {
if (CheckFlags(this->field_0x86.HWORD)) {
this->action = 4;
this->actionDelay = 0xc;
this->direction = 0x10;
-1
View File
@@ -1,7 +1,6 @@
#include "global.h"
#include "entity.h"
extern u32 Random();
extern bool32 CheckIsDungeon();
extern void sub_080AE068(Entity*);
extern void LoadFixedGFX(Entity*, u32);
+2 -6
View File
@@ -1,10 +1,8 @@
#include "global.h"
#include "entity.h"
#include "functions.h"
extern void sub_08086A6C();
extern s32 sub_080044EC();
extern void ProcessMovement();
extern u32 Random(void);
extern void (*gUnk_081206C4[99])(Entity*);
@@ -33,12 +31,10 @@ void sub_080869DC(Entity* ent) {
}
void sub_08086A28(Entity* ent) {
s32 iVar1;
if (ent->attachedEntity->next == NULL) {
ent->action = 2;
} else {
iVar1 = sub_080044EC(ent, 10240);
u32 iVar1 = sub_080044EC(ent, 10240);
if (iVar1 == 0) {
ent->action = 2;
}
+1 -1
View File
@@ -30,7 +30,7 @@ void sub_08089B18(Entity *this)
CopyPosition(this->parent, this);
break;
case 4:
if (!CheckFlags(this->field_0x86)) {
if (!CheckFlags(this->field_0x86.HWORD)) {
this->spriteSettings.b.draw = FALSE;
this->previousActionFlag = 1;
return;
+2 -2
View File
@@ -20,7 +20,7 @@ void ObjectA(Entity *this) {
uVar2 = 0x34;
}
this->field_0x70.HALF.LO = uVar2;
if (CheckFlags(this->field_0x86) != 0) {
if (CheckFlags(this->field_0x86.HWORD) != 0) {
SetTileType(*(u16*)&this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer);
if ((gRoomControls.unk2 & 1) != 0) {
gUnk_02000070 = 0;
@@ -31,7 +31,7 @@ void ObjectA(Entity *this) {
}
} else if (this->interactType != 0) {
SetTileType(*(u16*)&this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer);
SetFlag(this->field_0x86);
SetFlag(this->field_0x86.HWORD);
CreateDust(this);
sub_080526F8(-1);
DeleteThisEntity();
+3 -3
View File
@@ -28,7 +28,7 @@ void Pot(Entity* this) {
}
void sub_0808222C(Entity* this) {
if (this->entityType.parameter == 1 && CheckFlags(this->field_0x86)) {
if (this->entityType.parameter == 1 && CheckFlags(this->field_0x86.HWORD)) {
DeleteThisEntity();
}
@@ -269,7 +269,7 @@ static void sub_08082850(Entity* this, Entity* parent) {
}
if (this->entityType.parameter == 1) {
SetFlag(this->field_0x86);
SetFlag(this->field_0x86.HWORD);
}
DeleteThisEntity();
@@ -290,7 +290,7 @@ u32 sub_0808288C(Entity* this, u32 form, u32 arg2, u32 arg3) {
if (entity) {
if (arg3 == 2) {
entity->actionDelay = 5;
entity->field_0x86 = this->field_0x86;
entity->field_0x86.HWORD = this->field_0x86.HWORD;
} else {
entity->actionDelay = 0;
}
+6 -6
View File
@@ -32,7 +32,7 @@ void sub_080851AC(Entity* this) {
}
this->animationState = this->entityType.parameter & 2;
if ((this->entityType).form == 3) {
uVar1 = CheckFlags(this->field_0x86);
uVar1 = CheckFlags(this->field_0x86.HWORD);
this->field_0x7a.HWORD = uVar1;
if ((u16)(uVar1 & -1) != 0) {
this->animationState = (this->animationState + 2) & 3;
@@ -45,11 +45,11 @@ void sub_080851AC(Entity* this) {
}
void sub_08085264(Entity* this) {
if (CheckFlags(this->field_0x86)) {
if (CheckFlags(this->field_0x86.HWORD)) {
this->action = 2;
this->field_0xf = 8;
if (this->entityType.form == 1) {
ClearFlag(this->field_0x86);
ClearFlag(this->field_0x86.HWORD);
}
this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3;
InitializeAnimation(this, this->animationState);
@@ -62,7 +62,7 @@ void sub_080852B4(Entity* this) {
if (--this->field_0xf == 0) {
this->action = 3;
this->field_0xf = this->actionDelay;
this->field_0x7a.HWORD = CheckFlags(this->field_0x86);
this->field_0x7a.HWORD = CheckFlags(this->field_0x86.HWORD);
this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3;
InitializeAnimation(this, this->animationState);
sub_08085394(this);
@@ -77,13 +77,13 @@ void sub_08085308(Entity* this) {
case 1:
break;
case 2:
if (CheckFlags(this->field_0x86) == 0) {
if (CheckFlags(this->field_0x86.HWORD) == 0) {
this->action = 1;
return;
}
break;
case 3:
if (CheckFlags(this->field_0x86) == *(u16*)&this->field_0x7a) {
if (CheckFlags(this->field_0x86.HWORD) == *(u16*)&this->field_0x7a) {
this->field_0xf = 0xff;
} else {
this->field_0xf = 1;
+1 -1
View File
@@ -1,7 +1,7 @@
#include "global.h"
#include "entity.h"
#include "functions.h"
extern u32 Random(void);
extern void sub_0806F69C(Entity*);
extern void (*const gUnk_08121060[])(Entity*);
+2 -2
View File
@@ -23,7 +23,7 @@ void TreeHidingPortal(Entity* this) {
}
void sub_0809E83C(Entity* this) {
if (CheckFlags(this->field_0x86)) {
if (CheckFlags(this->field_0x86.HWORD)) {
sub_0809E96C(this);
DeleteThisEntity();
}
@@ -60,7 +60,7 @@ void sub_0809E8BC(Entity* this) {
void sub_0809E8EC(Entity* this) {
if (--this->actionDelay == 0) {
SetFlag(this->field_0x86);
SetFlag(this->field_0x86.HWORD);
sub_08078A90(0);
PlaySFX(0x73);
DeleteThisEntity();