summaryrefslogtreecommitdiff
path: root/src/object
diff options
context:
space:
mode:
authortheo3 <arisstephenson2@gmail.com>2022-03-27 00:19:10 -0700
committertheo3 <arisstephenson2@gmail.com>2022-03-27 00:19:10 -0700
commitca139bf5584ceaada7fbd19291a91559851918ce (patch)
tree16581618ed2c11480402867f0b4d31fb0c035d5f /src/object
parent5208bfd1aa3d0103fb8e57ba08a99511e1b524b7 (diff)
parent74f88fe5eeaf14ed3f6e8d6344aca88a36d7a697 (diff)
merge
Diffstat (limited to 'src/object')
-rw-r--r--src/object/bakerOven.c2
-rw-r--r--src/object/bigBarrel.c6
-rw-r--r--src/object/bird.c305
-rw-r--r--src/object/book.c46
-rw-r--r--src/object/button.c2
-rw-r--r--src/object/cuccoMinigame.c358
-rw-r--r--src/object/figurineDevice.c8
-rw-r--r--src/object/fileScreenObjects.c4
-rw-r--r--src/object/fireballChain.c41
-rw-r--r--src/object/floatingPlatform.c7
-rw-r--r--src/object/gyorgBossObject.c1
-rw-r--r--src/object/houseDoorExterior.c4
-rw-r--r--src/object/lilypadSmall.c20
-rw-r--r--src/object/mazaalBossObject.c207
-rw-r--r--src/object/minecart.c309
-rw-r--r--src/object/object49.c8
-rw-r--r--src/object/object96.c181
-rw-r--r--src/object/object98.c68
-rw-r--r--src/object/object99.c39
-rw-r--r--src/object/objectA6.c51
-rw-r--r--src/object/objectA9.c37
-rw-r--r--src/object/objectAB.c59
-rw-r--r--src/object/objectAD.c54
-rw-r--r--src/object/objectB.c2
-rw-r--r--src/object/objectB4.c135
-rw-r--r--src/object/objectBlockingStairs.c350
-rw-r--r--src/object/picoBloom.c47
-rw-r--r--src/object/playerClone.c11
-rw-r--r--src/object/pot.c2
-rw-r--r--src/object/smallIceBlock.c15
-rw-r--r--src/object/specialFx.c10
31 files changed, 2205 insertions, 184 deletions
diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c
index fd2b80aa..d4b26c28 100644
--- a/src/object/bakerOven.c
+++ b/src/object/bakerOven.c
@@ -22,7 +22,7 @@ void sub_0809CC74(Entity* this) {
/* Create steam clouds */
for (i = 0; i < 3; i++) {
ent = CreateObject(BAKER_OVEN, 1, i);
- if (ent) {
+ if (ent != NULL) {
ent->parent = this;
PositionRelative(this, ent, 16 * Q_16_16((i + 1) / 2) - Q_16_16(8.0), Q_16_16(-14.0));
}
diff --git a/src/object/bigBarrel.c b/src/object/bigBarrel.c
index af09b0f4..77e6ff6a 100644
--- a/src/object/bigBarrel.c
+++ b/src/object/bigBarrel.c
@@ -105,7 +105,7 @@ void sub_08088BE0(BigBarrelEntity* this) {
if (CheckLocalFlag(0x15) == 0) {
sub_08088C78(this, 2, 0, 0xffffff88);
ent = sub_08088C78(this, 4, 0x15, 0);
- if (ent) {
+ if (ent != NULL) {
ent->x.HALF.HI = gRoomControls.origin_x + 0x48;
ent->y.HALF.HI = gRoomControls.origin_y + 200;
}
@@ -114,7 +114,7 @@ void sub_08088BE0(BigBarrelEntity* this) {
if (CheckLocalFlag(0x16) == 0) {
sub_08088C78(this, 2, 1, 0x78);
ent = sub_08088C78(this, 4, 0x16, 0);
- if (ent) {
+ if (ent != NULL) {
ent->x.HALF.HI = gRoomControls.origin_x + 0x188;
ent->y.HALF.HI = gRoomControls.origin_y + 200;
}
@@ -249,7 +249,7 @@ void sub_08088E74(BigBarrelEntity* this) {
} else {
if ((gRoomTransition.frameCount & 7U) == 0) {
ent = CreateObjectWithParent(super, OBJECT_2A, 0, 0x1e);
- if (ent) {
+ if (ent != NULL) {
ent->updatePriority = 3;
ent->spriteRendering.b3 = 0;
ent->spritePriority.b0 = 0;
diff --git a/src/object/bird.c b/src/object/bird.c
index f16d46b5..3cb75c4b 100644
--- a/src/object/bird.c
+++ b/src/object/bird.c
@@ -2,22 +2,45 @@
#include "object.h"
#include "functions.h"
#include "item.h"
+#include "message.h"
+#include "game.h"
-extern void (*const gUnk_08123EC0[])(Entity*);
-extern void (*const gUnk_08123EEC[])(Entity*);
-extern void (*const gUnk_08123EF4[])(Entity*);
-extern void (*const gUnk_08123EFC[])(Entity*);
-extern void (*const gUnk_08123F04[])(Entity*);
+extern u16 script_EzloTalkOcarina[];
+
+void Bird_Type0(Entity*);
+void Bird_Type1(Entity*);
+void Bird_Type2(Entity*);
+void Bird_Type3(Entity*);
+void Bird_Type8(Entity*);
+void Bird_Type9(Entity*);
+void Bird_Type10(Entity*);
+void Bird_Type0_Init(Entity*);
+void Bird_Type0_Action1(Entity*);
+void Bird_Type1_Init(Entity*);
+void Bird_Type1_Action1(Entity*);
+void Bird_Type1_Action1_Subaction0(Entity*);
+void Bird_Type1_Action1_Subaction1(Entity*);
+void Bird_Type2_Init(Entity*);
+void Bird_Type2_Action1(Entity*);
void Bird(Entity* this) {
- gUnk_08123EC0[this->type](this);
+ static void (*const typeFuncs[])(Entity*) = {
+ Bird_Type0, Bird_Type1, Bird_Type2, Bird_Type3, Bird_Type3, Bird_Type3,
+ Bird_Type3, Bird_Type3, Bird_Type8, Bird_Type9, Bird_Type10,
+ };
+ typeFuncs[this->type](this);
}
-void sub_0809CF3C(Entity* this) {
- gUnk_08123EEC[this->action](this);
+void Bird_Type0(Entity* this) {
+ static void (*const actionFuncs[])(Entity*) = {
+ Bird_Type0_Init,
+ Bird_Type0_Action1,
+ };
+
+ actionFuncs[this->action](this);
}
-void sub_0809CF54(Entity* this) {
+void Bird_Type0_Init(Entity* this) {
Entity* target;
this->action++;
@@ -42,8 +65,7 @@ void sub_0809CF54(Entity* this) {
}
}
-void sub_0809CFEC(Entity* this) {
-
+void Bird_Type0_Action1(Entity* this) {
LinearMoveUpdate(this);
GravityUpdate(this, *(s16*)&this->field_0x68.HWORD);
if (this->actionDelay != 0) {
@@ -56,22 +78,30 @@ void sub_0809CFEC(Entity* this) {
UpdateAnimationSingleFrame(this);
}
-void sub_0809D030(Entity* this) {
- gUnk_08123EF4[this->action](this);
+void Bird_Type1(Entity* this) {
+ static void (*const actionFuncs[])(Entity*) = {
+ Bird_Type1_Init,
+ Bird_Type1_Action1,
+ };
+ actionFuncs[this->action](this);
}
-void sub_0809D048(Entity* this) {
+void Bird_Type1_Init(Entity* this) {
this->action++;
this->collisionLayer = 1;
UpdateSpriteForCollisionLayer(this);
InitAnimationForceUpdate(this, 0x17);
}
-void sub_0809D06C(Entity* this) {
- gUnk_08123EFC[this->subAction](this);
+void Bird_Type1_Action1(Entity* this) {
+ static void (*const subActionFuncs[])(Entity*) = {
+ Bird_Type1_Action1_Subaction0,
+ Bird_Type1_Action1_Subaction1,
+ };
+ subActionFuncs[this->subAction](this);
}
-void sub_0809D084(Entity* this) {
+void Bird_Type1_Action1_Subaction0(Entity* this) {
u32 temp;
if (this->parent != NULL) {
@@ -85,7 +115,7 @@ void sub_0809D084(Entity* this) {
}
}
-void sub_0809D0AC(Entity* this) {
+void Bird_Type1_Action1_Subaction1(Entity* this) {
Entity* fx;
if (sub_080044EC(this, 0x1800) < 2) {
@@ -102,28 +132,32 @@ void sub_0809D0AC(Entity* this) {
}
}
-void sub_0809D0F4(Entity* this) {
- gUnk_08123F04[this->action](this);
+void Bird_Type2(Entity* this) {
+ static void (*const actionFuncs[])(Entity*) = {
+ Bird_Type2_Init,
+ Bird_Type2_Action1,
+ };
+ actionFuncs[this->action](this);
}
-void sub_0809D10C(Entity* this) {
+void Bird_Type2_Init(Entity* this) {
this->action++;
this->collisionLayer = 1;
UpdateSpriteForCollisionLayer(this);
InitAnimationForceUpdate(this, 0x17);
}
-void sub_0809D130(Entity* this) {
+void Bird_Type2_Action1(Entity* this) {
if ((gPlayerState.flags & PL_MINISH) != 0) {
sub_0800445C(this);
} else if (IsCollidingPlayer(this) != 0) {
- CreateItemEntity(0x17, 0, 0);
+ CreateItemEntity(ITEM_OCARINA, 0, 0);
gSave.windcrests |= 0x10000000;
DeleteThisEntity();
}
}
-void sub_0809D178(Entity* this) {
+void Bird_Type3(Entity* this) {
if (this->action == 0) {
this->action++;
@@ -131,6 +165,7 @@ void sub_0809D178(Entity* this) {
UpdateSpriteForCollisionLayer(this);
this->frame = 0x80;
}
+
if ((this->frame & ANIM_DONE) != 0) {
InitializeAnimation(this, Random() & 3);
this->frameDuration = (Random() & 0xf) + 0x10;
@@ -142,3 +177,225 @@ void sub_0809D178(Entity* this) {
GetNextFrame(this);
}
}
+
+void Bird_Type8(Entity* this) {
+ Entity* pEVar5;
+
+ switch (this->action) {
+ case 0:
+ if (this->actionDelay != 0) {
+ this->frameIndex = 0xff;
+ this->actionDelay--;
+ return;
+ }
+ this->action = 1;
+ this->zVelocity = 0;
+ this->z.WORD = Q_16_16(-20.0);
+ this->speed = 0x180;
+ this->direction = 8;
+ this->collisionLayer = 1;
+ this->spritePriority.b0 = 0;
+ this->spriteRendering.b3 = 0;
+ this->spriteOrientation.flipY = 1;
+ this->x.HALF.HI = gRoomControls.scroll_x;
+ this->y.HALF.HI = gPlayerEntity.y.HALF.HI;
+ this->child = NULL;
+ SetDefaultPriority(this, 6);
+ InitAnimationForceUpdate(this, 0);
+ SoundReq(0x123);
+ break;
+ case 1:
+ this->collisionLayer = gPlayerEntity.collisionLayer;
+ this->speed += 8;
+ if (this->speed > 0x300) {
+ this->speed = 0x300;
+ }
+
+ if ((gPlayerEntity.flags & 0x80) != 0 && (gMessage.doTextBox & 0x7f) == 0 && gPlayerEntity.action != 28 &&
+ gPlayerEntity.action != 6 && gPlayerEntity.action != 9 && gPlayerState.framestate != 24 &&
+ gPlayerState.framestate != 11 && gPlayerState.framestate != 8 && sub_08079F8C() &&
+ (EntityInRectRadius(this, &gPlayerEntity, 0xe, 0xe))) {
+ s32 z = gPlayerEntity.z.HALF.HI - this->z.HALF.HI - 8;
+ if ((u16)z < 0x20 && gPlayerEntity.health != 0) {
+ pEVar5 = CreateObject(0x95, 10, 0);
+ if (pEVar5 != NULL) {
+ this->child = pEVar5;
+ this->action = 2;
+ this->actionDelay = 8;
+ this->speed = 0x300;
+ this->field_0x68.HWORD = 0xe000;
+ sub_08079184();
+ sub_08078B48();
+ ResetPlayerAnimationAndAction();
+ sub_08077B20();
+ gPlayerState.swim_state = 0;
+ gPlayerState.jump_status = 0;
+ gPlayerEntity.flags &= 0x7f;
+ gPlayerEntity.spriteSettings.draw = 0;
+ gPriorityHandler.sys_priority = 6;
+ gUnk_02034490.unk0 = 1;
+ }
+ }
+ }
+ break;
+ default:
+ sub_08078B48();
+ gPlayerEntity.spriteSettings.draw = 0;
+ break;
+ }
+ LinearMoveUpdate(this);
+ GravityUpdate(this, (s16)this->field_0x68.HWORD);
+ UpdateAnimationSingleFrame(this);
+ pEVar5 = this->child;
+ if (pEVar5 != NULL) {
+ if (gPlayerEntity.x.HALF.HI < this->x.HALF.HI - 8) {
+ this->actionDelay = 0;
+ }
+
+ if (this->actionDelay == 0) {
+ PositionRelative(this, pEVar5, 0xfff80000, 0);
+ pEVar5->z.HALF.HI += 0x18;
+ pEVar5->spritePriority.b0 = this->spritePriority.b0;
+ pEVar5->spriteRendering.b3 = this->spriteRendering.b3;
+ pEVar5->spriteOrientation.flipY = this->spriteOrientation.flipY;
+ } else {
+ this->actionDelay--;
+ CopyPosition(&gPlayerEntity, pEVar5);
+ }
+ }
+
+ if (CheckOnScreen(this) == 0) {
+ if (this->action == 2) {
+ gSave.windcrests |= 0x10000000;
+ MenuFadeIn(9, 0);
+ }
+ pEVar5 = this->child;
+ if (pEVar5 != NULL) {
+ DeleteEntityAny(pEVar5);
+ }
+ DeleteThisEntity();
+ }
+}
+
+void Bird_Type9(Entity* this) {
+ Entity* pEVar1;
+ Entity* child;
+
+ if (this->action == 0) {
+ this->action = 1;
+ this->spriteSettings.draw = 1;
+ this->zVelocity = -0x28000;
+ this->z.WORD = 0xffb4c000;
+ this->field_0x68.HWORD = 0xf000;
+ this->speed = 0x300;
+ this->direction = 8;
+ this->collisionLayer = 1;
+ this->spritePriority.b0 = 0;
+ this->spriteRendering.b3 = 0;
+ this->spriteOrientation.flipY = 1;
+ ;
+ SetDefaultPriority(this, 6);
+ this->x.HALF.HI = gRoomControls.scroll_x;
+ this->y.HALF.HI = gPlayerEntity.y.HALF.HI;
+ SoundReq(SFX_123);
+ this->spritePriority.b1 = 2;
+ InitAnimationForceUpdate(this, 0);
+ sub_08078B48();
+ } else if (this->action == 1) {
+ gPlayerEntity.spriteSettings.draw = 0;
+ child = this->child;
+ if (child != NULL) {
+ PositionRelative(this, child, Q_16_16(-8), 0);
+ child->z.HALF.HI += 0x18;
+ child->spritePriority.b0 = this->spritePriority.b0;
+ child->spriteRendering.b3 = this->spriteRendering.b3;
+ child->spriteOrientation.flipY = this->spriteOrientation.flipY;
+ }
+ sub_08078B48();
+ if (gRoomControls.scroll_x + 0x78 < this->x.HALF.HI) {
+ this->action++;
+ this->spritePriority.b1 = 1;
+ if (child != NULL) {
+ child->action++;
+ }
+ gRoomControls.camera_target = &gPlayerEntity;
+ gPlayerEntity.spriteSettings.draw = 1;
+ ResetPlayerAnimationAndAction();
+ ResetPlayerEventPriority();
+ gUnk_02034490.unk0 = 0;
+ if (!CheckGlobalFlag(WARP_1ST)) {
+ pEVar1 = CreateObject(OBJECT_69, 0, 0);
+ if (pEVar1 != NULL) {
+ *(ScriptExecutionContext**)&pEVar1->cutsceneBeh = StartCutscene(pEVar1, script_EzloTalkOcarina);
+ SetGlobalFlag(WARP_1ST);
+ }
+ }
+ }
+ }
+ LinearMoveUpdate(this);
+ GravityUpdate(this, (short)this->field_0x68.HWORD);
+ UpdateAnimationSingleFrame(this);
+ if (!CheckOnScreen(this)) {
+ DeleteThisEntity();
+ }
+}
+
+void Bird_Type10(Entity* this) {
+ this->palette.b.b0 = gPlayerEntity.palette.b.b0;
+ switch (this->action) {
+ case 0:
+ this->action = 1;
+ this->spriteSettings.draw = 1;
+ this->collisionLayer = 1;
+ this->spritePriority.b0 = 0;
+ this->spriteRendering.b3 = 0;
+ this->spriteOrientation.flipY = 1;
+ SetDefaultPriority(this, 6);
+ InitAnimationForceUpdate(this, 0xe0);
+ case 1:
+ UpdateAnimationSingleFrame(this);
+ break;
+ case 2:
+ this->action = 3;
+ break;
+ case 3:
+ DeleteThisEntity();
+ break;
+ }
+}
+
+void CreateBird(void) {
+ Entity* birdEnt;
+
+#ifndef EU
+ if (AreaAllowsWarp()) {
+#else
+ if (AreaIsOverworld()) {
+#endif
+ if (!FindEntity(OBJECT, BIRD, 6, 8, 0)) {
+ birdEnt = CreateObject(BIRD, 8, 0);
+ if (birdEnt != NULL) {
+ birdEnt->actionDelay = 0;
+ }
+ }
+ }
+}
+
+void sub_0809D738(void) {
+ Entity* pEVar1;
+ Entity* pEVar2;
+
+ pEVar1 = CreateObject(BIRD, 9, 0);
+ if (pEVar1 != NULL) {
+ gRoomControls.camera_target = NULL;
+ SetDefaultPriority(pEVar1, 6);
+ SetPlayerEventPriority();
+ pEVar2 = CreateObject(BIRD, 10, 0);
+ if (pEVar2 != NULL) {
+ pEVar1->child = pEVar2;
+ }
+ gUnk_02034490.unk0 = 1;
+ } else {
+ ResetPlayerAnimationAndAction();
+ }
+}
diff --git a/src/object/book.c b/src/object/book.c
index f42b2f1d..3c9e12b5 100644
--- a/src/object/book.c
+++ b/src/object/book.c
@@ -15,11 +15,9 @@ void Book(Entity* this) {
}
void sub_0809B3C4(Entity* this) {
- u32 obtained;
-
- obtained = GetInventoryValue(this->type + ITEM_QST_BOOK1);
+ u32 obtained = GetInventoryValue(this->type + ITEM_QST_BOOK1);
if (this->type2 != 3) {
- if (obtained) {
+ if (obtained != 0) {
DeleteThisEntity();
}
} else {
@@ -42,7 +40,7 @@ void sub_0809B3C4(Entity* this) {
}
UpdateSpriteForCollisionLayer(this);
- InitAnimationForceUpdate(this, this->type + 0x39);
+ InitAnimationForceUpdate(this, this->type + ITEM_QST_BOOK1);
switch (this->type2) {
case 0:
@@ -55,22 +53,23 @@ void sub_0809B3C4(Entity* this) {
case 1: {
u32 scroll;
u32 height;
+
this->action = 3;
scroll = (u16)gRoomControls.scroll_y - 0x10;
height = (u16)this->y.HALF.HI - scroll;
this->z.HALF.HI -= height;
- return;
+ break;
}
case 2:
this->action = 4;
- return;
+ break;
case 3:
this->action = 5;
this->subAction = 0;
this->spritePriority.b0 = 3;
break;
default:
- return;
+ break;
}
}
@@ -89,10 +88,10 @@ void sub_0809B4A8(Entity* this) {
this->action = 2;
this->actionDelay = 30;
- this->speed = 64;
- this->direction = 16;
+ this->speed = 0x40;
+ this->direction = 0x10;
- gPlayerState.pushedObject = 0x9e;
+ gPlayerState.pushedObject = TREE_THORNS;
gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= PL_BUSY;
@@ -101,7 +100,7 @@ void sub_0809B4A8(Entity* this) {
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
EnqueueSFX(SFX_10F);
} else {
- this->actionDelay = 0x16;
+ this->actionDelay = 22;
}
}
@@ -109,12 +108,12 @@ void sub_0809B524(Entity* this) {
if (--this->actionDelay == 0) {
if (--this->field_0xf == 0) {
this->action = 3;
- this->y.HALF.HI += 32;
- this->z.HALF.HI -= 32;
+ this->y.HALF.HI += 0x20;
+ this->z.HALF.HI -= 0x20;
} else {
this->action = 1;
this->actionDelay = 22;
- this->field_0x80.HALF.LO = 24;
+ this->field_0x80.HALF.LO = 0x18;
}
}
@@ -134,7 +133,7 @@ void sub_0809B56C(Entity* this) {
SetFlag(this->field_0x86.HWORD);
fx = CreateFx(this, FX_DEATH, 0);
- if (fx) {
+ if (fx != NULL) {
SortEntityAbove(this, fx);
}
}
@@ -143,7 +142,7 @@ void sub_0809B5B4(Entity* this) {
if (gPlayerState.flags & PL_MINISH) {
sub_0800445C(this);
} else if (IsCollidingPlayer(this)) {
- CreateItemEntity(this->type + 0x39, 0, 0);
+ CreateItemEntity(this->type + ITEM_QST_BOOK1, 0, 0);
DeleteThisEntity();
}
}
@@ -152,9 +151,8 @@ void sub_0809B5EC(Entity* this) {
if (this->spriteSettings.draw == 1) {
switch (this->subAction) {
case 0: {
- Entity* parent;
- parent = FindEntityByID(NPC, STURGEON, 7);
- if (!parent) {
+ Entity* parent = FindEntityByID(NPC, STURGEON, 7);
+ if (parent == NULL) {
return;
}
if (parent->x.HALF.HI < this->x.HALF.HI) {
@@ -170,7 +168,7 @@ void sub_0809B5EC(Entity* this) {
break;
}
case 1: {
- if (!this->parent || !this->parent->next) {
+ if ((this->parent == NULL) || (this->parent->next == NULL)) {
DeleteThisEntity();
return;
}
@@ -206,9 +204,8 @@ void sub_0809B5EC(Entity* this) {
}
u32 sub_0809B688(Entity* this) {
- u32 ret;
+ u32 ret = EntityInRectRadius(this, &gPlayerEntity, 6, 12);
- ret = EntityInRectRadius(this, &gPlayerEntity, 6, 12);
if (ret == 1 && gPlayerState.field_0xd != 16) {
ret = 0;
}
@@ -217,8 +214,7 @@ u32 sub_0809B688(Entity* this) {
}
void sub_0809B6B0(Entity* parent, Entity* this) {
- s32 offset;
- offset = (s32)gUnk_08123D94[parent->animationState >> 1] << 16;
+ s32 offset = (s32)gUnk_08123D94[parent->animationState >> 1] << 16;
PositionRelative(parent, this, 0, offset);
diff --git a/src/object/button.c b/src/object/button.c
index 5a29e636..d4f602ba 100644
--- a/src/object/button.c
+++ b/src/object/button.c
@@ -242,7 +242,7 @@ u32 sub_08081F7C(Entity* this, u32 r7) {
if (this->actionDelay == 0)
return 1;
if (--this->actionDelay > 6) {
- if (this->child)
+ if (this->child != NULL)
this->child->spriteOffsetY = -4;
} else {
if (this->actionDelay == 6) {
diff --git a/src/object/cuccoMinigame.c b/src/object/cuccoMinigame.c
new file mode 100644
index 00000000..19f63c3f
--- /dev/null
+++ b/src/object/cuccoMinigame.c
@@ -0,0 +1,358 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "script.h"
+#include "npc.h"
+#include "fileselect.h"
+#include "functions.h"
+#include "object.h"
+#include "enemy.h"
+
+typedef struct {
+ Entity base;
+ s16 unk68;
+ s16 unk6a;
+ s16 unk6c;
+ u16 unk6e;
+ u8 unk70[0x18];
+} ObjectB9Entity;
+
+typedef Entity* ObjectB9Heap[10];
+
+u32 sub_080A1514();
+
+const u16 gUnk_08124C20[] = {
+ 25, 0x2, 25, 0x3, 30, 0x4, 45, 0x5, 50, 0x5, 45, 0x5, 50, 0x6, 60, 0x7, 55, 0x2, 55, 0x3,
+};
+
+static const u16 pObjectB9_MinigameCuccoDefs[][30] = {
+ { 0x0001, 0x02E9, 0x0318, 0x0001, 0x0280, 0x0380, 0x0002, 0x0277, 0x0314, 0x0001,
+ 0x0332, 0x0248, 0x0001, 0x0257, 0x028C, 0x0001, 0x0199, 0x031B, 0x0001, 0x0321,
+ 0x01B4, 0x0002, 0x02DF, 0x01D8, 0x0001, 0x03AD, 0x02DE, 0x0001, 0x0216, 0x01CC },
+ { 0x0001, 0x02E9, 0x0318, 0x0001, 0x0280, 0x0380, 0x0002, 0x0277, 0x0314, 0x0001,
+ 0x0332, 0x0248, 0x0001, 0x0257, 0x028C, 0x0001, 0x0199, 0x031B, 0x0001, 0x0321,
+ 0x01B4, 0x0002, 0x02DF, 0x01D8, 0x0001, 0x03AD, 0x02DE, 0x0001, 0x0216, 0x01CC },
+ { 0x0001, 0x02E9, 0x0318, 0x0001, 0x0280, 0x0380, 0x0002, 0x0277, 0x0314, 0x0001,
+ 0x0332, 0x0248, 0x0001, 0x0257, 0x028C, 0x0001, 0x0199, 0x031B, 0x0001, 0x0321,
+ 0x01B4, 0x0002, 0x02DF, 0x01D8, 0x0001, 0x03AD, 0x02DE, 0x0001, 0x0216, 0x01CC },
+ {
+ 0x0002, 0x02F6, 0x0346, 0x0001, 0x0266, 0x033C, 0x0001, 0x0319, 0x0296, 0x0001,
+ 0x0284, 0x0284, 0x0002, 0x0216, 0x0284, 0x0001, 0x0142, 0x0330, 0x0002, 0x0179,
+ 0x039F, 0x0001, 0x03A6, 0x0280, 0x0001, 0x039A, 0x015D, 0x0001, 0x031E, 0x01E5,
+ },
+ { 0x0001, 0x0296, 0x0314, 0x0001, 0x02E6, 0x0231, 0x0001, 0x0254, 0x0290, 0x0001,
+ 0x01F8, 0x0325, 0x0001, 0x0185, 0x0367, 0x0001, 0x0320, 0x01D6, 0x0002, 0x01F8,
+ 0x0287, 0x0002, 0x029D, 0x01B1, 0x0002, 0x01F9, 0x022D, 0x0002, 0x0114, 0x0321 },
+ { 0x0002, 0x02F6, 0x0346, 0x0001, 0x0266, 0x033C, 0x0001, 0x0319, 0x0296, 0x0001,
+ 0x0284, 0x0284, 0x0002, 0x0216, 0x0284, 0x0001, 0x0142, 0x0330, 0x0002, 0x0179,
+ 0x039F, 0x0002, 0x022D, 0x01CB, 0x0001, 0x039A, 0x015D, 0x0001, 0x031E, 0x01E5 },
+ { 0x0001, 0x02E9, 0x0318, 0x0001, 0x0280, 0x0380, 0x0002, 0x0277, 0x0314, 0x0001,
+ 0x0332, 0x0248, 0x0001, 0x0257, 0x028C, 0x0001, 0x0199, 0x031B, 0x0001, 0x0321,
+ 0x01B4, 0x0002, 0x02DF, 0x01D8, 0x0001, 0x03AD, 0x02DE, 0x0001, 0x0216, 0x01CC },
+ { 0x0001, 0x02E9, 0x0318, 0x0002, 0x0280, 0x0380, 0x0002, 0x0277, 0x0314, 0x0001,
+ 0x0332, 0x0248, 0x0001, 0x0257, 0x028C, 0x0001, 0x0199, 0x031B, 0x0001, 0x0321,
+ 0x01B4, 0x0002, 0x02DF, 0x01D8, 0x0002, 0x03AD, 0x02DE, 0x0001, 0x0216, 0x01CC },
+ { 0x0001, 0x004D, 0x00F3, 0x0001, 0x011A, 0x0247, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
+ { 0x0001, 0x0051, 0x0328, 0x0002, 0x0114, 0x0321, 0x0002, 0x0332, 0x0248, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }
+};
+
+static const u8 gUnk_08124EA0[] = { 0x3F, 0x0A, 0x01, 0x00, 0x3F, 0x0A, 0x01, 0x00, 0x3F, 0x14, 0x01, 0x00, 0x3F, 0x14,
+ 0x01, 0x00, 0x3F, 0x1E, 0x01, 0x00, 0x3F, 0x1E, 0x01, 0x00, 0x5C, 0x6E, 0x01, 0x00,
+ 0x5C, 0x6F, 0x01, 0x00, 0x5C, 0x70, 0x01, 0x00, 0x63, 0x00, 0x01, 0x00 };
+
+static const u16 CuccoMinigame_Sounds[] = { SFX_VO_CUCCO5, SFX_VO_CUCCO_CALL };
+
+static const u8 CuccoMinigameRupees[] = { 0, 10, 50, 0 };
+
+void ObjectB9(ObjectB9Entity* this) {
+ int index;
+ u32 val;
+ u8* puVar2;
+ const u16* ptr;
+
+ if (super->action == 0) {
+ super->action++;
+ ptr = gUnk_08124C20 + sub_080A1514() * 2;
+ this->unk68 = ptr[0] * 0x3c;
+ this->unk6a = 0;
+ this->unk6c = ptr[1];
+ this->unk6e = 1;
+
+ for (puVar2 = this->unk70, val = 0, index = 9; index >= 0; index--) {
+ *puVar2++ = val;
+ }
+ sub_0807DD64(super);
+ sub_0806EC20(super);
+ }
+ sub_0807DD94(super, 0);
+}
+
+NONMATCH("asm/non_matching/objectB9/sub_080A1270.inc", void sub_080A1270(ObjectB9Entity* this)) {
+ s32 iVar1;
+ int iVar2;
+ s32 iVar4;
+ s32 sVar6;
+ int iVar7;
+ s8* ptr;
+ s32 val;
+ Entity* pEnt;
+ Entity** entArray;
+
+ sVar6 = 0;
+ entArray = ((Entity**)super->myHeap);
+ ptr = this->unk70;
+ iVar1 = (gRoomControls.origin_x + 0x360);
+ iVar4 = (gRoomControls.origin_y + 0x350);
+ iVar1 = (iVar1 << 16) >> 16;
+ iVar4 = (iVar4 << 16) >> 16;
+ val = -1;
+
+ for (iVar7 = 0; iVar7 < 9; iVar7++) {
+ pEnt = entArray[iVar7];
+ if (((s8*)ptr)[iVar7] == 0) {
+ if (pEnt->next != NULL && pEnt != NULL) {
+ if ((iVar1 <= pEnt->x.HALF.HI) && (iVar4 <= pEnt->y.HALF.HI)) {
+ ptr[iVar7] = pEnt->type + 1;
+ pEnt->type2 = 1;
+ sVar6++;
+ SoundReq(CuccoMinigame_Sounds[pEnt->type]);
+ }
+ } else {
+ ((s8*)ptr)[iVar7] = val;
+ }
+ } else if (0 < (s8)ptr[iVar7]) {
+ sVar6++;
+ if (pEnt->next != NULL && pEnt != NULL) {
+ iVar2 = iVar1 + 4;
+ if (iVar2 > pEnt->x.HALF.HI) {
+ pEnt->x.HALF.HI = iVar2;
+ }
+ iVar2 = iVar4 + 4;
+ if (iVar2 > pEnt->y.HALF.HI) {
+ pEnt->y.HALF.HI = iVar2;
+ }
+ } else {
+ ((s8*)ptr)[iVar7] = val;
+ }
+ }
+ }
+
+ this->unk6a = sVar6;
+ gPlayerState.field_0x27[0] = 0xff;
+ if (--this->unk68 < 1) {
+ SoundReq(SFX_CUCCO_MINIGAME_BELL);
+ sub_08050384();
+ } else {
+ gActiveScriptInfo.commandSize = 0;
+ }
+}
+END_NONMATCH
+
+void CuccoMinigame_Cleanup(ObjectB9Entity* this) {
+ Entity** puVar1;
+ s8* pcVar2;
+ int index;
+
+ pcVar2 = this->unk70;
+ puVar1 = super->myHeap;
+
+ for (index = 9; index >= 0; index--, pcVar2++, puVar1++) {
+ Entity* pEnt = *puVar1;
+ if (*pcVar2 >= 0 && pEnt != NULL) {
+ DeleteEntityAny(pEnt);
+ }
+ }
+}
+
+void sub_080A13B4(ObjectB9Entity* this, ScriptExecutionContext* context) {
+ if (this->unk6a >= this->unk6c) {
+ MessageFromTarget(0x300c);
+ context->condition = 1;
+ } else {
+ MessageFromTarget(0x3005);
+ context->condition = 0;
+ }
+}
+
+void sub_080A13E8(ObjectB9Entity* this) {
+ bool32 bVar2;
+ const u8* ptr = &gUnk_08124EA0[sub_080A1514() * 4];
+
+ bVar2 = 0;
+ switch (ptr[0]) {
+ case 0x3f:
+ if (gSave.stats.hasAllFigurines) {
+ bVar2 = 1;
+ }
+ break;
+ case 0x5c:
+ if (gSave.didAllFusions) {
+ bVar2 = 1;
+ }
+ break;
+ case 0x63:
+ if (!CheckGlobalFlag(0x4f)) {
+ SetGlobalFlag(0x4f);
+ break;
+ }
+ bVar2 = 1;
+ break;
+ }
+
+ if (!bVar2) {
+ sub_080A7C18(ptr[0], ptr[1], 0);
+ } else {
+ this->unk6e = 2;
+ }
+}
+
+void sub_080A1460(ObjectB9Entity* this) {
+ s8* pcVar1;
+ int iVar2;
+ s32 rupees;
+ const u8* ptr;
+
+ sub_080A1514();
+ pcVar1 = this->unk70;
+ rupees = 0;
+ ptr = CuccoMinigameRupees;
+
+ for (iVar2 = 9; iVar2 >= 0; iVar2--) {
+ // Weird register addition
+ // ptr[*pcVar1] translates to add r0,r3,r0 but should be add r0,r3
+ u32 temp = *pcVar1;
+ temp += (int)ptr;
+ rupees += *(u8*)temp;
+ pcVar1++;
+ }
+ ModRupees(rupees);
+ MessageNoOverlap(0x3007, super);
+ gMessage.rupees = (u16)rupees;
+}
+
+void sub_080A14A8(void) {
+ int iVar1;
+
+ iVar1 = sub_080A1514();
+ iVar1++;
+ if (iVar1 > 9) {
+ iVar1 = 9;
+ }
+
+ if (iVar1 & 1) {
+ SetGlobalFlag(0x4b);
+ } else {
+ ClearGlobalFlag(0x4b);
+ }
+
+ if (iVar1 & 2) {
+ SetGlobalFlag(0x4c);
+ } else {
+ ClearGlobalFlag(0x4c);
+ }
+
+ if (iVar1 & 4) {
+ SetGlobalFlag(0x4d);
+ } else {
+ ClearGlobalFlag(0x4d);
+ }
+
+ if (iVar1 & 8) {
+ SetGlobalFlag(0x4e);
+ } else {
+ ClearGlobalFlag(0x4e);
+ }
+}
+
+u32 sub_080A1514(void) {
+ u32 rv = 0;
+
+ if (CheckGlobalFlag(0x4b)) {
+ rv = 1;
+ }
+
+ if (CheckGlobalFlag(0x4c)) {
+ rv |= 2;
+ }
+
+ if (CheckGlobalFlag(0x4d)) {
+ rv |= 4;
+ }
+
+ if (CheckGlobalFlag(0x4e)) {
+ rv |= 8;
+ }
+ return rv;
+}
+
+void CuccoMinigame_Init(Entity* this, ScriptExecutionContext* context) {
+ Entity* pEnt;
+ const short* pCuccoMinigameDef;
+ int index;
+ Entity** ppEVar5;
+ RoomControls* room;
+
+ context->condition = 0;
+ pEnt = CreateObject(CUCCO_MINIGAME, 0, 0);
+ if (pEnt != NULL) {
+ pEnt->myHeap = (u32*)zMalloc(sizeof(ObjectB9Heap));
+ if (pEnt->myHeap == NULL) {
+ DeleteEntityAny(pEnt);
+ } else {
+ *(ScriptExecutionContext**)&((GenericEntity*)pEnt)->cutsceneBeh =
+ (ScriptExecutionContext*)StartCutscene(pEnt, (u16*)context->intVariable);
+ pCuccoMinigameDef = pObjectB9_MinigameCuccoDefs[sub_080A1514()];
+ ppEVar5 = (Entity**)pEnt->myHeap;
+ room = &gRoomControls;
+ for (index = 9; index >= 0; index--, pCuccoMinigameDef += 3) {
+ if (pCuccoMinigameDef[0] < 1) {
+ pEnt = NULL;
+ } else {
+ pEnt = (Entity*)CreateEnemy(CUCCO_AGGR, pCuccoMinigameDef[0] - 1);
+ if (pEnt != NULL) {
+ pEnt->x.HALF.HI = room->origin_x + pCuccoMinigameDef[1];
+ pEnt->y.HALF.HI = room->origin_y + pCuccoMinigameDef[2];
+ pEnt->collisionLayer = 1;
+ }
+ }
+ *ppEVar5++ = pEnt;
+ }
+ context->condition = 1;
+ }
+ }
+}
+
+void sub_080A1608(void) {
+ u16 messageIndex;
+ const u16* ptr;
+
+ messageIndex = 0x3002;
+ if (CheckRoomFlag(1)) {
+ messageIndex = 0x3006;
+ }
+ MessageFromTarget(messageIndex);
+ gMessage.textWindowPosX = 1;
+ gMessage.textWindowPosY = 0;
+ ptr = &gUnk_08124C20[sub_080A1514() * 2];
+ gMessage.rupees = ptr[0];
+ gMessage.field_0x14 = ptr[1];
+}
+
+void sub_080A1648(void) {
+ SetTileType(0x407f, 0xd36, 1);
+ SetTileType(0x407f, 0xd37, 1);
+ SetTileType(0x407f, 0xd38, 1);
+ SetTileType(0x407e, 0xd75, 1);
+ SetTileType(0x407e, 0xe75, 1);
+}
+
+void sub_080A169C(void) {
+ sub_0807BA8C(0xd36, 1);
+ sub_0807BA8C(0xd37, 1);
+ sub_0807BA8C(0xd38, 1);
+ sub_0807BA8C(0xd75, 1);
+ sub_0807BA8C(0xe75, 1);
+}
diff --git a/src/object/figurineDevice.c b/src/object/figurineDevice.c
index df7dbdc5..a9efe80c 100644
--- a/src/object/figurineDevice.c
+++ b/src/object/figurineDevice.c
@@ -303,7 +303,7 @@ void FigurineDevice_Action4(FigurineDeviceEntity* this) {
gMessage.textWindowPosX = 1;
gMessage.textWindowPosY = 0xc;
#endif
- gMessage.field_0x10 = this->unk_81;
+ gMessage.rupees = this->unk_81;
break;
}
}
@@ -417,9 +417,9 @@ void sub_080882A8(FigurineDeviceEntity* this) {
sub_08057044(this->unk_83, &gUnk_020227E8[1], 0x202020);
ptr = (u8*)0x02000000;
if (ptr[7] == 0) {
- sub_0805F46C((u32)gUnk_08120AE4[super->type2], &gUnk_08120AB4);
+ sub_0805F46C((u32)gUnk_08120AE4[super->type2], (Font*)&gUnk_08120AB4); // TODO convert data
} else {
- sub_0805F46C((u32)gUnk_08120AE4[super->type2], &gUnk_08120ACC);
+ sub_0805F46C((u32)gUnk_08120AE4[super->type2], (Font*)&gUnk_08120ACC); // TODO convert data
}
gScreen.bg0.updated = 1;
}
@@ -477,7 +477,7 @@ void sub_08088478(void) {
gMessage.textWindowPosX = 1;
gMessage.textWindowPosY = 0xc;
if (set0x10) {
- gMessage.field_0x10 = 5;
+ gMessage.rupees = 5;
}
#ifndef EU
gPlayerEntity.animationState = 6;
diff --git a/src/object/fileScreenObjects.c b/src/object/fileScreenObjects.c
index 7d2a295f..c7cac4e7 100644
--- a/src/object/fileScreenObjects.c
+++ b/src/object/fileScreenObjects.c
@@ -252,7 +252,7 @@ void sub_0808EABC(Entity* this) {
void sub_0808EB74(Entity* this) {
Entity* entity = sub_0808EC80(gMapDataBottomSpecial.unk6);
- if (entity) {
+ if (entity != NULL) {
this->x.WORD = entity->x.WORD;
this->y.WORD = entity->y.WORD;
this->spriteRendering.b3 = entity->spriteRendering.b3;
@@ -305,7 +305,7 @@ void sub_0808EBB8(Entity* this) {
// Fall through
default:
entity = sub_0808EC80(var0);
- if (entity) {
+ if (entity != NULL) {
SortEntityBelow(entity, this);
this->spriteRendering.b3 = entity->spriteRendering.b3;
x = entity->x.HALF.HI;
diff --git a/src/object/fireballChain.c b/src/object/fireballChain.c
new file mode 100644
index 00000000..ac5322b7
--- /dev/null
+++ b/src/object/fireballChain.c
@@ -0,0 +1,41 @@
+#define NENT_DEPRECATED
+#include "global.h"
+#include "entity.h"
+#include "functions.h"
+#include "projectile.h"
+#include "projectile/winder.h"
+
+void FireballChain(Entity* thisx) {
+ WinderEntity* newSegment;
+ Entity* parent;
+ Entity* child;
+ s32 i;
+ s32 j;
+
+ if (gEntCount > 0x42) {
+ return;
+ }
+
+ for (i = 0; i < 5; i++) {
+ u16* tmp;
+
+ newSegment = (WinderEntity*)CreateProjectile(WINDER);
+ if (i == 0) {
+ child = parent = &newSegment->base;
+ }
+
+ newSegment->base.type = i;
+ newSegment->base.parent = parent;
+ newSegment->base.child = child;
+ CopyPosition(thisx, &newSegment->base);
+
+ for (j = 0, tmp = newSegment->positions; j < WINDER_NUM_SEGMENTS; j++) {
+ *tmp++ = thisx->x.HALF.HI;
+ *tmp++ = thisx->y.HALF.HI;
+ }
+
+ child = &newSegment->base;
+ }
+
+ DeleteThisEntity();
+}
diff --git a/src/object/floatingPlatform.c b/src/object/floatingPlatform.c
index d62d7603..9701ba66 100644
--- a/src/object/floatingPlatform.c
+++ b/src/object/floatingPlatform.c
@@ -33,12 +33,11 @@ void sub_080860D8(FloatingPlatformEntity* this) {
}
void sub_0808611C(FloatingPlatformEntity* this) {
- int iVar2;
+ bool32 iVar2 = sub_08086168(this);
- iVar2 = sub_08086168(this);
if (super->actionDelay != 0 && super->parent->actionDelay == 0) {
- if (iVar2 != 0) {
+ if (iVar2) {
super->parent->actionDelay++;
}
@@ -46,7 +45,7 @@ void sub_0808611C(FloatingPlatformEntity* this) {
} else if (super->actionDelay == 0) {
sub_080A2BE4(super, iVar2);
} else {
- sub_080A2BE4(super, 0);
+ sub_080A2BE4(super, FALSE);
}
if (--this->unk70 == 0) {
diff --git a/src/object/gyorgBossObject.c b/src/object/gyorgBossObject.c
index b63b8d81..ebbec424 100644
--- a/src/object/gyorgBossObject.c
+++ b/src/object/gyorgBossObject.c
@@ -10,7 +10,6 @@
extern const ScreenTransitionData gUnk_0813ABD0;
-extern u32 sub_08079F8C(void);
struct GyorgChildSpawns {
s16 offsetX;
s16 offsetY;
diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c
index 1627c7e8..baadd362 100644
--- a/src/object/houseDoorExterior.c
+++ b/src/object/houseDoorExterior.c
@@ -53,7 +53,7 @@ void sub_080866D8(Entity* this) {
if ((*((u32*)(&this->field_0x68)) & mask) == 0 && sub_080867CC(prop->unk5) &&
CheckRegionOnScreen(prop->unk0, prop->unk2, 32, 32)) {
entity = CreateObject(HOUSE_DOOR_EXT, prop->unk7, prop->unk6);
- if (entity) {
+ if (entity != NULL) {
entity->field_0x6c.HALF.LO = i;
entity->x.HALF.HI = gRoomControls.origin_x + prop->unk0 + 16;
entity->y.HALF.HI = gRoomControls.origin_y + prop->unk2 + 32;
@@ -157,7 +157,7 @@ static void sub_080868EC(Entity* entity, unk_80868EC* arg1) {
void sub_0808692C(Entity* this) {
this->flags &= ~ENT_SCRIPTED;
this->type2 = 2;
- this->action = this->frameIndex == 0 ? 1 : 2;
+ this->action = (this->frameIndex == 0) ? 1 : 2;
this->subAction = 0;
this->actionDelay = 8;
}
diff --git a/src/object/lilypadSmall.c b/src/object/lilypadSmall.c
index ce03ff99..eed1578f 100644
--- a/src/object/lilypadSmall.c
+++ b/src/object/lilypadSmall.c
@@ -4,7 +4,7 @@
extern u16 gUnk_08123318[];
static void sub_08097B24(Entity* this);
-static u32 sub_08097ADC(Entity* this);
+static bool32 sub_08097ADC(Entity* this);
void LilypadSmall(Entity* this) {
u32 rand;
@@ -29,19 +29,19 @@ void LilypadSmall(Entity* this) {
}
}
-static u32 sub_08097ADC(Entity* this) {
- if ((gPlayerState.flags & PL_MINISH) == 0) {
- return 0;
+static bool32 sub_08097ADC(Entity* this) {
+ if (!(gPlayerState.flags & PL_MINISH)) {
+ return FALSE;
} else if (EntityInRectRadius(this, &gPlayerEntity, 8, 8) == 0) {
- return 0;
- } else if (sub_08079F8C() == 0) {
- return 0;
+ return FALSE;
+ } else if (!sub_08079F8C()) {
+ return FALSE;
} else {
gPlayerState.field_0x14 = 1;
if (gPlayerEntity.z.HALF.HI != 0) {
- return 0;
+ return FALSE;
} else {
- return 1;
+ return TRUE;
}
}
}
@@ -52,7 +52,7 @@ static void sub_08097B24(Entity* this) {
u16* temp3;
if (--this->actionDelay == 0) {
- this->actionDelay = 0x5a;
+ this->actionDelay = 90;
this->frameIndex = (this->frameIndex + 1) & 3;
}
temp3 = gUnk_08123318;
diff --git a/src/object/mazaalBossObject.c b/src/object/mazaalBossObject.c
new file mode 100644
index 00000000..adc3ab6d
--- /dev/null
+++ b/src/object/mazaalBossObject.c
@@ -0,0 +1,207 @@
+#define NENT_DEPRECATED
+#include "global.h"
+#include "entity.h"
+#include "enemy.h"
+#include "functions.h"
+#include "item.h"
+#include "object.h"
+#include "player.h"
+#include "new_player.h"
+#include "room.h"
+#include "screen.h"
+#include "sound.h"
+
+extern u16 script_Object89Mazaal[];
+
+typedef struct {
+ /* 0x00 */ Entity base;
+ /* 0x68 */ u8 unk_68[0x1C];
+ /* 0x84 */ ScriptExecutionContext* cutsceneBeh;
+} MazaalBossObjectEntity;
+
+enum MazaalBossObjectActions {
+ /* 0 */ MAZAAL_BOSS_OBJECT_ACTION_0,
+ /* 1 */ MAZAAL_BOSS_OBJECT_ACTION_1,
+ /* 2 */ MAZAAL_BOSS_OBJECT_ACTION_2,
+ /* 3 */ MAZAAL_BOSS_OBJECT_ACTION_3,
+ /* 4 */ MAZAAL_BOSS_OBJECT_ACTION_4,
+ /* 5 */ MAZAAL_BOSS_OBJECT_ACTION_5,
+ /* 6 */ MAZAAL_BOSS_OBJECT_ACTION_6,
+ /* 7 */ MAZAAL_BOSS_OBJECT_ACTION_7,
+ /* 8 */ MAZAAL_BOSS_OBJECT_ACTION_8,
+};
+
+void MazaalBossObject_Action0(MazaalBossObjectEntity* this); // 0809AB04
+void MazaalBossObject_Action1(MazaalBossObjectEntity* this); // 0809ABA4
+void MazaalBossObject_Action2(MazaalBossObjectEntity* this); // 0809ABB0
+void MazaalBossObject_Action3(MazaalBossObjectEntity* this); // 0809ABD4
+void MazaalBossObject_Action4(MazaalBossObjectEntity* this); // 0809ABF4
+void MazaalBossObject_Action5(MazaalBossObjectEntity* this); // 0809AC3C
+void MazaalBossObject_Action6(MazaalBossObjectEntity* this); // 0809ACA0
+void MazaalBossObject_Action7(MazaalBossObjectEntity* this); // 0809ACCC
+void MazaalBossObject_Action8(MazaalBossObjectEntity* this); // 0809ACE8
+void sub_0809AD68(MazaalBossObjectEntity* this); // 0809AD68
+void sub_0809AD8C(MazaalBossObjectEntity* this); // 0809AD8C
+
+void MazaalBossObject(Entity* thisx) {
+ static void (*const MazaalBossObject_Actions[])(MazaalBossObjectEntity*) = {
+ MazaalBossObject_Action0, MazaalBossObject_Action1, MazaalBossObject_Action2,
+ MazaalBossObject_Action3, MazaalBossObject_Action4, MazaalBossObject_Action5,
+ MazaalBossObject_Action6, MazaalBossObject_Action7, MazaalBossObject_Action8,
+ };
+
+ MazaalBossObject_Actions[thisx->action]((MazaalBossObjectEntity*)thisx);
+}
+
+void MazaalBossObject_Action0(MazaalBossObjectEntity* this) {
+ Entity* mazaalHead;
+
+ if (CheckFlags(0x31)) {
+ sub_0809AD68(this);
+ sub_0809AD8C(this);
+ DeleteThisEntity();
+ }
+
+ mazaalHead = CreateEnemy(MAZAAL_HEAD, 0);
+ if (mazaalHead == NULL) {
+ return;
+ }
+
+ CopyPosition(super, mazaalHead);
+ super->child = mazaalHead;
+
+ if (gRoomTransition.field_0x38 != 0) {
+ if (gRoomTransition.field_0x39 != 0) {
+ DeleteThisEntity();
+ }
+
+ super->action = MAZAAL_BOSS_OBJECT_ACTION_7;
+ super->spriteSettings.draw = 0;
+ gRoomControls.camera_target = super;
+ sub_080809D4();
+ } else {
+ super->action = MAZAAL_BOSS_OBJECT_ACTION_1;
+ super->actionDelay = 30;
+ super->frameIndex = gRoomTransition.field_0x38;
+ super->spritePriority.b0 = 7;
+ super->spriteOffsetY = 0x20;
+
+ this->cutsceneBeh = StartCutscene(super, script_Object89Mazaal);
+ }
+}
+
+void MazaalBossObject_Action1(MazaalBossObjectEntity* this) {
+ ExecuteScriptForEntity(super, NULL);
+}
+
+void MazaalBossObject_Action2(MazaalBossObjectEntity* this) {
+ if (--super->actionDelay == 0) {
+ super->action = MAZAAL_BOSS_OBJECT_ACTION_3;
+ super->actionDelay = 120;
+ gRoomControls.camera_target = super->child;
+ }
+}
+
+void MazaalBossObject_Action3(MazaalBossObjectEntity* this) {
+ if (--super->actionDelay == 0) {
+ super->action = MAZAAL_BOSS_OBJECT_ACTION_4;
+ super->actionDelay = 90;
+ super->child->subAction = 1;
+ }
+}
+
+void MazaalBossObject_Action4(MazaalBossObjectEntity* this) {
+ if (super->child->subAction > 2) {
+ if (--super->actionDelay == 0) {
+ super->action = MAZAAL_BOSS_OBJECT_ACTION_5;
+ super->actionDelay = 8;
+ super->field_0xf = 0;
+ super->spriteRendering.alphaBlend = BLDALPHA_BLEND(1, 0);
+
+ gScreen.controls.layerFXControl =
+ BLDCNT_TGT2_BG3 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG0 | BLDCNT_EFFECT_BLEND;
+ gScreen.controls.alphaBlend = BLDALPHA_BLEND(0x10, 0);
+ }
+ }
+}
+
+void MazaalBossObject_Action5(MazaalBossObjectEntity* this) {
+ u32 tmp;
+
+ if (--super->actionDelay == 0) {
+ super->actionDelay = 8;
+
+ tmp = ++super->field_0xf;
+ tmp &= 0xFF;
+ gScreen.controls.alphaBlend = BLDALPHA_BLEND((0x10 - tmp) & 0xFF, tmp);
+
+ if (super->field_0xf > 15) {
+ super->spriteRendering.alphaBlend = BLDALPHA_BLEND(4, 0);
+ gScreen.controls.layerFXControl = 0;
+ super->action = MAZAAL_BOSS_OBJECT_ACTION_6;
+ super->actionDelay = 15;
+ super->spriteSettings.draw = 0;
+ }
+ }
+}
+
+void MazaalBossObject_Action6(MazaalBossObjectEntity* this) {
+ if (--super->actionDelay == 0) {
+ super->child->subAction = 6;
+ gRoomTransition.field_0x38 = 0xF1;
+
+ DeleteEntity(super);
+ }
+}
+
+void MazaalBossObject_Action7(MazaalBossObjectEntity* this) {
+ if (super->child->actionDelay == 1) {
+ super->action = MAZAAL_BOSS_OBJECT_ACTION_8;
+ super->subAction = 0;
+ super->actionDelay = 180;
+ }
+}
+
+void MazaalBossObject_Action8(MazaalBossObjectEntity* this) {
+ switch (super->subAction) {
+ default:
+ if (--super->actionDelay == 0) {
+ super->actionDelay = 90;
+ super->subAction = 1;
+ SoundReq(SFX_SECRET_BIG);
+ SetFlag(0x31);
+ sub_0809AD8C(this);
+ }
+ break;
+ case 1:
+ if (--super->actionDelay == 0) {
+ super->actionDelay = 120;
+ super->subAction = 2;
+ sub_0809AD68(this);
+ }
+ break;
+ case 2:
+ if (--super->actionDelay == 0) {
+ gRoomControls.camera_target = &gNewPlayerEntity.base;
+ gPlayerState.controlMode = CONTROL_1;
+ DeleteThisEntity();
+ }
+ break;
+ }
+}
+
+void sub_0809AD68(MazaalBossObjectEntity* this) {
+ LoadRoomEntityList(GetCurrentRoomProperty(super->type));
+ if (GetInventoryValue(ITEM_OCARINA) != 0) {
+ LoadRoomEntityList(GetCurrentRoomProperty(super->type2));
+ }
+}
+
+void sub_0809AD8C(MazaalBossObjectEntity* this) {
+ Entity* archway = CreateObject(ARCHWAY, 0x22, 0);
+
+ if (archway != NULL) {
+ archway->x.HALF.HI = gRoomControls.origin_x + 0xB8;
+ archway->y.HALF.HI = gRoomControls.origin_y + 8;
+ }
+}
diff --git a/src/object/minecart.c b/src/object/minecart.c
index ddd5d8f1..608c7e51 100644
--- a/src/object/minecart.c
+++ b/src/object/minecart.c
@@ -1,67 +1,82 @@
+#define NENT_DEPRECATED
#include "object.h"
#include "functions.h"
#include "hitbox.h"
-extern u32 sub_08091DDC(Entity*);
+typedef struct {
+ Entity base;
+ u8 filler[0x1C];
+ struct_030010EC* minecartData;
+} MinecartEntity;
+
extern u32 sub_08007DD6(u32, u32);
extern void sub_08017744(Entity*);
-extern void sub_08091C0C(Entity*);
-extern void (*const gUnk_081223A8[])(Entity*);
+u32 sub_08091DDC(MinecartEntity*);
+void sub_080916EC(MinecartEntity*);
+void sub_080917DC(MinecartEntity*);
+void sub_080918A4(MinecartEntity*);
+void sub_080919AC(MinecartEntity*);
+void sub_08091C0C(MinecartEntity*);
+void sub_08091C98(MinecartEntity*);
+void sub_08091CC8(MinecartEntity*);
+void sub_08091D90(MinecartEntity*);
-extern const s8 gUnk_081223C8[];
extern const u32 gUnk_081223D8[];
void Minecart(Entity* this) {
- gUnk_081223A8[this->action](this);
+ static void (*const actionFuncs[])(MinecartEntity*) = {
+ sub_080916EC, sub_080917DC, sub_080918A4, sub_080919AC, sub_08091C0C, sub_08091C98, sub_08091CC8, sub_08091D90,
+ };
+ actionFuncs[this->action]((MinecartEntity*)this);
this->bitfield = 0;
}
-void sub_080916EC(Entity* this) {
- struct_030010EC* unk = &gRoomTransition.minecart_data[this->actionDelay];
+void sub_080916EC(MinecartEntity* this) {
+ struct_030010EC* unk = &gRoomTransition.minecart_data[super->actionDelay];
- *(struct_030010EC**)&this->cutsceneBeh.HWORD = unk;
- if ((gRoomControls.room != unk->field_0x4) || (gPlayerState.flags & PL_IN_MINECART) != 0) {
+ this->minecartData = unk;
+ if ((gRoomControls.room != unk->room) || (gPlayerState.flags & PL_IN_MINECART) != 0) {
DeleteThisEntity();
}
- this->x.HALF.HI = gRoomControls.origin_x + ((unk->field_0x0 & 0x3f) << 4) + 8;
- this->y.HALF.HI = gRoomControls.origin_y + ((unk->field_0x0 & 0xfc << 4) >> 2) + 8;
- this->animationState = unk->field_0x5;
- this->type2 = unk->field_0x6;
- this->action = 1;
- this->hitbox = (Hitbox*)&gUnk_080FD310;
- COLLISION_ON(this);
- this->hitType = 1;
- this->field_0x3c = 0x47;
- this->hurtType = 0x44;
- this->flags2 = 0x80;
- this->direction = DirectionFromAnimationState(this->animationState);
- this->speed = 0x700;
- this->spritePriority.b1 = 3;
- InitAnimationForceUpdate(this, this->type2 + 4 + this->animationState);
- SetTile(0x4022, COORD_TO_TILE(this), this->collisionLayer);
+ super->x.HALF.HI = gRoomControls.origin_x + ((unk->tilePos & 0x3f) << 4) + 8;
+ super->y.HALF.HI = gRoomControls.origin_y + ((unk->tilePos & 0xfc << 4) >> 2) + 8;
+ super->animationState = unk->animationState;
+ super->type2 = unk->field_0x6;
+ super->action = 1;
+ super->hitbox = (Hitbox*)&gUnk_080FD310;
+ COLLISION_ON(super);
+ super->hitType = 1;
+ super->field_0x3c = 0x47;
+ super->hurtType = 0x44;
+ super->flags2 = 0x80;
+ super->direction = DirectionFromAnimationState(super->animationState);
+ super->speed = 0x700;
+ super->spritePriority.b1 = 3;
+ InitAnimationForceUpdate(super, super->type2 + 4 + super->animationState);
+ SetTile(0x4022, COORD_TO_TILE(super), super->collisionLayer);
}
-void sub_080917DC(Entity* this) {
- if ((this->bitfield & 0x7f) == 0x1d) {
- this->zVelocity = Q_16_16(2.625);
- this->action = 7;
- InitAnimationForceUpdate(this, this->type2 + 4 + this->animationState);
+void sub_080917DC(MinecartEntity* this) {
+ if ((super->bitfield & 0x7f) == 0x1d) {
+ super->zVelocity = Q_16_16(2.625);
+ super->action = 7;
+ InitAnimationForceUpdate(super, super->type2 + 4 + super->animationState);
SoundReq(SFX_13B);
} else {
- if (sub_0800445C(this) != 0) {
+ if (sub_0800445C(super) != 0) {
if (!((gPlayerState.flags & (PL_MINISH | PL_ROLLING)) || gPlayerState.field_0x1c ||
gPlayerState.heldObject || gPlayerState.jump_status)) {
- this->actionDelay++;
+ super->actionDelay++;
} else {
- this->actionDelay = 0;
+ super->actionDelay = 0;
}
} else {
- this->actionDelay = 0;
+ super->actionDelay = 0;
}
- if (this->type2 == 0) {
- if (this->actionDelay > 8) {
- this->action++;
+ if (super->type2 == 0) {
+ if (super->actionDelay > 8) {
+ super->action++;
gPlayerState.jump_status = 0x81;
gPlayerState.flags |= PL_ENTER_MINECART;
gPlayerEntity.zVelocity = Q_16_16(2.0);
@@ -72,100 +87,102 @@ void sub_080917DC(Entity* this) {
SoundReq(SFX_PLY_JUMP);
}
} else {
- this->actionDelay = 0;
+ super->actionDelay = 0;
}
}
}
-void sub_080918A4(Entity* this) {
- if (EntityInRectRadius(this, &gPlayerEntity, 2, 2) != 0) {
- gPlayerEntity.x.HALF.HI = this->x.HALF.HI;
- gPlayerEntity.y.HALF.HI = this->y.HALF.HI;
+void sub_080918A4(MinecartEntity* this) {
+ if (EntityInRectRadius(super, &gPlayerEntity, 2, 2) != 0) {
+ gPlayerEntity.x.HALF.HI = super->x.HALF.HI;
+ gPlayerEntity.y.HALF.HI = super->y.HALF.HI;
if (gPlayerEntity.z.HALF.HI > -0x10) {
if (gPlayerEntity.zVelocity >= 0) {
return;
}
- gPlayerEntity.animationState = this->animationState << 1;
+ gPlayerEntity.animationState = super->animationState << 1;
gPlayerState.flags = (gPlayerState.flags ^ PL_ENTER_MINECART) | PL_IN_MINECART;
- this->action++;
- this->field_0xf = 1;
- this->flags |= ENT_PERSIST;
- this->hitType = 0x97;
- this->field_0x3c = (gPlayerEntity.field_0x3c + 1) | 0x20;
- this->flags2 = gPlayerEntity.flags2;
- this->hurtType = 0x18;
- this->damage = 8;
- sub_0801766C(this);
- RestorePrevTileEntity(COORD_TO_TILE(this), this->collisionLayer);
+ super->action++;
+ super->field_0xf = 1;
+ super->flags |= ENT_PERSIST;
+ super->hitType = 0x97;
+ super->field_0x3c = (gPlayerEntity.field_0x3c + 1) | 0x20;
+ super->flags2 = gPlayerEntity.flags2;
+ super->hurtType = 0x18;
+ super->damage = 8;
+ sub_0801766C(super);
+ RestorePrevTileEntity(COORD_TO_TILE(super), super->collisionLayer);
SoundReq(SFX_137);
}
} else {
- gPlayerEntity.direction = GetFacingDirection(&gPlayerEntity, this);
+ gPlayerEntity.direction = GetFacingDirection(&gPlayerEntity, super);
}
if (gPlayerEntity.zVelocity < 0) {
- gPlayerEntity.spritePriority.b0 = this->spritePriority.b0 - 1;
+ gPlayerEntity.spritePriority.b0 = super->spritePriority.b0 - 1;
}
}
-void sub_080919AC(Entity* this) {
+void sub_080919AC(MinecartEntity* this) {
+ static const s8 gUnk_081223C8[] = { 0, -7, 7, 0, 0, 7, -7, 0 };
+
u32 iVar2;
u32 uVar3;
gRoomControls.unk5 = 7;
if ((gPlayerState.flags & PL_IN_MINECART) == 0) {
- this->action = 1;
+ super->action = 1;
return;
}
if ((gPlayerEntity.frame & 0xf) == 0) {
- COLLISION_OFF(this);
- CopyPosition(this, &gPlayerEntity);
+ COLLISION_OFF(super);
+ CopyPosition(super, &gPlayerEntity);
if ((gPlayerEntity.frame & 0xf0) == 0x10) {
- this->spriteOffsetY = 1;
+ super->spriteOffsetY = 1;
} else {
- this->spriteOffsetY = 0;
+ super->spriteOffsetY = 0;
}
} else {
- COLLISION_ON(this);
+ COLLISION_ON(super);
gPlayerEntity.speed = 0;
- LinearMoveUpdate(this);
- CopyPosition(this, &gPlayerEntity);
- gPlayerEntity.spritePriority.b0 = this->spritePriority.b0 - 1;
+ LinearMoveUpdate(super);
+ CopyPosition(super, &gPlayerEntity);
+ gPlayerEntity.spritePriority.b0 = super->spritePriority.b0 - 1;
if (!sub_08091DDC(this)) {
if ((gRoomTransition.frameCount & 0xf) == 0) {
SoundReq(SFX_138);
}
- if (--this->field_0xf == 0xff) {
+ if (--super->field_0xf == 0xff) {
SoundReq(SFX_PLY_VO7);
- this->field_0xf = 0x3c;
+ super->field_0xf = 0x3c;
}
- uVar3 = GetRelativeCollisionTile(this, gUnk_081223C8[this->animationState * 2],
- gUnk_081223C8[this->animationState * 2 + 1]);
- iVar2 = sub_08007DD6(uVar3, gUnk_081223D8[this->animationState]);
+ uVar3 = GetRelativeCollisionTile(super, gUnk_081223C8[super->animationState * 2],
+ gUnk_081223C8[super->animationState * 2 + 1]);
+ iVar2 = sub_08007DD6(uVar3, gUnk_081223D8[super->animationState]);
if (iVar2 == 0) {
- this->direction = DirectionTurnAround(this->direction);
- this->animationState = AnimationStateFlip90(this->animationState);
+ super->direction = DirectionTurnAround(super->direction);
+ super->animationState = AnimationStateFlip90(super->animationState);
} else {
switch (uVar3) {
case 0x64:
- this->flags &= ~ENT_PERSIST;
- this->hitType = 1;
- this->field_0x3c = 0x47;
- this->hurtType = 0x44;
- this->flags2 = 0x80;
- this->action = 6;
- sub_08017744(this);
+ super->flags &= ~ENT_PERSIST;
+ super->hitType = 1;
+ super->field_0x3c = 0x47;
+ super->hurtType = 0x44;
+ super->flags2 = 0x80;
+ super->action = 6;
+ sub_08017744(super);
gPlayerState.jump_status = 0x41;
gPlayerState.flags = (gPlayerState.flags ^ PL_IN_MINECART) | PL_ENTER_MINECART;
gPlayerEntity.zVelocity = Q_16_16(2.0);
gPlayerEntity.speed = 0x200;
- gPlayerEntity.animationState = this->animationState << 1;
- gPlayerEntity.direction = this->direction;
+ gPlayerEntity.animationState = super->animationState << 1;
+ gPlayerEntity.direction = super->direction;
gPlayerEntity.flags |= PL_MINISH;
- sub_08004168(this);
- InitAnimationForceUpdate(this, this->animationState + 0xc);
+ sub_08004168(super);
+ InitAnimationForceUpdate(super, super->animationState + 0xc);
SoundReq(SFX_PLY_VO4);
SoundReq(SFX_139);
return;
@@ -177,21 +194,135 @@ void sub_080919AC(Entity* this) {
case 0x6d:
case 0x6e:
case 0x6f:
- if (uVar3 == GetTileUnderEntity(this)) {
+ if (uVar3 == GetTileUnderEntity(super)) {
sub_08091C0C(this);
- gPlayerEntity.animationState = this->animationState << 1;
+ gPlayerEntity.animationState = super->animationState << 1;
return;
}
break;
}
}
- gPlayerEntity.animationState = this->animationState << 1;
- if (this->animIndex == this->animationState) {
- UpdateAnimationSingleFrame(this);
+ gPlayerEntity.animationState = super->animationState << 1;
+ if (super->animIndex == super->animationState) {
+ UpdateAnimationSingleFrame(super);
} else {
- InitAnimationForceUpdate(this, this->animationState);
+ InitAnimationForceUpdate(super, super->animationState);
}
}
}
}
+
+void sub_08091C0C(MinecartEntity* this) {
+ sub_08004168(super);
+ CopyPosition(super, &gPlayerEntity);
+ switch (GetTileUnderEntity(super)) {
+ case 0x67:
+ if (super->direction == DirectionWest) {
+ super->direction = DirectionNorth;
+ super->animationState = 0;
+ } else {
+ super->direction = DirectionEast;
+ super->animationState = 1;
+ }
+ break;
+ case 0x68:
+ if (super->direction == DirectionEast) {
+ super->direction = DirectionSouth;
+ super->animationState = 2;
+ } else {
+ super->direction = DirectionWest;
+ super->animationState = 3;
+ }
+ break;
+ case 0x69:
+ if (super->direction == DirectionEast) {
+ super->direction = DirectionNorth;
+ super->animationState = 0;
+ } else {
+ super->direction = DirectionWest;
+ super->animationState = 3;
+ }
+ break;
+ case 0x6a:
+ if (super->direction == DirectionWest) {
+ super->direction = DirectionSouth;
+ super->animationState = 2;
+ } else {
+ super->direction = DirectionEast;
+ super->animationState = 1;
+ }
+ break;
+ default:
+ super->action = 3;
+ return;
+ }
+
+ super->action = 3;
+ gPlayerEntity.animationState = super->animationState << 1;
+}
+
+void sub_08091C98(MinecartEntity* this) {
+ LinearMoveUpdate(super);
+ CopyPosition(super, &gPlayerEntity);
+ if (gRoomControls.reload_flags == 0) {
+ super->action = 3;
+ super->speed = 0x700;
+ gRoomControls.camera_target = &gPlayerEntity;
+ }
+}
+
+void sub_08091CC8(MinecartEntity* this) {
+ struct_030010EC* minecartData;
+
+ if (gPlayerState.jump_status == 0) {
+ super->action = 1;
+ super->direction = DirectionTurnAround(super->direction);
+ super->animationState ^= 2;
+ gPlayerState.flags ^= PL_ENTER_MINECART;
+ minecartData = this->minecartData;
+ minecartData->tilePos = COORD_TO_TILE(super);
+ minecartData->room = gRoomControls.room;
+ minecartData->animationState = super->animationState;
+ InitAnimationForceUpdate(super, super->animationState + 0x10);
+ SetTile(0x4022, COORD_TO_TILE(super), super->collisionLayer);
+ } else {
+ UpdateAnimationSingleFrame(super);
+ gPlayerEntity.spritePriority.b0 = super->spritePriority.b0 - 1;
+ }
+}
+
+void sub_08091D90(MinecartEntity* this) {
+ if (super->zVelocity < 0) {
+ UpdateAnimationSingleFrame(super);
+ }
+ if (((super->frame & 0x7f) == 0) && GravityUpdate(super, 0x2000) == 0) {
+ super->type2 ^= 4;
+ super->action = 1;
+ this->minecartData->field_0x6 = super->type2;
+ SoundReq(SFX_13C);
+ }
+}
+
+bool32 sub_08091DDC(MinecartEntity* this) {
+ static const s8 gUnk_081223D0[] = { 0, -8, 8, 0, 0, 8, -8, 0 };
+ if ((sub_080B1AF0(super, gUnk_081223D0[super->animationState * 2], gUnk_081223D0[super->animationState * 2 + 1]) ==
+ 0xff) &&
+ (sub_0807BD14(&gPlayerEntity, super->animationState))) {
+ super->updatePriority = 6;
+ super->action = 5;
+ switch (super->direction) {
+ case 0:
+ case 8:
+ case 0x10:
+ case 0x18:
+ super->speed = 0xa0;
+ break;
+ }
+ gPlayerEntity.direction = super->direction;
+ gRoomControls.camera_target = super;
+ return 1;
+ } else {
+ return 0;
+ }
+}
diff --git a/src/object/object49.c b/src/object/object49.c
index 1b74b298..4eca5e6e 100644
--- a/src/object/object49.c
+++ b/src/object/object49.c
@@ -195,7 +195,7 @@ void sub_0808F3DC(Entity* this) {
if (this->type == 5 && (this->frame & 1)) {
Entity* entity = CreateObjectWithParent(this->child, 0x49, 8, 0);
- if (entity) {
+ if (entity != NULL) {
entity->parent = this->parent;
entity->child = this->parent->parent;
}
@@ -262,19 +262,19 @@ void sub_0808F554(Entity* this) {
void sub_0808F5EC(Entity* this) {
Entity* entity = CreateObjectWithParent(this->child, 0x49, 5, 0);
- if (entity) {
+ if (entity != NULL) {
entity->parent = this;
entity->child = this->child;
}
entity = CreateObjectWithParent(this->child, 0x49, 6, 0);
- if (entity) {
+ if (entity != NULL) {
entity->parent = this;
entity->child = this->child;
}
entity = CreateObjectWithParent(this->child, 0x49, 7, 0);
- if (entity) {
+ if (entity != NULL) {
entity->parent = this;
entity->child = this->child;
}
diff --git a/src/object/object96.c b/src/object/object96.c
new file mode 100644
index 00000000..2ffac509
--- /dev/null
+++ b/src/object/object96.c
@@ -0,0 +1,181 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "player.h"
+#include "asm.h"
+#include "functions.h"
+#include "sound.h"
+#include "item.h"
+#include "flags.h"
+#include "effects.h"
+
+typedef struct _struct_gUnk_08123FB0 {
+ void (*const funcEnt)(Entity*);
+ bool32 (*const func)(Entity*, const struct _struct_gUnk_08123FB0*);
+ s8 unk08;
+ s8 unk09;
+ u8 unk0a;
+ u8 unk0b;
+ u8 unk0c;
+ u8 type;
+ u8 unk0e;
+ u8 unk0f;
+ s32 zVelocity;
+ u32 unk14;
+ s16 speed;
+ s16 y;
+ u16 flag;
+ u8 actionDelay;
+ u8 unk1f;
+} struct_gUnk_08123FB0;
+
+static_assert(sizeof(struct_gUnk_08123FB0) == 0x20);
+
+void sub_0809D91C(Entity*);
+bool32 sub_0809D93C(Entity*, const struct_gUnk_08123FB0*);
+void Object96_Init(Entity*, const struct_gUnk_08123FB0*);
+void Object96_Action1(Entity*, const struct_gUnk_08123FB0*);
+void Object96_Action2(Entity*, const struct_gUnk_08123FB0*);
+void Object96_Action3(Entity*, const struct_gUnk_08123FB0*);
+
+static const struct_gUnk_08123FB0 gUnk_08123FB0[] = {
+ { sub_0809D91C, sub_0809D93C, 0, 0, 0x30, 0x30, 0x1, 0x3c, 0x3c, 0x13, 0x10000, 0x1800, 0x60, 0x40, 0x4021, 0x1,
+ 0x0 },
+ { sub_0809D91C, NULL, 0, 0, 0, 0, 0, 0x63, 0x63, 0x10, 0, 0x1800, 0, 0x18,
+#if defined(JP) || defined(DEMO_JP) || defined(EU)
+ 0xCD,
+#else
+ 0xd0,
+#endif
+ 0, 0 },
+ { sub_0809D91C, NULL, 0, 0, 0, 0, 0, 0x3c, 0x3c, 0xf, 0x10000, 0x1800, 0x60, 0x40, 0x4021, 0x1, 0x0 },
+ { sub_0809D91C, NULL, 0, 0, 0, 0, 0, 0x3c, 0x3c, 0x2, 0x10000, 0x1800, 0x140, 0x40, 0x4021, 0x1, 0x0 },
+ { sub_0809D91C, NULL, 0, 0, 0, 0, 0x0, 0x3c, 0x3c, 0xd, 0x10000, 0x1800, 0x60, 0x40, 0x4021, 0x1, 0x0 },
+ { sub_0809D91C, NULL, 0, 0, 0, 0, 0x0, 0x3c, 0x3c, 0x1a, 0x10000, 0x1800, 0x100, 0x40, 0x4021, 0x1, 0x0 },
+ { sub_0809D91C, NULL, 0, 0, 0, 0, 0x0, 0x3c, 0x3c, 0x13, 0x10000, 0x1800, 0x60, 0x40, 0x4021, 0x1, 0x0 },
+ { NULL, NULL, 0, 0, 0, 0, 0x0, 0x5c, 0x5c, 0x81, 0, 0x1800, 0x100, 0x20, 0x0, 0x1, 0x0 },
+};
+
+void Object96(Entity* this) {
+ static void (*const actionFuncs[])(Entity*, const struct_gUnk_08123FB0*) = {
+ Object96_Init,
+ Object96_Action1,
+ Object96_Action2,
+ Object96_Action3,
+ };
+ actionFuncs[this->action](this, &gUnk_08123FB0[this->type]);
+}
+
+void Object96_Init(Entity* this, const struct_gUnk_08123FB0* param_2) {
+ u32 type;
+ u32 dir;
+
+ this->action++;
+ this->collisionLayer = 2;
+ this->spriteRendering.b3 = 1;
+ this->zVelocity = param_2->zVelocity;
+ this->direction = param_2->unk0f;
+ this->speed = param_2->speed;
+ this->y.HALF.HI -= param_2->y;
+ this->z.WORD = 0;
+ this->actionDelay = param_2->actionDelay;
+ if ((this->direction & 0x80)) {
+ dir = this->direction;
+ if (dir == 0x81) {
+ this->direction = (((gPlayerEntity.animationState * 4 + (Random() & 3)) - 2) & 0x1f) ^ 0x10;
+ }
+ }
+ UpdateSpriteForCollisionLayer(this);
+ type = this->type;
+ sub_08080CB4(this);
+ this->type = type;
+}
+
+void Object96_Action1(Entity* this, const struct_gUnk_08123FB0* param_2) {
+ u32 type;
+ s32 iVar3;
+
+ iVar3 = 1;
+ if (param_2->func != NULL) {
+ iVar3 = param_2->func(this, param_2);
+ }
+ if (iVar3 != 0) {
+ this->action++;
+ this->y.HALF.HI += param_2->y;
+ this->z.HALF.HI -= param_2->y;
+ }
+ type = this->type;
+ this->type = param_2->type;
+ sub_08080CB4(this);
+ this->type = type;
+}
+
+void Object96_Action2(Entity* this, const struct_gUnk_08123FB0* param_2) {
+ u8 type;
+
+ LinearMoveUpdate(this);
+ if (sub_080044EC(this, param_2->unk14) < 2) {
+ if (this->actionDelay) {
+ this->actionDelay--;
+ this->zVelocity = param_2->unk14 << 3;
+ } else {
+ this->action++;
+ this->collisionLayer = gPlayerEntity.collisionLayer;
+ UpdateSpriteForCollisionLayer(this);
+ if (param_2->funcEnt != NULL) {
+ param_2->funcEnt(this);
+ }
+ }
+ SoundReq(SFX_RUPEE_BOUNCE);
+ }
+ type = this->type;
+ this->type = param_2->type;
+ sub_08080CB4(this);
+ this->type = type;
+}
+
+void Object96_Action3(Entity* this, const struct_gUnk_08123FB0* param_2) {
+ u8 type;
+
+ if (gPlayerState.flags & 0x80) {
+ sub_0800445C(this);
+ } else {
+ if (IsCollidingPlayer(this)) {
+ CreateItemEntity(param_2->type, this->type2, 0);
+ if (param_2->flag) {
+ SetFlag(param_2->flag);
+ }
+ DeleteThisEntity();
+ }
+ }
+ type = this->type;
+ this->type = param_2->type;
+ sub_08080CB4(this);
+ this->type = type;
+}
+
+void sub_0809D91C(Entity* this) {
+ Entity* fxEnt;
+
+ fxEnt = CreateFx(this, FX_DASH, 0);
+ if (fxEnt != NULL) {
+ SortEntityBelow(this, fxEnt);
+ }
+ SoundReq(SFX_SECRET);
+}
+
+bool32 sub_0809D93C(Entity* this, const struct_gUnk_08123FB0* param_2) {
+ u32 uVar1;
+
+ if (gPlayerEntity.action == 6 && ((param_2->unk0c >> gPlayerEntity.animationState & 1) != 0)) {
+ uVar1 = (gPlayerEntity.x.HALF.HI - this->x.HALF.HI) + param_2->unk08 + param_2->unk0a;
+ if (param_2->unk0a * 2 <= (u16)uVar1) {
+ return 0;
+ }
+
+ uVar1 = (gPlayerEntity.y.HALF.HI - (this->y.HALF.HI + param_2->y)) + param_2->unk09 + param_2->unk0b;
+ if (param_2->unk0b * 2 > (u16)uVar1) {
+ return 1;
+ }
+ }
+ return 0;
+}
diff --git a/src/object/object98.c b/src/object/object98.c
new file mode 100644
index 00000000..798836dc
--- /dev/null
+++ b/src/object/object98.c
@@ -0,0 +1,68 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "projectile.h"
+#include "room.h"
+#include "functions.h"
+
+typedef struct {
+ Entity base;
+ u8 filler[0xC];
+ u16 unk74;
+ u16 unk76;
+ u8 filler2[0x6];
+ u8 unk7e;
+} Object98Entity;
+
+void sub_0809E360(Object98Entity*);
+void sub_0809E3E4(Object98Entity*);
+
+void Object98(Entity* this) {
+ static void (*const actionFuncs[])(Object98Entity*) = {
+ sub_0809E360,
+ sub_0809E3E4,
+ };
+
+ actionFuncs[this->action]((Object98Entity*)this);
+}
+
+void sub_0809E360(Object98Entity* this) {
+ u32 bVar1;
+ Entity* projEnt;
+ u32 index;
+
+ if (8 < super->actionDelay) {
+ super->actionDelay = 8;
+ }
+
+ if (0x48 - super->actionDelay > gEntCount) {
+ for (index = 0; index < super->actionDelay; index++) {
+ projEnt = CreateProjectile(GURUGURU_BAR_PROJECTILE);
+ projEnt->actionDelay = 14 + 12 * index;
+ projEnt->parent = super;
+ }
+
+ super->action = 1;
+ bVar1 = this->unk7e;
+ this->unk76 = bVar1 << 8;
+ super->animationState = bVar1 << 6;
+ SetDefaultPriority(super, 0);
+ if (super->type != 0) {
+ super->child = (Entity*)GetCurrentRoomProperty(super->type);
+ sub_080A2CC0(super, (u16**)&super->child, &this->unk74);
+ }
+ }
+}
+
+void sub_0809E3E4(Object98Entity* this) {
+ this->unk76 += super->type2;
+ super->animationState = this->unk76 >> 2;
+ if (super->type != 0) {
+ if ((super->direction & 0x80) == 0) {
+ LinearMoveUpdate(super);
+ }
+
+ if (--this->unk74 == 0) {
+ sub_080A2CC0(super, (u16**)&super->child, &this->unk74);
+ }
+ }
+}
diff --git a/src/object/object99.c b/src/object/object99.c
new file mode 100644
index 00000000..e8bf6a33
--- /dev/null
+++ b/src/object/object99.c
@@ -0,0 +1,39 @@
+#include "entity.h"
+#include "coord.h"
+
+void Object99(Entity* this) {
+ Entity* parent;
+
+ parent = this->parent;
+ if (parent->next == NULL) {
+ DeleteThisEntity();
+ }
+
+ if (this->action == 0) {
+ this->action = 1;
+ this->field_0x76.HALF.LO = parent->animationState;
+ this->field_0x74.HALF.LO = this->spriteOffsetX;
+ this->field_0x74.HALF.HI = this->spriteOffsetY;
+ InitializeAnimation(this, this->animationState);
+ }
+
+ if (parent->animationState != this->field_0x76.HALF.LO) {
+ DeleteThisEntity();
+ }
+ this->spriteSettings.draw = parent->spriteSettings.draw;
+ CopyPositionAndSpriteOffset(parent, this);
+ this->spriteOffsetX += this->field_0x74.HALF.LO;
+ this->spriteOffsetY += this->field_0x74.HALF.HI;
+ if (this->animationState != 2) {
+ this->y.HALF.HI++;
+ this->spriteOffsetY--;
+ } else {
+ this->y.HALF.HI--;
+ this->spriteOffsetY++;
+ }
+
+ GetNextFrame(this);
+ if (this->frame & 0x80) {
+ DeleteThisEntity();
+ }
+}
diff --git a/src/object/objectA6.c b/src/object/objectA6.c
new file mode 100644
index 00000000..fc77a54e
--- /dev/null
+++ b/src/object/objectA6.c
@@ -0,0 +1,51 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "flags.h"
+#include "hitbox.h"
+#include "effects.h"
+
+typedef struct {
+ Entity base;
+ u8 filler[0x1E];
+ u16 objFlags;
+} ObjectA6Entity;
+
+void sub_0809F920(ObjectA6Entity*);
+void sub_0809F964(ObjectA6Entity*);
+
+void ObjectA6(Entity* this) {
+ static void (*const actionFuncs[])(ObjectA6Entity*) = {
+ sub_0809F920,
+ sub_0809F964,
+ };
+
+ actionFuncs[this->action]((ObjectA6Entity*)this);
+}
+
+void sub_0809F920(ObjectA6Entity* this) {
+ if (CheckFlags(this->objFlags)) {
+ DeleteThisEntity();
+ }
+
+ super->action = 1;
+ COLLISION_ON(super);
+ super->field_0x3c = 7;
+ super->hurtType = 0x48;
+ super->hitType = 1;
+ super->flags2 = 2;
+ super->hitbox = (Hitbox*)&gHitbox_0;
+}
+
+void sub_0809F964(ObjectA6Entity* this) {
+ Entity* fxEnt;
+
+ if (super->bitfield == 0xa1) {
+ fxEnt = CreateFx(super, FX_MAGIC_STORM, 0);
+ if (fxEnt != NULL) {
+ fxEnt->spritePriority.b0 = 3;
+ fxEnt->spriteOffsetY = -5;
+ }
+ SetFlag(this->objFlags);
+ DeleteThisEntity();
+ }
+}
diff --git a/src/object/objectA9.c b/src/object/objectA9.c
new file mode 100644
index 00000000..6d9981ba
--- /dev/null
+++ b/src/object/objectA9.c
@@ -0,0 +1,37 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "sound.h"
+
+void sub_0809FEF8(Entity*);
+void sub_0809FF28(Entity*);
+
+void ObjectA9(Entity* this) {
+ static void (*const actionFuncs[])(Entity*) = {
+ sub_0809FEF8,
+ sub_0809FF28,
+ DeleteEntity,
+ };
+
+ actionFuncs[this->action]((Entity*)this);
+}
+
+void sub_0809FEF8(Entity* this) {
+ static const u8 typeAnimationStates[] = { 0x2, 0x0, 0x43, 0x0 };
+ static const u16 typeSounds[] = { SFX_124, SFX_197, SFX_11D, SFX_NONE };
+ this->action = 1;
+ InitializeAnimation(this, typeAnimationStates[this->type]);
+ SoundReq(typeSounds[this->type]);
+}
+
+void sub_0809FF28(Entity* this) {
+ Entity* pEVar1;
+
+ GetNextFrame(this);
+ if (this->frame & 0x80) {
+ this->action = 2;
+ pEVar1 = this->parent;
+ pEVar1->flags = this->actionDelay;
+ pEVar1->spriteSettings.draw = this->field_0xf;
+ ((GenericEntity*)pEVar1)->field_0x6c.HALF.HI &= 0xef;
+ }
+}
diff --git a/src/object/objectAB.c b/src/object/objectAB.c
new file mode 100644
index 00000000..767c5238
--- /dev/null
+++ b/src/object/objectAB.c
@@ -0,0 +1,59 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "flags.h"
+#include "asm.h"
+#include "player.h"
+#include "coord.h"
+
+extern void sub_0805B390(u32);
+
+void ObjectAB_Init(Entity*);
+void ObjectAB_Action1(Entity*);
+void ObjectAB_Action2(Entity*);
+void sub_080A0190(Entity*);
+
+void ObjectAB(Entity* this) {
+ static void (*const actionFuncs[])(Entity*) = {
+ ObjectAB_Init,
+ ObjectAB_Action1,
+ ObjectAB_Action2,
+ };
+
+ actionFuncs[this->action]((Entity*)this);
+}
+
+void ObjectAB_Init(Entity* this) {
+ this->action++;
+ this->collisionLayer = 1;
+ this->spriteRendering.b3 = 3;
+ this->spritePriority.b0 = 7;
+ this->subAction = 0;
+ InitializeAnimation(this, 0);
+}
+
+void ObjectAB_Action1(Entity* this) {
+ if (CheckRoomFlag(0)) {
+ GetNextFrame(this);
+ if (this->frame & 0x80) {
+ this->action++;
+ }
+ }
+}
+
+void ObjectAB_Action2(Entity* this) {
+ if (CheckRoomFlag(1)) {
+ sub_080A0190(this);
+ RequestPriorityDuration(this, 0x1e);
+ if (EntityInRectRadius(this, &gPlayerEntity, 0x10, 0x10)) {
+ sub_0805B390(0x37);
+ }
+ }
+}
+
+void sub_080A0190(Entity* this) {
+ this->subAction = 1;
+ CopyPosition(this, &gPlayerEntity);
+ gPlayerState.queued_action = 3;
+ gPlayerState.field_0x38 = 0;
+ gPlayerState.flags |= PL_PIT_IS_EXIT;
+}
diff --git a/src/object/objectAD.c b/src/object/objectAD.c
new file mode 100644
index 00000000..ca73277e
--- /dev/null
+++ b/src/object/objectAD.c
@@ -0,0 +1,54 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "functions.h"
+#include "screen.h"
+
+void sub_080A04A4(Entity*);
+void sub_080A04E0(Entity*);
+void sub_080A04E8();
+
+void ObjectAD(Entity* this) {
+ static void (*const actionFuncs[])(Entity*) = {
+ sub_080A04A4,
+ sub_080A04E0,
+ };
+
+ actionFuncs[this->action]((Entity*)this);
+}
+
+void sub_080A04A4(Entity* this) {
+ this->action = 1;
+ this->frameIndex = 4;
+ this->actionDelay = 0;
+ this->spriteRendering.b3 = 3;
+ this->spritePriority.b0 = 7;
+ this->z.WORD = 0;
+ this->spriteRendering.alphaBlend = 1;
+ sub_080A04E8();
+}
+
+void sub_080A04E0(Entity* this) {
+ sub_080A04E8();
+}
+
+void sub_080A04E8(Entity* this) {
+ int iVar2;
+ u32 uVar3;
+
+ iVar2 = (this->parent->z.HALF.HI < 0 ? -this->parent->z.HALF.HI : this->parent->z.HALF.HI) + 0x100;
+ SetAffineInfo(this, iVar2, iVar2, 0);
+ iVar2 = ((0x1c0 - iVar2) * 10) / iVar2;
+ if (this->parent->type == 0x41) {
+ uVar3 = iVar2 * 2;
+ if (0xc < uVar3) {
+ uVar3 = 0xc;
+ }
+ iVar2 = (0x10 - iVar2) * 0x100;
+ iVar2 |= uVar3;
+ iVar2 &= 0xffff;
+ } else {
+ iVar2 |= (0x10 - iVar2) * 0x100;
+ iVar2 &= 0xffff;
+ }
+ gScreen.controls.alphaBlend = iVar2;
+}
diff --git a/src/object/objectB.c b/src/object/objectB.c
index f0cfc4e5..fbf4ef50 100644
--- a/src/object/objectB.c
+++ b/src/object/objectB.c
@@ -124,7 +124,7 @@ void ObjectB_Action2(ObjectBEntity* this) {
break;
}
MessageFromTarget(messageIndex);
- gMessage.field_0x10 = super->type2;
+ gMessage.rupees = super->type2;
}
}
}
diff --git a/src/object/objectB4.c b/src/object/objectB4.c
new file mode 100644
index 00000000..90c3b287
--- /dev/null
+++ b/src/object/objectB4.c
@@ -0,0 +1,135 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "menu.h"
+#include "coord.h"
+#include "object.h"
+
+extern void sub_0806FB00(Entity*, u32, u32, u32);
+extern bool32 sub_0806FB38(Entity*);
+
+void ObjectB4_Type0(Entity*);
+void ObjectB4_Type1(Entity*);
+void ObjectB4_Type2(Entity*);
+void ObjectB4_Type3(Entity*);
+
+const u16 gUnk_08124B10[] = { 0x40, 0x58, 0x68, 0x80, 0x94, 0xA8, 0xB0, 0x0 };
+
+void ObjectB4(Entity* this) {
+ static void (*const typeFuncs[])(Entity*) = {
+ ObjectB4_Type0,
+ ObjectB4_Type1,
+ ObjectB4_Type2,
+ ObjectB4_Type3,
+ };
+
+ typeFuncs[this->type]((Entity*)this);
+}
+
+void ObjectB4_Type0(Entity* this) {
+ Entity* pEVar3;
+
+ switch (this->action) {
+ case 0:
+ this->action = 1;
+ this->spriteSettings.draw = 2;
+ this->frameIndex = 9;
+ this->actionDelay = 8;
+ this->field_0xf = 0;
+ this->spriteRendering.b3 = 1;
+ this->spritePriority.b0 = 4;
+ this->spriteOrientation.flipY = 1;
+ sub_0806FB00(this, 0xbf, 0x48, 0x1e);
+ break;
+ case 1:
+ if ((this->field_0xf < 7) && (--this->actionDelay == 0)) {
+ this->actionDelay = 1;
+ pEVar3 = CreateObject(OBJECT_B4, 1, this->field_0xf);
+ if (pEVar3 != NULL) {
+ CopyPosition(this, pEVar3);
+ pEVar3->y.HALF.HI = 0x68;
+ SortEntityBelow(this, pEVar3);
+ }
+ this->field_0xf++;
+ }
+
+ if (sub_0806FB38(this) || (1 < gMenu.menuType)) {
+ this->x.HALF.HI = 0xbf;
+ this->y.HALF.HI = 0x48;
+ this->frameIndex = 10;
+ this->action = 2;
+ while (this->field_0xf < 7) {
+ pEVar3 = CreateObject(OBJECT_B4, 1, this->field_0xf);
+ if (pEVar3 != NULL) {
+ CopyPosition(this, pEVar3);
+ pEVar3->y.HALF.HI = 0x68;
+ SortEntityBelow(this, pEVar3);
+ }
+ this->field_0xf++;
+ }
+
+ pEVar3 = CreateObject(OBJECT_B4, 2, 0);
+ if (pEVar3 != NULL) {
+ pEVar3->x.HALF.HI = 0xc4;
+ pEVar3->y.HALF.HI = 0x2c;
+ SortEntityAbove(this, pEVar3);
+ }
+
+ pEVar3 = CreateObject(OBJECT_B4, 3, 0);
+ if (pEVar3 != NULL) {
+ pEVar3->x.HALF.HI = 0xb4;
+ pEVar3->y.HALF.HI = 0x19;
+ SortEntityAbove(this, pEVar3);
+ }
+ }
+ }
+}
+
+void ObjectB4_Type1(Entity* this) {
+ switch (this->action) {
+ case 0:
+ this->action = 1;
+ this->spriteSettings.draw = 2;
+ this->frameIndex = this->type2 + 2;
+ sub_0806FB00(this, gUnk_08124B10[this->type2], 0x68, 0x14);
+ break;
+ case 1:
+ if (sub_0806FB38(this) || 1 < gMenu.menuType) {
+ this->x.HALF.HI = gUnk_08124B10[this->type2];
+ this->y.HALF.HI = 0x68;
+ this->spritePriority.b0 = 7 - this->type2;
+ this->action = 2;
+ }
+ break;
+ }
+}
+
+void ObjectB4_Type2(Entity* this) {
+ static const u8 gUnk_08124B30[] = { 9, 10, 11, 12, 11, 10, 9, -1 };
+ if (this->action == 0) {
+ this->action = 1;
+ this->spriteSettings.draw = 2;
+ this->spriteRendering.b3 = 1;
+ this->spritePriority.b0 = 0;
+ this->spriteOrientation.flipY = 1;
+ this->frameIndex = 11;
+ this->actionDelay = (Random() & 0x3f) + 0x40;
+ this->field_0xf = 0;
+ }
+
+ if (--this->actionDelay == 0) {
+ this->actionDelay = 4;
+ this->frameIndex = gUnk_08124B30[this->field_0xf++] + 2;
+ if (gUnk_08124B30[this->field_0xf] == 0xff) {
+ this->actionDelay = (Random() & 0x3f) + 0x40;
+ this->field_0xf = 0;
+ }
+ }
+}
+
+void ObjectB4_Type3(Entity* this) {
+ if (this->action == 0) {
+ this->action = 1;
+ this->spriteSettings.draw = 2;
+ this->frameIndex = 15;
+ }
+}
diff --git a/src/object/objectBlockingStairs.c b/src/object/objectBlockingStairs.c
new file mode 100644
index 00000000..f9aa6a1b
--- /dev/null
+++ b/src/object/objectBlockingStairs.c
@@ -0,0 +1,350 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "flags.h"
+#include "sound.h"
+#include "functions.h"
+#include "asm.h"
+#include "object.h"
+#include "effects.h"
+
+typedef struct {
+ Entity base;
+ u8 filler[0x10];
+ u16 tilePos;
+ u8 unk7a;
+ u8 unk7b;
+ u8 filler2[0xA];
+ u16 objFlags;
+} ObjectBlockingStairsEntity;
+
+extern const Hitbox gUnk_080FD288;
+
+void ObjectBlockingStairs_Init(ObjectBlockingStairsEntity*);
+void ObjectBlockingStairs_Action1(ObjectBlockingStairsEntity*);
+void ObjectBlockingStairs_Action2(ObjectBlockingStairsEntity*);
+void ObjectBlockingStairs_Action3(ObjectBlockingStairsEntity*);
+void sub_080932A8(ObjectBlockingStairsEntity*);
+void sub_08093248(ObjectBlockingStairsEntity*);
+void sub_08093280(ObjectBlockingStairsEntity*);
+void sub_08093334(ObjectBlockingStairsEntity*);
+void sub_08093364(ObjectBlockingStairsEntity*);
+void ObjectBlockingStairs_Action4(ObjectBlockingStairsEntity*);
+u32 sub_080932D8(u32);
+void sub_080931A4(ObjectBlockingStairsEntity*, u32);
+
+void ObjectBlockingStairs(Entity* this) {
+ static void (*const actionFuncs[])(ObjectBlockingStairsEntity*) = {
+ ObjectBlockingStairs_Init, ObjectBlockingStairs_Action1, ObjectBlockingStairs_Action2,
+ ObjectBlockingStairs_Action3, ObjectBlockingStairs_Action4,
+ };
+
+ actionFuncs[this->action]((ObjectBlockingStairsEntity*)this);
+}
+
+void ObjectBlockingStairs_Init(ObjectBlockingStairsEntity* this) {
+ int iVar1;
+ u32 uVar2;
+
+ switch (sub_080932D8(super->type)) {
+ case 1:
+ super->action = 4;
+ super->x.HALF.HI -= 0x20;
+ uVar2 = 2;
+ break;
+ case 2:
+ super->action = 4;
+ super->x.HALF.HI += 0x20;
+ uVar2 = 3;
+ break;
+ default:
+ super->action = 1;
+ super->speed = 0x80;
+ super->field_0x16 = 1;
+ super->actionDelay = 0;
+ super->field_0xf = 0;
+ this->unk7a = 0x20;
+ this->unk7b = 0x80;
+ if (super->type == 0) {
+ super->hitbox = (Hitbox*)&gUnk_080FD288;
+ }
+ uVar2 = 0;
+ if ((this->objFlags) && !CheckFlags(this->objFlags)) {
+ uVar2 = 1;
+ }
+ break;
+ }
+
+ sub_080931A4(this, uVar2);
+}
+
+void ObjectBlockingStairs_Action1(ObjectBlockingStairsEntity* this) {
+ u32 tileType;
+ int xDist;
+ Entity* ent;
+
+ xDist = (int)gPlayerEntity.x.HALF.HI - super->x.HALF.HI;
+
+ if (this->objFlags) {
+ if (!CheckFlags(this->objFlags)) {
+ return;
+ }
+ if (this->unk7a != 0) {
+ sub_080932A8(this);
+ return;
+ }
+ }
+
+ if ((this->unk7b & 0x3f) == 0) {
+ this->unk7b |= 0xf;
+ sub_080931A4(this, 0);
+ if (xDist < 0) {
+ this->unk7b |= 0x40;
+ }
+ }
+
+ if (this->unk7b & 0x40) {
+ tileType = (u32)GetTileType(this->tilePos - 1, super->collisionLayer);
+ } else {
+ tileType = (u32)GetTileType(this->tilePos + 1, super->collisionLayer);
+ }
+
+ switch (tileType) {
+ case 0x4030:
+ case 0x4031:
+ super->action = 3;
+ super->direction = Direction8FromAnimationState(gPlayerEntity.animationState);
+ super->speed = 0x80;
+ super->actionDelay = 0x40;
+ RequestPriorityDuration(super, 0x50);
+ EnqueueSFX(SFX_10F);
+ sub_08093248(this);
+ return;
+ }
+
+ if ((gPlayerEntity.animationState & 2) == 0) {
+ return;
+ }
+ RegisterCarryEntity(super);
+
+ if (this->unk7b & 0x80) {
+ this->unk7b &= ~0x80;
+ if ((this->unk7b & 0x40) != 0) {
+ SetTile(0x402c, this->tilePos - 1, super->collisionLayer);
+ SetTile(0x403d, this->tilePos + 1, super->collisionLayer);
+ } else {
+ SetTile(0x403d, this->tilePos - 1, super->collisionLayer);
+ SetTile(0x402d, this->tilePos + 1, super->collisionLayer);
+ }
+ } else if (this->unk7b & 0x40) {
+ if (xDist >= 5) {
+ this->unk7b &= ~(0x40 | 0x80);
+ SetTile(0x403d, this->tilePos - 1, super->collisionLayer);
+ SetTile(0x402d, this->tilePos + 1, super->collisionLayer);
+ }
+ } else {
+ if (-xDist > 4) {
+ this->unk7b |= 0x40;
+ SetTile(0x402c, this->tilePos - 1, super->collisionLayer);
+ SetTile(0x403d, this->tilePos + 1, super->collisionLayer);
+ }
+ }
+}
+
+void ObjectBlockingStairs_Action2(ObjectBlockingStairsEntity* this) {
+ if (super->actionDelay) {
+ sub_08093280(this);
+ } else {
+ if (gPlayerState.heldObject == 0x12) {
+ if ((gPlayerEntity.frame & 2) != 0 && ++super->field_0xf > 8) {
+ gPlayerState.queued_action = 16;
+ gPlayerState.field_0x38 = 0x40;
+ gPlayerState.flags |= PL_BUSY;
+ gPlayerEntity.x.HALF.LO = 0;
+ gPlayerEntity.y.HALF.LO = 0;
+ super->direction = (gPlayerEntity.animationState ^ 4) << 2;
+ super->actionDelay = 0x40;
+ EnqueueSFX(SFX_10F);
+ sub_08093248(this);
+ }
+ } else if (super->subAction == 6) {
+ super->action = 1;
+ super->field_0xf = 0;
+ }
+ }
+}
+
+void ObjectBlockingStairs_Action3(ObjectBlockingStairsEntity* this) {
+ sub_0800445C(super);
+ LinearMoveUpdate(super);
+ if (--super->actionDelay == 0) {
+ sub_08093334(this);
+ }
+ sub_08093364(this);
+}
+
+void ObjectBlockingStairs_Action4(ObjectBlockingStairsEntity* this) {
+}
+
+void sub_080931A4(ObjectBlockingStairsEntity* this, u32 param_2) {
+ static const u16 gUnk_08122850[] = { 0x4027, 0x4023, 0x4028, 0x402c, 0x402b, 0x402d, 0x4029, 0x4026, 0x402a };
+ static const u16 gUnk_08122862[] = { 0x4027, 0x4023, 0x4028, 0x4024, 0x4022, 0x4025, 0x4029, 0x4026, 0x402a };
+ static const u16 gUnk_08122874[] = { 0x4027, 0x4023, 0x4023, 0x4024, 0x4022, 0x4022, 0x4029, 0x4026, 0x4026 };
+ static const u16 gUnk_08122886[] = { 0x4023, 0x4023, 0x4028, 0x4022, 0x4022, 0x4025, 0x4026, 0x4026, 0x402a };
+
+ u32 collisionLayer;
+ const u16* pTileTypes;
+ u32 index;
+ u32 tilePos;
+ int iVar5;
+
+ this->tilePos = COORD_TO_TILE(super);
+ tilePos = this->tilePos - 0x40;
+ collisionLayer = super->collisionLayer;
+
+ switch (param_2) {
+ case 1:
+ pTileTypes = gUnk_08122862;
+ break;
+ case 2:
+ pTileTypes = gUnk_08122874;
+ break;
+ case 3:
+ pTileTypes = gUnk_08122886;
+ break;
+ default:
+ case 0:
+ pTileTypes = gUnk_08122850;
+ break;
+ }
+
+ for (index = 0, iVar5 = 0; index < 9; index++) {
+ u32 pos = tilePos + iVar5 + index - 1;
+ SetTile(pTileTypes[index], pos, collisionLayer);
+ switch (index) {
+ case 2:
+ iVar5 = 0x3d;
+ break;
+ case 5:
+ iVar5 = 0x7a;
+ break;
+ }
+ }
+}
+
+void sub_08093248(ObjectBlockingStairsEntity* this) {
+ u32 collisionLayer;
+ u32 tilePos;
+ u32 index;
+ int iVar4;
+
+ tilePos = this->tilePos - 0x40;
+ collisionLayer = super->collisionLayer;
+ for (index = 0, iVar4 = 0; index < 9; index++) {
+ sub_0807BA8C(tilePos + iVar4 + index - 1, collisionLayer);
+ switch (index) {
+ case 2:
+ iVar4 = 0x3d;
+ break;
+ case 5:
+ iVar4 = 0x7a;
+ break;
+ }
+ }
+}
+
+void sub_08093280(ObjectBlockingStairsEntity* this) {
+ sub_0800445C(super);
+ LinearMoveUpdate(super);
+ if (--super->actionDelay == 0) {
+ sub_08093334(this);
+ }
+ sub_08093364(this);
+}
+
+void sub_080932A8(ObjectBlockingStairsEntity* this) {
+ this->unk7a--;
+ switch (this->unk7a & 3) {
+ case 1:
+ super->spriteOffsetX = 1;
+ break;
+ case 3:
+ super->spriteOffsetX = -1;
+ break;
+ default:
+ super->spriteOffsetX = 0;
+ break;
+ }
+}
+
+typedef struct {
+ u32 flagBank;
+ u16 unk4;
+ u16 unk6;
+} struct_gUnk_08122898;
+
+const struct_gUnk_08122898 gUnk_08122898[] = {
+ { 0x200, 0xa1, 0xa2 },
+ { 0x8c0, 0x6f, 0x70 },
+};
+
+u32 sub_080932D8(u32 param_1) {
+ const struct_gUnk_08122898* ptr = gUnk_08122898 + param_1;
+
+ if (CheckLocalFlagByBank(ptr->flagBank, ptr->unk4)) {
+ return 1;
+ } else {
+ if (CheckLocalFlagByBank(ptr->flagBank, ptr->unk6)) {
+ return 2;
+ } else {
+ return 0;
+ }
+ }
+}
+
+void sub_08093308(u32 param_1, u32 param_2) {
+ const struct_gUnk_08122898* ptr = gUnk_08122898 + param_1;
+ if (param_2 == 1) {
+ SetLocalFlagByBank(ptr->flagBank, ptr->unk4);
+ } else if (param_2 == 2) {
+ SetLocalFlagByBank(ptr->flagBank, ptr->unk6);
+ }
+}
+
+void sub_08093334(ObjectBlockingStairsEntity* this) {
+ u32 uVar1;
+
+ super->action = 4;
+ if (super->direction & 0x10) {
+ uVar1 = 1;
+ } else {
+ uVar1 = 2;
+ }
+ sub_080931A4(this, uVar1 + 1);
+ sub_08093308(super->type, uVar1);
+ EnqueueSFX(SFX_SECRET);
+}
+
+void sub_08093364(ObjectBlockingStairsEntity* this) {
+ s32 sVar1;
+ Entity* dashEffectEnt;
+
+ if ((super->actionDelay & 3) == 0) {
+ dashEffectEnt = CreateObject(SPECIAL_FX, FX_DASH, 0);
+ if (dashEffectEnt != NULL) {
+ dashEffectEnt->parent = super;
+ CopyPosition(super, dashEffectEnt);
+ if (super->direction & 0x10) {
+ dashEffectEnt->x.HALF.HI += 0x12;
+ } else {
+ dashEffectEnt->x.HALF.HI -= 0x12;
+ }
+
+ sVar1 = dashEffectEnt->y.HALF.HI;
+ if (super->actionDelay & 8) {
+ dashEffectEnt->y.HALF.HI = sVar1 + 8;
+ } else {
+ dashEffectEnt->y.HALF.HI = sVar1 - 8;
+ }
+ }
+ }
+}
diff --git a/src/object/picoBloom.c b/src/object/picoBloom.c
new file mode 100644
index 00000000..de912b8a
--- /dev/null
+++ b/src/object/picoBloom.c
@@ -0,0 +1,47 @@
+#define NENT_DEPRECATED
+#include "entity.h"
+#include "asm.h"
+#include "sound.h"
+
+void PicoBloom_Init(Entity*);
+void PicoBloom_Action1(Entity*);
+void PicoBloom_Action2(Entity*);
+
+void PicoBloom(Entity* this) {
+ static void (*const actionFuncs[])(Entity*) = {
+ PicoBloom_Init,
+ PicoBloom_Action1,
+ PicoBloom_Action2,
+ };
+
+ actionFuncs[this->action](this);
+}
+
+void PicoBloom_Init(Entity* this) {
+ static const u8 typeAnimationStates[] = { 3, 0, 3, 3, 3, 3 };
+ u32 nextAction;
+
+ nextAction = this->type2;
+ if (nextAction != 1) {
+ nextAction = 2;
+ }
+ this->action = nextAction;
+ this->actionDelay = (Random() & 0x7f) + 0x7f;
+ this->collisionLayer = 1;
+ UpdateSpriteForCollisionLayer(this);
+ InitializeAnimation(this, typeAnimationStates[this->type] + this->type2);
+}
+
+void PicoBloom_Action1(Entity* this) {
+ if (--this->actionDelay == 0) {
+ this->action++;
+ }
+}
+
+void PicoBloom_Action2(Entity* this) {
+ GetNextFrame(this);
+ if (this->frame & 1) {
+ this->frame &= ~1;
+ EnqueueSFX(SFX_21B);
+ }
+}
diff --git a/src/object/playerClone.c b/src/object/playerClone.c
index 4de97df9..3e7eadab 100644
--- a/src/object/playerClone.c
+++ b/src/object/playerClone.c
@@ -1,5 +1,6 @@
#define NENT_DEPRECATED
#include "entity.h"
+#include "collision.h"
#include "room.h"
#include "asm.h"
#include "sound.h"
@@ -49,7 +50,12 @@ void PlayerClone_Init(PlayerCloneEntity* this) {
SoundReq(SFX_112);
}
-const u16 PlayerCloneCollisions[] = { 0x2206, 0x6044, 0x4460, 0x622 };
+const u16 PlayerCloneCollisions[] = {
+ COL_NORTH_FULL | COL_WEST_SOUTH | COL_EAST_SOUTH,
+ COL_NORTH_EAST | COL_SOUTH_EAST | COL_EAST_FULL,
+ COL_SOUTH_FULL | COL_WEST_NORTH | COL_EAST_NORTH,
+ COL_NORTH_WEST | COL_SOUTH_WEST | COL_WEST_FULL,
+};
void PlayerClone_Action1(PlayerCloneEntity* this) {
static const Hitbox PlayerCloneHitbox = { 0, -3, { 5, 3, 3, 5 }, 6, 6 };
@@ -104,7 +110,8 @@ void PlayerClone_Action2(PlayerCloneEntity* this) {
super->y.HALF.HI = gPlayerEntity.y.HALF.HI + this->unk7a;
sub_08084CAC(this);
sub_080085B0(super);
- if ((super->collisions & 0x6666) != 0x6666) {
+ if ((super->collisions & (COL_NORTH_FULL | COL_SOUTH_FULL | COL_EAST_FULL | COL_WEST_FULL)) !=
+ (COL_NORTH_FULL | COL_SOUTH_FULL | COL_EAST_FULL | COL_WEST_FULL)) {
for (index = 0; index <= 3; index++) {
if (PlayerCloneCollisions[index] == (PlayerCloneCollisions[index] & super->collisions)) {
break;
diff --git a/src/object/pot.c b/src/object/pot.c
index 22ee8ce0..a11c6d4d 100644
--- a/src/object/pot.c
+++ b/src/object/pot.c
@@ -283,7 +283,7 @@ u32 sub_0808288C(Entity* this, u32 form, u32 arg2, u32 arg3) {
break;
default:
entity = CreateObjectWithParent(this, GROUND_ITEM, form, arg2);
- if (entity) {
+ if (entity != NULL) {
if (arg3 == 2) {
entity->actionDelay = 5;
entity->field_0x86.HWORD = this->field_0x86.HWORD;
diff --git a/src/object/smallIceBlock.c b/src/object/smallIceBlock.c
index 1b821625..e9689baf 100644
--- a/src/object/smallIceBlock.c
+++ b/src/object/smallIceBlock.c
@@ -7,6 +7,7 @@
#define NENT_DEPRECATED
#include "global.h"
+#include "collision.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
@@ -204,7 +205,7 @@ bool32 sub_0809953C(SmallIceBlockEntity* this) {
uVar3 = sub_0800442E(super);
if (uVar3 != 0) {
- return 0;
+ return FALSE;
}
ProcessMovement2(super);
sub_0800445C(super);
@@ -216,17 +217,17 @@ bool32 sub_0809953C(SmallIceBlockEntity* this) {
}
switch (super->direction >> 3) {
case 0:
- if ((super->collisions & 0xe) == 0) {
- return 0;
+ if ((super->collisions & COL_NORTH_ANY) == COL_NONE) {
+ return FALSE;
}
if ((u32)(super->y.HALF.HI & 0xf) - 7 < 3) {
super->y.HALF.HI = (super->y.HALF.HI & 0xfff0) + 8;
- return 1;
+ return TRUE;
}
sub_0809969C(this);
break;
case 1:
- if ((super->collisions & 0xe000) == 0) {
+ if ((super->collisions & COL_EAST_ANY) == COL_NONE) {
return FALSE;
}
if ((u32)(super->x.HALF.HI & 0xf) - 7 < 3) {
@@ -236,7 +237,7 @@ bool32 sub_0809953C(SmallIceBlockEntity* this) {
sub_0809969C(this);
break;
case 2:
- if ((super->collisions & 0xe0) == 0) {
+ if ((super->collisions & COL_SOUTH_ANY) == COL_NONE) {
return FALSE;
}
if ((u32)(super->y.HALF.HI & 0xf) - 7 < 3) {
@@ -246,7 +247,7 @@ bool32 sub_0809953C(SmallIceBlockEntity* this) {
sub_0809969C(this);
break;
default:
- if ((super->collisions & 0xe00) != 0) {
+ if ((super->collisions & COL_WEST_ANY) != COL_NONE) {
if ((u32)(super->x.HALF.HI & 0xf) - 7 < 3) {
super->x.HALF.HI = (super->x.HALF.HI & 0xfff0) + 8;
return TRUE;
diff --git a/src/object/specialFx.c b/src/object/specialFx.c
index c5262d9c..dc51b4c4 100644
--- a/src/object/specialFx.c
+++ b/src/object/specialFx.c
@@ -144,6 +144,7 @@ void sub_080844E0(SpecialFxObject* this) {
static const u8 gUnk_0811FAC8[] = { 0x03, 0x37, 0x38, 0x39 };
static const u8 gUnk_0811FACC[] = { 0x17, 0x3e, 0x3f, 0x40 };
const struct_0811F960* ptr;
+
super->action = 1;
super->flags &= ~0x80;
super->spriteSettings.draw = 1;
@@ -219,7 +220,7 @@ void sub_08084680(SpecialFxObject* this) {
}
void sub_08084694(SpecialFxObject* this) {
- if (!super->parent || !super->parent->next) {
+ if ((super->parent == NULL) || (super->parent->next == NULL)) {
DeleteThisEntity();
}
GetNextFrame(super);
@@ -253,12 +254,15 @@ void sub_080846B0(SpecialFxObject* this) {
void sub_0808471C(SpecialFxObject* this) {
static const s8 gUnk_0811FB08[] = { -8, -8, 8, -8, -8, 8, 8, 8 };
+
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
u32 i;
+
for (i = 0; i < 4; i++) {
Entity* fx = CreateFx(super, 0x24, 0);
- if (fx) {
+
+ if (fx != NULL) {
const s8* ptr = &gUnk_0811FB08[2 * i];
fx->x.HALF.HI += ptr[0];
fx->y.HALF.HI += ptr[1];
@@ -280,7 +284,7 @@ void sub_08084784(SpecialFxObject* this) {
void sub_08084798(SpecialFxObject* this) {
GetNextFrame(super);
- if ((super->frame & ANIM_DONE) || !super->child->next) {
+ if ((super->frame & ANIM_DONE) || (super->child->next == NULL)) {
DeleteThisEntity();
}
}