summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortheo3 <arisstephenson2@gmail.com>2021-03-15 21:17:25 -0700
committertheo3 <arisstephenson2@gmail.com>2021-03-15 21:24:10 -0700
commitaf98f5f9a30e7276ffe9c21c903cc6f1a866e39c (patch)
treea48a5365ff74fbb6282af2e9774b1aeba63642f5 /src
parentc319dc53d3bc67909be7bbe75538d796bc99ddff (diff)
several more player functions done
Diffstat (limited to 'src')
-rw-r--r--src/arm_proxy.c33
-rw-r--r--src/code_0804AA84.c8
-rw-r--r--src/code_0805436C.c2
-rw-r--r--src/code_08077DF4.c2
-rw-r--r--src/enemy/acroBandits.c6
-rw-r--r--src/enemy/beetle.c12
-rw-r--r--src/enemy/bobomb.c14
-rw-r--r--src/enemy/bombPeahat.c18
-rw-r--r--src/enemy/businessScrub.c28
-rw-r--r--src/enemy/darkNut.c2
-rw-r--r--src/enemy/doorMimic.c4
-rw-r--r--src/enemy/fireballGuy.c2
-rw-r--r--src/enemy/gibdo.c10
-rw-r--r--src/enemy/gyorgMale.c200
-rw-r--r--src/enemy/helmasaur.c14
-rw-r--r--src/enemy/keese.c4
-rw-r--r--src/enemy/lakitu.c4
-rw-r--r--src/enemy/lakituCloud.c6
-rw-r--r--src/enemy/likeLike.c6
-rw-r--r--src/enemy/madderpillar.c4
-rw-r--r--src/enemy/moldorm.c6
-rw-r--r--src/enemy/moldworm.c16
-rw-r--r--src/enemy/octorok.c6
-rw-r--r--src/enemy/peahat.c12
-rw-r--r--src/enemy/pesto.c14
-rw-r--r--src/enemy/puffstool.c8
-rw-r--r--src/enemy/rockChuchu.c4
-rw-r--r--src/enemy/rollobite.c10
-rw-r--r--src/enemy/rope.c10
-rw-r--r--src/enemy/rupeeLike.c6
-rw-r--r--src/enemy/slime.c9
-rw-r--r--src/enemy/smallPesto.c6
-rw-r--r--src/enemy/spark.c2
-rw-r--r--src/enemy/spearMoblin.c4
-rw-r--r--src/enemy/spikedBeetle.c2
-rw-r--r--src/enemy/spinyChuchu.c6
-rw-r--r--src/enemy/tektite.c10
-rw-r--r--src/enemy/tektiteGolden.c10
-rw-r--r--src/enemy/wisp.c6
-rw-r--r--src/game.c3
-rw-r--r--src/item.c1
-rw-r--r--src/item11.c4
-rw-r--r--src/manager/manager15.c6
-rw-r--r--src/manager/manager1A.c4
-rw-r--r--src/manager/manager3.c18
-rw-r--r--src/npc/beedle.c2
-rw-r--r--src/npc/bigGoron.c4
-rw-r--r--src/npc/cow.c24
-rw-r--r--src/object/backgroundCloud.c10
-rw-r--r--src/object/bakerOven.c4
-rw-r--r--src/object/bird.c4
-rw-r--r--src/object/button.c2
-rw-r--r--src/object/houseDoorExterior.c6
-rw-r--r--src/object/itemOnGround.c6
-rw-r--r--src/object/object2A.c2
-rw-r--r--src/object/object49.c4
-rw-r--r--src/object/object86.c8
-rw-r--r--src/object/pot.c12
-rw-r--r--src/player.c697
-rw-r--r--src/script.c4
60 files changed, 940 insertions, 411 deletions
diff --git a/src/arm_proxy.c b/src/arm_proxy.c
index e18e4a1c..05d5235f 100644
--- a/src/arm_proxy.c
+++ b/src/arm_proxy.c
@@ -30,7 +30,7 @@ extern void LoadResources();
extern void FadeMain();
extern u32 sub_0805E3B0();
extern void HandlePlayerLife();
-extern void sub_08070680();
+extern void DoPlayerAction();
extern void sub_080171F0();
extern void sub_08078FB0();
extern void DrawEntity();
@@ -69,17 +69,6 @@ typedef struct {
extern NPCStruct gUnk_02031EC0[100];
typedef struct {
- u8 unk0;
- u8 unk1;
- u8 unk2;
- u8 unk3;
- u8 freezeTime;
- u8 unk9;
-} EntityHandler;
-
-extern EntityHandler gUnk_03003DC0;
-
-typedef struct {
void* last;
void* first;
void* node;
@@ -156,7 +145,7 @@ void PlayerUpdate(Entity* this) {
}
}
HandlePlayerLife(this);
- sub_08070680(this);
+ DoPlayerAction(this);
if ((this->height.WORD == 0) && (this->action == 1 || this->action == 9))
sub_08008790(this, 8);
sub_080171F0();
@@ -174,7 +163,7 @@ void HandlePlayerLife(Entity* this) {
gUnk_0200AF00.filler25[8] = 0;
gUnk_0200AF00.filler25[9] = 0;
- if ((gPlayerEntity.bitfield & 0x80) && (gPlayerEntity.hurtBlinkTime > 0))
+ if ((gPlayerEntity.bitfield & 0x80) && (gPlayerEntity.iframes > 0))
SoundReq(SFX_86);
gPlayerState.flags.all &= ~(0x2000000 | 0x200);
@@ -278,7 +267,7 @@ void sub_080171F0(void) {
sub_0807A8D8(&gPlayerEntity);
if (gPlayerState.jumpStatus & 0xc0)
- gPlayerEntity.hurtBlinkTime = 0xfe;
+ gPlayerEntity.iframes = 0xfe;
if (gPlayerEntity.action != 0x17) {
sub_08077FEC(gPlayerEntity.action);
@@ -286,17 +275,17 @@ void sub_080171F0(void) {
}
void ItemUpdate(Entity* this) {
- if ((this->flags & 1) == 0 && this->action == 0 && this->previousActionFlag == 0)
+ if ((this->flags & 1) == 0 && this->action == 0 && this->subAction == 0)
ItemInit(this);
if (!sub_0805E3B0(this)) {
gPlayerItemFunctions[this->id](this);
this->bitfield &= ~0x80;
- if (this->hurtBlinkTime != 0) {
- if (this->hurtBlinkTime > 0)
- this->hurtBlinkTime--;
+ if (this->iframes != 0) {
+ if (this->iframes > 0)
+ this->iframes--;
else
- this->hurtBlinkTime++;
+ this->iframes++;
}
}
DrawEntity(this);
@@ -340,8 +329,8 @@ void ObjectUpdate(Entity* this) {
if (((this->flags & 1) == 0) && (this->action == 0))
sub_080A2838(this);
- if (this->hurtBlinkTime != 0)
- this->hurtBlinkTime++;
+ if (this->iframes != 0)
+ this->iframes++;
if (!sub_0805E3B0(this)) {
gObjectFunctions[this->id](this);
this->bitfield &= ~0x80;
diff --git a/src/code_0804AA84.c b/src/code_0804AA84.c
index 59485d74..406a513b 100644
--- a/src/code_0804AA84.c
+++ b/src/code_0804AA84.c
@@ -18,7 +18,7 @@ extern void (*const gUnk_080D412C[])();
extern struct_02018EB0 gUnk_02018EB0;
u32 sub_0804AA84(void) {
- if (gArea.fadeOut != 0) {
+ if (gArea.playShrinkSeq) {
gMain.transition = 4;
gArea.filler[8] = 0;
gArea.filler[9] = 0;
@@ -26,8 +26,8 @@ u32 sub_0804AA84(void) {
sub_0805E5A8();
return 1;
} else {
- gArea.filler[18] = gArea.fadeOut;
- *(vu8*)&gArea.fadeOut = gArea.fadeOut;
+ gArea.filler[18] = gArea.playShrinkSeq;
+ *(vu8*)&gArea.playShrinkSeq = gArea.playShrinkSeq;
return 0;
}
}
@@ -40,7 +40,7 @@ void sub_0804AAD4(void) {
MemClear32((void*)&gUnk_02018EB0, 0x28);
gUnk_02018EB0.unk = 0;
EraseAllEntities();
- CreateObject(0x3d, gArea.field_0x17, 0);
+ CreateObject(0x3d, gArea.curPortalType, 0);
gArea.filler[8]++;
}
diff --git a/src/code_0805436C.c b/src/code_0805436C.c
index be879f99..20aee72e 100644
--- a/src/code_0805436C.c
+++ b/src/code_0805436C.c
@@ -133,7 +133,7 @@ u32 sub_080544C8(u32 arg0) {
}
}
-u32 sub_080544DC(u32 arg0) {
+u32 GetBottleContaining(u32 arg0) {
if (arg0 == gSave.stats.bottles[0]) {
return 1;
} else if (arg0 == gSave.stats.bottles[1]) {
diff --git a/src/code_08077DF4.c b/src/code_08077DF4.c
index 1697ecb0..0dc90c4a 100644
--- a/src/code_08077DF4.c
+++ b/src/code_08077DF4.c
@@ -35,7 +35,7 @@ void sub_08077E3C(Entity* ent, u32 idx) {
void sub_08077E54(Entity* ent) {
ent->action = gPlayerEntity.animIndex;
*(u8*)&ent->spriteIndex = gPlayerEntity.frameIndex;
- ent->previousActionFlag = gPlayerEntity.frameDuration;
+ ent->subAction = gPlayerEntity.frameDuration;
ent->actionDelay = gPlayerEntity.frames.all;
}
diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c
index 2825aed5..09463b1e 100644
--- a/src/enemy/acroBandits.c
+++ b/src/enemy/acroBandits.c
@@ -62,8 +62,8 @@ void sub_080318DC(Entity* this) {
do {
brother->action = 5;
brother->spritePriority.b1 = 1;
- if (brother->hurtBlinkTime == 0)
- brother->hurtBlinkTime = -12;
+ if (brother->iframes == 0)
+ brother->iframes = -12;
} while (brother = brother->attachedEntity, brother != NULL);
}
if (this->parent) {
@@ -113,7 +113,7 @@ void sub_080318DC(Entity* this) {
}
void sub_08031A60(Entity* this) {
- if (this->hurtBlinkTime > 0)
+ if (this->iframes > 0)
sub_08003FC4(this, 0x1800);
sub_08001324(this);
diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c
index 5ba78755..0e9c9586 100644
--- a/src/enemy/beetle.c
+++ b/src/enemy/beetle.c
@@ -66,7 +66,7 @@ void sub_08021818(Entity* this) {
void sub_08021848(Entity* this) {
if (sub_0806F520(this)) {
- gUnk_080CB5C8[this->previousActionFlag](this);
+ gUnk_080CB5C8[this->subAction](this);
} else {
this->action = 3;
this->height.HALF.HI = 0;
@@ -75,7 +75,7 @@ void sub_08021848(Entity* this) {
}
void sub_0802187C(Entity* this) {
- this->previousActionFlag = 2;
+ this->subAction = 2;
}
void nullsub_130(Entity* this) {
@@ -98,8 +98,8 @@ void sub_080218B4(Entity* this) {
}
void sub_080218CC(Entity* this) {
- if (this->previousActionFlag == 0) {
- this->previousActionFlag = 1;
+ if (this->subAction == 0) {
+ this->subAction = 1;
this->spriteSettings.b.draw = 1;
this->direction = ((sub_08049F84(this, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & 0x1f;
this->speed = 0x100;
@@ -124,8 +124,8 @@ void sub_080218CC(Entity* this) {
}
void sub_08021984(Entity* this) {
- if (this->previousActionFlag == 0) {
- this->previousActionFlag = 1;
+ if (this->subAction == 0) {
+ this->subAction = 1;
this->flags |= 0x80;
this->spriteSettings.b.draw = 3;
this->height.HALF.HI = -0x80;
diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c
index d9c1a2a8..3d724227 100644
--- a/src/enemy/bobomb.c
+++ b/src/enemy/bobomb.c
@@ -63,8 +63,8 @@ void sub_0802C688(Entity* this) {
}
void sub_0802C7AC(Entity* this) {
- if (this->previousActionFlag < 3 && !sub_0806F520(this)) {
- this->previousActionFlag = 0;
+ if (this->subAction < 3 && !sub_0806F520(this)) {
+ this->subAction = 0;
this->field_0xf = 1;
this->height.HALF.HI = 0;
if (this->field_0x82.HALF.LO != 2) {
@@ -75,7 +75,7 @@ void sub_0802C7AC(Entity* this) {
this->field_0x80.HALF.HI = 0;
} else {
this->height.HALF.HI = -1;
- gUnk_080CD600[this->previousActionFlag](this);
+ gUnk_080CD600[this->subAction](this);
if (this->actionDelay != 0) {
GetNextFrame(this);
}
@@ -83,7 +83,7 @@ void sub_0802C7AC(Entity* this) {
}
void sub_0802C820(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 60;
}
@@ -180,11 +180,11 @@ void sub_0802C91C(Entity* this) {
}
void sub_0802C9B8(Entity* this) {
- gUnk_080CD618[this->previousActionFlag](this);
+ gUnk_080CD618[this->subAction](this);
}
void sub_0802C9D0(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->flags &= ~0x80;
this->spritePriority.b1 = 0;
this->field_0x82.HALF.HI = 1;
@@ -255,7 +255,7 @@ void nullsub_150(Entity* this) {
void sub_0802CB68(Entity* this) {
this->action = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->direction = Random() & 0x18;
this->direction |= 4;
this->flags |= 0x80;
diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c
index 228855be..46c7d8b2 100644
--- a/src/enemy/bombPeahat.c
+++ b/src/enemy/bombPeahat.c
@@ -70,11 +70,11 @@ void sub_0802A8AC(Entity* this) {
}
void sub_0802A8C8(Entity* this) {
- gUnk_080CD140[this->previousActionFlag](this);
+ gUnk_080CD140[this->subAction](this);
}
void sub_0802A8E0(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 60;
}
@@ -102,7 +102,7 @@ void sub_0802A91C(Entity* this) {
void sub_0802A924(Entity* this) {
this->action = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->actionDelay = 0;
this->field_0xf = 0;
this->hitbox = (Hitbox*)&gUnk_080CD16C;
@@ -128,7 +128,7 @@ void sub_0802A9A8(Entity* this) {
if (this->actionDelay) {
if (--this->actionDelay == 0) {
this->action = 2;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->actionDelay = 0x40;
sub_0802ACDC(this, 8);
}
@@ -254,7 +254,7 @@ void sub_0802AB40(Entity* this) {
void sub_0802AC08(Entity* this) {
if (this->frames.all & 0x80) {
this->action = 2;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->actionDelay = 0x40;
this->speed = 0xc0;
sub_0802ACDC(this, 8);
@@ -386,7 +386,7 @@ void sub_0802AE68(Entity* this) {
}
void sub_0802AEBC(Entity* this) {
- gUnk_080CD158[this->previousActionFlag](this);
+ gUnk_080CD158[this->subAction](this);
}
void sub_0802AED4(Entity* this) {
@@ -407,7 +407,7 @@ void sub_0802AED4(Entity* this) {
}
void sub_0802AF28(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
sub_08079BD8(this);
this->spritePriority.b1 = 2;
GetNextFrame(this);
@@ -424,7 +424,7 @@ void sub_0802AF58(Entity* this) {
void sub_0802AF74(Entity* this) {
this->action = 3;
- this->previousActionFlag = 0;
+ this->subAction = 0;
if (this->actionDelay > 60) {
this->actionDelay = 60;
}
@@ -510,7 +510,7 @@ void sub_0802B048(Entity* this) {
} else {
if (this->field_0xf) {
if (--this->field_0xf == 0) {
- if (action == 2 && this->previousActionFlag == 1) {
+ if (action == 2 && this->subAction == 1) {
gPlayerState.heldObject = 0;
}
sub_0805EC60(this);
diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c
index 49ba9ea1..2c80b226 100644
--- a/src/enemy/businessScrub.c
+++ b/src/enemy/businessScrub.c
@@ -54,7 +54,7 @@ void sub_08028934(Entity* this) {
if (this->damageType == 1 && (this->bitfield & 0x7f) == 0x42) {
this->action = 3;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->actionDelay = 0x28;
this->flags &= ~0x80;
sub_080290E0(this, 4);
@@ -97,7 +97,7 @@ void sub_08028A48(Entity* this) {
this->actionDelay--;
} else if (sub_08028F98(this, 0)) {
sub_08029078(this);
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->field_0xf = 1;
}
}
@@ -106,11 +106,11 @@ void sub_08028A74(Entity* this) {
u32 unk;
GetNextFrame(this);
- switch (this->previousActionFlag) {
+ switch (this->subAction) {
case 0:
unk = 1;
if (this->frames.all & 0x80) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->actionDelay = 0x3c;
this->field_0xf = 0x10;
sub_08028FDC(this);
@@ -120,7 +120,7 @@ void sub_08028A74(Entity* this) {
case 1:
unk = 1;
if (--this->actionDelay == 0) {
- this->previousActionFlag = 2;
+ this->subAction = 2;
this->actionDelay = 0x20;
this->field_0xf = 0;
sub_08028FDC(this);
@@ -141,14 +141,14 @@ void sub_08028A74(Entity* this) {
ent->parent = this;
ent->direction = this->direction;
this->frames.all &= ~1;
- this->previousActionFlag = 3;
+ this->subAction = 3;
}
}
break;
case 3:
unk = 2;
if (this->frames.all & 0x80) {
- this->previousActionFlag = 4;
+ this->subAction = 4;
this->actionDelay = 0x50;
sub_080290E0(this, 1);
}
@@ -157,13 +157,13 @@ void sub_08028A74(Entity* this) {
unk = 2;
if (--this->actionDelay == 0) {
if (sub_08028F98(this, 0)) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->actionDelay = 0x3c;
this->field_0xf = 0x10;
sub_08028FDC(this);
} else {
sub_08028FFC(this);
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->actionDelay = 0x50;
this->field_0xf = 0;
}
@@ -174,7 +174,7 @@ void sub_08028A74(Entity* this) {
if (!sub_08028F98(this, unk)) {
sub_08028FFC(this);
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->actionDelay = 0x50;
this->field_0xf = 0;
}
@@ -183,11 +183,11 @@ void sub_08028A74(Entity* this) {
void sub_08028BC4(Entity* this) {
Entity* iVar1;
- switch (this->previousActionFlag) {
+ switch (this->subAction) {
case 0:
if (this->actionDelay == 0) {
if (this->frames.all & 0x80) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
sub_08028FDC(this);
sub_080290E0(this, 5);
this->spritePriority.b1 = 1;
@@ -199,7 +199,7 @@ void sub_08028BC4(Entity* this) {
case 1:
if (this->frames.all & 0x80) {
this->action = 4;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->actionDelay = 0x1e;
this->field_0xf = 5;
sub_080290E0(this, 0);
@@ -314,7 +314,7 @@ void sub_08028E40(Entity* this) {
struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD;
this->action = 4;
- this->previousActionFlag = gTextBox.doTextBox & 0x7f;
+ this->subAction = gTextBox.doTextBox & 0x7f;
this->actionDelay = 1;
if (CheckLocalFlag(offer->field_0xa) == 0) {
SetLocalFlag(offer->field_0xa);
diff --git a/src/enemy/darkNut.c b/src/enemy/darkNut.c
index 83fa7296..18561e86 100644
--- a/src/enemy/darkNut.c
+++ b/src/enemy/darkNut.c
@@ -241,7 +241,7 @@ void sub_08020FAC(Entity* this) {
if (this->field_0x7a.HALF.LO) {
this->field_0x7a.HALF.LO--;
} else {
- this->hurtBlinkTime = -8;
+ this->iframes = -8;
sub_08021390(this);
}
} else {
diff --git a/src/enemy/doorMimic.c b/src/enemy/doorMimic.c
index 27357c08..2bfc1fc4 100644
--- a/src/enemy/doorMimic.c
+++ b/src/enemy/doorMimic.c
@@ -4,7 +4,7 @@
extern s16 sub_080001DA(u32, u32); // ?
extern void sub_08049CF4();
-extern u32 sub_0806FBFC(u32, u32, u32, u32);
+extern u32 CheckPlayerProximity(u32, u32, u32, u32);
void sub_080221C0();
typedef struct {
@@ -54,7 +54,7 @@ void sub_08022034(Entity* this) {
void sub_0802209C(Entity* this) {
if (this->actionDelay == 0) {
- if (sub_0806FBFC(this->field_0x78.HWORD, this->field_0x7a.HWORD, 0x10, 0x10)) {
+ if (CheckPlayerProximity(this->field_0x78.HWORD, this->field_0x7a.HWORD, 0x10, 0x10)) {
this->action = 2;
this->actionDelay = 0x12;
InitializeAnimation(this, this->type2 + 4);
diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c
index e2d8914d..c7bdbbe2 100644
--- a/src/enemy/fireballGuy.c
+++ b/src/enemy/fireballGuy.c
@@ -79,7 +79,7 @@ void sub_08045454(Entity* this) {
tmp = 0;
ent->type2 = 1;
ent->height.HALF.HI = tmp;
- ent->hurtBlinkTime = -0x10;
+ ent->iframes = -0x10;
/* Set MiniFireballGuy offset relative to killed slime. */
sub_08045178(this, ent, off->h, off->v);
diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c
index f3228707..bc338a94 100644
--- a/src/enemy/gibdo.c
+++ b/src/enemy/gibdo.c
@@ -337,12 +337,12 @@ NONMATCH("asm/non_matching/gibdo/sub_08037A58.inc", void sub_08037A58(Entity* th
sub_08037ACC(this);
this->action = 7;
this->spritePriority.b0 = (this->spritePriority.b0 & 0xf8) | 4;
- if (this->hurtBlinkTime == 0) {
- this->hurtBlinkTime = 0xec;
+ if (this->iframes == 0) {
+ this->iframes = 0xec;
}
this->damageType = 0x26;
this->flags2 |= 1;
- this->hurtBlinkTime = 0xf4;
+ this->iframes = 0xf4;
this->field_0x3e = (this->animationState << 3) ^ 0x10;
this->field_0x42 = 8;
this->field_0x46 = 0x180;
@@ -354,7 +354,7 @@ END_NONMATCH
void sub_08037ACC(Entity* this) {
gPlayerState.flags.all &= 0xFFFFFEFF;
gPlayerEntity.flags |= 0x80;
- gPlayerEntity.hurtBlinkTime = 0x1e;
+ gPlayerEntity.iframes = 0x1e;
gPlayerEntity.field_0x3e = DirectionFromAnimationState(this->animationState);
gPlayerEntity.field_0x42 = 4;
gPlayerEntity.field_0x46 = 0x180;
@@ -362,7 +362,7 @@ void sub_08037ACC(Entity* this) {
// Damage player maybe?
void sub_08037B10(Entity* this) {
u32 h;
- gPlayerEntity.hurtBlinkTime = 0xc;
+ gPlayerEntity.iframes = 0xc;
h = ModHealth(-8);
sub_0800449C(&gPlayerEntity, 0x7a);
if (h == 0) {
diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c
index 1edbf4f9..f8a0b890 100644
--- a/src/enemy/gyorgMale.c
+++ b/src/enemy/gyorgMale.c
@@ -29,54 +29,54 @@ const u16 gUnk_080D1C60[8];
void GyorgMale(Entity*);
void sub_08046898(Entity*); // action 0
void sub_08046910(Entity*); // action 1
-void sub_08046930(Entity*); // action 1 previousActionFlag 0
-void sub_0804696C(Entity*); // action 1 previousActionFlag 1
-void sub_080469CC(Entity*); // action 1 previousActionFlag 2
-void sub_080469F4(Entity*); // action 1 previousActionFlag 3
-void sub_08046A30(Entity*); // action 1 previousActionFlag 4
-void sub_08046A54(Entity*); // action 1 previousActionFlag 5
-void sub_08046A78(Entity*); // action 1 previousActionFlag 6
+void sub_08046930(Entity*); // action 1 subAction 0
+void sub_0804696C(Entity*); // action 1 subAction 1
+void sub_080469CC(Entity*); // action 1 subAction 2
+void sub_080469F4(Entity*); // action 1 subAction 3
+void sub_08046A30(Entity*); // action 1 subAction 4
+void sub_08046A54(Entity*); // action 1 subAction 5
+void sub_08046A78(Entity*); // action 1 subAction 6
void sub_08046A9C(Entity*); // action 2
-void sub_08046AE8(Entity*); // action 2 previousActionFlag 0
-void sub_08046B18(Entity*); // action 2 previousActionFlag 1
-void sub_08046B8C(Entity*); // action 2 previousActionFlag 2
-void sub_08046C04(Entity*); // action 2 previousActionFlag 3
-void sub_08046C88(Entity*); // action 2 previousActionFlag 4
+void sub_08046AE8(Entity*); // action 2 subAction 0
+void sub_08046B18(Entity*); // action 2 subAction 1
+void sub_08046B8C(Entity*); // action 2 subAction 2
+void sub_08046C04(Entity*); // action 2 subAction 3
+void sub_08046C88(Entity*); // action 2 subAction 4
void sub_08046CEC(Entity*); // action 3
-void sub_08046D44(Entity*); // action 3 previousActionFlag 0
-void sub_08046D98(Entity*); // action 3 previousActionFlag 1
-void sub_08046E0C(Entity*); // action 3 previousActionFlag 2
-void sub_08046E68(Entity*); // action 3 previousActionFlag 3
-void sub_08046EF4(Entity*); // action 3 previousActionFlag 4
+void sub_08046D44(Entity*); // action 3 subAction 0
+void sub_08046D98(Entity*); // action 3 subAction 1
+void sub_08046E0C(Entity*); // action 3 subAction 2
+void sub_08046E68(Entity*); // action 3 subAction 3
+void sub_08046EF4(Entity*); // action 3 subAction 4
void sub_08046F64(Entity*); // action 4
-void sub_08046FE8(Entity*); // action 4 previousActionFlag 0
-void sub_0804702C(Entity*); // action 4 previousActionFlag 1
-void sub_080470B4(Entity*); // action 4 previousActionFlag 2
-void sub_08047140(Entity*); // action 4 previousActionFlag 3
-void sub_0804717C(Entity*); // action 4 previousActionFlag 4
-void sub_080471C8(Entity*); // action 4 previousActionFlag 5
-void sub_0804723C(Entity*); // action 4 previousActionFlag 6
-void sub_08047284(Entity*); // action 4 previousActionFlag 7
-void sub_080472BC(Entity*); // action 4 previousActionFlag 8
-void sub_08047310(Entity*); // action 4 previousActionFlag 9
+void sub_08046FE8(Entity*); // action 4 subAction 0
+void sub_0804702C(Entity*); // action 4 subAction 1
+void sub_080470B4(Entity*); // action 4 subAction 2
+void sub_08047140(Entity*); // action 4 subAction 3
+void sub_0804717C(Entity*); // action 4 subAction 4
+void sub_080471C8(Entity*); // action 4 subAction 5
+void sub_0804723C(Entity*); // action 4 subAction 6
+void sub_08047284(Entity*); // action 4 subAction 7
+void sub_080472BC(Entity*); // action 4 subAction 8
+void sub_08047310(Entity*); // action 4 subAction 9
void sub_0804736C(Entity*); // action 5
-void sub_080473B8(Entity*); // action 5 previousActionFlag 0
-void sub_080473F0(Entity*); // action 5 previousActionFlag 1
-void sub_08047484(Entity*); // action 5 previousActionFlag 2
-void sub_08047508(Entity*); // action 5 previousActionFlag 3
-void sub_080475F4(Entity*); // action 5 previousActionFlag 4
-void sub_0804763C(Entity*); // action 5 previousActionFlag 5
-void sub_0804772C(Entity*); // action 5 previousActionFlag 6
+void sub_080473B8(Entity*); // action 5 subAction 0
+void sub_080473F0(Entity*); // action 5 subAction 1
+void sub_08047484(Entity*); // action 5 subAction 2
+void sub_08047508(Entity*); // action 5 subAction 3
+void sub_080475F4(Entity*); // action 5 subAction 4
+void sub_0804763C(Entity*); // action 5 subAction 5
+void sub_0804772C(Entity*); // action 5 subAction 6
void sub_08047778(Entity*); // action 6
-void sub_08047798(Entity*); // action 6 previousActionFlag 0
-void sub_080477F0(Entity*); // action 6 previousActionFlag 1
-void sub_08047914(Entity*); // action 6 previousActionFlag 2
-void sub_08047978(Entity*); // action 6 previousActionFlag 3
-void sub_08047B08(Entity*); // action 6 previousActionFlag 4
+void sub_08047798(Entity*); // action 6 subAction 0
+void sub_080477F0(Entity*); // action 6 subAction 1
+void sub_08047914(Entity*); // action 6 subAction 2
+void sub_08047978(Entity*); // action 6 subAction 3
+void sub_08047B08(Entity*); // action 6 subAction 4
void sub_08047B84(Entity*); // action 7
-void sub_08047BA4(Entity*); // action 7 previousActionFlag 0
-void sub_08047BF0(Entity*); // action 7 previousActionFlag 1, also called elsewhere
-void sub_08047D24(Entity*); // action 7 previousActionFlag 2
+void sub_08047BA4(Entity*); // action 7 subAction 0
+void sub_08047BF0(Entity*); // action 7 subAction 1, also called elsewhere
+void sub_08047D24(Entity*); // action 7 subAction 2
void sub_08047D88(Entity*); //
void sub_08047DF0(Entity*, u32);
void sub_08047E48(Entity*); //
@@ -118,7 +118,7 @@ void sub_08046898(Entity* this) {
tmp->parent = this;
this->attachedEntity = tmp;
this->action = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->spriteRendering.b0 = 3;
this->spriteSettings.b.draw = 1;
this->spriteOrientation.flipY = 2;
@@ -136,20 +136,20 @@ void (*const gUnk_080D1B1C[7])(Entity*) = { sub_08046930, sub_0804696C, sub_0804
sub_08046A30, sub_08046A54, sub_08046A78 };
void sub_08046910(Entity* this) {
- gUnk_080D1B1C[this->previousActionFlag](this);
+ gUnk_080D1B1C[this->subAction](this);
UpdateAnimationSingleFrame(this);
}
void sub_08046930(Entity* this) {
if (this->type) {
- this->previousActionFlag = 5;
+ this->subAction = 5;
this->direction = 0x20;
this->speed = 0x280;
}
sub_08047D88(this);
if (this->field_0x7c.BYTES.byte0 == 0)
return;
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->actionDelay = 1;
this->animationState = 0;
this->direction = 0;
@@ -159,7 +159,7 @@ void sub_08046930(Entity* this) {
void sub_0804696C(Entity* this) {
sub_08047E48(this);
if (gRoomControls.roomOriginY + 0x130 > this->y.HALF.HI) {
- this->previousActionFlag = 2;
+ this->subAction = 2;
this->direction = 0x80;
this->speed = 0x100;
this->spriteOrientation.flipY = 3;
@@ -177,7 +177,7 @@ void sub_0804696C(Entity* this) {
void sub_080469CC(Entity* this) {
sub_08047E48(this);
if (gRoomControls.roomOriginY + 0x210 < this->y.HALF.HI) {
- this->previousActionFlag = 3;
+ this->subAction = 3;
this->direction = 0x90;
}
}
@@ -185,7 +185,7 @@ void sub_080469CC(Entity* this) {
void sub_080469F4(Entity* this) {
sub_08047E48(this);
if (gRoomControls.roomOriginY + 0x290 < this->y.HALF.HI) {
- this->previousActionFlag = 4;
+ this->subAction = 4;
this->spriteOrientation.flipY = 2;
this->spriteRendering.b3 = 2;
}
@@ -195,14 +195,14 @@ void sub_08046A30(Entity* this) {
sub_08047D88(this);
if (((Entity*)this->myHeap)->prev->field_0x6c.HWORD & 1) {
this->action = 2;
- this->previousActionFlag = 0;
+ this->subAction = 0;
}
}
void sub_08046A54(Entity* this) {
sub_08047E48(this);
if (gRoomControls.roomOriginX + 0x380 < this->x.HALF.HI) {
- this->previousActionFlag = 6;
+ this->subAction = 6;
}
}
@@ -210,7 +210,7 @@ void sub_08046A78(Entity* this) {
sub_08047D88(this);
if (((Entity*)this->myHeap)->prev->field_0x6c.HWORD & 0x10) {
this->action = 3;
- this->previousActionFlag = 0;
+ this->subAction = 0;
}
}
@@ -222,16 +222,16 @@ void sub_08046A9C(Entity* this) {
InitAnimationForceUpdate(this, 0);
}
}
- gUnk_080D1B38[this->previousActionFlag](this);
+ gUnk_080D1B38[this->subAction](this);
UpdateAnimationSingleFrame(this);
if (this->field_0x7c.BYTES.byte0) {
this->action = 6;
- this->previousActionFlag = 0;
+ this->subAction = 0;
}
}
void sub_08046AE8(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->speed = 0x180;
sub_08048178(this, ((Entity*)this->myHeap)->next->animationState >> 5);
this->field_0x76.HWORD = this->direction << 8;
@@ -248,7 +248,7 @@ void sub_08046B18(Entity* this) {
}
this->direction = this->field_0x76.HWORD >> 8;
} else {
- this->previousActionFlag = 2;
+ this->subAction = 2;
}
sub_08047D88(this);
sub_08047EA4(this, ((0x100 - this->direction) & 0xFF) << 8);
@@ -256,7 +256,7 @@ void sub_08046B18(Entity* this) {
void sub_08046B8C(Entity* this) {
if (sub_0806FCB8(this, this->field_0x80.HWORD, this->field_0x82.HWORD, 4)) {
- this->previousActionFlag = 3;
+ this->subAction = 3;
this->field_0x76.HWORD = this->direction << 8;
this->field_0x80.HWORD = gRoomControls.roomOriginX + 0x200;
this->field_0x82.HWORD = gRoomControls.roomOriginY + 0x210;
@@ -278,7 +278,7 @@ void sub_08046C04(Entity* this) {
}
this->direction = this->field_0x76.HWORD >> 8;
} else {
- this->previousActionFlag = 4;
+ this->subAction = 4;
this->field_0x70.HALF.LO = ((tmp + 0x20) & 0xC0) >> 6;
}
sub_08047D88(this);
@@ -287,7 +287,7 @@ void sub_08046C04(Entity* this) {
void sub_08046C88(Entity* this) {
if (sub_0806FCB8(this, this->field_0x80.HWORD, this->field_0x82.HWORD, 4)) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
sub_08048178(this, sub_08048158(this->field_0x70.HALF_U.LO));
sub_08047D88(this);
} else {
@@ -305,11 +305,11 @@ void sub_08046CEC(Entity* this) {
InitAnimationForceUpdate(this, 1);
}
}
- gUnk_080D1B4C[this->previousActionFlag](this);
+ gUnk_080D1B4C[this->subAction](this);
UpdateAnimationSingleFrame(this);
if (((Entity*)this->myHeap)->prev->field_0x6c.HWORD & 2) {
this->action = 2;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->animationState = this->speed;
}
}
@@ -318,7 +318,7 @@ const u16 gUnk_080D1B60[8] = { 0x200, 0x184, 0x28C, 0x210, 0x200, 0x29C, 0x174,
void sub_08046D44(Entity* this) {
const u16* tmp;
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->speed = 0x200;
tmp = gUnk_080D1B60 + (((Entity*)this->myHeap)->next->animationState >> 5);
this->field_0x80.HWORD = tmp[0] + gRoomControls.roomOriginX;
@@ -337,7 +337,7 @@ void sub_08046D98(Entity* this) {
}
this->direction = this->field_0x76.HWORD >> 8;
} else {
- this->previousActionFlag = 2;
+ this->subAction = 2;
}
sub_08047D88(this);
sub_08047EA4(this, ((0x100 - this->direction) & 0xFF) << 8);
@@ -345,7 +345,7 @@ void sub_08046D98(Entity* this) {
void sub_08046E0C(Entity* this) {
if (sub_0806FCB8(this, this->field_0x80.HWORD, this->field_0x82.HWORD, 4)) {
- this->previousActionFlag = 3;
+ this->subAction = 3;
this->field_0x76.HWORD = this->direction << 8;
sub_08047D88(this);
} else {
@@ -369,7 +369,7 @@ void sub_08046E68(Entity* this) {
sub_08047D88(this);
sub_08047EA4(this, ((0x100 - this->direction) & 0xFF) << 8);
} else {
- this->previousActionFlag = 4;
+ this->subAction = 4;
this->actionDelay = 0x3F;
this->field_0xf = 1;
this->direction = (gUnk_080D1B70[Random() & 1] + tmp) & 0xC0;
@@ -408,7 +408,7 @@ void sub_08046F64(Entity* this) {
InitAnimationForceUpdate(this, 1);
}
}
- gUnk_080D1B94[this->previousActionFlag](this);
+ gUnk_080D1B94[this->subAction](this);
UpdateAnimationSingleFrame(this);
if (--this->field_0x7c.HALF.HI == 0) {
Entity* tmp;
@@ -422,12 +422,12 @@ void sub_08046F64(Entity* this) {
}
if (((Entity*)this->myHeap)->prev->field_0x6c.HWORD & 4) {
this->action = 5;
- this->previousActionFlag = 0;
+ this->subAction = 0;
}
}
void sub_08046FE8(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->speed = 0x1c0;
this->field_0x7c.HALF.HI = 0x1e;
this->field_0x80.HWORD = gRoomControls.roomOriginX + 0x290;
@@ -446,7 +446,7 @@ void sub_0804702C(Entity* this) {
}
sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8);
if (sub_0806FCB8(this, this->field_0x80.HWORD, this->field_0x82.HWORD, (this->speed >> 0x10) + 0x10)) {
- this->previousActionFlag = 2;
+ this->subAction = 2;
this->field_0x76.HWORD = this->direction << 8;
this->speed = 0x280;
}
@@ -466,7 +466,7 @@ void sub_080470B4(Entity* this) {
sub_08047D88(this);
sub_08047EA4(this, ((0x100 - this->direction) & 0xFF) << 8);
} else {
- this->previousActionFlag = 3;
+ this->subAction = 3;
this->speed = 0x200;
this->field_0x76.HWORD = this->direction << 8;
this->field_0x74.HWORD = gUnk_080D1BBC[Random() & 1];
@@ -479,7 +479,7 @@ void sub_08047140(Entity* this) {
this->direction = this->field_0x76.HWORD >> 8;
if (this->direction > 0xbf) {
this->direction = 0xC0;
- this->previousActionFlag = 4;
+ this->subAction = 4;
}
sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8);
}
@@ -490,7 +490,7 @@ void sub_0804717C(Entity* this) {
}
sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8);
if (gRoomControls.roomOriginX + 0x200 > this->x.HALF.HI) {
- this->previousActionFlag = 5;
+ this->subAction = 5;
}
}
@@ -506,19 +506,19 @@ void sub_080471C8(Entity* this) {
return;
if (this->field_0x74.HWORD > 0x100) {
if (Random() & 1) {
- this->previousActionFlag = 6;
+ this->subAction = 6;
} else {
- this->previousActionFlag = 0;
+ this->subAction = 0;
}
} else {
- this->previousActionFlag = 0;
+ this->subAction = 0;
}
}
void sub_0804723C(Entity* this) {
this->direction -= 2;
if (this->direction < 0xc0) {
- this->previousActionFlag = 7;
+ this->subAction = 7;
this->speed = 0x200;
this->direction = 0xc0;
this->field_0x76.HWORD = 0xc000;
@@ -532,7 +532,7 @@ void sub_08047284(Entity* this) {
this->direction = this->field_0x76.HWORD >> 8;
if (this->direction < 0x40) {
this->direction = 0x40;
- this->previousActionFlag = 8;
+ this->subAction = 8;
}
sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8);
}
@@ -544,7 +544,7 @@ void sub_080472BC(Entity* this) {
sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8);
if (gRoomControls.roomOriginX + 0x2B0 >= this->x.HALF.HI)
return;
- this->previousActionFlag = 9;
+ this->subAction = 9;
this->field_0x76.HWORD = this->direction << 8;
}
@@ -556,7 +556,7 @@ void sub_08047310(Entity* this) {
this->direction = this->field_0x76.HWORD >> 8;
if ((u8)(this->direction + 0x7F) < 0x40) {
this->direction = 0xC0;
- this->previousActionFlag = 4;
+ this->subAction = 4;
}
sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8);
}
@@ -570,16 +570,16 @@ void sub_0804736C(Entity* this) {
InitAnimationForceUpdate(this, 0);
}
}
- gUnk_080D1BC0[this->previousActionFlag](this);
+ gUnk_080D1BC0[this->subAction](this);
UpdateAnimationSingleFrame(this);
if (this->currentHealth == 0) {
this->action = 7;
- this->previousActionFlag = 0;
+ this->subAction = 0;
}
}
void sub_080473B8(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->speed = 0x120;
this->field_0x80.HWORD = gRoomControls.roomOriginX + 0x200;
this->field_0x82.HWORD = gRoomControls.roomOriginY + 0x1D0;
@@ -606,7 +606,7 @@ void sub_080473F0(Entity* this) {
}
sub_08047DF0(this, ((0x100 - this->direction) & 0xFF) << 8);
if (sub_0806FCB8(this, this->field_0x80.HWORD, this->field_0x82.HWORD, 8)) {
- this->previousActionFlag = 2;
+ this->subAction = 2;
this->field_0x76.HWORD = this->direction << 8;
this->speed = 0x180;
}
@@ -624,7 +624,7 @@ void sub_08047484(Entity* this) {
sub_08047D88(this);
sub_08047EA4(this, ((0x100 - this->direction) & 0xFF) << 8);
} else {
- this->previousActionFlag = 3;
+ this->subAction = 3;
this->speed = 0x200;
this->direction = 0x40;
this->field_0x76.HWORD = 0x4000;
@@ -664,7 +664,7 @@ void sub_08047508(Entity* this) {
}
sub_08047E48(this);
if (gRoomControls.roomOriginX + 0x280 < this->x.HALF.HI) {
- this->previousActionFlag = 4;
+ this->subAction = 4;
this->speed = 0x200;
this->animationState = this->direction;
this->field_0x76.HWORD = this->direction << 8;
@@ -682,7 +682,7 @@ void sub_080475F4(Entity* this) {
this->direction = this->field_0x76.HWORD >> 8;
if (this->direction >= 0xc0) {
this->direction = 0xc0;
- this->previousActionFlag = 5;
+ this->subAction = 5;
this->speed = 0x200;
this->field_0x7c.HALF.HI = 0x3c;
}
@@ -719,7 +719,7 @@ void sub_0804763C(Entity* this) {
}
sub_08047E48(this);
if (gRoomControls.roomOriginX + 0x180 > this->x.HALF.HI) {
- this->previousActionFlag = 6;
+ this->subAction = 6;
this->speed = 0x200;
this->animationState = this->direction;
this->field_0x76.HWORD = this->direction << 8;
@@ -737,7 +737,7 @@ void sub_0804772C(Entity* this) {
this->direction = this->field_0x76.HWORD >> 8;
if (this->direction <= 0x40) {
this->direction = 0x40;
- this->previousActionFlag = 3;
+ this->subAction = 3;
this->speed = 0x200;
this->field_0x7c.HALF.HI = 0x1e;
}
@@ -747,12 +747,12 @@ void sub_0804772C(Entity* this) {
void (*const gUnk_080D1BDC[5])(Entity*) = { sub_08047798, sub_080477F0, sub_08047914, sub_08047978, sub_08047B08 };
void sub_08047778(Entity* this) {
- gUnk_080D1BDC[this->previousActionFlag](this);
+ gUnk_080D1BDC[this->subAction](this);
UpdateAnimationSingleFrame(this);
}
void sub_08047798(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->speed = 0x80;
if (this->x.HALF.HI - gRoomControls.roomOriginX < 0x1F8) {
this->field_0x80.HWORD = 0xa8;
@@ -774,7 +774,7 @@ void sub_080477F0(Entity* this) {
sub_08047E48(this);
if (!sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x80)) {
this->action = 2;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->spriteOrientation.flipY = 2;
this->spriteRendering.b3 = 2;
this->direction = this->animationState;
@@ -785,7 +785,7 @@ void sub_080477F0(Entity* this) {
this->spriteRendering.b3 = 3;
}
if (sub_0806FCB8(this, this->field_0x80.HWORD, this->field_0x82.HWORD, 4)) {
- this->previousActionFlag = 2;
+ this->subAction = 2;
this->field_0x76.HWORD = this->animationState << 8;
this->field_0x74.HWORD = gUnk_080D1BF0[Random() & 1];
if (((Entity*)this->myHeap)->prev->field_0x6c.HWORD & 1) {
@@ -804,7 +804,7 @@ void sub_08047914(Entity* this) {
this->animationState = this->field_0x76.HWORD >> 8;
sub_08047EA4(this, ((0x100 - this->animationState) & 0xFF) << 8);
} else {
- this->previousActionFlag = 3;
+ this->subAction = 3;
this->field_0x70.HALF.LO = 0x3C;
this->field_0x7c.HALF.HI = ((this->type * 0xF) << 2) + 0x78;
sub_080A1D70(((Entity*)this->myHeap)->prev, this->animationState);
@@ -839,7 +839,7 @@ void sub_08047978(Entity* this) {
}
if (!sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x80)) {
this->action = 2;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->spriteOrientation.flipY = 2;
this->spriteRendering.b3 = 2;
this->direction = this->animationState;
@@ -848,7 +848,7 @@ void sub_08047978(Entity* this) {
return;
if (this->attachedEntity->action != 1)
return;
- this->previousActionFlag = 4;
+ this->subAction = 4;
if (this->type == 0) {
if ((((Entity*)this->myHeap)->next->animationState >> 6) == 1) {
this->field_0x80.HWORD = gRoomControls.roomOriginX + 0x1C0;
@@ -882,11 +882,11 @@ void sub_08047B08(Entity* this) {
return;
if (this->type == 0) {
this->action = 7;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->direction ^= 0x80;
} else {
this->action = 4;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->spriteOrientation.flipY = 2;
this->spriteRendering.b3 = 2;
this->direction = this->animationState;
@@ -896,12 +896,12 @@ void sub_08047B08(Entity* this) {
void (*const gUnk_080D1BF4[3])(Entity*) = { sub_08047BA4, sub_08047BF0, sub_08047D24 };
void sub_08047B84(Entity* this) {
- gUnk_080D1BF4[this->previousActionFlag](this);
+ gUnk_080D1BF4[this->subAction](this);
UpdateAnimationSingleFrame(this);
}
void sub_08047BA4(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->actionDelay = 0x78;
this->field_0xf = 0;
if (gRoomControls.roomOriginX + 0x200 < this->x.HALF.HI) {
@@ -937,7 +937,7 @@ void sub_08047BF0(Entity* this) {
this->speed = 0x140;
sub_08047E48(this);
if (this->y.HALF.HI > gRoomControls.roomOriginY + 0x270) {
- this->previousActionFlag = 2;
+ this->subAction = 2;
this->field_0x7c.HALF.HI = 0xAA;
SoundReq(0x12D);
InitAnimationForceUpdate(this, 1);
diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c
index 723050a4..ed7a71b8 100644
--- a/src/enemy/helmasaur.c
+++ b/src/enemy/helmasaur.c
@@ -62,16 +62,16 @@ void sub_0802BBC4(Entity* this) {
void sub_0802BC20(Entity* this) {
if (this->damageType != 0x19) {
if (sub_0806F520(this)) {
- gUnk_080CD42C[this->previousActionFlag](this);
+ gUnk_080CD42C[this->subAction](this);
}
- } else if (2 < this->previousActionFlag || sub_0806F520(this)) {
- gUnk_080CD438[this->previousActionFlag](this);
+ } else if (2 < this->subAction || sub_0806F520(this)) {
+ gUnk_080CD438[this->subAction](this);
}
}
void sub_0802BC74(Entity* this) {
sub_0802C1C0(this);
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 60;
this->animationState = (gPlayerEntity.animationState >> 1) ^ 2;
InitializeAnimation(this, this->animationState);
@@ -101,7 +101,7 @@ void sub_0802BCA8(Entity* this) {
}
void sub_0802BCFC(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 60;
}
@@ -259,7 +259,7 @@ void sub_0802BF78(Entity* this) {
void sub_0802BF98(Entity* this) {
if (sub_0806F520(this)) {
- gUnk_080CD450[this->previousActionFlag](this);
+ gUnk_080CD450[this->subAction](this);
} else {
this->action = 2;
this->actionDelay = 30;
@@ -268,7 +268,7 @@ void sub_0802BF98(Entity* this) {
}
void sub_0802BFD0(Entity* this) {
- this->previousActionFlag = 2;
+ this->subAction = 2;
}
void sub_0802BFD8(Entity* this) {
diff --git a/src/enemy/keese.c b/src/enemy/keese.c
index 0462b254..35904a3e 100644
--- a/src/enemy/keese.c
+++ b/src/enemy/keese.c
@@ -43,12 +43,12 @@ void sub_08021d98(Entity* this) {
void sub_08021DA8(Entity* this) {
if (sub_0806F520(this)) {
- gUnk_080CB6C4[this->previousActionFlag](this);
+ gUnk_080CB6C4[this->subAction](this);
}
}
void sub_08021DCC(Entity* this) {
- this->previousActionFlag = 2;
+ this->subAction = 2;
}
void sub_08021DD4(Entity* this) {
diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c
index 163ec9e1..5d6fcb6e 100644
--- a/src/enemy/lakitu.c
+++ b/src/enemy/lakitu.c
@@ -140,12 +140,12 @@ void sub_0803C784(Entity* this) {
void sub_0803C820(Entity* this) {
if (sub_0806F520(this)) {
- gUnk_080D0148[this->previousActionFlag](this);
+ gUnk_080D0148[this->subAction](this);
}
}
void sub_0803C844(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 0x3c;
}
diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c
index 80679029..467e273c 100644
--- a/src/enemy/lakituCloud.c
+++ b/src/enemy/lakituCloud.c
@@ -38,16 +38,16 @@ void sub_0803CCEC(Entity* this) {
void sub_0803CCFC(Entity* this) {
if (sub_0806F520(this) == 0) {
- if (this->previousActionFlag == 2) {
+ if (this->subAction == 2) {
sub_0803CE3C(this);
}
} else {
- gUnk_080D043C[this->previousActionFlag](this);
+ gUnk_080D043C[this->subAction](this);
}
}
void sub_0803CD2C(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 0x3c;
}
diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c
index 60a7b7b7..53af5aad 100644
--- a/src/enemy/likeLike.c
+++ b/src/enemy/likeLike.c
@@ -210,7 +210,7 @@ void sub_0802810C(Entity* this) {
gPlayerState.flags.all &= 0xffffffef;
gPlayerEntity.flags |= 0x80;
gPlayerEntity.field_0x20 = 0x18000;
- gPlayerEntity.hurtBlinkTime = -60;
+ gPlayerEntity.iframes = -60;
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
gPlayerEntity.spritePriority.b1 = this->field_0x82.HALF.HI;
gPlayerEntity.height.HALF.HI = gPlayerEntity.spriteOffsetY;
@@ -219,8 +219,8 @@ void sub_0802810C(Entity* this) {
this->actionDelay = 0x50;
this->field_0xf = 0;
this->flags2 |= 2;
- if (this->hurtBlinkTime == 0) {
- this->hurtBlinkTime = -18;
+ if (this->iframes == 0) {
+ this->iframes = -18;
}
}
#else
diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c
index 9c2d526f..012f5abf 100644
--- a/src/enemy/madderpillar.c
+++ b/src/enemy/madderpillar.c
@@ -460,12 +460,12 @@ void sub_0802A098(Entity* this) {
void sub_0802A0F8(Entity* this) {
if (this->currentHealth != 0) {
- if ((this->bitfield & 0x80) && this->hurtBlinkTime != 0) {
+ if ((this->bitfield & 0x80) && this->iframes != 0) {
Entity* ent = this;
u32 i;
for (i = 0; i < 6; i++) {
ent = ent->attachedEntity;
- ent->hurtBlinkTime = this->hurtBlinkTime;
+ ent->iframes = this->iframes;
}
}
} else {
diff --git a/src/enemy/moldorm.c b/src/enemy/moldorm.c
index 186bee30..429905be 100644
--- a/src/enemy/moldorm.c
+++ b/src/enemy/moldorm.c
@@ -40,9 +40,9 @@ void sub_08022BEC(Entity* this) {
this->animationState = ((this->direction + 2) & 0x1c) >> 2;
this->frameIndex = this->animationState;
- this->attachedEntity->hurtBlinkTime = this->hurtBlinkTime;
- (*(Entity**)&this->field_0x7c)->hurtBlinkTime = this->hurtBlinkTime;
- (*(Entity**)&this->field_0x80)->hurtBlinkTime = this->hurtBlinkTime;
+ this->attachedEntity->iframes = this->iframes;
+ (*(Entity**)&this->field_0x7c)->iframes = this->iframes;
+ (*(Entity**)&this->field_0x80)->iframes = this->iframes;
sub_0804AA30(this, gUnk_080CBBA0);
}
diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c
index 3bf68715..2ac1af64 100644
--- a/src/enemy/moldworm.c
+++ b/src/enemy/moldworm.c
@@ -67,12 +67,12 @@ void sub_080230CC(Entity* this) {
}
void sub_080230E4(Entity* this) {
- if (this->previousActionFlag == 0xff) {
+ if (this->subAction == 0xff) {
this->action = 7;
this->actionDelay = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->damageType = 0x85;
- this->hurtBlinkTime = -8;
+ this->iframes = -8;
this->field_0x7c.BYTES.byte3 = 0;
this->field_0x7a.HALF.HI = 0;
if (this->bitfield == 0x80 || this->bitfield == 0x9e) {
@@ -90,7 +90,7 @@ void sub_080230E4(Entity* this) {
gPlayerEntity.spriteSettings.b.draw = 1;
gPlayerEntity.field_0x20 = 0x18000;
gPlayerEntity.direction = 0xff;
- gPlayerEntity.hurtBlinkTime = -0x14;
+ gPlayerEntity.iframes = -0x14;
gPlayerState.jumpStatus = 0x41;
gPlayerState.flags.all &= 0xfff7ffff;
}
@@ -410,7 +410,7 @@ void sub_08023894(Entity* this) {
gPlayerEntity.y.HALF.HI = this->y.HALF.HI;
gPlayerEntity.direction = DirectionRoundUp(GetFacingDirection(*(Entity**)&this->field_0x74, this));
gPlayerEntity.animationState = gPlayerEntity.direction >> 2;
- gPlayerEntity.hurtBlinkTime = 12;
+ gPlayerEntity.iframes = 12;
ModHealth(-0x10);
sub_0800449C(&gPlayerEntity, 0x7a);
}
@@ -421,7 +421,7 @@ void sub_0802390C(Entity* this) {
if (this->bitfield & 0x80) {
Entity* ent = this->attachedEntity;
do {
- ent->hurtBlinkTime = this->hurtBlinkTime;
+ ent->iframes = this->iframes;
} while (ent = ent->attachedEntity, ent != NULL);
} else {
Entity* ent = this->attachedEntity;
@@ -431,7 +431,7 @@ void sub_0802390C(Entity* this) {
if (bVar2 != 0) {
u32 tmp;
ent->currentHealth = 0xff;
- tmp = (u8)ent->hurtBlinkTime;
+ tmp = (u8)ent->iframes;
if (this->currentHealth >= bVar2) {
this->currentHealth -= bVar2;
} else {
@@ -440,7 +440,7 @@ void sub_0802390C(Entity* this) {
ent = this;
do {
- ent->hurtBlinkTime = tmp;
+ ent->iframes = tmp;
} while (ent = ent->attachedEntity, ent != NULL);
break;
}
diff --git a/src/enemy/octorok.c b/src/enemy/octorok.c
index d89e4e65..4a021874 100644
--- a/src/enemy/octorok.c
+++ b/src/enemy/octorok.c
@@ -55,16 +55,16 @@ void sub_0801EB0C(Entity* this) {
}
void sub_0801EB2C(Entity* this) {
- if (this->previousActionFlag < 3 && !sub_0806F520(this)) {
+ if (this->subAction < 3 && !sub_0806F520(this)) {
Octorok_Pause(this);
InitializeAnimation(this, this->animationState);
} else {
- gUnk_080CA158[this->previousActionFlag](this);
+ gUnk_080CA158[this->subAction](this);
}
}
void sub_0801EB68(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 60;
}
diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c
index 07fd3f5a..85a38d74 100644
--- a/src/enemy/peahat.c
+++ b/src/enemy/peahat.c
@@ -58,14 +58,14 @@ void sub_0801FFDC(Entity* this) {
this->animationState = PeahatAnimation_SlicedPropeller;
this->action = 5;
this->speed = 0x80;
- this->hurtBlinkTime = -30;
+ this->iframes = -30;
this->field_0x80.HALF.HI = 0;
InitializeAnimation(this, this->animationState);
} else if (this->bitfield == 0x9b) {
this->animationState = PeahatAnimation_BrokenPropeller;
this->action = 5;
this->speed = 0x80;
- this->hurtBlinkTime = -30;
+ this->iframes = -30;
this->field_0x80.HALF.HI = 0;
InitializeAnimation(this, this->animationState);
} else if (this->bitfield == 0x80) {
@@ -87,14 +87,14 @@ void sub_0801FFDC(Entity* this) {
}
void sub_08020088(Entity* this) {
- if (2 >= this->previousActionFlag && !sub_0806F520(this))
+ if (2 >= this->subAction && !sub_0806F520(this))
return;
- gUnk_080CA5BC[this->previousActionFlag](this);
+ gUnk_080CA5BC[this->subAction](this);
}
void sub_080200B4(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 60;
if (this->animationState == PeahatAnimation_Flying) {
this->animationState = PeahatAnimation_BrokenPropeller;
@@ -150,7 +150,7 @@ void Peahat_Fly(Entity* this) {
if (sub_08049FDC(this, 1)) {
if (this->field_0x82.HALF.HI == 0 && (this->field_0xf & 0xf) == 0 && sub_08049F1C(this, gUnk_020000B0, 0x30)) {
this->action = 2;
- this->previousActionFlag = Random() & 3;
+ this->subAction = Random() & 3;
this->actionDelay = 60;
this->speed = 160;
}
diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c
index a8d24fa2..f34d439a 100644
--- a/src/enemy/pesto.c
+++ b/src/enemy/pesto.c
@@ -78,20 +78,20 @@ void sub_08023FE0(Entity* this) {
}
void sub_08023FF0(Entity* this) {
- if (this->previousActionFlag < 3 && !sub_0806F520(this)) {
+ if (this->subAction < 3 && !sub_0806F520(this)) {
this->action = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->flags |= 0x80;
this->damageType = 0x77;
this->actionDelay = 1;
this->speed = 0x40;
} else {
- gUnk_080CBEF8[this->previousActionFlag](this);
+ gUnk_080CBEF8[this->subAction](this);
}
}
void sub_08024038(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 60;
GetNextFrame(this);
}
@@ -129,7 +129,7 @@ void sub_080240B8(Entity* this) {
u32 direction = (Random() & 0xc0) >> 3;
sub_0804A720(this);
this->action = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->field_0x80.HALF.LO = 0;
if (direction & 8) {
this->y.HALF.HI += (direction & 0x10) ? -0x20 : 0x20;
@@ -829,7 +829,7 @@ void sub_08024E4C(Entity* this) {
player->spritePriority.b1 = 0;
if (this->field_0xf == 0) {
(this->field_0x86.HALF.HI++;
- player->hurtBlinkTime = 8;
+ player->iframes = 8;
ModHealth(-2);
sub_0800449C(player, 0x7a);
}
@@ -849,7 +849,7 @@ void sub_08024F50(Entity* this) {
CopyPosition(this, &gPlayerEntity);
gPlayerEntity.action = 1;
gPlayerEntity.flags |= 0x80;
- gPlayerEntity.hurtBlinkTime = -0x3c;
+ gPlayerEntity.iframes = -0x3c;
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
gPlayerEntity.speed = 0;
gPlayerEntity.spritePriority.b1 = this->cutsceneBeh.HALF.HI;
diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c
index 08908191..aba4ff55 100644
--- a/src/enemy/puffstool.c
+++ b/src/enemy/puffstool.c
@@ -74,7 +74,7 @@ void sub_08025020(Entity* this) {
if (0 < this->field_0x20) {
this->field_0x20 = 0;
}
- this->hurtBlinkTime = -0xc;
+ this->iframes = -0xc;
this->field_0x42 = 0;
if (this->field_0x80.HALF.LO == 0) {
this->animationState = (*(Entity**)&this->field_0x4c)->direction >> 3;
@@ -84,7 +84,7 @@ void sub_08025020(Entity* this) {
}
break;
default:
- if (this->damageType == 0x82 && this->hurtBlinkTime < 0) {
+ if (this->damageType == 0x82 && this->iframes < 0) {
Entity* ent = CreateObject(0x21, 2, 0);
if (ent != NULL) {
ent->spritePriority.b0 = 3;
@@ -108,14 +108,14 @@ void sub_0802511C(Entity* this) {
void sub_0802514C(Entity* this) {
sub_08003FC4(this, 0x2000);
if (sub_0806F520(this)) {
- gUnk_080CBFEC[this->previousActionFlag](this);
+ gUnk_080CBFEC[this->subAction](this);
} else {
sub_08025C2C(this);
}
}
void sub_08025180(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->actionDelay = Random();
this->animationState = (((*(Entity**)&this->field_0x4c)->direction ^ 0x10) >> 3);
InitializeAnimation(this, this->animationState + 4);
diff --git a/src/enemy/rockChuchu.c b/src/enemy/rockChuchu.c
index 01a0c9c7..dd4d31c6 100644
--- a/src/enemy/rockChuchu.c
+++ b/src/enemy/rockChuchu.c
@@ -43,7 +43,7 @@ void sub_08022254(Entity* this) {
ent = CreateEnemy(1, 1);
if (ent) {
ent->type2 = 1;
- ent->hurtBlinkTime = -8;
+ ent->iframes = -8;
sub_0804A4E4(this, ent);
this->action = 2;
this->flags &= ~0x80;
@@ -96,7 +96,7 @@ void sub_080223E4(Entity* this) {
ent = this->attachedEntity;
if (ent) {
ent->bitfield = 0x94;
- ent->hurtBlinkTime = 0x10;
+ ent->iframes = 0x10;
ent->field_0x42 = 0xc;
ent->field_0x3e = this->direction;
}
diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c
index 263b5625..5928e62b 100644
--- a/src/enemy/rollobite.c
+++ b/src/enemy/rollobite.c
@@ -63,18 +63,18 @@ void sub_080206E0(Entity* this) {
}
void sub_08020734(Entity* this) {
- if (this->previousActionFlag < 3 && !sub_0806F520(this)) {
+ if (this->subAction < 3 && !sub_0806F520(this)) {
this->action = 4;
this->flags |= 0x80;
this->direction = 0xff;
InitializeAnimation(this, this->animationState + 0x10);
} else {
- gUnk_080CA6A4[this->previousActionFlag](this);
+ gUnk_080CA6A4[this->subAction](this);
}
}
void sub_0802077C(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 60;
}
@@ -132,11 +132,11 @@ void Rollobite_Walk(Entity* this) {
}
void sub_08020874(Entity* this) {
- gUnk_080CA6BC[this->previousActionFlag](this);
+ gUnk_080CA6BC[this->subAction](this);
}
void sub_0802088C(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->flags &= ~0x80;
this->cutsceneBeh.HALF.HI = gPlayerEntity.animationState;
this->spritePriority.b1 = 0;
diff --git a/src/enemy/rope.c b/src/enemy/rope.c
index d1d73723..f6076324 100644
--- a/src/enemy/rope.c
+++ b/src/enemy/rope.c
@@ -36,12 +36,12 @@ void sub_080313AC(Entity* this) {
void sub_080313E8(Entity* this) {
if (sub_0806F520()) {
- gUnk_080CE470[this->previousActionFlag](this);
+ gUnk_080CE470[this->subAction](this);
}
}
void sub_0803140C(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 0x3c;
}
@@ -65,7 +65,7 @@ void sub_08031434(Entity* this) {
sub_08031600(this);
} else {
this->action = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->spriteSettings.b.draw = (this->spriteSettings.b.draw & 0xfc);
this->height.HALF.HI = -0x80;
this->frameIndex = 0xff;
@@ -73,13 +73,13 @@ void sub_08031434(Entity* this) {
}
void sub_08031480(Entity* this) {
- if (this->previousActionFlag == 0) {
+ if (this->subAction == 0) {
if (this->actionDelay != 0) {
this->actionDelay--;
} else {
sub_08031600(this);
this->action = 1;
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->spriteSettings.b.draw = 3;
this->spriteRendering.b3 = 1;
this->spriteOrientation.flipY = 1;
diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c
index 64584892..b1aebc92 100644
--- a/src/enemy/rupeeLike.c
+++ b/src/enemy/rupeeLike.c
@@ -234,7 +234,7 @@ void sub_080296D8(Entity* this) {
gPlayerState.flags.all &= 0xffffffef;
gPlayerEntity.flags |= 0x80;
gPlayerEntity.field_0x20 = 0x18000;
- gPlayerEntity.hurtBlinkTime = 0xa6;
+ gPlayerEntity.iframes = 0xa6;
gPlayerEntity.height.HALF.HI = -2;
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
gPlayerEntity.spritePriority.b1 = this->field_0x80.HALF.LO;
@@ -243,8 +243,8 @@ void sub_080296D8(Entity* this) {
this->action = 5;
this->field_0xf = 0x3c;
this->flags2 |= 3;
- if ((s8)this->hurtBlinkTime == 0) {
- this->hurtBlinkTime = 0xf4;
+ if ((s8)this->iframes == 0) {
+ this->iframes = 0xf4;
}
}
diff --git a/src/enemy/slime.c b/src/enemy/slime.c
index 9609232d..f6ea1d7f 100644
--- a/src/enemy/slime.c
+++ b/src/enemy/slime.c
@@ -4,12 +4,6 @@
#include "functions.h"
typedef struct {
- void* field_0x0;
- void* entityCount;
- u8 freezeTime;
-} EntityHandler;
-
-typedef struct {
s8 h, v;
} PACKED PosOffset;
@@ -29,7 +23,6 @@ extern u8 gUnk_080D16D0[4]; // Entity count per form
extern PosOffset gUnk_080D16D4[4];
extern u8 gEntCount;
-extern EntityHandler gHitboxCount;
void Slime(Entity* this) {
EnemyFunctionHandler(this, gUnk_080D16A4);
@@ -117,7 +110,7 @@ void sub_080450A8(Entity* this) {
ent->parent = entities[(i + count - 1) % count];
ent->type2 = 1;
ent->height.HALF.HI = 0;
- ent->hurtBlinkTime = -0x10;
+ ent->iframes = -0x10;
/* Set MiniSlime offset relative to killed slime. */
sub_08045178(this, ent, off->h, off->v);
diff --git a/src/enemy/smallPesto.c b/src/enemy/smallPesto.c
index 7b6dbbfd..7d5aea83 100644
--- a/src/enemy/smallPesto.c
+++ b/src/enemy/smallPesto.c
@@ -42,17 +42,17 @@ void sub_0803169C(Entity* this) {
iVar1 = sub_0806F520(this);
if (iVar1 == 0) {
this->action = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->flags = this->flags | 0x80;
this->speed = 0x40;
this->field_0xf = 1;
} else {
- gUnk_080CE554[this->previousActionFlag](this);
+ gUnk_080CE554[this->subAction](this);
}
}
void sub_080316DC(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 0x3c;
}
diff --git a/src/enemy/spark.c b/src/enemy/spark.c
index 210b8431..4a6541fa 100644
--- a/src/enemy/spark.c
+++ b/src/enemy/spark.c
@@ -19,7 +19,7 @@ void sub_0802B2E0(Entity* this) {
if (this->bitfield & 0x80) {
if ((this->bitfield & 0x7f) == 0x14) {
this->flags &= ~0x80;
- this->hurtBlinkTime = 0;
+ this->iframes = 0;
this->spriteSettings.b.draw = 0;
this->action = 2;
ent = CreateFx(this, 2, 0);
diff --git a/src/enemy/spearMoblin.c b/src/enemy/spearMoblin.c
index 68e0fef5..8523ae91 100644
--- a/src/enemy/spearMoblin.c
+++ b/src/enemy/spearMoblin.c
@@ -56,7 +56,7 @@ void sub_08028284(Entity* this) {
}
}
- this->attachedEntity->hurtBlinkTime = this->hurtBlinkTime;
+ this->attachedEntity->iframes = this->iframes;
if (this->currentHealth == 0) {
this->speed = 0;
this->field_0x82.HALF.LO = 0;
@@ -386,7 +386,7 @@ 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->iframes = -ent->iframes;
this->field_0x46 = ent->field_0x46;
this->field_0x42 = ent->field_0x42;
ent->field_0x42 = 0;
diff --git a/src/enemy/spikedBeetle.c b/src/enemy/spikedBeetle.c
index 503084e7..727243a2 100644
--- a/src/enemy/spikedBeetle.c
+++ b/src/enemy/spikedBeetle.c
@@ -52,7 +52,7 @@ void sub_0802B628(Entity* this) {
this->speed = 0xc0;
this->direction = this->field_0x3e;
this->field_0x42 = 0;
- this->hurtBlinkTime = -8;
+ this->iframes = -8;
this->damageType = 100;
InitializeAnimation(this, 9);
}
diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c
index 7bf39713..7b2424b8 100644
--- a/src/enemy/spinyChuchu.c
+++ b/src/enemy/spinyChuchu.c
@@ -117,11 +117,11 @@ void sub_080225EC(Entity* this) {
}
void sub_08022654(Entity* this) {
- switch (this->previousActionFlag) {
+ switch (this->subAction) {
case 0:
if (--this->field_0xf)
return;
- this->previousActionFlag = 1;
+ this->subAction = 1;
SoundReq(0x12d);
InitializeAnimation(this, 0);
/* fallthrough */
@@ -129,7 +129,7 @@ void sub_08022654(Entity* this) {
if (sub_08003FC4(this, 0x1800))
return;
- this->previousActionFlag = 2;
+ this->subAction = 2;
this->spriteSettings.b.draw = 1;
InitializeAnimation(this, 5);
EnqueueSFX(0x7d);
diff --git a/src/enemy/tektite.c b/src/enemy/tektite.c
index 66d2ca82..506cd20f 100644
--- a/src/enemy/tektite.c
+++ b/src/enemy/tektite.c
@@ -29,7 +29,7 @@ void sub_0802F150(Entity* this) {
switch (this->bitfield & 0x3f) {
case 0x14:
this->action = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
if (this->type != 0) {
this->actionDelay = 0xc0;
} else {
@@ -70,7 +70,7 @@ void sub_0802F210(Entity* this) {
sub_0804A720(this);
this->action = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->actionDelay = gUnk_080CDEF8[Random() & 3];
this->actionDelay = (Random() & 0x1f) + this->actionDelay;
this->field_0xf = 0;
@@ -119,7 +119,7 @@ void sub_0802F300(Entity* this) {
if (sub_080044EC(this, this->field_0x80.HWORD) == 1) {
this->action = 3;
- this->previousActionFlag = 0;
+ this->subAction = 0;
if (this->type != 0) {
rand = 0;
}
@@ -146,9 +146,9 @@ void sub_0802F300(Entity* this) {
}
}
- if ((this->previousActionFlag == 0) && (temp < this->height.HALF.HI)) {
+ if ((this->subAction == 0) && (temp < this->height.HALF.HI)) {
InitializeAnimation(this, 4);
- this->previousActionFlag = 1;
+ this->subAction = 1;
}
if (temp < -0xc) {
diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c
index 3bf14e34..35399b09 100644
--- a/src/enemy/tektiteGolden.c
+++ b/src/enemy/tektiteGolden.c
@@ -27,7 +27,7 @@ void sub_08037F00(Entity* this) {
sub_0804AA30(this, &gUnk_080CF4A0);
if (this->bitfield == 0x94) {
this->action = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->actionDelay = 0x14;
this->field_0xf = 0;
this->field_0x80.HALF.LO = 0;
@@ -69,7 +69,7 @@ void sub_08037FA0(Entity* this) {
}
sub_0804A720(this);
this->action = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->actionDelay = (Random() & 0x1f) + 0x20;
this->field_0xf = 0;
this->field_0x80.HALF.LO = 0;
@@ -106,7 +106,7 @@ void sub_08038048(Entity* this) {
if (sub_080044EC(this, 0x3000) == 1) {
this->action = 3;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->actionDelay = 0x14;
InitializeAnimation(this, 3);
return;
@@ -121,9 +121,9 @@ void sub_08038048(Entity* this) {
sub_08038168(this);
}
- if ((this->previousActionFlag == 0) && (temp < this->height.HALF.HI)) {
+ if ((this->subAction == 0) && (temp < this->height.HALF.HI)) {
InitializeAnimation(this, 4);
- this->previousActionFlag = 1;
+ this->subAction = 1;
}
if (temp < -0xc) {
diff --git a/src/enemy/wisp.c b/src/enemy/wisp.c
index 10463258..d611c173 100644
--- a/src/enemy/wisp.c
+++ b/src/enemy/wisp.c
@@ -49,7 +49,7 @@ void sub_08033564(Entity* this) {
break;
case 0x14:
this->flags &= 0x7f;
- this->hurtBlinkTime = 0;
+ this->iframes = 0;
this->spriteSettings.b.draw = FALSE;
ent = CreateFx(this, 2, 0);
if (ent != NULL) {
@@ -64,12 +64,12 @@ void sub_08033564(Entity* this) {
void sub_0803362C(Entity* this) {
if (sub_0806F520() != 0) {
- gUnk_080CEB98[this->previousActionFlag](this);
+ gUnk_080CEB98[this->subAction](this);
}
}
void sub_08033650(Entity* this) {
- this->previousActionFlag = 2;
+ this->subAction = 2;
}
void sub_08033658(Entity* this) {
diff --git a/src/game.c b/src/game.c
index 08d0198a..8d4654b0 100644
--- a/src/game.c
+++ b/src/game.c
@@ -13,7 +13,6 @@
extern u8 gArea;
extern Entity gPlayerEntity;
-extern u32 gUnk_03000B80;
extern u32 gUnk_03003FC0;
extern u16 gWalletSizes[4];
@@ -238,7 +237,7 @@ void InitializePlayer(void) {
Entity* pl;
sub_080784C8();
- MemClear32((void*)&gUnk_03000B80, 0x70);
+ MemClear32((void*)&gUnk_03000B80, sizeof(gUnk_03000B80));
MemClear32((void*)&gPlayerState, 0xb0);
MemFill32(0xffffffff, &gPlayerState.field_0x40, 0x40);
diff --git a/src/item.c b/src/item.c
index ad7a419b..efe29411 100644
--- a/src/item.c
+++ b/src/item.c
@@ -28,7 +28,6 @@ extern void (*const gUnk_0811BDE0[])(ItemBehavior* beh, u32);
extern void (*const gUnk_0811BDE8[])(ItemBehavior* beh, u32);
extern void (*const gUnk_0811BDF4[])(ItemBehavior* beh, u32);
-extern u8 gUnk_02034490;
#if 0
void Ocarina(ItemBehavior* beh, u32 inputFlags) {
gOcarinaStates[beh->stateID](beh, inputFlags);
diff --git a/src/item11.c b/src/item11.c
index 984d02e0..78d4168b 100644
--- a/src/item11.c
+++ b/src/item11.c
@@ -16,7 +16,7 @@ extern Hitbox* gUnk_080B3DE8[];
void Item11(Entity* this) {
if (this->currentHealth) {
- this->hurtBlinkTime = 0;
+ this->iframes = 0;
gUnk_080B3DD0[this->action](this);
} else {
DeleteThisEntity();
@@ -82,7 +82,7 @@ void sub_08018DE8(Entity* this) {
sub_08018F6C(this);
break;
case 5:
- this->attachedEntity->previousActionFlag = 4;
+ this->attachedEntity->subAction = 4;
this->flags = this->flags | 0x80;
this->action = 2;
this->spritePriority.b0 = 2;
diff --git a/src/manager/manager15.c b/src/manager/manager15.c
index 87135c56..66e92559 100644
--- a/src/manager/manager15.c
+++ b/src/manager/manager15.c
@@ -251,10 +251,10 @@ void sub_0805A664(Manager15* this) {
sub_0805A68C(this);
}
-extern u32 sub_0806FBFC(u32, u32, u32, u32);
+extern u32 CheckPlayerProximity(u32, u32, u32, u32);
void sub_0805A68C(Manager15* this) {
- if (sub_0806FBFC(this->unk_38 - 0x18, this->unk_3a - 0x18, 0x30, 0x30)) {
+ if (CheckPlayerProximity(this->unk_38 - 0x18, this->unk_3a - 0x18, 0x30, 0x30)) {
if (this->unk_2c <= 0x1007) {
gScreen.controls.alphaBlend = ++this->unk_2c;
this->unk_22 = 0;
@@ -285,7 +285,7 @@ void sub_0805A6E8(Manager15* this) {
}
u32 sub_0805A73C(Manager15* this) {
- return sub_0806FBFC(this->unk_38 - 0x6, this->unk_3a - 0x6, 0xC, 0xC);
+ return CheckPlayerProximity(this->unk_38 - 0x6, this->unk_3a - 0x6, 0xC, 0xC);
}
void sub_0805A758(Manager15* this) {
diff --git a/src/manager/manager1A.c b/src/manager/manager1A.c
index 19a1dbca..46acfb2e 100644
--- a/src/manager/manager1A.c
+++ b/src/manager/manager1A.c
@@ -30,7 +30,7 @@ void sub_0805B030(Manager1A* this) {
}
extern void sub_08052D74(void*, void*, void*);
-extern u32 sub_0806FBFC(u32, u32, u32, u32);
+extern u32 CheckPlayerProximity(u32, u32, u32, u32);
typedef struct struct_08108764 {
u8 unk_00;
@@ -138,7 +138,7 @@ void sub_0805B168(Manager1A* this) {
u32 sub_0805B1CC(Manager1A* this) {
u32 re = 0;
- if (sub_0806FBFC(this->unk_20, this->unk_22, this->unk_24, this->unk_26)) {
+ if (CheckPlayerProximity(this->unk_20, this->unk_22, this->unk_24, this->unk_26)) {
if ((gPlayerState.flags.all & 0x4) && (gPlayerState.flags.all & 0x1)) {
gPlayerState.flags.all |= 0x8000;
} else if (gPlayerState.flags.all & 0x8000) {
diff --git a/src/manager/manager3.c b/src/manager/manager3.c
index 5234f149..15676771 100644
--- a/src/manager/manager3.c
+++ b/src/manager/manager3.c
@@ -6,6 +6,8 @@
#include "player.h"
#include "functions.h"
+// Facilitates the usage of minish portals.
+
typedef struct {
Manager manager;
u32 unk_20;
@@ -21,7 +23,7 @@ typedef struct {
} Manager3;
extern s8 gUnk_08107C6C[];
-extern u32 sub_0806FBFC(u32, u32, u32, u32);
+extern u32 CheckPlayerProximity(u32, u32, u32, u32);
extern u32 sub_08057810(void);
extern u32 sub_080002C0(u16, u16, u8);
extern void sub_080577AC(u32, u32, u32);
@@ -34,14 +36,14 @@ void sub_080576C0(Manager3* this) {
this->unk_24 = this->unk_3a + gRoomControls.roomOriginY - 0x20;
return;
}
- if (sub_0806FBFC(this->unk_20, this->unk_24, 0x40, 0x40)) {
- gArea.field_0x12 = this->unk_20 + 0x20;
- gArea.field_0x14 = this->unk_24 + 0x20 + gUnk_08107C6C[this->manager.unk_0a];
- gArea.field_0x16 = this->unk_34;
- gArea.field_0x17 = this->manager.unk_0a;
+ if (CheckPlayerProximity(this->unk_20, this->unk_24, 0x40, 0x40)) {
+ gArea.curPortalX = this->unk_20 + 0x20;
+ gArea.curPortalY = this->unk_24 + 0x20 + gUnk_08107C6C[this->manager.unk_0a];
+ gArea.curPortalExitDirection = this->unk_34;
+ gArea.curPortalType = this->manager.unk_0a;
if (!CheckGlobalFlag(EZERO_1ST)) {
gArea.field_0x18 = 1;
- gArea.field_0x17 = 5;
+ gArea.curPortalType = 5;
} else {
if ((gPlayerState.flags.all & 0x20) && gPlayerState.jumpStatus == 0) {
gArea.field_0x18 = 2;
@@ -90,7 +92,7 @@ void sub_080577AC(u32 baseX, u32 baseY, u32 layer) {
}
u32 sub_08057810(void) {
- if ((gPlayerState.flags.all & 0x80) && !gPlayerState.field_0xaa && (gArea.field_0x17 != 0x6) &&
+ if ((gPlayerState.flags.all & 0x80) && !gPlayerState.field_0xaa && (gArea.curPortalType != 0x6) &&
(gPlayerState.heldObject == 0)) {
switch (gPlayerState.field_0xa8) {
case 0:
diff --git a/src/npc/beedle.c b/src/npc/beedle.c
index 3e09302f..b4d25858 100644
--- a/src/npc/beedle.c
+++ b/src/npc/beedle.c
@@ -159,6 +159,6 @@ void sub_080634EC(Entity* this) {
void sub_08063504(Entity* this, ScriptExecutionContext* context) {
u32 uVar1;
- uVar1 = sub_080544DC(gUnk_0810C88C[this->type2]);
+ uVar1 = GetBottleContaining(gUnk_0810C88C[this->type2]);
context->condition = BOOLCAST(uVar1);
}
diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c
index d4896ce9..c51e4199 100644
--- a/src/npc/bigGoron.c
+++ b/src/npc/bigGoron.c
@@ -20,7 +20,7 @@ void BigGoron(Entity* this) {
void sub_0806CF30(Entity* this) {
if (this->action == 0) {
this->action = 1;
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x68.HWORD = this->x.HALF.HI;
sub_0805E3A0(this, 2);
sub_0806D0B0(this);
@@ -30,7 +30,7 @@ void sub_0806CF30(Entity* this) {
HandleEntity0x82Actions(this);
}
- switch (this->previousActionFlag) {
+ switch (this->subAction) {
case 0:
case 1:
if (gScreenTransition.frameCount % 4 == 0) {
diff --git a/src/npc/cow.c b/src/npc/cow.c
index d5e7988d..62d31597 100644
--- a/src/npc/cow.c
+++ b/src/npc/cow.c
@@ -56,8 +56,8 @@ void sub_08068FC0(Entity* ent) {
void sub_08069018(Entity* ent) {
s32 var0;
- if (ent->previousActionFlag == 0) {
- ent->previousActionFlag++;
+ if (ent->subAction == 0) {
+ ent->subAction++;
ent->field_0xf = (Random() & 0x3F) + 0x3C;
InitAnimationForceUpdate(ent, ent->animationState);
}
@@ -70,7 +70,7 @@ void sub_08069018(Entity* ent) {
} else {
ent->action = 3;
}
- ent->previousActionFlag = var0;
+ ent->subAction = var0;
}
sub_0806924C(ent);
@@ -79,10 +79,10 @@ void sub_08069018(Entity* ent) {
void sub_08069068(Entity* ent) {
s32 var0;
- if (ent->previousActionFlag == 0) {
+ if (ent->subAction == 0) {
u32 anim;
- ent->previousActionFlag++;
+ ent->subAction++;
anim = (Random() & 2) - 1;
anim = (anim + ent->animationState) & 3;
@@ -126,7 +126,7 @@ void sub_08069068(Entity* ent) {
var0 = --ent->field_0xf;
if (var0 == 0) {
ent->action = 3;
- ent->previousActionFlag = var0;
+ ent->subAction = var0;
}
sub_0806924C(ent);
@@ -134,7 +134,7 @@ void sub_08069068(Entity* ent) {
void sub_08069124(Entity* ent) {
UpdateAnimationSingleFrame(ent);
- gUnk_08111928[ent->previousActionFlag](ent);
+ gUnk_08111928[ent->subAction](ent);
sub_0806924C(ent);
}
@@ -142,13 +142,13 @@ void sub_08069148(Entity* ent) {
u32 var0 = Random() & 3;
var0 += 3;
ent->field_0xf = var0;
- ent->previousActionFlag = 1;
+ ent->subAction = 1;
InitAnimationForceUpdate(ent, ent->animationState + 8);
}
void sub_08069168(Entity* ent) {
if ((s8)ent->frames.all < 0) {
- ent->previousActionFlag = 2;
+ ent->subAction = 2;
InitAnimationForceUpdate(ent, ent->animationState + 12);
}
}
@@ -160,14 +160,14 @@ void sub_08069188(Entity* ent) {
if (((s8)--ent->field_0xf) != 0)
return;
- ent->previousActionFlag = 3;
+ ent->subAction = 3;
InitAnimationForceUpdate(ent, ent->animationState + 16);
}
void sub_080691BC(Entity* ent) {
if ((s8)ent->frames.all < 0) {
ent->action = 1;
- ent->previousActionFlag = 0;
+ ent->subAction = 0;
InitAnimationForceUpdate(ent, ent->animationState + 4);
}
}
@@ -175,7 +175,7 @@ void sub_080691BC(Entity* ent) {
void sub_080691E0(Entity* ent) {
if (UpdateFuseInteraction(ent) != 0) {
ent->action = 1;
- ent->previousActionFlag = 0;
+ ent->subAction = 0;
}
}
diff --git a/src/object/backgroundCloud.c b/src/object/backgroundCloud.c
index df2625a3..f47d276c 100644
--- a/src/object/backgroundCloud.c
+++ b/src/object/backgroundCloud.c
@@ -24,7 +24,7 @@ void sub_0808F658(Entity* this) {
this->animationState = 0;
this->x.HALF.HI += (Random() & 0xf) << 4;
this->actionDelay = 0;
- this->previousActionFlag = 0;
+ this->subAction = 0;
}
void sub_0808F6E0(Entity* this) {
@@ -35,8 +35,8 @@ void sub_0808F6E0(Entity* this) {
}
void sub_0808F70C(Entity* this) {
- if (this->previousActionFlag == 0) {
- this->previousActionFlag = 1;
+ if (this->subAction == 0) {
+ this->subAction = 1;
this->actionDelay = ((Random() & 7) << 3) + 31;
if ((this->direction & 0x10)) {
@@ -49,10 +49,10 @@ void sub_0808F70C(Entity* this) {
this->y.HALF.HI = gUnk_08121EB3[this->type2 * 2 + (Random() & 1)];
}
- if (this->previousActionFlag == 1) {
+ if (this->subAction == 1) {
if (--this->actionDelay == 0) {
this->action = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
}
}
}
diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c
index a64217f1..12cbf897 100644
--- a/src/object/bakerOven.c
+++ b/src/object/bakerOven.c
@@ -59,12 +59,12 @@ void sub_0809CD0C(Entity* this) {
}
/* Damage minish link if he touches a steam cloud */
- if (this->field_0xf == 0 && gPlayerEntity.hurtBlinkTime == 0 && this->frameIndex &&
+ if (this->field_0xf == 0 && gPlayerEntity.iframes == 0 && this->frameIndex &&
sub_0806FC80(this, &gPlayerEntity, 4)) {
this->field_0xf++;
ModHealth(-2);
sub_0800449C(&gPlayerEntity, 0x7a);
- gPlayerEntity.hurtBlinkTime = 16;
+ gPlayerEntity.iframes = 16;
gPlayerEntity.field_0x3e = 16;
gPlayerEntity.field_0x42 = 12;
gPlayerEntity.field_0x46 = 16;
diff --git a/src/object/bird.c b/src/object/bird.c
index 6d126380..ca248b21 100644
--- a/src/object/bird.c
+++ b/src/object/bird.c
@@ -69,7 +69,7 @@ void sub_0809D048(Entity* this) {
}
void sub_0809D06C(Entity* this) {
- gUnk_08123EFC[this->previousActionFlag](this);
+ gUnk_08123EFC[this->subAction](this);
}
void sub_0809D084(Entity* this) {
@@ -80,7 +80,7 @@ void sub_0809D084(Entity* this) {
if (temp != 0) {
PositionRelative(this->parent, this, 0, 0x80000);
} else {
- this->previousActionFlag++;
+ this->subAction++;
this->field_0x20 = temp;
}
}
diff --git a/src/object/button.c b/src/object/button.c
index 23a2ee8d..b98d6169 100644
--- a/src/object/button.c
+++ b/src/object/button.c
@@ -47,7 +47,7 @@ void sub_08081FF8(Entity*);
void sub_08081BAC(Entity* this) {
if (sub_08081CB0(this)) {
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->actionDelay = 0xA;
sub_0805E4E0(this, 0xA);
sub_08081FF8(this);
diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c
index 0d9b6e81..2b6edaae 100644
--- a/src/object/houseDoorExterior.c
+++ b/src/object/houseDoorExterior.c
@@ -61,7 +61,7 @@ void sub_080866D8(Entity* this) {
entity->field_0x68.HWORD = prop->unk0;
entity->field_0x6a.HWORD = prop->unk2;
entity->collisionLayer = prop->unk4;
- entity->previousActionFlag = prop->unk5;
+ entity->subAction = prop->unk5;
UpdateSpriteForCollisionLayer(entity);
*((u32*)(&this->field_0x68)) |= mask;
if (prop->unk8) {
@@ -98,7 +98,7 @@ static void sub_0808681C(Entity* this) {
this->spriteSettings.b.draw = 1;
this->frameIndex = 0;
this->hitbox = &gUnk_081206AC;
- if (this->previousActionFlag == 1) {
+ if (this->subAction == 1) {
this->action = 2;
this->frameIndex = 1;
}
@@ -158,7 +158,7 @@ void sub_0808692C(Entity* this) {
this->flags &= 0xFD;
this->type2 = 2;
this->action = this->frameIndex == 0 ? 1 : 2;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->actionDelay = 8;
}
diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c
index b794b546..b30b1d33 100644
--- a/src/object/itemOnGround.c
+++ b/src/object/itemOnGround.c
@@ -162,7 +162,7 @@ static void sub_080810FC(Entity* this) {
sub_08081598(this);
} else {
this->action = 2;
- this->previousActionFlag = 0;
+ this->subAction = 0;
this->flags |= 0x80;
this->flags2 = 0x11;
CopyPosition(&gPlayerEntity, this);
@@ -304,11 +304,11 @@ void sub_0808136C(Entity* this) {
}
static void sub_080813BC(Entity* this) {
- gUnk_0811E840[this->previousActionFlag](this);
+ gUnk_0811E840[this->subAction](this);
}
void sub_080813D4(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 1;
this->spriteSettings.b.draw = 1;
}
diff --git a/src/object/object2A.c b/src/object/object2A.c
index ffd00460..dca66978 100644
--- a/src/object/object2A.c
+++ b/src/object/object2A.c
@@ -31,7 +31,7 @@ void sub_08089B18(Entity* this) {
case 4:
if (!CheckFlags(this->field_0x86.HWORD)) {
this->spriteSettings.b.draw = FALSE;
- this->previousActionFlag = 1;
+ this->subAction = 1;
return;
}
}
diff --git a/src/object/object49.c b/src/object/object49.c
index 16bf7bb9..7271d2d6 100644
--- a/src/object/object49.c
+++ b/src/object/object49.c
@@ -150,13 +150,13 @@ void sub_0808F2C0(Entity* this) {
void sub_0808F370(Entity* this) {
if (this->action == 0) {
- if (this->parent->previousActionFlag == 1) {
+ if (this->parent->subAction == 1) {
this->action = 1;
this->field_0x70.WORD = 0;
sub_0808F5EC(this);
}
} else {
- u8 flag = this->parent->previousActionFlag - 1;
+ u8 flag = this->parent->subAction - 1;
if (flag < 5) {
if (this->field_0x70.WORD == 0) {
if (--(*(u32*)&this->field_0x74) == -1) {
diff --git a/src/object/object86.c b/src/object/object86.c
index 9706e040..8aadd5ff 100644
--- a/src/object/object86.c
+++ b/src/object/object86.c
@@ -18,7 +18,7 @@ void sub_08099DD0(Entity* this) {
this->collisionLayer = 1;
this->spriteRendering.b3 = 3;
this->spritePriority.b0 = 7;
- this->previousActionFlag = 0;
+ this->subAction = 0;
if (GetInventoryValue(0x46)) {
this->action = 4;
this->frameIndex = 0;
@@ -31,7 +31,7 @@ void sub_08099DD0(Entity* this) {
void sub_08099E10(Entity* this) {
if (CheckLocalFlag(0x74)) {
GetNextFrame(this);
- if ((this->frames.all == 1) && (this->previousActionFlag == 0)) {
+ if ((this->frames.all == 1) && (this->subAction == 0)) {
this->frames.all = 0;
sub_08099ECC(this);
}
@@ -56,7 +56,7 @@ void sub_08099E58(Entity* this) {
void sub_08099E8C(Entity* this) {
if (sub_080041A0(this, &gPlayerEntity, 0xc, 0xc)) {
- if (this->previousActionFlag == 0) {
+ if (this->subAction == 0) {
sub_08099ECC(this);
sub_0805E4E0(this, 0x1e);
}
@@ -70,7 +70,7 @@ void nullsub_534(Entity* this) {
}
void sub_08099ECC(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
CopyPosition(this, &gPlayerEntity);
gPlayerState.playerAction = 3;
gPlayerState.field_0x34[4] = 0;
diff --git a/src/object/pot.c b/src/object/pot.c
index f28fb9ee..1c44efef 100644
--- a/src/object/pot.c
+++ b/src/object/pot.c
@@ -62,7 +62,7 @@ void sub_08082310(Entity* this) {
switch (var0) {
case 0x13:
this->action = 3;
- this->previousActionFlag = 0;
+ this->subAction = 0;
break;
case 0x1D:
SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer);
@@ -114,7 +114,7 @@ void sub_08082310(Entity* this) {
}
void sub_080824F8(Entity* this) {
- gUnk_0811F0A8[this->previousActionFlag](this);
+ gUnk_0811F0A8[this->subAction](this);
}
void sub_08082510(Entity* this) {
@@ -125,7 +125,7 @@ void sub_08082510(Entity* this) {
this->flags2 = gPlayerEntity.flags2;
this->spriteOffsetY = 0;
SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer);
- this->previousActionFlag++;
+ this->subAction++;
}
void nullsub_511(Entity* this) {
@@ -166,7 +166,7 @@ void sub_080825F0(Entity* this) {
static void sub_08082608(Entity* this) {
this->action = 1;
- this->previousActionFlag = 0;
+ this->subAction = 0;
}
void sub_08082614(Entity* this) {
@@ -203,11 +203,11 @@ void sub_08082614(Entity* this) {
}
void sub_080826E4(Entity* this) {
- gUnk_0811F0C4[this->previousActionFlag](this);
+ gUnk_0811F0C4[this->subAction](this);
}
void sub_080826FC(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->field_0x1d = 48;
this->actionDelay = 0;
}
diff --git a/src/player.c b/src/player.c
index 7dfcbb93..49949c20 100644
--- a/src/player.c
+++ b/src/player.c
@@ -7,34 +7,60 @@
#include "area.h"
#include "save.h"
-extern const void (*const gUnk_0811B9E0[])(Entity*);
-extern const void (*const gUnk_0811BA60[])(Entity*);
-extern const void (*const gUnk_0811BA68[])(Entity*);
-extern const void (*const gUnk_0811BA74[])(Entity*);
-extern const void (*const gUnk_0811BA7C[])(Entity*);
-extern const void (*const gUnk_0811BA88[])(Entity*);
-extern const void (*const gUnk_0811BA94[])(Entity*);
-extern const void (*const gUnk_0811BA9C[])(Entity*);
-
-extern void sub_08079458();
+static void (*const sPlayerActions[])(Entity*);
+extern void (*const gUnk_0811BA60[])(Entity*);
+extern void (*const gUnk_0811BA68[])(Entity*);
+extern void (*const gUnk_0811BA74[])(Entity*);
+extern void (*const gUnk_0811BA7C[])(Entity*);
+extern void (*const gUnk_0811BA88[])(Entity*);
+extern void (*const gUnk_0811BA94[])(Entity*);
+extern void (*const gUnk_0811BA9C[])(Entity*);
+extern void (*const gUnk_0811BAD4[])(Entity*);
+extern void (*const gUnk_0811BAE4[])(Entity*);
+extern void (*const gUnk_0811BB3C[])(Entity*);
+
+extern void RespawnPlayer();
extern void sub_080797EC();
extern void sub_08079E08();
extern void sub_08078F60();
+extern void sub_0806F948();
+extern void sub_08077698();
+extern void sub_0805E544();
+extern void sub_080717F8();
+extern void DoExitTransition();
+extern void UnfreezeTime();
+extern void sub_08071A6C();
+extern void sub_08052BB8();
+extern void sub_08079258();
+extern void sub_08071AF0();
+extern void sub_080728AC();
+extern void sub_0807A298();
+extern u32 sub_08079B24();
+extern void sub_08079708();
+extern void sub_080792D8();
+
+typedef struct {
+ u8 frame;
+ u8 dummy;
+ u16 speed;
+} PushFrames;
+
+extern PushFrames gUnk_0811BAF0[];
extern Hitbox gUnk_08114F88;
+extern ScreenTransitionData gUnk_0813AB58;
-// inject
-void sub_08070680(Entity* this) {
- gUnk_0811B9E0[this->action](this);
+void DoPlayerAction(Entity* this) {
+ sPlayerActions[this->action](this);
}
-void sub_08070698(Entity* this) {
+void PlayerInit(Entity* this) {
Entity* ent;
gPlayerState.field_0x0[0] = 0xff;
- gPlayerState.field_0x16[0] = gPlayerEntity.x.HALF.HI;
- gPlayerState.field_0x16[1] = gPlayerEntity.y.HALF.HI;
- this->flags = this->flags | 0x80;
+ gPlayerState.startPosX = gPlayerEntity.x.HALF.HI;
+ gPlayerState.startPosY = gPlayerEntity.y.HALF.HI;
+ this->flags |= 0x80;
this->spritePriority.b0 = 0xc;
this->spritePriority.b1 = 1;
this->spriteSettings.b.shadow = 1;
@@ -74,9 +100,7 @@ void sub_08070698(Entity* this) {
}
// PlayerState.flags need to be 100% before this one can reasonably be done
-NONMATCH("asm/non_matching/player/sub_08070794.s", void sub_08070794(Entity* this)) {
-}
-END_NONMATCH
+ASM_FUNC("asm/non_matching/player/sub_08070794.s", void PlayerNormal(Entity* this))
void sub_08070BEC(Entity* this, u32 r0) {
if (r0 & 1)
@@ -88,12 +112,12 @@ void sub_08070BEC(Entity* this, u32 r0) {
sub_08079E08();
}
-void sub_08070C10(Entity* this) {
- gPlayerState.field_0xd[0] = 0xFF;
+void PlayerFall(Entity* this) {
+ gPlayerState.field_0xd = 0xFF;
gPlayerState.pushedObject = 0x80;
gPlayerState.field_0xa8 = 10;
- gUnk_0811BA60[this->previousActionFlag](this);
+ gUnk_0811BA60[this->subAction](this);
}
void sub_08070C3C(Entity* this) {
@@ -111,7 +135,7 @@ void sub_08070C3C(Entity* this) {
else
gPlayerState.field_0x8 = 0x1b8;
- this->previousActionFlag++;
+ this->subAction++;
this->flags &= ~0x80;
this->spritePriority.b1 = 0;
ResetPlayer();
@@ -128,16 +152,16 @@ void sub_08070CB4(Entity* this) {
this->spriteSettings.b.draw = 0;
} else {
gPlayerState.flags.all &= ~(0x4 | 0x8000);
- sub_08079458();
+ RespawnPlayer();
gPlayerState.field_0xa = 0;
- this->hurtBlinkTime = 0x20;
+ this->iframes = 32;
ModHealth(-2);
}
}
}
-void sub_08070D20(Entity* this) {
- gUnk_0811BA68[this->previousActionFlag](this);
+void PlayerBounce(Entity* this) {
+ gUnk_0811BA68[this->subAction](this);
}
void sub_08070D38(Entity* this) {
@@ -145,7 +169,7 @@ void sub_08070D38(Entity* this) {
this->direction = ((this->animationState & 0xe) << 2) ^ 0x10;
this->speed = 0x100;
this->field_0x42 = 0;
- this->previousActionFlag++;
+ this->subAction++;
this->actionDelay = gPlayerState.field_0x38;
this->spriteIndex = 1;
@@ -201,7 +225,7 @@ NONMATCH("asm/non_matching/player/sub_08070DC4.s", void sub_08070DC4(Entity* thi
this->spriteIndex = 1;
this->actionDelay = 8;
- this->previousActionFlag++;
+ this->subAction++;
if ((gPlayerState.flags.all & 0x80) == 0)
gPlayerState.field_0x8 = 0x100;
@@ -224,7 +248,7 @@ void sub_08070E9C(Entity* this) {
gPlayerState.field_0x27[0] = 4;
gPlayerState.field_0xa8 = 0x13;
sub_0807A1B8();
- gUnk_0811BA74[this->previousActionFlag](this);
+ gUnk_0811BA74[this->subAction](this);
}
}
@@ -232,7 +256,7 @@ void sub_08070EDC(Entity* this) {
this->scriptedScene = 2;
if ((gTextBox.doTextBox & 0x7f) != 0)
- this->previousActionFlag = 1;
+ this->subAction = 1;
if ((gPlayerState.flags.all & 0x80) == 0)
sub_08079938();
@@ -248,13 +272,13 @@ void sub_08070f24(Entity* this) {
}
}
-void sub_08070F50(Entity* this) {
+void PlayerItemGet(Entity* this) {
Entity* child;
u8* temp; // todo: retype
gPlayerState.field_0xa8 = 0x15;
this->flags &= ~(0x80);
- gUnk_0811BA7C[this->previousActionFlag](this);
+ gUnk_0811BA7C[this->subAction](this);
child = this->attachedEntity;
if (child != NULL) {
@@ -275,7 +299,7 @@ void sub_08070FA4(Entity* this) {
gPlayerState.jumpStatus = 0;
if ((gPlayerState.flags.all & 0x80) == 0) {
- if ((gPlayerState.flags.all & 0x8) != 0) {
+ if (gPlayerState.flags.all & 0x8) {
if (sub_080542AC(gPlayerState.field_0x38)) {
temp = 0x45e;
} else {
@@ -291,16 +315,15 @@ void sub_08070FA4(Entity* this) {
gPlayerState.field_0x8 = temp;
}
- this->previousActionFlag = 1;
+ this->subAction = 1;
ResetPlayer();
sub_08078F60();
}
void sub_08071020(Entity* this) {
UpdateAnimationSingleFrame(this);
- if (this->frames.all != 0) {
- this->previousActionFlag = 2;
- }
+ if (this->frames.all != 0)
+ this->subAction = 2;
}
void sub_08071038(Entity* this) {
@@ -310,24 +333,24 @@ void sub_08071038(Entity* this) {
if (sub_08078EFC() || (gTextBox.doTextBox & 0x7f))
return;
- if ((this->frames.all & 0x80) != 0) {
+ if (this->frames.all & 0x80) {
this->attachedEntity = 0;
this->field_0x42 = 0;
- this->hurtBlinkTime = 0xf8;
+ this->iframes = 248;
gPlayerState.jumpStatus = 0;
sub_080791D0();
}
}
-void sub_08071084(Entity* this) {
+void PlayerJump(Entity* this) {
gPlayerState.field_0xa8 = 0xb;
- gUnk_0811BA88[this->previousActionFlag](this);
+ gUnk_0811BA88[this->subAction](this);
}
void sub_080710A8(Entity* this) {
u32 temp;
- this->previousActionFlag++;
+ this->subAction++;
gPlayerState.flags.all |= 1;
gPlayerState.flags.all &= ~(0x400 | 0x800);
@@ -353,7 +376,7 @@ void sub_080710A8(Entity* this) {
asm("lsl r0, r0, #0x4");
this->field_0x20 = (temp - 4) * 64 * 64;
- this->speed = 0x100;
+ this->speed = 256;
sub_0807A108();
SoundReq(0x7c);
SoundReq(0x78);
@@ -367,7 +390,7 @@ void sub_08071130(Entity* this) {
if (gPlayerState.field_0x1a[1] == 0) {
UpdateAnimationSingleFrame(this);
- if ((this->frames.all & 1))
+ if (this->frames.all & 1)
return;
}
@@ -401,7 +424,7 @@ void sub_08071130(Entity* this) {
this->actionDelay = 6;
if (((gPlayerState.heldObject | gPlayerState.keepFacing) == 0) && ((gPlayerState.flags.all & 0x80) == 0)) {
- if ((gPlayerState.flags.all & 0x8) != 0) {
+ if (gPlayerState.flags.all & 0x8) {
gPlayerState.field_0x8 = 0x424;
} else {
gPlayerState.field_0x8 = 0x820;
@@ -409,7 +432,7 @@ void sub_08071130(Entity* this) {
this->animIndex = 0xff;
}
- this->previousActionFlag++;
+ this->subAction++;
sub_08078F60();
this->field_0x42 = 0;
SoundReq(0x7d);
@@ -428,33 +451,31 @@ void sub_08071208(Entity* this) {
}
}
-void sub_08071248(Entity* this) {
+void PlayerDrown(Entity* this) {
gPlayerState.field_0xa8 = 0x16;
gPlayerState.flags.all |= 4;
this->flags &= ~0x80;
- gUnk_0811BA94[this->previousActionFlag](this);
+ gUnk_0811BA94[this->subAction](this);
}
void sub_0807127C(Entity* this) {
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->spritePriority.b1 = 0;
- if ((gPlayerState.flags.all & 0x80) != 0) {
+ if (gPlayerState.flags.all & 0x80) {
this->actionDelay = 0x3c;
gPlayerState.field_0x8 = 0xc19;
SoundReq(0x84);
} else {
- if ((gPlayerState.flags.all & 0x10000) == 0) {
+ if ((gPlayerState.flags.all & 0x10000) == 0)
sub_08004168(this);
- }
CreateFx(this, 11, 0);
- if ((gPlayerState.flags.all & 8) == 0) {
+ if ((gPlayerState.flags.all & 8) == 0)
gPlayerState.field_0x8 = 0x72c;
- } else {
+ else
gPlayerState.field_0x8 = 0x44c;
- }
}
ResetPlayer();
}
@@ -480,28 +501,29 @@ void sub_080712F0(Entity* this) {
return;
this->field_0x42 = 0;
- this->hurtBlinkTime = 0x20;
+ this->iframes = 32;
this->spritePriority.b1 = 1;
this->spriteSettings.b.draw = FALSE;
- gPlayerState.flags.all &= ~(0x4);
- sub_08079458();
+ gPlayerState.flags.all &= ~0x4;
+ RespawnPlayer();
}
-void sub_08071380(Entity* this) {
+static void PlayerUsePortal(Entity* this) {
gPlayerState.field_0xa8 = 0xe;
- gUnk_0811BA9C[this->previousActionFlag](this);
+ gUnk_0811BA9C[this->subAction](this);
- if ((this->previousActionFlag == 7) || (this->previousActionFlag < 3))
+ // probably a switch
+ if ((this->subAction == 7) || (this->subAction < 3))
return;
if ((gPlayerState.flags.all & 0x20) == 0)
return;
- if ((gInput.newKeys & 0x102) == 0)
+ if ((gInput.newKeys & (0x100 | 0x2)) == 0)
return;
- if (CheckIsDungeon() || gArea.field_0x17 == 3) {
- this->previousActionFlag = 7;
+ if (CheckIsDungeon() || gArea.curPortalType == 3) {
+ this->subAction = 7;
this->actionDelay = 30;
DoFade(7, 16);
SoundReq(0xf8);
@@ -510,19 +532,19 @@ void sub_08071380(Entity* this) {
}
}
-void sub_08071400(Entity* this) {
+static void PortalJumpOnUpdate(Entity* this) {
u16 x;
u16 y;
- this->flags &= ~(0x80);
+ this->flags &= ~0x80;
this->field_0x42 = 0;
- x = gArea.field_0x12;
- y = gArea.field_0x14;
+ x = gArea.curPortalX;
+ y = gArea.curPortalY;
if ((this->x.HALF.HI != x) || (this->y.HALF.HI != y)) {
- this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, gArea.field_0x12, gArea.field_0x14);
- this->speed = 0x100;
+ this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, gArea.curPortalX, gArea.curPortalY);
+ this->speed = 256;
sub_08079E08();
}
@@ -531,17 +553,542 @@ void sub_08071400(Entity* this) {
if (gPlayerState.jumpStatus == 0) {
gPlayerState.flags.all |= 0x20;
- this->previousActionFlag = 1;
+ this->subAction = 1;
this->animationState = 4;
this->spriteSettings.b.flipX = FALSE;
- if (gArea.field_0x17 == 4) {
+ if (gArea.curPortalType == 4) {
gPlayerState.field_0x8 = 0x52c;
}
}
this->actionDelay = 8;
- if (gArea.field_0x17 != 3) {
+ if (gArea.curPortalType != 3) {
this->spritePriority.b0 = 3;
}
}
+
+static void PortalStandUpdate(Entity* this) {
+ switch (gArea.curPortalType) {
+ case 4:
+ case 5:
+ sub_0806F948(&gPlayerEntity);
+ break;
+ }
+
+ if ((gPlayerState.field_0xd & 0x84) == 0) {
+ if (this->direction != gPlayerState.field_0xd) {
+ this->actionDelay = 8;
+ }
+ if (--this->actionDelay == 0xff) {
+ this->direction = gPlayerState.field_0xd;
+ this->animationState = this->direction >> 2;
+ this->field_0x20 = 0x20000;
+ this->speed = 256;
+ this->action = 9;
+ this->subAction = 7;
+ this->field_0xf = 0;
+ gPlayerState.field_0x8 = (gPlayerState.flags.all & 8) ? 0x41C : 0x80C;
+ gPlayerState.flags.all &= ~0x20;
+ return;
+ }
+ this->direction = gPlayerState.field_0xd;
+ } else {
+ this->actionDelay = 8;
+ }
+
+ if (gArea.curPortalType == 4) {
+ if (this->frames.all == 0) {
+ UpdateAnimationSingleFrame(this);
+ return;
+ }
+ } else {
+ sub_08077698(this);
+ }
+ sub_08079938();
+}
+
+static void PortalActivateInit(Entity* this) {
+ gRoomControls.cameraTarget = NULL;
+ gUnk_02034490[0] = 1;
+ this->subAction = 3;
+ this->field_0xf = 0x1e;
+ gPlayerState.field_0x8 = 0x738;
+ CreateObjectWithParent(this, 6, 1, 0);
+ sub_08077B20();
+ sub_0805E544();
+}
+
+static void PortalActivateUpdate(Entity* this) {
+ if (this->field_0xf)
+ return;
+
+ UpdateAnimationSingleFrame(this);
+
+ if (gPlayerState.flags.all & 0x80)
+ this->subAction = 4;
+}
+
+static void PortalShrinkInit(Entity* this) {
+ this->subAction = 5;
+ this->spritePriority.b1 = 0;
+ this->field_0xf = 0;
+ this->spriteRendering.b0 = 3;
+ *(u32*)&this->field_0x80.HWORD = 0x100;
+ *(u32*)&this->cutsceneBeh = 0x100;
+ sub_0805EC9C(this, 0x100, 0x100, 0);
+ gPlayerState.field_0x8 = 0x2c3;
+ gPlayerState.flags.all |= 0x80;
+ SoundReq(0x16f);
+}
+
+// horrible
+ASM_FUNC("asm/non_matching/player/sub_08071634.s", static void PortalShrinkUpdate(Entity* this))
+
+static void PortalEnterUpdate(Entity* this) {
+ if (this->actionDelay == 0) {
+ if (sub_08003FC4(this, 0x2000))
+ return;
+
+ this->spriteSettings.b.draw = FALSE;
+
+ if (gArea.curPortalType == 3) {
+ if (--this->field_0xf == 0)
+ sub_080717F8(this);
+ return;
+ }
+ if (gArea.curPortalType == 6)
+ DoExitTransition(&gUnk_0813AB58);
+ else
+ gArea.playShrinkSeq = 1;
+
+ return;
+ }
+ this->actionDelay--;
+}
+
+static void PortalUnknownUpdate(Entity* this) {
+ if (gFadeControl.active)
+ return;
+
+ if (this->actionDelay != 0) {
+ this->actionDelay--;
+ return;
+ }
+
+ sub_080717F8(this);
+ sub_080500F4(0x10);
+}
+
+extern s16 gUnk_0811BAC4[];
+
+void sub_080717F8(Entity* this) {
+ u32 x;
+ u32 y;
+ this->animationState = gArea.curPortalExitDirection << 1;
+ this->x.HALF.HI = gArea.curPortalX + gUnk_0811BAC4[gArea.curPortalExitDirection * 2];
+ this->y.HALF.HI = gArea.curPortalY + gUnk_0811BAC4[gArea.curPortalExitDirection * 2 + 1];
+ gArea.unk1A = 0xb4;
+ gUnk_02034490[0] = 0;
+ this->action = 9;
+ this->subAction = 0;
+ gPlayerState.flags.all = (gPlayerState.flags.all & ~0x20) | 0x80;
+ sub_0805EC60(this);
+ UnfreezeTime();
+}
+
+void PlayerTalkEzlo(Entity* this) {
+ if (sub_08078EFC()) {
+ sub_08056360();
+ sub_08071A6C();
+ } else {
+ gPlayerState.field_0xa8 = 0x13;
+ this->flags &= ~0x80;
+ gUnk_0811BAD4[this->subAction](this);
+ }
+}
+
+void sub_080718A0(Entity* this) {
+ ResetPlayer();
+ gUnk_03000B80.filler[0x63] = 0;
+ this->iframes = 0;
+ gUnk_03003DC0.unk0 = 6;
+ this->scriptedScene = 6;
+
+ if (gPlayerState.flags.all & 0x80) {
+ this->subAction = 2;
+ this->spritePriority.b1 = 0;
+ sub_08052BB8();
+ return;
+ }
+
+ if (gPlayerState.jumpStatus == 0) {
+ this->subAction++;
+
+ if (this->animationState == 2)
+ gPlayerState.field_0x8 = 0x3ca;
+ else
+ gPlayerState.field_0x8 = 0x3c6;
+
+ this->spriteSettings.b.flipX = 0;
+ return;
+ }
+
+ if (!sub_08003FC4(this, 0x2000))
+ gPlayerState.jumpStatus = 0;
+}
+
+void sub_0807193C(Entity* this) {
+ Entity* child;
+
+ UpdateAnimationSingleFrame(this);
+ if (this->frames.all & 0x80) {
+ this->subAction++;
+ child = CreateObjectWithParent(this, 6, 0, 0);
+ this->attachedEntity = child;
+ if (child != NULL) {
+ if (this->animationState == 2)
+ gPlayerState.field_0x8 = 0x3cc;
+ else
+ gPlayerState.field_0x8 = 0x3c7;
+ sub_08052BB8();
+ }
+ }
+}
+
+void sub_08071990(Entity* this) {
+ u32 temp;
+
+ if ((gTextBox.doTextBox & 0x7f) == 0) {
+ this->subAction++;
+
+ if ((gPlayerState.flags.all & 0x80) == 0) {
+ if (this->animationState == 2)
+ gPlayerState.field_0x8 = 0x3cd;
+ else
+ gPlayerState.field_0x8 = 0x3c9;
+ } else {
+ sub_08071A6C();
+ sub_08079258();
+ }
+ return;
+ }
+
+ if (gPlayerState.flags.all & 0x80)
+ return;
+
+ if (this->animationState == 2)
+ temp = 4;
+ else
+ temp = 0;
+
+ if (this->attachedEntity->actionDelay != 0) {
+ if ((u8)(temp + 200) != this->animIndex) {
+ gPlayerState.field_0x8 = temp + 0x3c8;
+ return;
+ }
+ } else {
+ if ((u8)(temp + 199) != this->animIndex) {
+ gPlayerState.field_0x8 = temp + 0x3c7;
+ return;
+ }
+ }
+ UpdateAnimationSingleFrame(this);
+}
+
+void sub_08071A4C(Entity* this) {
+ UpdateAnimationSingleFrame(this);
+ if (this->frames.all & 0x80) {
+ sub_08071A6C();
+ sub_0807921C();
+ }
+}
+
+void sub_08071A6C(void) {
+ gUnk_03003DC0.unk0 = 0;
+ gPlayerEntity.scriptedScene = gPlayerEntity.scriptedScene2;
+}
+
+void PlayerPush(Entity* this) {
+ gPlayerState.field_0xa8 = 0x19;
+ gUnk_0811BAE4[this->subAction](this);
+}
+
+void sub_08071AB0(Entity* this) {
+ u32 speed;
+
+ this->subAction++;
+ gPlayerState.flags.all |= 1;
+ if (this->type == 1) {
+ this->speed = 0;
+ this->actionDelay = 0;
+ this->field_0xf = 1;
+ } else {
+ this->speed = (gPlayerState.flags.all & 0x80) ? 64 : 128;
+ }
+ sub_08071AF0(this);
+}
+
+void sub_08071AF0(Entity* this) {
+ gPlayerState.field_0x80 = 0;
+ UpdateAnimationSingleFrame(this);
+ if (this->type == 1) {
+ if (--this->field_0xf == 0) {
+ if (gUnk_0811BAF0[this->actionDelay].frame != 0xff) {
+ this->field_0xf = gUnk_0811BAF0[this->actionDelay].frame;
+ this->speed = gUnk_0811BAF0[this->actionDelay].speed;
+ this->actionDelay++;
+ } else {
+ this->subAction++;
+ return;
+ }
+ }
+ } else {
+ gPlayerState.pushedObject--;
+ if ((gPlayerState.pushedObject & 0x7f) == 0) {
+ this->subAction++;
+ }
+ }
+ sub_08079E08();
+}
+
+void sub_08071B60(Entity* this) {
+ gPlayerState.pushedObject = 2;
+ gPlayerState.flags.all &= ~0x1;
+ this->type = 0;
+ this->field_0x42 = 0;
+ sub_080728AC(this);
+ this->field_0xf = 6;
+ if ((gPlayerState.flags.all & 0x80) == 0) {
+ gPlayerState.field_0x8 = 0x104;
+ this->spriteIndex = 3;
+ InitAnimationForceUpdate(this, (this->animationState >> 1) + 0x3c);
+ }
+}
+
+extern void (*const gUnk_0811BB2C[])(Entity*);
+
+void PlayerMinishDie(Entity* this) {
+ this->flags &= ~0x80;
+ gUnk_0811BB2C[this->subAction](this);
+ gPlayerState.field_0xa8 = 0x12;
+}
+
+void sub_08071BDC(Entity* this) {
+ u32 temp;
+
+ if (gPlayerState.flags.all & (0x10 | 0x100))
+ return;
+
+ if (sub_08003FC4(this, 0x2000)) {
+ if ((gPlayerState.flags.all & 8) != 0)
+ gPlayerState.field_0x8 = 0x420;
+ else
+ gPlayerState.field_0x8 = 0x810;
+ return;
+ }
+
+ gPlayerState.playerAction = 0;
+ if (gPlayerState.flags.all & 0x80) {
+ if ((u8)(gPlayerState.field_0x10[2] - 8) < 3) {
+ sub_0807A298(this);
+ RespawnPlayer();
+ this->action = 10;
+ }
+ temp = 0xc1a;
+ } else {
+ temp = (gPlayerState.flags.all & 8) ? 0x459 : 0x1bc;
+ }
+ gPlayerState.field_0x8 = temp;
+
+ gPlayerState.flags.all &= ~(0x1000000 | 0x200000 | 0x40000 | 0x800 | 0x400 | 0x100 | 0x1);
+ this->subAction = 1;
+ this->animationState = 4;
+ this->spritePriority.b1 = 1;
+ this->spriteSettings.b.draw = 3;
+ gPlayerState.jumpStatus = 0;
+ gPlayerState.pushedObject = 0;
+ sub_0800451C(this);
+ ResetPlayer();
+ SoundReq(0x87);
+}
+
+void sub_08071CAC(Entity* this) {
+ UpdateAnimationSingleFrame(this);
+ if (this->frames.all & 0x80) {
+ u32 temp;
+ if ((gPlayerState.flags.all & 0x80) == 0)
+ temp = (gPlayerState.flags.all & 8) ? 0x45a : 0x2bd;
+ else
+ temp = 0xc1b;
+ gPlayerState.field_0x8 = temp;
+
+ this->subAction = 2;
+ this->actionDelay = 0xf0;
+ SoundReq(0x7b);
+ }
+}
+
+void sub_08071D04(Entity* this) {
+ int idx;
+ int deltaHealth;
+
+ UpdateAnimationSingleFrame(this);
+ if (this->frames.all == 0)
+ return;
+
+ deltaHealth = 0;
+ idx = GetBottleContaining(0x28);
+ if (idx != 0) {
+ gSave.stats.bottles[idx - 1] = 0x20;
+ CreateObject(0x40, 0x60, 2);
+ deltaHealth = 32;
+ }
+
+ if (deltaHealth != 0) {
+ ModHealth(deltaHealth);
+ this->subAction = 3;
+ gPlayerState.field_0x3c[0] = 0;
+ this->direction = 0xff;
+ this->speed = 0;
+ this->field_0x20 = 0x18000;
+ gPlayerState.jumpStatus = 1;
+ gPlayerState.swimState = 0;
+ return;
+ }
+
+ gScreenTransition.field_0x4[1] = 1;
+}
+
+void sub_08071D80(Entity* this) {
+ UpdateAnimationSingleFrame(this);
+ gPlayerState.field_0x14 = 1;
+ sub_08073904(this);
+ if ((gPlayerState.jumpStatus & 7) == 3) {
+ gPlayerState.jumpStatus = 0;
+ this->iframes = 226;
+ UnfreezeTime();
+ sub_080791D0();
+ }
+}
+
+void sub_08071DB8(Entity* this) {
+ gUnk_0811BB3C[this->subAction](this);
+}
+
+void sub_08071DD0(Entity* this) {
+ this->actionDelay = gPlayerState.field_0x38;
+ if (gPlayerState.field_0x39 != 0) {
+ gPlayerState.field_0x39 = 0;
+ this->subAction = 2;
+ gPlayerState.field_0x8 = 0x100;
+ } else {
+ this->subAction = 1;
+ gPlayerState.field_0x8 = 0x114;
+ }
+}
+
+void sub_08071E04(Entity* this) {
+ if ((this->height.WORD != 0) && (gPlayerState.field_0x14 == '\0')) {
+ sub_0807A1B8();
+ if (gPlayerState.field_0x10[2] == 1) {
+ gPlayerState.field_0x10[1] = 7;
+ gPlayerState.flags.all |= 0x200;
+ sub_080791BC();
+ return;
+ }
+ }
+
+ UpdateAnimationSingleFrame(this);
+ if (sub_08079B24() == 0) {
+ sub_08079708(this);
+ return;
+ }
+
+ sub_080792D8();
+ if (sub_0807953C())
+ this->actionDelay -= 2;
+ else
+ this->actionDelay -= 1;
+
+ if ((s8)this->actionDelay < 1)
+ sub_080791BC();
+}
+
+void sub_08071E74(Entity* this) {
+ u32 temp;
+
+ sub_08003FC4(this, 0x2000);
+ sub_08079E08();
+ temp = this->actionDelay--;
+ if (temp == 0)
+ sub_080791BC();
+}
+
+void PlayerInit(Entity*);
+void PlayerNormal(Entity*);
+void PlayerInit(Entity*);
+void PlayerFall(Entity*);
+void PlayerJump(Entity*);
+void PlayerPush(Entity*);
+void PlayerBounce(Entity*);
+void sub_08070E9C(Entity*);
+void PlayerItemGet(Entity*);
+void PlayerMinish(Entity*);
+void PlayerMinishDie(Entity*);
+void sub_08071DB8(Entity*);
+void PlayerEmptyBottle(Entity*);
+void PlayerFrozen(Entity*);
+void sub_0807204C(Entity*);
+void sub_080720DC(Entity*);
+void PlayerPull(Entity*);
+void PlayerLava(Entity*);
+void PlayerWarp(Entity*);
+void sub_08072454(Entity*);
+void PlayerDrown(Entity*);
+void PlayerUsePortal(Entity*);
+void PlayerTalkEzlo(Entity*);
+void PlayerRoomTransition(Entity*);
+void PlayerRoll(Entity*);
+void sub_080728AC(Entity*);
+void PlayerInHole(Entity*);
+void sub_08072C9C(Entity*);
+void sub_08074C44(Entity*);
+void sub_08072F34(Entity*);
+void PlayerUseEntrance(Entity*);
+void PlayerParachute(Entity*);
+
+static void (*const sPlayerActions[])(Entity*) = {
+ [PLAYER_INIT] = PlayerInit,
+ [PLAYER_NORMAL] = PlayerNormal,
+ [PLAYER_DUMMY] = PlayerInit,
+ [PLAYER_FALL] = PlayerFall,
+ [PLAYER_JUMP] = PlayerJump,
+ [PLAYER_PUSH] = PlayerPush,
+ [PLAYER_BOUNCE] = PlayerBounce,
+ [PLAYER_08070E9C] = sub_08070E9C,
+ [PLAYER_ITEMGET] = PlayerItemGet,
+ [PLAYER_MINISH] = PlayerMinish,
+ [PLAYER_MINISHDIE] = PlayerMinishDie,
+ [PLAYER_08071DB8] = sub_08071DB8,
+ [PLAYER_EMPTYBOTTLE] = PlayerEmptyBottle,
+ [PLAYER_FROZEN] = PlayerFrozen,
+ [PLAYER_0807204C] = sub_0807204C,
+ [PLAYER_080720DC] = sub_080720DC,
+ [PLAYER_PULL] = PlayerPull,
+ [PLAYER_LAVA] = PlayerLava,
+ [PLAYER_WARP] = PlayerWarp,
+ [PLAYER_08072454] = sub_08072454,
+ [PLAYER_DROWN] = PlayerDrown,
+ [PLAYER_USEPORTAL] = PlayerUsePortal,
+ [PLAYER_TALKEZLO] = PlayerTalkEzlo,
+ [PLAYER_ROOMTRANSITION] = PlayerRoomTransition,
+ [PLAYER_ROLL] = PlayerRoll,
+ [PLAYER_080728AC] = sub_080728AC,
+ [PLAYER_INHOLE] = PlayerInHole,
+ [PLAYER_08072C9C] = sub_08072C9C,
+ [PLAYER_08074C44] = sub_08074C44,
+ [PLAYER_08072F34] = sub_08072F34,
+ [PLAYER_USEENTRANCE] = PlayerUseEntrance,
+ [PLAYER_PARACHUTE] = PlayerParachute,
+};
diff --git a/src/script.c b/src/script.c
index 6e4d577a..450ff8f9 100644
--- a/src/script.c
+++ b/src/script.c
@@ -853,7 +853,7 @@ void ScriptCommand_BuyItem(Entity* entity, ScriptExecutionContext* context) {
}
void ScriptCommand_0807E48C(Entity* entity, ScriptExecutionContext* context) {
- context->condition = sub_080544DC(context->scriptInstructionPointer[1]);
+ context->condition = GetBottleContaining(context->scriptInstructionPointer[1]);
gActiveScriptInfo.flags |= 1;
}
@@ -1085,7 +1085,7 @@ void ScriptCommand_0807E8E4(Entity* entity, ScriptExecutionContext* context) {
void ScriptCommand_0807E908(Entity* entity, ScriptExecutionContext* context) {
entity->action = context->scriptInstructionPointer[1];
- entity->previousActionFlag = 0;
+ entity->subAction = 0;
}
void ScriptCommand_SetIntVariable(Entity* entity, ScriptExecutionContext* context) {