diff options
| author | notyourav <65437533+notyourav@users.noreply.github.com> | 2022-03-15 14:47:12 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-15 14:47:12 -0700 |
| commit | 784dd6714f1a5799de8b920a3fd74722b9cc2009 (patch) | |
| tree | 7a4f0b16e437828e89db2ea5017ae9b072027b85 /src | |
| parent | 40a8f686fd3d39880f88df95da9944c7171231bb (diff) | |
| parent | 9f33b784227458d36fadf8184a0eb9ad738017bb (diff) | |
Merge pull request #444 from hatal175/objects2
Decompile various objects
Diffstat (limited to 'src')
| -rw-r--r-- | src/object.c | 2 | ||||
| -rw-r--r-- | src/object/bigIceBlock.c | 3 | ||||
| -rw-r--r-- | src/object/object15.c | 48 | ||||
| -rw-r--r-- | src/object/object17.c | 45 | ||||
| -rw-r--r-- | src/object/object1F.c | 102 | ||||
| -rw-r--r-- | src/object/object28.c | 62 | ||||
| -rw-r--r-- | src/object/object37.c | 51 | ||||
| -rw-r--r-- | src/object/object44.c | 70 | ||||
| -rw-r--r-- | src/object/object45.c | 44 | ||||
| -rw-r--r-- | src/object/object52.c | 22 | ||||
| -rw-r--r-- | src/object/object53.c | 64 | ||||
| -rw-r--r-- | src/object/object63.c | 65 | ||||
| -rw-r--r-- | src/object/object66.c | 34 | ||||
| -rw-r--r-- | src/object/object67.c | 338 | ||||
| -rw-r--r-- | src/object/object68.c | 3 | ||||
| -rw-r--r-- | src/object/object75.c | 14 | ||||
| -rw-r--r-- | src/object/object76.c | 14 | ||||
| -rw-r--r-- | src/object/object79.c | 113 | ||||
| -rw-r--r-- | src/object/object81.c | 39 | ||||
| -rw-r--r-- | src/object/object9.c | 156 | ||||
| -rw-r--r-- | src/object/object9B.c | 42 | ||||
| -rw-r--r-- | src/object/objectA7.c | 11 | ||||
| -rw-r--r-- | src/object/objectB6.c | 16 | ||||
| -rw-r--r-- | src/object/playerClone.c | 187 | ||||
| -rw-r--r-- | src/object/smallIceBlock.c | 5 | ||||
| -rw-r--r-- | src/object/treeHidingPortal.c | 35 | ||||
| -rw-r--r-- | src/player.c | 2 |
27 files changed, 1577 insertions, 10 deletions
diff --git a/src/object.c b/src/object.c index caddaddc..da1eb312 100644 --- a/src/object.c +++ b/src/object.c @@ -18,7 +18,7 @@ void (*const gObjectFunctions[])(Entity*) = { [OBJECT_D] = ObjectD, [OBJECT_E] = ObjectE, [SPECIAL_FX] = SpecialFx, - [OBJECT_10] = Object10, + [PLAYER_CLONE] = PlayerClone, [OBJECT_11] = Object11, [OBJECT_12] = Object12, [RAILTRACK] = Railtrack, diff --git a/src/object/bigIceBlock.c b/src/object/bigIceBlock.c index c7d7a2bd..09407bc4 100644 --- a/src/object/bigIceBlock.c +++ b/src/object/bigIceBlock.c @@ -10,6 +10,7 @@ #include "object.h" #include "functions.h" #include "hitbox.h" +#include "item.h" typedef struct { /*0x00*/ Entity base; @@ -91,7 +92,7 @@ void BigIceBlock_Action2(BigIceBlockEntity* this) { if (super->type != 2) { SetFlag(this->unk_86); } else { - CreateGroundItemWithFlags(super, 0x53, 0, this->unk_86); + CreateGroundItemWithFlags(super, ITEM_SMALL_KEY, 0, this->unk_86); } } super->action = 3; diff --git a/src/object/object15.c b/src/object/object15.c new file mode 100644 index 00000000..25bfe1f5 --- /dev/null +++ b/src/object/object15.c @@ -0,0 +1,48 @@ +#define NENT_DEPRECATED +#include "entity.h" + +void Object15_Init(Entity*); +void Object15_Action1(Entity*); + +void Object15(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + Object15_Init, + Object15_Action1, + }; + + actionFuncs[this->action](this); +} + +void Object15_Init(Entity* this) { + this->action = 1; + this->spriteSettings.draw = 1; + InitializeAnimation(this, this->animIndex); +} + +void Object15_Action1(Entity* this) { + if (this->type == 0) { + GetNextFrame(this); + } + + if (this->type2 != 0) { + this->spriteSettings.draw ^= 1; + } + + if ((int)(this->actionDelay * 0x1000000) >= 0) { + if (this->actionDelay) { + if (--this->actionDelay == 0) { + DeleteThisEntity(); + } + } else { + if ((this->frame & 0x80) != 0) { + DeleteThisEntity(); + } + } + } + + if (this->child != NULL) { + this->x = this->child->x; + this->y = this->child->y; + this->z = this->child->z; + } +} diff --git a/src/object/object17.c b/src/object/object17.c new file mode 100644 index 00000000..419b3173 --- /dev/null +++ b/src/object/object17.c @@ -0,0 +1,45 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "player.h" +#include "asm.h" +#include "room.h" +#include "coord.h" + +void Object17_Init(Entity*); +void Object17_Action1(Entity*); + +void Object17(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + Object17_Init, + Object17_Action1, + }; + + actionFuncs[this->action](this); +} + +void Object17_Init(Entity* this) { + this->action = 1; + this->speed = 0x80; + this->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; + this->spritePriority.b0 = gPlayerEntity.spritePriority.b0; + this->collisionLayer = gPlayerEntity.collisionLayer; + this->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; + this->type = Random() & 1; + InitializeAnimation(this, 0x11); +} + +void Object17_Action1(Entity* this) { + if (this->type != 0) { + if ((gRoomTransition.frameCount & 1) == 0) { + GetNextFrame(this); + } + } else { + GetNextFrame(this); + } + + if (sub_0806F3E4(this)) { + DeleteThisEntity(); + } else if ((gPlayerState.field_0x1c & 0xf) != 1) { + DeleteThisEntity(); + } +} diff --git a/src/object/object1F.c b/src/object/object1F.c new file mode 100644 index 00000000..2c548d67 --- /dev/null +++ b/src/object/object1F.c @@ -0,0 +1,102 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "player.h" +#include "functions.h" +#include "asm.h" +#include "effects.h" + +typedef struct { + Entity base; + u8 filler[0x4]; + u32 unk6c; +} Object1FEntity; + +void Object1F_Init(Object1FEntity*); +void Object1F_Action1(Object1FEntity*); +void Object1F_Action2(Object1FEntity*); + +void Object1F(Entity* this) { + static void (*const actionFuncs[])(Object1FEntity*) = { + Object1F_Init, + Object1F_Action1, + Object1F_Action2, + }; + + actionFuncs[this->action]((Object1FEntity*)this); +} + +typedef struct { + u8 animationState; + u8 unk1; + u8 unk2; + u8 spriteVramOffset; +} gUnk_08120A18_struct; + +void Object1F_Init(Object1FEntity* this) { + static const gUnk_08120A18_struct gUnk_08120A18[] = { + { 0x0, 0x2, 0xA, 0xE8 }, + { 0x0, 0x5, 0x20, 0xE0 }, + }; + static const s8 gUnk_08120A20[] = { 0, -18, 16, 0, 0, 12, -16, 0 }; + + u32 temp; + super->action = 1; + super->zVelocity = 0x2c000; + super->direction = super->animationState << 2 ^ 0x10; + if (super->animationState == 0) { + super->spritePriority.b0--; + } + super->x.HALF.HI = gUnk_08120A20[super->animationState] + super->x.HALF.HI; + super->y.HALF.HI = gUnk_08120A20[super->animationState + 1] + super->y.HALF.HI; + + super->spriteVramOffset = gUnk_08120A18[super->field_0xf].spriteVramOffset; + temp = gUnk_08120A18[super->field_0xf].unk1; + super->palette.b.b0 = temp; + this->unk6c = gUnk_08120A18[super->field_0xf].unk2; + super->collisionLayer = gPlayerEntity.collisionLayer; + super->speed = 0x100; + InitializeAnimation(super, gUnk_08120A18[super->field_0xf].animationState); +} + +void Object1F_Action1(Object1FEntity* this) { + u32 uVar1; + + if (this->unk6c) { + this->unk6c--; + uVar1 = gPlayerState.field_0x3c[1]; + } else { + ProcessMovement2(super); + uVar1 = GravityUpdate(super, 0x2800); + } + + if (uVar1 == 0) { + super->action = 2; + } +} + +void Object1F_Action2(Object1FEntity* this) { + u8 bVar1; + + bVar1 = sub_080B1B0C(super); + switch (bVar1) { + case 0x21: + CreateFx(super, FX_FALL_DOWN, 0); + break; + case 0x25: + CreateFx(super, FX_LAVA_SPLASH, 0); + break; + case 0x24: + case 0x30: + CreateFx(super, FX_WATER_SPLASH, 0); + break; + default: + if (super->type2 != 0) { + if (super->type2 == 15) { + CreateFx(super, super->actionDelay, 0x80); + } else { + CreateObjectWithParent(super, super->type2, super->actionDelay, 0); + } + } + } + DeleteThisEntity(); +} diff --git a/src/object/object28.c b/src/object/object28.c new file mode 100644 index 00000000..90c2be50 --- /dev/null +++ b/src/object/object28.c @@ -0,0 +1,62 @@ +#include "entity.h" +#include "room.h" + +void Object28(Entity* this) { + int iVar1; + int diffY; + int diffX; + int iVar4; + int temp; + + if (this->action == 0) { + this->action = 1; + this->spriteSettings.draw = 3; + this->frameIndex = this->type2; + this->spriteOrientation.flipY = 3; + this->spriteRendering.b3 = 3; + if (this->type == 3) { + this->spritePriority.b0 = 6; + } else { + this->spritePriority.b0 = 7; + } + this->field_0x68.HWORD = this->x.HALF.HI; + this->field_0x6a.HWORD = this->y.HALF.HI; + SetDefaultPriority(this, 6); + } + if ((this->flags & 0x10) == 0) { + iVar4 = (int)this->x.HALF.HI - (int)gRoomControls.scroll_x; + diffX = iVar4 - 0x78; + iVar1 = (int)this->y.HALF.HI - (int)gRoomControls.scroll_y; + diffY = iVar1 - 0x50; + if (diffX < 0) { + temp = (iVar4 - 0x75); + } else { + temp = diffX; + } + diffX = temp >> 2; + + if (diffY < 0) { + temp = iVar1 - 0x4d; + } else { + temp = diffY; + } + diffY = temp >> 2; + + if (diffX < -0x10) { + diffX = -0x10; + } + if (0x10 < diffX) { + diffX = 0x10; + } + + if (diffY < -0x10) { + diffY = -0x10; + } + if (0x10 < diffY) { + diffY = 0x10; + } + + this->x.HALF.HI = this->field_0x68.HWORD + diffX; + this->y.HALF.HI = this->field_0x6a.HWORD + diffY; + } +} diff --git a/src/object/object37.c b/src/object/object37.c new file mode 100644 index 00000000..99eca229 --- /dev/null +++ b/src/object/object37.c @@ -0,0 +1,51 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "functions.h" +#include "save.h" +#include "item.h" + +typedef struct { + Entity base; + u8 filler[0x8]; + u16 unk70; + u8 filler2[0x6]; + u16* unk78; +} Object37Entity; + +extern u32 sub_0806F798(Entity*); + +void Object37_Init(Object37Entity*); +void Object37_Action1(Object37Entity*); + +void Object37(Entity* this) { + static void (*const actionFuncs[])(Object37Entity*) = { + Object37_Init, + Object37_Action1, + }; + + actionFuncs[this->action]((Object37Entity*)this); +} + +void Object37_Init(Object37Entity* this) { + u16* puVar1; + + puVar1 = GetLayerByIndex(super->collisionLayer)->mapData + sub_0806F798(super); + this->unk78 = puVar1; + this->unk70 = *puVar1; + super->action = 1; +} + +void Object37_Action1(Object37Entity* this) { + Entity* item; + + if ((gSave.unk24E[0] != 0) && (this->unk70 != *this->unk78)) { + item = CreateGroundItem(super, ITEM_RUPEE100, 0); + if (item != 0) { + item->direction = gPlayerEntity.animationState << 2; + item->speed = 0x80; + item->zVelocity = 0x20000; + } + gSave.unk24E[0] = 1; + DeleteThisEntity(); + } +} diff --git a/src/object/object44.c b/src/object/object44.c new file mode 100644 index 00000000..0753c7f4 --- /dev/null +++ b/src/object/object44.c @@ -0,0 +1,70 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "asm.h" +#include "sound.h" +#include "room.h" +#include "functions.h" + +void sub_0808E298(Entity*); +void sub_0808E318(Entity*); +void sub_0808E354(Entity*, u32); + +void Object44(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + sub_0808E298, + sub_0808E318, + }; + + actionFuncs[this->action]((Entity*)this); +} + +void sub_0808E298(Entity* this) { + int x; + int y; + + this->collisionLayer = 2; + this->action = 1; + x = 0; + y = 0; + switch (GetTileTypeByEntity(this)) { + case 0x343: + x = 0x10; + case 0x344: + y = 0x10; + break; + case 0x345: + x = 0x10; + break; + case 0x346: + break; + default: + DeleteThisEntity(); + break; + } + + this->x.HALF.HI = (this->x.HALF.HI + x) & 0xfff0; + this->y.HALF.HI = (this->y.HALF.HI + y) & 0xfff0; + InitializeAnimation(this, 0); + sub_0808E354(this, 0x347); + sub_0808E318(this); +} + +void sub_0808E318(Entity* this) { + GetNextFrame(this); + if (this->frame & 0x80) { + sub_0808E354(this, 0x343); + DeleteThisEntity(); + } else { + if (this->frame & 1) { + EnqueueSFX(SFX_18B); + } + } +} + +void sub_0808E354(Entity* this, u32 param_2) { + u16 uVar1 = param_2; + sub_0807B7D8(uVar1, COORD_TO_TILE_OFFSET(this, 0x10, 0x10), 2); + sub_0807B7D8(uVar1 + 1, COORD_TO_TILE_OFFSET(this, 0, 0x10), 2); + sub_0807B7D8(uVar1 + 2, COORD_TO_TILE_OFFSET(this, 0x10, 0), 2); + sub_0807B7D8(uVar1 + 3, COORD_TO_TILE_OFFSET(this, 0, 0), 2); +} diff --git a/src/object/object45.c b/src/object/object45.c new file mode 100644 index 00000000..1de0e0f1 --- /dev/null +++ b/src/object/object45.c @@ -0,0 +1,44 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "player.h" +#include "item.h" + +void sub_0808E42C(Entity*); +void sub_0808E448(Entity*); + +void Object45(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + sub_0808E42C, + sub_0808E448, + }; + + actionFuncs[this->action]((Entity*)this); +} + +void sub_0808E42C(Entity* this) { + this->action = 1; + this->updatePriority = 6; + InitializeAnimation(this, this->type); +} + +void sub_0808E448(Entity* this) { + if (1 < IsItemEquipped(ITEM_LANTERN_ON)) { + DeleteThisEntity(); + } + GetNextFrame(this); + + switch (this->frame) { + case 0x80: + DeleteThisEntity(); + case 1: + this->spriteSettings.draw ^= 1; + break; + default: + this->spriteSettings.draw = 1; + break; + } + + if (this->type == 0) { + this->z.WORD -= 0x8000; + } +} diff --git a/src/object/object52.c b/src/object/object52.c new file mode 100644 index 00000000..d5905484 --- /dev/null +++ b/src/object/object52.c @@ -0,0 +1,22 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "flags.h" +#include "room.h" + +extern void sub_08078828(Entity*); +extern void sub_080A7C8C(u32 pos, u32 layer); + +void Object52(Entity* this) { + if (this->action == 0) { + if (CheckLocalFlag(this->type)) { + DeleteThisEntity(); + } + this->action = 1; + this->collisionLayer = 1; + sub_08078828(this); + } + if (this->interactType != 0) { + sub_080A7C8C(COORD_TO_TILE(this), 2); + DeleteThisEntity(); + } +} diff --git a/src/object/object53.c b/src/object/object53.c new file mode 100644 index 00000000..0e10371e --- /dev/null +++ b/src/object/object53.c @@ -0,0 +1,64 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "functions.h" +#include "asm.h" + +void sub_08091120(Entity*); +void sub_08091198(Entity*); + +void Object53(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + sub_08091120, + sub_08091198, + }; + + actionFuncs[this->action]((Entity*)this); +} + +typedef struct { + u8 animationState; + u8 palette; + u8 spriteVramOffset; + u8 spriteIndex; +} gUnk_08122288_struct; + +void sub_08091120(Entity* this) { + static const gUnk_08122288_struct gUnk_08122288[] = { { 0x0, 0x2, 0xe8, 0xa7 }, + { 0x0, 0x5, 0xe0, 0xa7 }, + { 0x0, 0x5, 0xf2, 0xa7 } }; + u32 temp; + this->action++; + this->spriteVramOffset = gUnk_08122288[this->type].spriteVramOffset; + temp = gUnk_08122288[this->type].palette; + this->palette.b.b0 = temp; + this->spriteIndex = gUnk_08122288[this->type].spriteIndex; + this->spriteSettings.draw = 1; + this->spriteRendering.b3 = 2; + this->zVelocity = 0x2a000; + InitializeAnimation(this, gUnk_08122288[this->type].animationState); + sub_08004168(this); +} + +void sub_08091198(Entity* this) { + if (this->zVelocity < 0) { + this->spriteSettings.flipY = 1; + } + + if (GravityUpdate(this, 0x2000)) { + return; + } + + switch ((u8)this->type2) { + case 0: + case 0xff: + break; + case 0xf: + CreateFx(this, this->actionDelay, 0x80); + break; + default: + CreateObjectWithParent(this, this->type2, this->actionDelay, 0); + break; + } + + DeleteThisEntity(); +} diff --git a/src/object/object63.c b/src/object/object63.c new file mode 100644 index 00000000..5cdd827e --- /dev/null +++ b/src/object/object63.c @@ -0,0 +1,65 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "functions.h" +#include "asm.h" +#include "object.h" + +void sub_08093D88(Entity*); +void sub_08093DE0(Entity*); +void Object63_Delete(Entity*); +void sub_08093E10(Entity*, Entity*); + +void Object63(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + sub_08093D88, + sub_08093DE0, + Object63_Delete, + }; + + actionFuncs[this->action]((Entity*)this); +} + +void sub_08093D88(Entity* this) { + Entity* objEnt; + + this->action = 1; + this->z.HALF.HI -= 8; + this->zVelocity = 0x2a000; + this->actionDelay = 32; + switch (this->type) { + case 0: + if (CreateRandomItemDrop(this, 4) == 0) { + this->action = 2; + } + this->child->zVelocity = this->zVelocity; + break; + case 1: + objEnt = CreateObject(0, OBJECT_BLOCKING_STAIRS, 0); + if (objEnt != NULL) { + objEnt->actionDelay = 5; + sub_08093E10(this, objEnt); + } + break; + } +} + +void sub_08093DE0(Entity* this) { + if (--this->actionDelay == 0) { + this->action = 2; + } + + if ((this->actionDelay & 1) != 0) { + this->child->y.HALF.HI++; + } +} + +void Object63_Delete(Entity* this) { + DeleteEntity(this); +} + +void sub_08093E10(Entity* this, Entity* ent) { + CopyPosition(this, ent); + ent->parent = this; + this->child = ent; + ent->zVelocity = this->zVelocity; +} diff --git a/src/object/object66.c b/src/object/object66.c new file mode 100644 index 00000000..02f31e6c --- /dev/null +++ b/src/object/object66.c @@ -0,0 +1,34 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "functions.h" + +void Object66(Entity* this) { + int iVar2; + int iVar4; + Entity* parent; + + parent = this->parent; + if (parent->z.HALF.HI != 0) { + if (this->action == 0) { + this->action = 1; + this->spriteSettings.draw = 1; + this->spritePriority.b0 = 6; + this->spriteOffsetY = 5; + InitializeAnimation(this, 1); + } + this->x.HALF.HI = parent->x.HALF.HI; + this->y.HALF.HI = parent->y.HALF.HI; + this->spriteOrientation.flipY = parent->spriteOrientation.flipY; + this->spriteRendering.b3 = parent->spriteRendering.b3; + if (parent->z.HALF.HI > -0x40) { + iVar2 = 0x100; + iVar4 = 0x200; + } else { + iVar2 = 0x100 - 2 * (parent->z.HALF.HI + 0x40); + iVar4 = 0x200 - 4 * (parent->z.HALF.HI + 0x40); + } + sub_0805EC9C(this, iVar2, iVar4, 0); + } else { + DeleteThisEntity(); + } +} diff --git a/src/object/object67.c b/src/object/object67.c new file mode 100644 index 00000000..05218223 --- /dev/null +++ b/src/object/object67.c @@ -0,0 +1,338 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "room.h" +#include "player.h" +#include "asm.h" +#include "functions.h" +#include "object.h" +#include "effects.h" + +typedef struct { + Entity base; + u8 filler[0xC]; + u32 unk74; + u32 unk78; + u32 unk7c; + union SplitWord unk80; + union SplitWord unk84; +} Object67Entity; + +extern Hitbox gUnk_080FD2E8; + +void sub_08094148(Object67Entity*); +void sub_08094398(Object67Entity*); +void sub_08094424(Object67Entity*); +void sub_08094540(Object67Entity*); +void sub_08094570(Object67Entity*); +void sub_08094660(Object67Entity*); +void sub_08094708(Object67Entity*, u32, u32); + +extern bool32 AllocMutableHitbox(Entity*); + +void Object67(Entity* this) { + static void (*const actionFuncs[])(Object67Entity*) = { + sub_08094148, sub_08094398, sub_08094424, sub_08094540, sub_08094570, + }; + + actionFuncs[this->action]((Object67Entity*)this); +} + +typedef struct { + u8 unk0; + u8 direction; + s8 x; + s8 y; +} gUnk_081229D0_struct; + +typedef struct { + s8 x; + s8 y; + u8 actionDelay; + u8 unk3; + u8 unk4; + u8 filler[3]; +} gUnk_081229F0_struct; + +void sub_08094148(Object67Entity* this) { + static const gUnk_081229D0_struct gUnk_081229D0[] = { + { 0, 12, 8, 8 }, { 0x40, 0x14, -8, 8 }, { 0x80, 4, 8, -8 }, { 0xC0, 0x1C, -8, -8 }, + { 0, 12, 0, 0 }, { 0x40, 0x14, 0, 0 }, { 0x80, 4, 0, 0 }, { 0xC0, 0x1C, -0, 0 }, + }; + static const gUnk_081229F0_struct gUnk_081229F0[] = { + { -32, -40, 1, 2, 0, { 0 } }, + { 0x1f, -40, 3, 2, 0x40, { 0 } }, + { -32, 0x17, 1, 0, 0x80, { 0 } }, + { 0x1f, 0x17, 3, 0, 0xC0, { 0 } }, + }; + const gUnk_081229F0_struct* ptr; + + switch (super->type) { + case 2: + if (super->subAction == 0) { + super->subAction = 1; + this->unk78 = 0x168; + gRoomControls.camera_target = super; + } else { + if (--this->unk78 == -1) { + gRoomControls.camera_target = &gPlayerEntity; + DeleteThisEntity(); + } + } + sub_08078B48(); + return; + case 0: + super->direction = gUnk_081229D0[super->type2].direction; + super->x.HALF.HI += gUnk_081229D0[super->type2].x; + super->y.HALF.HI += gUnk_081229D0[super->type2].y; + if ((gUnk_081229D0[super->type2].unk0 & 0x40) != 0) { + super->spriteSettings.flipX = 1; + } + if ((gUnk_081229D0[super->type2].unk0 & 0x80) != 0) { + super->spriteSettings.flipY = 1; + } + if (super->type2 < 4) { + super->zVelocity = (Random() & 0x1ffff) | 0x28000; + super->speed = 0x100; + InitializeAnimation(super, 0x56); + } else { + super->zVelocity = 0x28000; + super->speed = 0x100; + super->direction = (Random() & 3) | super->direction; + InitializeAnimation(super, 0x57); + } + break; + case 1: + if (super->type2 == 0) { + super->child = CreateObjectWithParent(super, OBJECT_67, 1, 0x80); + if (super->child != NULL) { + super->child->child = super->parent; + } + } + + switch (super->type2) { + default: + super->frameIndex = 75; + super->spriteRendering.alphaBlend = 1; + super->speed = 0x7000; + super->spriteRendering.b3 = 3; + super->spritePriority.b0 = 7; + super->spriteRendering.b0 = 3; + ptr = gUnk_081229F0 + super->type2; + super->x.HALF.HI = ptr->x + super->x.HALF.HI; + super->y.HALF.HI = ptr->y + super->y.HALF.HI; + super->actionDelay = ptr->actionDelay; + super->field_0xf = ptr->unk3; + this->unk7c = 0xce; + this->unk74 = 0; + if ((ptr->unk4 & 0x40) != 0) { + this->unk80.HALF.HI = 0xff00; + } else { + this->unk80.HALF.HI = 0x100; + } + if ((ptr->unk4 & 0x80) != 0) { + this->unk84.HALF.HI = 0xff00; + } else { + this->unk84.HALF.HI = 0x100; + } + + if (AllocMutableHitbox(super)) { + super->hitbox->offset_x = gUnk_080FD2E8.offset_x; + super->hitbox->offset_y = gUnk_080FD2E8.offset_y; + super->hitbox->unk2[0] = gUnk_080FD2E8.unk2[0]; + super->hitbox->unk2[1] = gUnk_080FD2E8.unk2[1]; + super->hitbox->unk2[2] = gUnk_080FD2E8.unk2[2]; + super->hitbox->unk2[3] = gUnk_080FD2E8.unk2[3]; + super->hitbox->width = gUnk_080FD2E8.width; + super->hitbox->height = gUnk_080FD2E8.height; + COLLISION_ON(super); + super->collisionLayer = 2; + super->field_0x3c = 7; + super->hurtType = 0x48; + super->hitType = 0x7a; + super->flags2 = 1; + } + break; + case 0x80: + super->spriteSettings.draw = 0; + break; + } + break; + } + + super->action = 1; + sub_08094398(this); +} + +void sub_08094398(Object67Entity* this) { + switch (super->type) { + case 0: + GetNextFrame(super); + LinearMoveUpdate(super); + if (GravityUpdate(super, 0x4000) == 0) { + if (super->type2 < 4) { + CreateFx(super, FX_LAVA_SPLASH, 0); + } + DeleteThisEntity(); + } + break; + case 1: + if (super->type2 != 0x80) { + if (--this->unk7c == -1) { + this->unk7c = 600; + super->action = 2; + } + sub_0805EC9C(super, this->unk80.HALF_U.HI, this->unk84.HALF_U.HI, 0); + } else { + if ((((GenericEntity*)super->child)->field_0x78.HALF.HI & 0x80) == 0) { + DeleteThisEntity(); + } + sub_08094660(this); + } + break; + } +} + +void sub_08094424(Object67Entity* this) { + u32 uVar2; + u32 uVar5; + + if (this->unk80.HALF.HI < 0) { + this->unk80.WORD += (int)super->speed; + uVar2 = -this->unk80.HALF.HI; + } else { + this->unk80.WORD -= (int)super->speed; + uVar2 = this->unk80.HALF_U.HI; + } + + if (this->unk84.HALF.HI < 0) { + this->unk84.WORD += (int)super->speed; + uVar5 = -this->unk84.HALF.HI; + } else { + this->unk84.WORD -= (int)super->speed; + uVar5 = this->unk84.HALF_U.HI; + } + + if (0x2000 < super->speed) { + super->speed -= 0x100; + } + + if (--this->unk7c == -1) { + this->unk80.HALF.LO = 0; + this->unk84.HALF.LO = 0; + super->action = 3; + this->unk7c = 0x78; + } else { + sub_0806FCF4(super, this->unk80.HALF.HI, 0x20, super->actionDelay); + sub_0806FCF4(super, this->unk84.HALF.HI, 0x20, super->field_0xf); + sub_0805EC9C(super, this->unk80.HALF_U.HI, this->unk84.HALF_U.HI, 0); + } + + if (super->hitbox != NULL) { + super->hitbox->width = (u32)(0x10000 / (s32)uVar2) >> 3; + super->hitbox = super->hitbox; + super->hitbox->height = (u32)(0x10000 / (s32)uVar5) >> 3; + super->hitbox->offset_x = super->spriteOffsetX; + super->hitbox->offset_y = super->spriteOffsetY; + } +} + +void sub_08094540(Object67Entity* this) { + if (--this->unk7c == -1) { + super->action = 4; + this->unk7c = 2; + } + sub_0805EC9C(super, this->unk80.HALF_U.HI, this->unk84.HALF_U.HI, 0); +} + +void sub_08094570(Object67Entity* this) { + u32 uVar2; + u32 uVar3; + + if ((this->unk80.HALF_U.HI == 0x100) || (this->unk80.HALF.HI == -0x100)) { + if (this->unk7c == 0) { + ((GenericEntity*)super->parent)->field_0x7c.HALF.LO = 0; + if ((((GenericEntity*)super->parent)->field_0x78.HALF.HI & 0x80) == 0) { + DeleteThisEntity(); + } + } else { + this->unk7c--; + } + } else { + if (this->unk80.HALF.HI < 0) { + this->unk80.HALF.HI--; + uVar2 = -this->unk80.HALF.HI; + } else { + this->unk80.HALF.HI++; + uVar2 = this->unk80.HALF_U.HI; + } + + if (this->unk84.HALF.HI < 0) { + this->unk84.HALF.HI = this->unk84.HALF.HI + -1; + uVar3 = -this->unk84.HALF.HI; + } else { + this->unk84.HALF.HI = this->unk84.HALF.HI + 1; + uVar3 = this->unk84.HALF_U.HI; + } + sub_0806FCF4(super, this->unk80.HALF.HI, 0x20, super->actionDelay); + sub_0806FCF4(super, this->unk84.HALF.HI, 0x20, super->field_0xf); + sub_0805EC9C(super, this->unk80.HALF_U.HI, this->unk84.HALF_U.HI, 0); + } + + if (super->hitbox != NULL) { + super->hitbox->width = (u32)(0x10000 / (s32)uVar2) >> 3; + super->hitbox->height = (u32)(0x10000 / (s32)uVar3) >> 3; + super->hitbox->offset_x = super->spriteOffsetX; + super->hitbox->offset_y = super->spriteOffsetY; + } +} + +void sub_08094660(Object67Entity* this) { + int iVar1; + int spriteOffsetX; + int iVar3; + int iVar4; + int iVar5; + + spriteOffsetX = (s8)super->parent->spriteOffsetX; + if (spriteOffsetX < 0) { + spriteOffsetX = -spriteOffsetX; + } + + spriteOffsetX = spriteOffsetX * 2; + if (spriteOffsetX < 0) { + iVar5 = spriteOffsetX + 0xf; + } else { + iVar5 = spriteOffsetX; + } + + iVar1 = iVar5 >> 4; + if (this->unk74 < iVar1) { + this->unk74 = iVar1; + iVar3 = super->x.HALF.HI - spriteOffsetX - 0x40; + iVar4 = super->y.HALF.HI - spriteOffsetX - 0x40; + this->unk78 = 0x10; + this->unk7c = 0; + sub_08094708(this, iVar3, iVar4); + this->unk78 = 0; + this->unk7c = 0x10; + sub_08094708(this, iVar3, iVar4); + iVar3 = super->x.HALF.HI + spriteOffsetX + 0x30; + iVar4 = super->y.HALF.HI + spriteOffsetX + 0x30; + this->unk78 = 0xfffffff0; + this->unk7c = 0; + sub_08094708(this, iVar3, iVar4); + this->unk78 = 0; + this->unk7c = 0xfffffff0; + sub_08094708(this, iVar3, iVar4); + } +} + +void sub_08094708(Object67Entity* this, u32 param_2, u32 param_3) { + int index; + + for (index = this->unk74 * 2 + 8; index != 0; index--) { + sub_0807BA8C(TILE(param_2, param_3), 2); + param_2 = param_2 + this->unk78; + param_3 = param_3 + this->unk7c; + } +} diff --git a/src/object/object68.c b/src/object/object68.c index e5265aa9..d26bb550 100644 --- a/src/object/object68.c +++ b/src/object/object68.c @@ -10,6 +10,7 @@ #include "global.h" #include "object.h" #include "functions.h" +#include "item.h" typedef struct { /*0x00*/ Entity base; @@ -66,7 +67,7 @@ void sub_08094774(Object68Entity* this) { } break; case 2: - child = CreateGroundItem(&gPlayerEntity, 0x60, 0); + child = CreateGroundItem(&gPlayerEntity, ITEM_FAIRY, 0); super->child = child; if (child != NULL) { child->actionDelay = 1; diff --git a/src/object/object75.c b/src/object/object75.c new file mode 100644 index 00000000..efd305f6 --- /dev/null +++ b/src/object/object75.c @@ -0,0 +1,14 @@ +#define NENT_DEPRECATED +#include "entity.h" + +extern void sub_0808C964(Entity*); +extern void sub_0808CA10(Entity*); + +void Object75(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + sub_0808C964, + sub_0808CA10, + }; + + actionFuncs[this->action](this); +} diff --git a/src/object/object76.c b/src/object/object76.c new file mode 100644 index 00000000..79df5405 --- /dev/null +++ b/src/object/object76.c @@ -0,0 +1,14 @@ +#define NENT_DEPRECATED +#include "entity.h" + +extern void sub_0808C964(Entity*); +extern void sub_0808CA10(Entity*); + +void Object76(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + sub_0808C964, + sub_0808CA10, + }; + + actionFuncs[this->action](this); +} diff --git a/src/object/object79.c b/src/object/object79.c new file mode 100644 index 00000000..52480738 --- /dev/null +++ b/src/object/object79.c @@ -0,0 +1,113 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "player.h" +#include "functions.h" +#include "sound.h" + +typedef struct { + Entity base; + u8 filler[0x4]; + u32 unk6c; + union SplitWord objDir; + u32 unk74; + u16 unk78; + u16 unk7a; + u16 unk7c; + s16 unk7e; +} Object79Entity; + +void Object79_Init(Object79Entity*); +void Object79_Action1(Object79Entity*); +void Object79_Action2(Object79Entity*); +void sub_08098130(Object79Entity*); + +void Object79(Entity* this) { + static void (*const actionFuncs[])(Object79Entity*) = { + Object79_Init, + Object79_Action1, + Object79_Action2, + }; + + if ((gPlayerState.flags & PL_MINISH) != 0) { + DeleteThisEntity(); + } + + actionFuncs[this->action]((Object79Entity*)this); +} + +void Object79_Init(Object79Entity* this) { + static const u8 Object79_Directions[] = { DirectionSouthWest, DirectionWest, DirectionNorthWest, + DirectionNorthEast, DirectionEast, DirectionSouthEast }; + super->action++; + super->speed = 0; + this->unk6c = 0; + this->unk7a = 0x1200; + super->actionDelay = 0; + super->field_0xf = 30; + this->objDir.HALF.HI = Object79_Directions[super->type]; + this->unk74 = 0x2000; + SetDefaultPriority(super, 6); + if (super->type == 0) { + this->unk7e = 0x40; + LoadSwapGFX(super, 1, 0); + InitAnimationForceUpdate(super, super->type); + } else { + Entity* parent; + super->spriteVramOffset = super->parent->spriteVramOffset; + parent = super->parent; + super->frameIndex = super->type * 13 + parent->frameIndex; + } + sub_08098130(this); +} + +void Object79_Action1(Object79Entity* this) { + if (super->type == 0) { + UpdateAnimationSingleFrame(super); + if (super->type2 != 0) { + gPlayerEntity.field_0xf = 0; + super->action++; + InitAnimationForceUpdate(super, 1); + SoundReq(SFX_178); + } + } else { + Entity* parent = super->parent; + super->frameIndex = super->type * 13 + parent->frameIndex; + super->action = parent->action; + } +} + +void Object79_Action2(Object79Entity* this) { + if (this->unk6c >= 0x140001) { + gPlayerState.flags |= PL_MINISH; + DeleteThisEntity(); + } else { + if (super->type == 0) { + UpdateAnimationSingleFrame(super); + if (--this->unk7e << 16 == -0x10000) { + this->unk7e = 0x40; + SoundReq(SFX_178); + } + } else { + Entity* parent = super->parent; + super->frameIndex = super->type * 13 + parent->frameIndex; + } + this->unk6c += 0x1400; + this->objDir.WORD += this->unk74; + this->objDir.HALF.HI = DirectionNormalize(this->objDir.HALF.HI); + this->unk74 += 0x140; + if (--super->field_0xf == 0xff) { + super->field_0xf = 30; + super->actionDelay ^= 1; + } + sub_08098130(this); + } +} + +void sub_08098130(Object79Entity* this) { + CopyPosition(&gPlayerEntity, super); + super->direction = this->objDir.HALF.HI; + super->speed = this->unk7a; + LinearMoveUpdate(super); + super->y.WORD -= 0x140000; + super->y.WORD += this->unk6c; +} diff --git a/src/object/object81.c b/src/object/object81.c new file mode 100644 index 00000000..ea5b8072 --- /dev/null +++ b/src/object/object81.c @@ -0,0 +1,39 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "player.h" +#include "functions.h" +#include "sound.h" + +typedef struct { + Entity base; + u8 filler[0x18]; + u16 tilePos; +} Object81Entity; + +void Object81_Init(Object81Entity*); +void Object81_Action1(Object81Entity*); + +void Object81(Entity* this) { + static void (*const actionFuncs[])(Object81Entity*) = { + Object81_Init, + Object81_Action1, + }; + + actionFuncs[this->action]((Object81Entity*)this); +} + +void Object81_Init(Object81Entity* this) { + super->action = 1; + super->actionDelay = 0; + this->tilePos = COORD_TO_TILE(super); + if (gPlayerState.flags & PL_MINISH) { + super->collisionLayer = 2; + } else { + super->collisionLayer = 1; + } + UpdateSpriteForCollisionLayer(super); + sub_08000148(0x47, this->tilePos - 0x40, 1); +} + +void Object81_Action1(Object81Entity* this) { +} diff --git a/src/object/object9.c b/src/object/object9.c new file mode 100644 index 00000000..a3286f79 --- /dev/null +++ b/src/object/object9.c @@ -0,0 +1,156 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "message.h" +#include "kinstone.h" +#include "common.h" +#include "functions.h" + +// typedef struct { +// Entity base; +// u8 filler[0x18]; +// u16 tilePos; +// } Object81Entity; + +extern void sub_080ADDD8(u32, u32); +void sub_080838DC(Entity*); +void sub_08083A40(Entity*); +void Object9_Init(Entity*); +void Object9_Action1(Entity*); +void Object9_Action2(Entity*); + +#ifdef EU +static const s32 gUnk_0811F744[] = { + 0x00027940, + 0x00027B40, + 0x00027D40, + 0x00027F40, +}; +#else +static const s32 gUnk_0811F744[] = { + 0x00027980, + 0x00027B80, + 0x00027D80, + 0x00027F80, +}; +#endif + +void Object9(Entity* this) { + static void (*const gUnk_0811F754[])(Entity*) = { + Object9_Init, + Object9_Action1, + Object9_Action2, + }; + + u32 uVar2 = gPlayerState.field_0x27[0] > 0; + + switch (gFuseInfo._0) { + case 0: + case 1: + case 2: + if ((gMessage.doTextBox & 0x7f) != 0) { + default: + if (gUnk_03003DF0.unk_4[3] == 50) { + if (CheckKinstoneFused(0x32) == 0) { + uVar2 = 0; + break; + } + } + uVar2 = 1; + } + break; + } + + if (uVar2) { + sub_080838DC(this); + } + gUnk_0811F754[this->action](this); +} + +void sub_080838DC(Entity* this) { + this->spriteSettings.draw = 0; + this->spriteOrientation.flipY = 1; + this->spriteRendering.b3 = 0; + this->spritePriority.b0 = 0; + this->actionDelay = 4; + this->child = NULL; + this->action = 0; +} + +void Object9_Init(Entity* this) { + if (this->spriteAnimation[0] != 1) { + LoadSwapGFX(this, 1, 1); + this->spriteVramOffset -= 0x10; +#ifdef EU + sub_080ADDD8(1, 0x10277e0); +#else + sub_080ADDD8(1, 0x1027820); +#endif + sub_080838DC(this); + } + this->action = 1; + this->flags |= ENT_PERSIST; + SetDefaultPriority(this, 6); +} + +void Object9_Action1(Entity* this) { + if (this->actionDelay) { + this->actionDelay--; + } else { + if ((*(Entity**)(gUnk_03003DF0.unk_4 + 8) != NULL) && ((u8)(gUnk_03003DF0.unk_4[3] - 1) < 100)) { + this->child = *(Entity**)(gUnk_03003DF0.unk_4 + 8); + this->interactType = gUnk_03003DF0.unk_3; + sub_08083A40(this); + } + } +} + +void Object9_Action2(Entity* this) { + u32 bVar1; + u32 bVar2; + u32 bVar3; + u32 temp; + u32 temp2; + struct_080C9CBC* ptr; + + if ((this->type != 1) && + (((u8)(gUnk_03003DF0.unk_4[3] - 1) >= 100 || (this->child != *(Entity**)(gUnk_03003DF0.unk_4 + 8))))) { + sub_080838DC(this); + } else { + this->x = this->child->x; + this->y = this->child->y; + this->z = this->child->z; + if (this->frame == 1) { + this->frame = 0; + if (this->type == 0) { + bVar2 = gUnk_03003DF0.unk_4[3]; + } else { + bVar2 = this->type2; + } + ptr = gUnk_080C9CBC + bVar2; + bVar1 = ptr->_5[0]; + bVar3 = bVar1 & 1; + this->palette.b.b0 = bVar3; + temp = gUnk_0811F744[bVar1] < 0; + temp2 = (gUnk_0811F744[bVar1] & 0xffffff) | temp; + sub_080ADDD8(0, temp2 | 0x1000000); + } + GetNextFrame(this); + } +} + +void sub_08083A40(Entity* this) { + u32 bVar1; + + this->spriteSettings.draw = 1; + this->action = 2; + if (this->child->x.HALF.HI > gPlayerEntity.x.HALF.HI) { + bVar1 = 0; + this->spriteOffsetX = 8; + } else { + bVar1 = 1; + this->spriteOffsetX = -8; + } + this->spriteOffsetY = -18; + InitializeAnimation(this, bVar1); + Object9_Action2(this); +} diff --git a/src/object/object9B.c b/src/object/object9B.c new file mode 100644 index 00000000..1f88aefa --- /dev/null +++ b/src/object/object9B.c @@ -0,0 +1,42 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "coord.h" + +void sub_0809E7C0(Entity*); +void sub_0809E7E0(Entity*); +void sub_0809E7FC(Entity*); + +void Object9B(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + sub_0809E7C0, + sub_0809E7E0, + }; + + actionFuncs[this->action]((Entity*)this); +} + +void sub_0809E7C0(Entity* this) { + this->action = 1; + if (this->type2 != 0xff) { + sub_0809E7FC(this); + } + InitializeAnimation(this, this->type); +} + +void sub_0809E7E0(Entity* this) { + GetNextFrame(this); + if (this->frame & 0x80) { + DeleteThisEntity(); + } +} + +void sub_0809E7FC(Entity* this) { + static const s8 gUnk_081242D8[] = { + 0, -24, 16, -16, 24, 0, 16, 16, 0, 24, -16, 16, -24, 0, -16, -16, + }; + int iVar1; + const s8* ptr; + + ptr = &gUnk_081242D8[this->type2 * 2]; + PositionRelative(this->parent, this, ptr[0] << 0x10, ptr[1] << 0x10); +} diff --git a/src/object/objectA7.c b/src/object/objectA7.c new file mode 100644 index 00000000..bfcd80ab --- /dev/null +++ b/src/object/objectA7.c @@ -0,0 +1,11 @@ +#define NENT_DEPRECATED +#include "entity.h" + +void ObjectA7(Entity* this) { + if (this->action == 0) { + this->action = 1; + this->spritePriority.b0 = 6; + InitializeAnimation(this, 0); + } + GetNextFrame(this); +} diff --git a/src/object/objectB6.c b/src/object/objectB6.c new file mode 100644 index 00000000..aac1f103 --- /dev/null +++ b/src/object/objectB6.c @@ -0,0 +1,16 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "coord.h" + +void ObjectB6(Entity* this) { + if (this->parent->subAction > 3) { + DeleteThisEntity(); + } + if (this->action == 0) { + this->action = 1; + InitializeAnimation(this, this->type); + } + sub_0806FA90(this->parent, this, 0, this->type); + this->spriteOffsetY = this->spriteOffsetY - this->type; + GetNextFrame(this); +} diff --git a/src/object/playerClone.c b/src/object/playerClone.c new file mode 100644 index 00000000..eee252ae --- /dev/null +++ b/src/object/playerClone.c @@ -0,0 +1,187 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "room.h" +#include "asm.h" +#include "sound.h" +#include "player.h" +#include "functions.h" +#include "effects.h" + +typedef struct { + Entity base; + u8 filler[0x4]; + u32 unk6c; + u32 unk70; + u16 tilePos; + u16 unk76; + u16 unk78; + u16 unk7a; +} PlayerCloneEntity; + +extern Entity* sub_08077CF8(u32 subtype, u32 form, u32 parameter, u32 unk); +extern const s16 gUnk_080B4468[]; + +void PlayerClone_Init(PlayerCloneEntity*); +void PlayerClone_Action1(PlayerCloneEntity*); +void PlayerClone_Action2(PlayerCloneEntity*); +void sub_08084B1C(PlayerCloneEntity*); +void sub_08084CAC(PlayerCloneEntity*); + +void PlayerClone(Entity* this) { + static void (*const actionFuncs[])(PlayerCloneEntity*) = { + PlayerClone_Init, + PlayerClone_Action1, + PlayerClone_Action2, + }; + + actionFuncs[this->action]((PlayerCloneEntity*)this); +} + +void PlayerClone_Init(PlayerCloneEntity* this) { + super->action = 1; + super->spriteRendering.b3 = 2; + super->spritePriority.b0 = 4; + super->x.HALF.HI = (super->x.HALF.HI & 0xfff0) | 8; + super->y.HALF.HI = (super->y.HALF.HI & 0xfff0) | 8; + this->tilePos = COORD_TO_TILE(super); + InitializeAnimation(super, 8); + SetTile(0x4016, this->tilePos, super->collisionLayer); + SoundReq(SFX_112); +} + +const u16 PlayerCloneCollisions[] = { 0x2206, 0x6044, 0x4460, 0x622 }; + +void PlayerClone_Action1(PlayerCloneEntity* this) { + static const Hitbox PlayerCloneHitbox = { 0, -3, { 5, 3, 3, 5 }, 6, 6 }; + + if (gPlayerState.chargeState.action == 5) { + super->spriteSettings.draw = 1; + super->health = 1; + super->action = 2; + super->updatePriority = 6; + super->hitbox = (Hitbox*)&PlayerCloneHitbox; + super->field_0xf = (super->type + 1) * 15; + this->unk78 = super->x.HALF.HI - gPlayerEntity.x.HALF.HI; + this->unk7a = super->y.HALF.HI - gPlayerEntity.y.HALF.HI; + if ((this->unk78 != 0) && (this->unk7a != 0)) { + ((PlayerCloneEntity*)gPlayerClones[super->type])->unk70 = 1; + } + sub_08000152(0x315, this->tilePos, super->collisionLayer); + super->child = sub_08077CF8(1, super->type + 1, 0, ((GenericEntity*)gPlayerState.item)->field_0x68.HALF.LO); + if (super->child != NULL) { + super->child->parent = super; + } + sub_0801766C(super); + sub_0806FDA0(super); + PlayerClone_Action2(this); + } else if (gPlayerState.chargeState.action != 4) { + sub_08000152(0x315, this->tilePos, super->collisionLayer); + gPlayerClones[super->type] = NULL; + DeleteThisEntity(); + } else { + super->spriteSettings.draw ^= 1; + } +} + +void PlayerClone_Action2(PlayerCloneEntity* this) { + u32 index; + + if (super->field_0xf == 1) { + SoundReq(SFX_PLY_VO2); + super->field_0xf--; + } else if (super->field_0xf != 0) { + super->field_0xf--; + } + + if (gPlayerState.chargeState.action == 5 && gPlayerClones[super->type] != NULL && gPlayerState.framestate != 19 && + super->health != 0) { + if (gPlayerEntity.iframes >= 1) { + gPlayerState.chargeState.action = 1; + } else { + sub_080B1AA8(super); + sub_08084B1C(this); + super->x.HALF.HI = gPlayerEntity.x.HALF.HI + this->unk78; + super->y.HALF.HI = gPlayerEntity.y.HALF.HI + this->unk7a; + sub_08084CAC(this); + sub_080085B0(super); + if ((super->collisions & 0x6666) != 0x6666) { + for (index = 0; index <= 3; index++) { + if (PlayerCloneCollisions[index] == (PlayerCloneCollisions[index] & super->collisions)) { + break; + } + } + + if (index == 4) { + super->actionDelay = 0; + super->spriteSettings.draw = 1; + return; + } else { + if (super->actionDelay != 0) { + if (--super->actionDelay != 0) { + super->spriteSettings.draw ^= 1; + return; + } + } else { + super->actionDelay = 30; + return; + } + } + } + gPlayerState.chargeState.action = 1; + return; + } + } + DeleteClones(); + CreateFx(super, FX_SPARKLE_SECRET, 0); + DeleteEntity(super->child); + SoundReq(SFX_18F); + DeleteThisEntity(); +} + +void sub_08084B1C(PlayerCloneEntity* this) { + super->flags = gPlayerEntity.flags; + super->spriteVramOffset = gPlayerEntity.spriteVramOffset; + super->frameIndex = gPlayerEntity.frameIndex; + super->frameSpriteSettings = gPlayerEntity.frameSpriteSettings; + super->spriteIndex = gPlayerEntity.spriteIndex; + super->direction = gPlayerEntity.direction; + super->animationState = gPlayerEntity.animationState; + super->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX; + super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; + super->spritePriority.b0 = gPlayerEntity.spritePriority.b0; + super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; + super->collisionLayer = gPlayerEntity.collisionLayer; + super->flags2 = gPlayerEntity.flags2; + super->hitType = gPlayerEntity.hitType; + super->field_0x3c = gPlayerEntity.field_0x3c; + super->hurtType = gPlayerEntity.hurtType; + CopyPosition(super, super->child); + if (gPlayerState.field_0x3[1] != 0) { + super->child->damage = gPlayerState.item->damage; + super->child->frameIndex = gPlayerState.item->frameIndex; + super->child->spriteSettings.flipX = gPlayerState.item->spriteSettings.flipX; + super->child->spriteRendering.b3 = gPlayerState.item->spriteRendering.b3; + super->child->spritePriority.b0 = gPlayerState.item->spritePriority.b0; + if (super->child->spriteSettings.flipX) { + super->child->hitbox->offset_x = -super->child->hitbox->offset_x; + } + } + sub_0806FEBC(super, 0, 0); + sub_0806FEBC(super, 1, 0); + sub_0806FEBC(super, 2, super); + sub_0806FEBC(super, 3, 0); + sub_08078E84(super->child, super); +} + +void sub_08084CAC(PlayerCloneEntity* this) { + const s16* ptr; + + if (((PlayerCloneEntity*)gPlayerClones[super->type])->unk70 == 0) { + ptr = &gUnk_080B4468[super->animationState & 6]; + if (sub_080B1B54(GetTileType(COORD_TO_TILE_OFFSET(super, -ptr[0], -ptr[1]), super->collisionLayer)) == 0x72) { + ((PlayerCloneEntity*)gPlayerClones[0])->unk6c |= (1 << super->type); + } else { + ((PlayerCloneEntity*)gPlayerClones[0])->unk6c &= ~(1 << super->type); + } + } +} diff --git a/src/object/smallIceBlock.c b/src/object/smallIceBlock.c index 9e2cf781..3ffedb89 100644 --- a/src/object/smallIceBlock.c +++ b/src/object/smallIceBlock.c @@ -10,6 +10,7 @@ #include "object.h" #include "functions.h" #include "hitbox.h" +#include "item.h" typedef struct { /*0x00*/ Entity base; @@ -138,10 +139,10 @@ void SmallIceBlock_Action3(SmallIceBlockEntity* this) { } sub_0805EC9C(super, 0x100, gUnk_08123748[super->actionDelay >> 5], 0); if (super->type == 1) { - CreateGroundItemWithFlags(super, 0x53, 0, this->unk_86); + CreateGroundItemWithFlags(super, ITEM_SMALL_KEY, 0, this->unk_86); SoundReq(SFX_SECRET); } else if (super->type == 2) { - CreateGroundItemWithFlags(super, 0x52, 0, this->unk_86); + CreateGroundItemWithFlags(super, ITEM_BIG_KEY, 0, this->unk_86); SoundReq(SFX_SECRET); } super->action = 4; diff --git a/src/object/treeHidingPortal.c b/src/object/treeHidingPortal.c index aa450002..c4a0518a 100644 --- a/src/object/treeHidingPortal.c +++ b/src/object/treeHidingPortal.c @@ -7,12 +7,21 @@ #include "functions.h" #include "effects.h" -extern void (*const gUnk_08124354[])(Entity*); +extern const s16 gUnk_080B4468[]; -extern s16 gUnk_08124364[]; +void sub_0809E83C(Entity* this); +void sub_0809E86C(Entity* this); +void sub_0809E8BC(Entity* this); +void sub_0809E8EC(Entity* this); void TreeHidingPortal(Entity* this) { - gUnk_08124354[this->action](this); + static void (*const actionFuncs[])(Entity*) = { + sub_0809E83C, + sub_0809E86C, + sub_0809E8BC, + sub_0809E8EC, + }; + actionFuncs[this->action](this); } void sub_0809E83C(Entity* this) { @@ -61,8 +70,12 @@ void sub_0809E8EC(Entity* this) { } void sub_0809E918(Entity* this) { + static const s16 gUnk_08124364[] = { + 0, -4, 8, -4, 16, -4, 22, -4, -8, -4, -16, -4, -22, -4, 0, -12, 0, 4, 8, -12, + 8, 4, -8, -12, -8, 4, 8, -16, -8, -16, 12, -16, -12, -16, 16, -14, -16, -14, -1000, 0, + }; Entity* fx; - s16* i = gUnk_08124364; + const s16* i = gUnk_08124364; while (*i != -1000) { fx = CreateFx(this, FX_BUSH, 0); if (fx != NULL) { @@ -78,3 +91,17 @@ void sub_0809E918(Entity* this) { void sub_0809E96C(Entity* this) { CreateMinishEntrance(COORD_TO_TILE_OFFSET(this, 0x20, 0x8)); } + +u32 sub_0809E9A0(void) { + u32 rv; + const s16* ptr; + + if (gPlayerEntity.action != PLAYER_BOUNCE) { + rv = 0; + } else { + ptr = &gUnk_080B4468[gPlayerEntity.animationState & 6]; + rv = sub_080B1AE0(COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr[0], -ptr[1]), 1); + } + + return rv; +} diff --git a/src/player.c b/src/player.c index 5f15068c..252c178c 100644 --- a/src/player.c +++ b/src/player.c @@ -3501,7 +3501,7 @@ void SurfaceAction_CloneTile(Entity* this) { break; } if (n > i) { - Entity* e = CreateObjectWithParent(this, OBJECT_10, i, 0); + Entity* e = CreateObjectWithParent(this, PLAYER_CLONE, i, 0); gPlayerClones[i] = e; if (e != NULL) { CopyPosition(this, e); |
