Merge pull request #46 from HookedBehemoth:leever_guard

Nonmatching (Leever, guard)
This commit is contained in:
notyouraveragehooman
2020-08-08 10:24:43 -07:00
committed by GitHub
5 changed files with 296 additions and 493 deletions
+118 -145
View File
@@ -22,115 +22,100 @@ extern Entity* gUnk_020000B0;
extern u8 gUnk_080CA4C8[];
extern u16 gUnk_080CA4CA[];
extern s16 gSineTable[];
void Leever(Entity *this)
{
EnemyFunctionHandler(this, gUnk_080CA49C);
SetChildOffset(this, 0, 1, -0x10);
void Leever(Entity* this) {
EnemyFunctionHandler(this, gUnk_080CA49C);
SetChildOffset(this, 0, 1, -0x10);
}
void sub_0801FC28(Entity *this)
{
gUnk_080CA4B4[this->action](this);
void sub_0801FC28(Entity* this) {
gUnk_080CA4B4[this->action](this);
}
void sub_0801FC40(Entity *this)
{
if (this->bitfield == 0x80) {
if (this->action == 3) {
this->field_0x74 = 1;
void sub_0801FC40(Entity* this) {
if (this->bitfield == 0x80) {
if (this->action == 3) {
this->field_0x74 = 1;
}
} else {
if (this->field_0x43 != 0) {
sub_0804A9FC(this, 0x1c);
}
}
}
else {
if (this->field_0x43 != 0) {
sub_0804A9FC(this, 0x1c);
}
}
sub_0804AA30(this, gUnk_080CA49C);
sub_0804AA30(this, gUnk_080CA49C);
}
void sub_0801FC7C(Entity *this)
{
if ((this->entityType).form == 0) {
sub_0804A7D4(this);
}
else {
CreateDeathFx(this, 0xf1, 0);
}
}
void sub_0801FC9C(Entity *this)
{
sub_0804A720(this);
this->action = 1;
this->actionDelay = Random();
}
void sub_0801FCB0(Entity *this)
{
if (--this->actionDelay == 0) {
if (sub_0801FE68(this, Random() & 0x1f) != 0) {
this->action = 2;
this->spriteSettings.b.draw = TRUE;
this->direction = (GetFacingDirection(this, gUnk_020000B0) + gUnk_080CA4C8[Random() & 1]) & 0x1f;
InitializeAnimation(this, 0);
UpdateSpriteForCollisionLayer(this);
}
else {
this->actionDelay = (Random() & 0x18) + 8;
}
}
}
void sub_0801FD2C(Entity *this)
{
GetNextFrame(this);
if (this->frames.b.f3 != 0) {
this->action = 3;
if (this->entityType.form == 0) {
this->field_0x74 = 0xb4;
}
else {
this->field_0x74 = 0x6e;
}
InitializeAnimation(this,2);
}
else if (this->frames.b.f0 != 0) {
this->frames.all &= 0xfe;
this->flags |= 0x80;
void sub_0801FC7C(Entity* this) {
if ((this->entityType).form == 0) {
sub_0804A7D4(this);
} else {
CreateDeathFx(this, 0xf1, 0);
}
}
void sub_0801FD80(Entity *this)
{
sub_0801FED4(this);
GetNextFrame(this);
if (--this->field_0x74 == 0) {
this->action = 4;
this->flags &= 0x7f;
InitializeAnimation(this, 1);
}
}
void sub_0801FDB4(Entity *this)
{
sub_0801FED4(this);
GetNextFrame(this);
if ((this->frames.b.f3) != 0) {
void sub_0801FC9C(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->actionDelay = 0xf0;
this->spriteSettings.b.draw = FALSE;
}
this->actionDelay = Random();
}
u32 sub_0801FDE4(Entity *ent, s32 x, s32 y)
{
void sub_0801FCB0(Entity* this) {
if (--this->actionDelay == 0) {
if (sub_0801FE68(this, Random() & 0x1f) != 0) {
this->action = 2;
this->spriteSettings.b.draw = TRUE;
this->direction = (GetFacingDirection(this, gUnk_020000B0) + gUnk_080CA4C8[Random() & 1]) & 0x1f;
InitializeAnimation(this, 0);
UpdateSpriteForCollisionLayer(this);
} else {
this->actionDelay = (Random() & 0x18) + 8;
}
}
}
void sub_0801FD2C(Entity* this) {
GetNextFrame(this);
if (this->frames.b.f3 != 0) {
this->action = 3;
if (this->entityType.form == 0) {
this->field_0x74 = 0xb4;
} else {
this->field_0x74 = 0x6e;
}
InitializeAnimation(this, 2);
} else if (this->frames.b.f0 != 0) {
this->frames.all &= 0xfe;
this->flags |= 0x80;
}
}
void sub_0801FD80(Entity* this) {
sub_0801FED4(this);
GetNextFrame(this);
if (--this->field_0x74 == 0) {
this->action = 4;
this->flags &= 0x7f;
InitializeAnimation(this, 1);
}
}
void sub_0801FDB4(Entity* this) {
sub_0801FED4(this);
GetNextFrame(this);
if ((this->frames.b.f3) != 0) {
this->action = 1;
this->actionDelay = 0xf0;
this->spriteSettings.b.draw = FALSE;
}
}
u32 sub_0801FDE4(Entity* ent, s32 x, s32 y) {
u32 uVar3;
u16 *puVar4;
u16* puVar4;
if (sub_080002D4(x, y, gUnk_020000B0->collisionLayer) != 0) {
return 0;
} else {
@@ -147,60 +132,48 @@ u32 sub_0801FDE4(Entity *ent, s32 x, s32 y)
}
}
bool32 sub_0801FE68(Entity *ent, s32 arg2)
{
s32 sin, cos;
s32 x, y;
u32 i;
bool32 sub_0801FE68(Entity* ent, s32 arg2) {
s32 sin, cos;
s32 x, y;
u32 i;
if (sub_08049FDC(ent, 1) == 0) {
return 0;
}
else {
x = gUnk_020000B0->x.WORD;
y = gUnk_020000B0->y.WORD;
sin = gSineTable[arg2 * 8] << 11;
cos = gSineTable[arg2 * 8 + 0x40] << 11;
for (i = 0; i < 8; i++) {
x += sin;
y += -cos;
if (sub_0801FDE4(ent, x >> 0x10, y >> 0x10) == 0) {
return 0;
}
if (sub_08049FDC(ent, 1) == 0) {
return 0;
} else {
x = gUnk_020000B0->x.WORD;
y = gUnk_020000B0->y.WORD;
sin = gSineTable[arg2 * 8] << 11;
cos = gSineTable[arg2 * 8 + 0x40] << 11;
for (i = 0; i < 8; i++) {
x += sin;
y += -cos;
if (sub_0801FDE4(ent, x >> 0x10, y >> 0x10) == 0) {
return 0;
}
}
return 1;
}
return 1;
}
}
#if NON_MATCHING
void sub_0801FED4(Entity *this)
{
s16 sVar2;
if (sub_08049FDC(this, 1) == 0) {
this->field_0x74 = 1;
}
sVar2 = (this->frames.all & 0xf) * 0x20;
this->nonPlanarMovement = sVar2;
if (this->entityType.form == 0) {
this->field_0xf++;
if ((this->field_0xf & 0xf) == 0) {
sub_08004596(this, sub_0800132C(this, gUnk_020000B0));
extern u32 sub_0800132C(Entity*, Entity*);
void sub_0801FED4(Entity* this) {
s16 sVar2;
if (sub_08049FDC(this, 1) == 0) {
this->field_0x74 = 1;
}
}
else {
this->nonPlanarMovement = sVar2 + 0x40;
this->field_0xf++;
if ((this->field_0xf & 0x7) == 0) {
sub_08004596(this, sub_0800132C(this, gUnk_020000B0));
sVar2 = (this->frames.all & 0xf) * 0x20;
this->nonPlanarMovement = sVar2;
if (this->entityType.form == 0) {
if ((this->field_0xf++ & 0xf) == 0) {
sub_08004596(this, sub_0800132C(this, gUnk_020000B0));
}
} else {
this->nonPlanarMovement = sVar2 + 0x40;
if ((this->field_0xf++ & 0x7) == 0) {
sub_08004596(this, sub_0800132C(this, gUnk_020000B0));
}
}
}
sub_080AEF88(this);
sub_080AEF88(this);
}
#else
NAKED
void sub_0801FED4(Entity *this) {
asm(".include \"asm/non_matching/leever/sub_0801FED4.inc\"");
}
#endif
+178 -134
View File
@@ -30,6 +30,12 @@ extern u32 sub_0805ACC0(Entity*);
extern void sub_0807DDAC(Entity*, u32);
extern void sub_0807DDE4(Entity*);
extern void sub_0807000C(Entity*);
extern void sub_0806EE04(Entity*, void*, u32);
extern Entity* sub_080A7EE0(int);
extern void sub_08078778(Entity*);
extern void sub_0807DD64(Entity*);
void sub_08063DC8(Entity*);
void sub_08063F20(Entity*);
extern void (*const gUnk_0810F544[])(Entity*);
extern void (*const gUnk_0810F550[])(Entity*);
@@ -40,157 +46,195 @@ extern SpriteLoadData gUnk_0810F524[];
extern void* gUnk_0810F6BC[];
extern ScreenTransition gScreenTransition;
void Guard(Entity *this)
{
if ((this->flags & 2) != 0) {
gUnk_0810F544[this->action](this);
}
else {
sub_08063D24(this);
}
void Guard(Entity* this) {
if ((this->flags & 2) != 0) {
gUnk_0810F544[this->action](this);
} else {
sub_08063D24(this);
}
}
void sub_08063D24(Entity *this)
{
gUnk_0810F550[this->action](this);
sub_0806ED78(this);
void sub_08063D24(Entity* this) {
gUnk_0810F550[this->action](this);
sub_0806ED78(this);
}
NAKED
void sub_08063D44(Entity* this) {
asm(".include \"asm/non_matching/guard/sub_08063D44.inc\"");
}
Entity* ent;
u32 temp, idx;
void sub_08063DC8(Entity *this)
{
if ((this->entityType).form == 0xff) {
this->action = 2;
this->actionDelay = 0x1e;
this->animationState = sub_0806F5A4(GetFacingDirection(this,&gLinkEntity));
InitAnimationForceUpdate(this, this->animationState + 4);
}
else {
sub_0806EE20(this);
if (this->field_0x3e != this->animationState) {
this->animationState = this->field_0x3e;
InitializeAnimation(this, this->animationState + 4);
if (gUnk_03003DBC > 0x46)
return;
temp = this->entityType.subtype;
temp ^= 0x15;
idx = ((-temp | temp) >> 0x1f) * 4;
if (!LoadExtraSpriteData(this, &gUnk_0810F524[idx]))
return;
InitializeAnimation(this, 4);
sub_0806EE04(this, gUnk_0810F6BC[this->entityType.form], 0);
switch (this->entityType.form) {
case 0 ... 3:
ent = sub_080A7EE0(0xc);
ent->parent = this;
ent->field_0xf = 0x3c;
break;
case 4 ... 5:
sub_08078778(this);
break;
}
else {
GetNextFrame(this);
}
if (this->interactType != 0) {
this->action = 3;
this->interactType = 0;
InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this,&gLinkEntity)));
sub_08064428(this);
}
}
}
void sub_08063E54(Entity *this)
{
if (--this->actionDelay == 0) {
SetRoomFlag(0xf);
}
}
void sub_08063E6C(Entity *this)
{
if ((gTextBox.doTextBox & 0x7f) == 0) {
this->action = 1;
InitializeAnimation(this, this->animationState + 4);
}
}
NAKED
void sub_08063E90(Entity* this) {
asm(".include \"asm/non_matching/guard/sub_08063E90.inc\"");
}
void sub_08063F20(Entity *this)
{
sub_0807DDAC(this, 0);
sub_0807DDE4(this);
GetNextFrame(this);
if (this->interactType != 0) {
this->action++;
this->interactType = 0;
InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gLinkEntity)) + *(s8 *)&this->field_0x70);
sub_08064428(this);
}
this->entityType.form = 0;
sub_08063DC8(this);
}
void sub_08063F78(Entity *this)
{
if ((gTextBox.doTextBox & 0x7f) == 0) {
this->action = this->action - 1;
InitializeAnimation(this,(this->animationState >> 1) + 4 + *(s8 *)&this->field_0x70);
}
}
void Guard_Head(Entity *this)
{
u8 bVar1;
u32 uVar2;
u32 pbVar3;
u32 uVar4;
u32 pbVar5;
uVar2 = this->frames.all & 0x3f;
pbVar5 = (this->frameIndex & 0x3f);
uVar4 = this->frameSpriteSettings & 0x3f;
if ((this->entityType).subtype == 0x15) {
if ((this->frameIndex & 0x40) != 0) {
pbVar5 = pbVar5 + 0x21;
pbVar3 = 0xffffffff;
uVar4 = 0;
void sub_08063DC8(Entity* this) {
if ((this->entityType).form == 0xff) {
this->action = 2;
this->actionDelay = 0x1e;
this->animationState = sub_0806F5A4(GetFacingDirection(this, &gLinkEntity));
InitAnimationForceUpdate(this, this->animationState + 4);
} else {
sub_0806EE20(this);
if (this->field_0x3e != this->animationState) {
this->animationState = this->field_0x3e;
InitializeAnimation(this, this->animationState + 4);
} else {
GetNextFrame(this);
}
if (this->interactType != 0) {
this->action = 3;
this->interactType = 0;
InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gLinkEntity)));
sub_08064428(this);
}
}
else {
pbVar3 = (uVar2 + 0x19);
if ((this->frameSpriteSettings & 0x3f) != 0) {
uVar4 += 0x1f;
}
}
void sub_08063E54(Entity* this) {
if (--this->actionDelay == 0) {
SetRoomFlag(0xf);
}
}
else {
pbVar3 = (uVar2 + 0x46);
pbVar5 = pbVar5 + 0x2d;
if ((this->frameSpriteSettings & 0x3f) != 0) {
uVar4 += 0x4c;
}
void sub_08063E6C(Entity* this) {
if ((gTextBox.doTextBox & 0x7f) == 0) {
this->action = 1;
InitializeAnimation(this, this->animationState + 4);
}
}
uVar4--;
SetExtraSpriteFrame(this, 0, pbVar3);
SetExtraSpriteFrame(this, 1, pbVar5);
SetExtraSpriteFrame(this, 2, uVar4);
SetSpriteSubEntryOffsetData1(this, 1, 0);
SetSpriteSubEntryOffsetData2(this, 1, 2);
sub_0807000C(this);
}
void sub_08064030(Entity *arg0,Entity *arg1)
{
*(u32*)&arg1->animationState = (-gRoomVars.greatFairyState | gRoomVars.greatFairyState) >> 0x1f;
void sub_08063E90(Entity* this) {
Entity* ent;
u32 temp, idx;
u32 unk;
temp = this->entityType.subtype;
temp ^= 0x15;
idx = ((-temp | temp) >> 0x1f) * 4;
if (!LoadExtraSpriteData(this, &gUnk_0810F524[idx]))
return;
this->action++;
if (this->actionDelay) {
this->field_0x70.BYTES.byte0 = 8;
} else {
this->field_0x70.BYTES.byte0 = 0;
}
this->actionDelay = 0;
unk = sub_0805ACC0(this);
if (unk == 0) {
this->field_0x68.HWORD = this->x.HALF.HI;
this->field_0x6a.HWORD = this->y.HALF.HI;
} else {
this->field_0x68.HWORD = unk >> 0x10;
this->field_0x6a.HWORD = unk;
}
this->field_0x70.BYTES.byte1 = 0;
this->collisionLayer = 1;
UpdateSpriteForCollisionLayer(this);
sub_0807DD64(this);
sub_08063F20(this);
}
void sub_08064044(void)
{
gScreenTransition.unk = 1;
void sub_08063F20(Entity* this) {
sub_0807DDAC(this, 0);
sub_0807DDE4(this);
GetNextFrame(this);
if (this->interactType != 0) {
this->action++;
this->interactType = 0;
InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gLinkEntity)) + *(s8*)&this->field_0x70);
sub_08064428(this);
}
}
void sub_08064050(Entity *arg0, struct_08064050 *arg1)
{
u32 unk;
arg1->unk2 = 0;
switch (arg0->entityType.parameter) {
case 0x11:
arg1->unk2 = 1;
break;
case 0x12:
arg1->unk2 = 2;
break;
case 0x13:
arg1->unk2 = 3;
}
void sub_08063F78(Entity* this) {
if ((gTextBox.doTextBox & 0x7f) == 0) {
this->action = this->action - 1;
InitializeAnimation(this, (this->animationState >> 1) + 4 + *(s8*)&this->field_0x70);
}
}
void Guard_Head(Entity* this) {
u8 bVar1;
u32 uVar2;
u32 pbVar3;
u32 uVar4;
u32 pbVar5;
uVar2 = this->frames.all & 0x3f;
pbVar5 = (this->frameIndex & 0x3f);
uVar4 = this->frameSpriteSettings & 0x3f;
if ((this->entityType).subtype == 0x15) {
if ((this->frameIndex & 0x40) != 0) {
pbVar5 = pbVar5 + 0x21;
pbVar3 = 0xffffffff;
uVar4 = 0;
} else {
pbVar3 = (uVar2 + 0x19);
if ((this->frameSpriteSettings & 0x3f) != 0) {
uVar4 += 0x1f;
}
}
} else {
pbVar3 = (uVar2 + 0x46);
pbVar5 = pbVar5 + 0x2d;
if ((this->frameSpriteSettings & 0x3f) != 0) {
uVar4 += 0x4c;
}
}
uVar4--;
SetExtraSpriteFrame(this, 0, pbVar3);
SetExtraSpriteFrame(this, 1, pbVar5);
SetExtraSpriteFrame(this, 2, uVar4);
SetSpriteSubEntryOffsetData1(this, 1, 0);
SetSpriteSubEntryOffsetData2(this, 1, 2);
sub_0807000C(this);
}
void sub_08064030(Entity* arg0, Entity* arg1) {
*(u32*)&arg1->animationState = (-gRoomVars.greatFairyState | gRoomVars.greatFairyState) >> 0x1f;
}
void sub_08064044(void) {
gScreenTransition.unk = 1;
}
void sub_08064050(Entity* arg0, struct_08064050* arg1) {
u32 unk;
arg1->unk2 = 0;
switch (arg0->entityType.parameter) {
case 0x11:
arg1->unk2 = 1;
break;
case 0x12:
arg1->unk2 = 2;
break;
case 0x13:
arg1->unk2 = 3;
}
}