diff options
| author | Henny022p <info@henny022.de> | 2022-01-31 17:30:51 +0100 |
|---|---|---|
| committer | Henny022p <info@henny022.de> | 2022-01-31 17:30:51 +0100 |
| commit | 2a53ee4bf2ee7eea617280118c2188bffec77ae5 (patch) | |
| tree | 85ed631ab330f9ca3734bb77253a374e3ef0de21 /src/object | |
| parent | 9b60d9c5e24ed592524c25a9dc013417d6e7ee0c (diff) | |
| parent | 2b8d880ffc0a4548d25dc613d53a908d36362d84 (diff) | |
merge master
Diffstat (limited to 'src/object')
36 files changed, 1452 insertions, 167 deletions
diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c index a5b344ba..cdc65c3a 100644 --- a/src/object/bakerOven.c +++ b/src/object/bakerOven.c @@ -1,7 +1,7 @@ #include "object.h" +#include "functions.h" extern void SoundReqClipped(Entity*, u32); -extern u32 sub_0806FC80(Entity*, Entity*, s32); extern void sub_0809CDF0(Entity*); extern void (*const gUnk_08123E20[])(Entity*); @@ -24,7 +24,7 @@ void sub_0809CC74(Entity* this) { ent = CreateObject(BAKER_OVEN, 1, i); if (ent) { ent->parent = this; - PositionRelative(this, ent, (((i + 1) / 2) * 0x100000) - 0x80000, -0xe0000); + PositionRelative(this, ent, 16 * Q_16_16((i + 1) / 2) - Q_16_16(8.0), Q_16_16(-14.0)); } } sub_0809CDF0(this); @@ -61,7 +61,7 @@ void sub_0809CD0C(Entity* this) { sub_0806FC80(this, &gPlayerEntity, 4)) { this->field_0xf++; ModHealth(-2); - SoundReqClipped(&gPlayerEntity, 0x7a); + SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6); gPlayerEntity.iframes = 16; gPlayerEntity.knockbackDirection = 16; gPlayerEntity.knockbackDuration = 12; diff --git a/src/object/bigPushableLever.c b/src/object/bigPushableLever.c new file mode 100644 index 00000000..71f10a90 --- /dev/null +++ b/src/object/bigPushableLever.c @@ -0,0 +1,155 @@ +/** + * @file bigPushableLever.c + * @ingroup Objects + * + * @brief Big Pushable Lever object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68[8]; + /*0x70*/ u16 tilePositionUpper; + /*0x72*/ u16 tilePositionLower; + /*0x74*/ u16 tileIndexUpper; + /*0x76*/ u16 tileIndexLower; + /*0x78*/ u8 unk_78[12]; + /*0x84*/ u16 timer; + /*0x86*/ u16 pushedFlag; +} BigPushableLeverEntity; + +enum BigPushableLeverAction { + INIT, + IDLE, + PUSHING, +}; + +extern void (*const BigPushableLever_Actions[])(BigPushableLeverEntity*); +extern const u16 gUnk_081236E8[]; +extern const u8 BigPushableLever_InitialOffsets[]; +extern const u8 BigPushableLever_PushedOffsets[]; + +void BigPushableLever_SetIdle(BigPushableLeverEntity*); +bool32 BigPushableLever_ShouldStartPushing(BigPushableLeverEntity*); +void BigPushableLever_SetTiles(BigPushableLeverEntity*); +void BigPushableLever_CalculateSpriteOffsets(BigPushableLeverEntity*); + +#define TILE_INITIAL 0x4058 +#define TILE_PUSHED 0x4056 + +void BigPushableLever(BigPushableLeverEntity* this) { + BigPushableLever_Actions[super->action](this); +} + +void BigPushableLever_Init(BigPushableLeverEntity* this) { + super->spritePriority.b0 = 5; + BigPushableLever_SetIdle(this); +} + +void BigPushableLever_Idle(BigPushableLeverEntity* this) { + if (BigPushableLever_ShouldStartPushing(this)) { + super->action = PUSHING; + SetTile(this->tileIndexUpper, this->tilePositionUpper, super->collisionLayer); + SetTile(this->tileIndexLower, this->tilePositionLower, super->collisionLayer); + EnqueueSFX(SFX_132); + RequestPriorityDuration(super, 0x1e); + if (sub_08079F8C()) { + gPlayerState.pushedObject = 0x98; + gPlayerState.queued_action = 5; + gPlayerState.flags |= 1; + gPlayerEntity.x.HALF.LO = 0; + gPlayerEntity.y.HALF.LO = 0; + gPlayerEntity.direction = gPlayerEntity.animationState << 2; + } + } +} + +void BigPushableLever_Pushing(BigPushableLeverEntity* this) { + GetNextFrame(super); + if ((super->frame & 0x80) != 0) { + if (super->type2 == 0) { + SetFlag(this->pushedFlag); + } else { + ClearFlag(this->pushedFlag); + } + BigPushableLever_SetIdle(this); + } +} + +void BigPushableLever_SetIdle(BigPushableLeverEntity* this) { + super->action = IDLE; + this->timer = 0x3c; + BigPushableLever_SetTiles(this); +} + +void BigPushableLever_SetTiles(BigPushableLeverEntity* this) { + if (!CheckFlags(this->pushedFlag)) { + super->type2 = 0; + this->tilePositionUpper = COORD_TO_TILE_OFFSET(super, 0, 0x10); + this->tilePositionLower = this->tilePositionUpper - 0x40; + this->tileIndexUpper = GetTileIndex(this->tilePositionUpper, super->collisionLayer); + this->tileIndexLower = GetTileIndex(this->tilePositionLower, super->collisionLayer); + SetTile(0x4057, this->tilePositionUpper, super->collisionLayer); + SetTile(0x4058, this->tilePositionLower, super->collisionLayer); + InitializeAnimation(super, 1); + } else { + super->type2 = 1; + this->tilePositionUpper = COORD_TO_TILE_OFFSET(super, 0x10, 0); + this->tilePositionLower = this->tilePositionUpper - 1; + this->tileIndexUpper = GetTileIndex(this->tilePositionUpper, super->collisionLayer); + this->tileIndexLower = GetTileIndex(this->tilePositionLower, super->collisionLayer); + SetTile(0x4055, this->tilePositionUpper, super->collisionLayer); + SetTile(0x4056, this->tilePositionLower, super->collisionLayer); + InitializeAnimation(super, 0); + } +} + +bool32 BigPushableLever_ShouldStartPushing(BigPushableLeverEntity* this) { + if (GetTileIndex(this->tilePositionLower, super->collisionLayer) == 0x4059) { + if (--this->timer == 0) { + return TRUE; + } + BigPushableLever_CalculateSpriteOffsets(this); + SetTile(gUnk_081236E8[super->type2], this->tilePositionLower, super->collisionLayer); + } else { + this->timer = 0x3c; + super->spriteOffsetX = 0; + super->spriteOffsetY = 0; + } + return FALSE; +} + +void BigPushableLever_CalculateSpriteOffsets(BigPushableLeverEntity* this) { + const u8* offsets; + if (super->type2 == 0) { + offsets = BigPushableLever_InitialOffsets; + } else { + offsets = BigPushableLever_PushedOffsets; + } + offsets = &offsets[this->timer >> 2 & 6]; + super->spriteOffsetX = offsets[0]; + super->spriteOffsetY = offsets[1]; + if ((this->timer & 3) == 0) { + EnqueueSFX(SFX_131); + } +} + +void (*const BigPushableLever_Actions[])(BigPushableLeverEntity*) = { + BigPushableLever_Init, + BigPushableLever_Idle, + BigPushableLever_Pushing, +}; +const u16 gUnk_081236E8[] = { + TILE_INITIAL, + TILE_PUSHED, +}; +const u8 BigPushableLever_InitialOffsets[] = { + 0, 0, 0, 0, 255, 0, 0, 0, +}; +const u8 BigPushableLever_PushedOffsets[] = { + 0, 0, 0, 0, 0, 255, 0, 0, +}; diff --git a/src/object/bigVortex.c b/src/object/bigVortex.c index a26b7aae..1a3d8229 100644 --- a/src/object/bigVortex.c +++ b/src/object/bigVortex.c @@ -65,7 +65,7 @@ void sub_08098DC4(Entity* this) { sub_08004542(this); sub_08004542(&gPlayerEntity); gPlayerEntity.collisionLayer = 1; - ResolveEntityOnTop(this, &gPlayerEntity); + SortEntityAbove(this, &gPlayerEntity); gPlayerState.queued_action = PLAYER_PARACHUTE; gPlayerState.field_0x34[4] = 1; gPlayerState.field_0x34[5] = this->type2; @@ -101,12 +101,12 @@ void sub_08098E88(Entity* this) { ent1 = CreateObject(BIG_VORTEX, 1, 0); if (ent1 != NULL) { - PositionRelative(this, ent1, 0, -0x10000); + PositionRelative(this, ent1, 0, Q_16_16(-1.0)); ent1->spriteOffsetY = 8; } ent2 = CreateObject(BIG_VORTEX, 2, 0); if (ent2 != NULL) { - PositionRelative(this, ent2, 0, -0x20000); + PositionRelative(this, ent2, 0, Q_16_16(-2.0)); ent2->spriteOffsetY = 0x10; } } diff --git a/src/object/bird.c b/src/object/bird.c index 24e2693b..cafe1262 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -24,9 +24,9 @@ void sub_0809CF54(Entity* this) { this->spriteSettings.draw = TRUE; this->actionDelay = 0x31; this->field_0xf = 1; - this->zVelocity = -0x18000; - this->z.WORD = -0x38C000; - this->field_0x68.HWORD = -0x800; + this->zVelocity = Q_16_16(-1.5); + this->z.WORD = Q_16_16(-56.75); + this->field_0x68.HWORD = Q_16_16(-0.03125); this->speed = 0x280; this->direction = 8; this->collisionLayer = 2; @@ -37,8 +37,8 @@ void sub_0809CF54(Entity* this) { target = CreateObject(BIRD, 1, 0); if (target != NULL) { target->parent = this; - PositionRelative(this, target, 0, 0x80000); - ResolveEntityOnTop(this, target); + PositionRelative(this, target, 0, Q_16_16(8.0)); + SortEntityAbove(this, target); } } @@ -77,7 +77,7 @@ void sub_0809D084(Entity* this) { if (this->parent != NULL) { temp = this->parent->field_0xf; if (temp != 0) { - PositionRelative(this->parent, this, 0, 0x80000); + PositionRelative(this->parent, this, 0, Q_16_16(8.0)); } else { this->subAction++; this->zVelocity = temp; @@ -97,7 +97,7 @@ void sub_0809D0AC(Entity* this) { SoundReq(SFX_SECRET); fx = CreateFx(this, FX_DASH, 0); if (fx != NULL) { - ResolveEntityBelow(this, fx); + SortEntityBelow(this, fx); } } } @@ -116,7 +116,7 @@ void sub_0809D10C(Entity* this) { void sub_0809D130(Entity* this) { if ((gPlayerState.flags & PL_MINISH) != 0) { sub_0800445C(this); - } else if (sub_08017850(this) != 0) { + } else if (IsCollidingPlayer(this) != 0) { CreateItemEntity(0x17, 0, 0); gSave.windcrests |= 0x10000000; DeleteThisEntity(); diff --git a/src/object/book.c b/src/object/book.c index 7c3bf57e..c0003115 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -98,7 +98,7 @@ void sub_0809B4A8(Entity* this) { gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.direction = gPlayerEntity.animationState << 2; - EnqueueSFX(0x10f); + EnqueueSFX(SFX_10F); } else { this->actionDelay = 0x16; } @@ -134,14 +134,14 @@ void sub_0809B56C(Entity* this) { fx = CreateFx(this, FX_DEATH, 0); if (fx) { - ResolveEntityOnTop(this, fx); + SortEntityAbove(this, fx); } } void sub_0809B5B4(Entity* this) { if (gPlayerState.flags & PL_MINISH) { sub_0800445C(this); - } else if (sub_08017850(this)) { + } else if (IsCollidingPlayer(this)) { CreateItemEntity(this->type + 0x39, 0, 0); DeleteThisEntity(); } diff --git a/src/object/button.c b/src/object/button.c index 1d1c88d9..61f4e704 100644 --- a/src/object/button.c +++ b/src/object/button.c @@ -90,7 +90,7 @@ void sub_08081C30(Entity* this) { this->action = 2; ClearFlag(this->field_0x86.HWORD); SetTileType(0x77, this->field_0x74.HWORD, this->collisionLayer); - SoundReq(SFX_10C); + SoundReq(SFX_BUTTON_PRESS); } } @@ -101,7 +101,6 @@ void sub_08081C98(Entity* this) { } Entity* sub_08081D74(Entity*); -u32 sub_080001DA(u32, u32); u32 sub_08081CB0(Entity* this) { u16 tmp; @@ -114,7 +113,7 @@ u32 sub_08081CB0(Entity* this) { } else { tmp = GetTileType(this->field_0x74.HWORD, this->collisionLayer); if (tmp != 0x77 && tmp != 0x79 && tmp != 0x4035) { - this->field_0x70.HALF.LO = sub_080001DA(this->field_0x74.HWORD, this->collisionLayer); + this->field_0x70.HALF.LO = GetTileIndex(this->field_0x74.HWORD, this->collisionLayer); return 1; } } @@ -129,14 +128,13 @@ u32 sub_08081D28(Entity* this) { if (this->field_0x70.HALF_U.LO == 0xFFFF) { return 0; } - if (sub_080001DA(this->field_0x74.HWORD, this->collisionLayer) != this->field_0x70.HALF_U.LO) { + if (GetTileIndex(this->field_0x74.HWORD, this->collisionLayer) != this->field_0x70.HALF_U.LO) { return 0; } } return 1; } -extern u32 sub_080002E0(u32, u32); extern Entity* gPlayerClones[3]; u32 sub_08081E0C(Entity*); @@ -252,7 +250,7 @@ u32 sub_08081F7C(Entity* this, u32 r7) { SetFlag(this->field_0x86.HWORD); SetTileType(r7, this->field_0x74.HWORD, this->collisionLayer); sub_08081F24(this); - SoundReq(SFX_10C); + SoundReq(SFX_BUTTON_PRESS); if (this->field_0x70.HALF_U.LO != 0xFFFF) SetTile(this->field_0x70.HALF_U.LO, this->field_0x74.HWORD, this->collisionLayer); return 0; @@ -261,8 +259,6 @@ u32 sub_08081F7C(Entity* this, u32 r7) { return 1; } -extern void sub_080044AE(Entity*, u32, u32); - void sub_08081FF8(Entity* this) { u32 direction; u32 i; diff --git a/src/object/fileScreenObjects.c b/src/object/fileScreenObjects.c index 921b0b97..f68a531d 100644 --- a/src/object/fileScreenObjects.c +++ b/src/object/fileScreenObjects.c @@ -256,7 +256,7 @@ void sub_0808EB74(Entity* this) { this->x.WORD = entity->x.WORD; this->y.WORD = entity->y.WORD; this->spriteRendering.b3 = entity->spriteRendering.b3; - ResolveEntityBelow(entity, this); + SortEntityBelow(entity, this); } else { this->x.HALF.HI = 0xF000; this->y.HALF.HI = 0xF000; @@ -306,7 +306,7 @@ void sub_0808EBB8(Entity* this) { default: entity = sub_0808EC80(var0); if (entity) { - ResolveEntityBelow(entity, this); + SortEntityBelow(entity, this); this->spriteRendering.b3 = entity->spriteRendering.b3; x = entity->x.HALF.HI; y = entity->y.HALF.HI; @@ -322,7 +322,7 @@ static Entity* sub_0808EC80(int form) { Entity* entityA = (Entity*)&gEntityLists[6]; Entity* entityB = entityA->next; while (entityB != entityA) { - if ((entityB->kind == 0x6 && entityB->id == 0x48) && form == entityB->type) { + if ((entityB->kind == OBJECT && entityB->id == 0x48) && form == entityB->type) { return entityB; } entityB = entityB->next; diff --git a/src/object/furniture.c b/src/object/furniture.c index c625d1fb..5683156c 100644 --- a/src/object/furniture.c +++ b/src/object/furniture.c @@ -5,7 +5,6 @@ #include "object.h" extern void sub_080001D0(u32, u32, u32); -extern u32 sub_080001DA(u32, u32); enum { FURNITURE_INIT, @@ -220,7 +219,7 @@ static void FurnitureInit(FurnitureEntity* this) { case SMITH_FORGE: e = CreateObject(FURNITURE, FORGE_HELPER, 0); if (e != NULL) { - PositionRelative(super, e, 0x100000, 0x100000); + PositionRelative(super, e, Q_16_16(16.0), Q_16_16(16.0)); e->frameIndex = 1; e->updatePriority = PRIO_MESSAGE; } @@ -374,7 +373,7 @@ static void sub_08090B6C(FurnitureEntity* this) { } static void sub_08090CDC(u32 id, u32 pos, u32 layer) { - u16 cur = sub_080001DA(pos, layer); + u16 cur = GetTileIndex(pos, layer); u32 next = cur; u32 id2; @@ -451,7 +450,7 @@ static void sub_08090E4C(FurnitureEntity* this) { void sub_08090E64(FurnitureEntity* this) { Entity* e = CreateObject(OBJECT_2A, 0, 0); if (e != NULL) { - PositionRelative(super, e, (s16)((u16)-2 + super->type2) * 0x10000, 0); + PositionRelative(super, e, Q_16_16((s16)((u16)-2 + super->type2)), 0); e->z.HALF.HI -= 16; e->collisionLayer = 2; UpdateSpriteForCollisionLayer(e); diff --git a/src/object/greatFairy.c b/src/object/greatFairy.c index 3a1f9a13..70210ffa 100644 --- a/src/object/greatFairy.c +++ b/src/object/greatFairy.c @@ -92,8 +92,8 @@ void GreatFairy_DormantUpdate(Entity* this) { case 289: ripple = GreatFairy_CreateForm(this, RIPPLE, 0); if (ripple) { - PositionRelative(this, ripple, (s32)GreatFairy_RippleOffsets[this->actionDelay] * 65536, - (s32)GreatFairy_RippleOffsets[this->actionDelay + 1] * 65536); + PositionRelative(this, ripple, Q_16_16(GreatFairy_RippleOffsets[this->actionDelay]), + Q_16_16(GreatFairy_RippleOffsets[this->actionDelay + 1])); this->actionDelay += 2; break; } @@ -105,7 +105,7 @@ void GreatFairy_CreateBigRipple(Entity* this) { ripple = GreatFairy_CreateForm(this, BIGRIPPLE, 0); if (ripple != NULL) { - PositionRelative(this, ripple, 0, 0x80000); + PositionRelative(this, ripple, 0, Q_16_16(8.0)); this->action = 3; } } @@ -137,7 +137,7 @@ void GreatFairy_MiniUpdate(Entity* this) { } else { target = GreatFairy_CreateForm(this, WINGS, 0); if (target != NULL) { - PositionRelative(this, target, 0, -0x140000); + PositionRelative(this, target, 0, Q_16_16(-20.0)); this->action = 5; this->actionDelay = 120; this->field_0xf = 0; @@ -153,7 +153,7 @@ void GreatFairy_FinalUpdate(Entity* this) { --this->actionDelay; } else { if ((this->field_0xf == 0) && (target = GreatFairy_CreateForm(this, FORM9, 0), target != NULL)) { - PositionRelative(this, target, 0, -0x4C0000); + PositionRelative(this, target, 0, Q_16_16(-76.0)); target->parent = this; this->field_0xf = 1; } @@ -236,7 +236,7 @@ void GreatFairy_MiniRisingUpdate(Entity* this) { } else { if (((this->z.HALF.HI == -10) && (this->field_0xf == 0)) && (target = GreatFairy_CreateForm(this, DROPLET, 0), target != NULL)) { - PositionRelative(this, target, 0, 0x40000); + PositionRelative(this, target, 0, Q_16_16(4.0)); this->field_0xf = 1; } } @@ -350,7 +350,7 @@ void GreatFairy_BigRippleUpdate(Entity* this) { } else { target = GreatFairy_CreateForm(this, MINI, 0); if (target != NULL) { - PositionRelative(this, target, 0, -0x80000); + PositionRelative(this, target, 0, Q_16_16(-8.0)); gRoomVars.animFlags |= 2; DeleteEntity(this); } diff --git a/src/object/gyorgBossObject.c b/src/object/gyorgBossObject.c index ea0dc245..3bef5d5f 100644 --- a/src/object/gyorgBossObject.c +++ b/src/object/gyorgBossObject.c @@ -418,7 +418,8 @@ void sub_080A1FF0(GyorgBossObjectEntity* this) { } } if (this->unk_7b) { - if (sub_0806FCB8(&gPlayerEntity, gRoomControls.origin_x + 0x200, gRoomControls.origin_y + 0x210, 0x100)) { + if (EntityWithinDistance(&gPlayerEntity, gRoomControls.origin_x + 0x200, gRoomControls.origin_y + 0x210, + 0x100)) { if (super->actionDelay == 0) { super->actionDelay = 0x78; } else { diff --git a/src/object/heartContainer.c b/src/object/heartContainer.c index 9e8346b3..a81709c4 100644 --- a/src/object/heartContainer.c +++ b/src/object/heartContainer.c @@ -59,7 +59,7 @@ static void sub_0808E714(Entity* this) { static void sub_0808E764(Entity* this) { sub_08080CB4(this); - if (!(gPlayerState.flags & PL_MINISH) && sub_08017850(this)) { + if (!(gPlayerState.flags & PL_MINISH) && IsCollidingPlayer(this)) { SetFlag(this->cutsceneBeh.HWORD); CreateItemEntity(0x62, 0, 0); DeleteThisEntity(); diff --git a/src/object/hittableLever.c b/src/object/hittableLever.c new file mode 100644 index 00000000..401e9671 --- /dev/null +++ b/src/object/hittableLever.c @@ -0,0 +1,79 @@ +/** + * @file hittableLever.c + * @ingroup Objects + * + * @brief Hittable Lever object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68[8]; + /*0x70*/ u16 wasHit; /**< Has this lever been hit before. */ + /*0x72*/ u8 unk_72[0x14]; + /*0x86*/ u16 hitFlag; +} HittableLeverEntity; + +extern void (*const HittableLever_Actions[])(HittableLeverEntity*); +extern const Hitbox HittableLever_Hitbox; + +void HittableLever_UpdateTile(HittableLeverEntity*); + +void HittableLever(HittableLeverEntity* this) { + if (super->iframes == 0) { + this->wasHit = 0; + } + HittableLever_Actions[super->action](this); +} + +void HittableLever_Init(HittableLeverEntity* this) { + super->action = 1; + super->flags |= ENT_COLLIDE; + super->field_0x3c = 7; + super->hitType = 0x8f; + super->flags2 = 0xa; + super->hitbox = (Hitbox*)&HittableLever_Hitbox; + if (super->type == 0) { + if (CheckFlags(this->hitFlag)) { + super->type = 1; + } else { + super->type = 0; + } + } else { + SetFlag(this->hitFlag); + } + HittableLever_UpdateTile(this); +} + +void HittableLever_Idle(HittableLeverEntity* this) { + if (((super->bitfield & 0x80) != 0) && (this->wasHit == 0)) { + this->wasHit = 1; + super->type ^= 1; + super->iframes = -0x18; + HittableLever_UpdateTile(this); + if (CheckFlags(this->hitFlag)) { + ClearFlag(this->hitFlag); + } else { + SetFlag(this->hitFlag); + } + SoundReqClipped(super, SFX_117); + } +} + +void HittableLever_UpdateTile(HittableLeverEntity* this) { + if (super->type != 0) { + sub_0807B7D8(0x378, COORD_TO_TILE(super), super->collisionLayer); + } else { + sub_0807B7D8(0x377, COORD_TO_TILE(super), super->collisionLayer); + } +} + +void (*const HittableLever_Actions[])(HittableLeverEntity*) = { + HittableLever_Init, + HittableLever_Idle, +}; +const Hitbox HittableLever_Hitbox = { 0, 1, { 0, 0, 0, 0 }, 4, 3 }; diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index a1495848..92ba70b8 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -105,7 +105,7 @@ void sub_0808681C(Entity* this) { this->action = 2; this->frameIndex = 1; } - if (this->flags & 0x2) { + if (this->flags & ENT_SCRIPTED) { this->action = 2; } break; @@ -119,7 +119,7 @@ void sub_0808681C(Entity* this) { break; } - if (this->flags & 0x2) { + if (this->flags & ENT_SCRIPTED) { ExecuteScript(this, *(ScriptExecutionContext**)&this->cutsceneBeh); sub_080868EC(this, *(void**)&this->cutsceneBeh); } @@ -158,7 +158,7 @@ static void sub_080868EC(Entity* entity, unk_80868EC* arg1) { } void sub_0808692C(Entity* this) { - this->flags &= 0xFD; + this->flags &= ~ENT_SCRIPTED; this->type2 = 2; this->action = this->frameIndex == 0 ? 1 : 2; this->subAction = 0; diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index 35cb741b..2643ade9 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -18,7 +18,7 @@ void sub_080813BC(Entity*); void sub_080810FC(Entity*); bool32 CheckShouldPlayItemGetCutscene(Entity*); -extern u32 sub_080177A0(Entity*, Entity*); +extern u32 IsColliding(Entity*, Entity*); extern void GiveItem(u32, u32); extern void (*const gUnk_0811E7D4[])(Entity*); @@ -149,7 +149,7 @@ void sub_080810A8(Entity* this) { } if (this->zVelocity == 0) { - this->zVelocity = 0x1E000; + this->zVelocity = Q_16_16(1.875); } if (this->collisionLayer == 2) { @@ -269,10 +269,10 @@ void sub_080812A8(Entity* this) { void sub_080812E8(Entity* this) { PlayerState* playerState = &gPlayerState; #ifdef EU - if ((playerState->swim_state & 0x80) && sub_080177A0(this, &gPlayerEntity)) { + if ((playerState->swim_state & 0x80) && IsColliding(this, &gPlayerEntity)) { #else if ((playerState->swim_state & 0x80) && (playerState->flags & PL_MINISH) == 0 && - sub_080177A0(this, &gPlayerEntity)) { + IsColliding(this, &gPlayerEntity)) { #endif sub_080810FC(this); } @@ -283,13 +283,13 @@ void nullsub_510(Entity* this) { void sub_08081328(Entity* this) { Entity* other = this->child; - if (!(other->kind == 8 && other->id == 3)) { + if (!(other->kind == PLAYER_ITEM && other->id == 3)) { sub_08081404(this, 0); } else { CopyPosition(other, this); this->z.HALF.HI--; other = &gPlayerEntity; - if (sub_080177A0(this, other)) { + if (IsColliding(this, other)) { sub_080810FC(this); } } @@ -412,7 +412,7 @@ void sub_0808153C(Entity* this) { if (this->field_0x68.HALF.LO == 0) { if (!GravityUpdate(this, 0x1000) && !sub_0800442E(this)) { this->field_0x68.HALF.LO = 1; - this->zVelocity = 0x1E000; + this->zVelocity = Q_16_16(1.875); sub_0808148C(this->type); UpdateSpriteForCollisionLayer(this); } @@ -432,7 +432,7 @@ void sub_08081598(Entity* this) { COLLISION_OFF(this); this->action = 4; this->actionDelay = 14; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); this->spriteSettings.draw = 1; this->spritePriority.b1 = 2; this->spritePriority.b0 = 3; diff --git a/src/object/jarPortal.c b/src/object/jarPortal.c index 61ebb19a..a482621d 100644 --- a/src/object/jarPortal.c +++ b/src/object/jarPortal.c @@ -60,7 +60,7 @@ void sub_0808BF58(Entity* this) { GravityUpdate(this, 0x2000); switch (this->subAction) { case 0: - if (this->zVelocity <= 98303) { + if (this->zVelocity < Q_16_16(1.5)) { ++this->subAction; InitAnimationForceUpdate(this, 2); } @@ -69,7 +69,7 @@ void sub_0808BF58(Entity* this) { UpdateAnimationSingleFrame(this); if (!this->z.HALF.HI) { ++this->subAction; - this->zVelocity = 0x8000; + this->zVelocity = Q_16_16(0.5); } break; case 2: @@ -128,7 +128,7 @@ void sub_0808C0AC(Entity* this) { GravityUpdate(this, 0x2000); switch (this->subAction) { case 0: - if (this->zVelocity <= 98303) { + if (this->zVelocity < Q_16_16(1.5)) { this->subAction = 1; InitAnimationForceUpdate(this, 3); } @@ -137,7 +137,7 @@ void sub_0808C0AC(Entity* this) { UpdateAnimationSingleFrame(this); if (!this->z.HALF.HI) { ++this->subAction; - this->zVelocity = 0x8000; + this->zVelocity = Q_16_16(0.5); } break; case 2: @@ -157,7 +157,7 @@ u32 sub_0808C128(Entity* this) { void sub_0808C13C(Entity* this) { this->subAction = 0; - this->zVelocity = 163840; + this->zVelocity = Q_16_16(2.5); } void sub_0808C148(Entity* this, u32 a2) { diff --git a/src/object/lightableSwitch.c b/src/object/lightableSwitch.c index 639ffa17..a8d9dffd 100644 --- a/src/object/lightableSwitch.c +++ b/src/object/lightableSwitch.c @@ -48,7 +48,7 @@ void sub_0809EA80(Entity* this) { } else { SetFlag(this->field_0x86.HWORD); } - EnqueueSFX(0x110); + EnqueueSFX(SFX_110); } sub_0809EABC(this); } @@ -121,7 +121,7 @@ void sub_0809EBD8(Entity* this) { this->actionDelay = 0x10; this->frameIndex = 2; SetFlag(this->field_0x86.HWORD); - EnqueueSFX(0x110); + EnqueueSFX(SFX_110); } } @@ -135,7 +135,7 @@ void sub_0809EC08(Entity* this) { this->action = 1; this->frameIndex = 3; ClearFlag(this->field_0x86.HWORD); - EnqueueSFX(0x110); + EnqueueSFX(SFX_110); } } } diff --git a/src/object/lilypadLarge.c b/src/object/lilypadLarge.c new file mode 100644 index 00000000..9a7fe9d4 --- /dev/null +++ b/src/object/lilypadLarge.c @@ -0,0 +1,385 @@ +/** + * @file lilypadLarge.c + * @ingroup Objects + * + * @brief Large Lilypad object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "area.h" +#include "functions.h" +#include "item.h" +#include "object.h" + +typedef struct { + Entity base; + u8 unk_68[4]; + s32 unk_6c; + s32 unk_70; + s16 unk_74; + s16 unk_76; + union SplitWord unk_78; + union SplitWord unk_7c; + u8 unk_80[2]; + u16 unk_82; + u8 unk_84; + u8 unk_85; +} LilypadLargeEntity; + +extern void (*const gUnk_08120608[])(LilypadLargeEntity*); +extern Hitbox gUnk_08120640; +extern void (*const gUnk_0812062C[])(LilypadLargeEntity*); +extern u8 gUnk_08120638[]; +extern u8 gUnk_08126EE4[]; +extern u32 gUnk_08120620[]; + +void sub_080855E8(LilypadLargeEntity*); +void sub_08085CDC(LilypadLargeEntity*); +void sub_08085EFC(LilypadLargeEntity*); +void sub_08085F1C(LilypadLargeEntity*); +void sub_08085E74(LilypadLargeEntity*); +void sub_08085F48(LilypadLargeEntity*); +void sub_08085D28(LilypadLargeEntity*); +void sub_08085D60(LilypadLargeEntity*); + +void LilypadLarge(LilypadLargeEntity* this) { + gUnk_08120608[super->action](this); +} + +void sub_08085504(LilypadLargeEntity* this) { + if (super->type == 0xff) { + if (GetInventoryValue(ITEM_FLIPPERS)) { + DeleteThisEntity(); + } + super->type = 0; + } + if (super->type != 0) { + if (gArea.locationIndex == 0x1b) { + if (CheckLocalFlag(super->type2) == 0) { + DeleteThisEntity(); + } + } else { + if (CheckLocalFlag(super->type2) == 0) { + super->action = 5; + return; + } + } + } + if (super->actionDelay != 0) { + if (sub_080040A2(super) == 0) { + DeleteThisEntity(); + } + super->actionDelay = 0; + } else { + if (EntityHasDuplicateID(super) != 0) { + DeleteThisEntity(); + } + } + super->action = 1; + super->speed = 0x100; + super->spritePriority.b0 = 6; + super->hitbox = &gUnk_08120640; + super->flags |= ENT_COLLIDE; + super->field_0x3c = 7; + super->hitType = 1; + super->flags2 = 4; + this->unk_78.WORD = 0x1000000; + this->unk_7c.HALF_U.HI = 0x1000; + this->unk_85 = 0; + this->unk_84 = 0; + InitializeAnimation(super, 9); + sub_080855E8(this); +} + +ASM_FUNC("asm/non_matching/lilypadLarge/sub_080855E8.inc", void sub_080855E8(LilypadLargeEntity* this)); + +void sub_08085A1C(LilypadLargeEntity* this) { + gUnk_0812062C[super->subAction](this); + gPlayerState.flags |= 2; + sub_08078B48(); +} + +void sub_08085A44(LilypadLargeEntity* this) { + super->speed = 0x200; + if (sub_080002B4(super, 0x10, 0x18) != 0x11) { + super->direction = 0x18; + } else { + if (sub_080002B4(super, 0xfffffff0, 0x18) != 0x11) { + super->direction = 8; + } else { + super->direction = 0x10; + super->subAction = 1; + return; + } + } + sub_08085EFC(this); + sub_080AF134(super); + sub_08085F1C(this); +} + +void sub_08085A98(LilypadLargeEntity* this) { + sub_08085EFC(this); + LinearMoveUpdate(super); + sub_08085F1C(this); + if (0x7fffff < (u32)this->unk_78.WORD) { + this->unk_78.WORD -= 0x20000; + sub_0805EC9C(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); + } + if (sub_080002B4(super, 0, 0x18) != 0x11) { + super->subAction = 2; + if (gArea.locationIndex == 0x1b) { + super->y.HALF.HI += 0xd0; + super->z.HALF.HI = 0xff30; + this->unk_82 = 0x46; + SetLocalFlag(0x73); + } else { + super->y.HALF.HI += 0x40; + super->z.HALF.HI = 0xffc0; + this->unk_82 = 0xf; + } + CreateObjectWithParent(super, OBJECT_2B, 0, 0); + SoundReq(SFX_12D); + } +} + +void sub_08085B40(LilypadLargeEntity* this) { + if (super->z.WORD != 0) { + if (GravityUpdate(super, 0x2000) != 0) { + if ((u32)this->unk_78.WORD < 0x1200000) { + this->unk_78.WORD += 0x100000; + sub_0805EC9C(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); + } + gPlayerEntity.y.HALF.HI = (super->y.HALF.HI + super->z.HALF.HI) - this->unk_74; + if (gArea.locationIndex == 0x1b) { + gPlayerEntity.z.HALF.HI = super->y.HALF.HI - this->unk_74 - 0xd0 - gPlayerEntity.y.HALF.HI; + } else { + gPlayerEntity.z.HALF.HI = super->y.HALF.HI - this->unk_74 - 0x40 - gPlayerEntity.y.HALF.HI; + } + } + } else { + ResetCollisionLayer(super); + if (sub_080002B8(super) == 0xd) { + ResetCollisionLayer(&gPlayerEntity); + sub_08085CDC(this); + super->direction = GetFacingDirection(&gPlayerEntity, super); + LinearMoveDirection(&gPlayerEntity, 0x100, super->direction); + } + } + + if (this->unk_82 == 0) { + if (GravityUpdate(&gPlayerEntity, 0x2000) == 0) { + ResetCollisionLayer(&gPlayerEntity); + sub_08085F1C(this); + super->action = 1; + super->field_0xf = 4; + while (super->field_0xf != 0) { + sub_080A2AF4(super, 8, 10); + super->field_0xf--; + } + super->field_0xf = 1; + super->actionDelay |= 0x80; + this->unk_70 = 0; + this->unk_6c = 0; + if (sub_080002B8(super) == 0xd) { + super->action = 4; + } + } + } else { + this->unk_82--; + } +} + +void sub_08085C5C(LilypadLargeEntity* this) { + if (sub_0806FC80(super, &gPlayerEntity, 0x18) != 0) { + LinearMoveUpdate(super); + gPlayerEntity.speed = super->speed; + gPlayerEntity.direction = super->direction; + LinearMoveUpdate(&gPlayerEntity); + gPlayerState.flags |= 2; + if (super->collisionLayer == 1) { + ResetCollisionLayer(&gPlayerEntity); + } else { + sub_08004542(&gPlayerEntity); + } + } + if (gRoomControls.reload_flags == 0) { + super->flags &= ~ENT_PERSIST; + super->action = 1; + super->updatePriority = super->updatePriorityPrev; + gRoomControls.camera_target = &gPlayerEntity; + } +} + +void sub_08085CDC(LilypadLargeEntity* this) { + this->unk_78.WORD += 0x100000; + if (this->unk_78.WORD_U < 0x4000000) { + sub_0805EC9C(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); + } else { + DeleteThisEntity(); + } +} + +void sub_08085D10(LilypadLargeEntity* this) { + if (EntityHasDuplicateID(super) != 0) { + SetLocalFlag(super->type2); + DeleteThisEntity(); + } +} + +void sub_08085D28(LilypadLargeEntity* this) { + if (((gPlayerState.framestate != PL_STATE_TALKEZLO) && ((gPlayerState.flags & 2) != 0)) && + (sub_080002B4(super, 0, 0x18) == 0x11)) { + super->action = 2; + super->subAction = 0; + sub_08078B48(); + } +} + +NONMATCH("asm/non_matching/lilypadLarge/sub_08085D60.inc", void sub_08085D60(LilypadLargeEntity* this)) { + u32 r4; // horizontal direction? + u32 r6; // vertical direction? + if ((gPlayerState.flags & 2) != 0) { + if (gPlayerState.framestate != PL_STATE_DIE) { + if (gPlayerState.jump_status == 0) { + if ((super->direction & 7) == 0) { // North or South + r4 = super->direction; + r6 = super->direction; + } else { + if ((super->direction & 0x10) != 0) { // South(already top) or West + r4 = DirectionWest; + } else { + r4 = DirectionEast; + } + if (super->direction - 8 > 0x10) { // North(already top) or West(?) + r6 = DirectionNorth; + } else { + r6 = DirectionSouth; + } + } + if (r4 == DirectionWest || r4 == DirectionEast) { // Handle horizontal + u32 tmp = r4 >> 2; + s32 tmpX = gUnk_08120638[tmp]; + s32 tmpY = gUnk_08120638[tmp + 1]; + if (sub_080002CC(super, tmpX, tmpY) == 0xff) { + + if (sub_080806BC((super->x.HALF.HI - gRoomControls.origin_x) + tmpX, + (super->y.HALF.HI - gRoomControls.origin_y) + tmpY, r4, 5) == 0) { + if (sub_0807BD14(&gPlayerEntity, r4 >> 3) != 0) { + super->direction = r4; + sub_08085E74(this); + return; + } + } else { + super->direction = r4; + return; + } + } + } + if (r6 == DirectionNorth || r6 == DirectionSouth) { // Handle vertical + u32 tmp = r6 >> 2; + s32 tmpX = (u8)gUnk_08120638[tmp]; + s32 tmpY = gUnk_08120638[tmp + 1]; + if (sub_080002CC(super, tmpX, tmpY) == 0xff) { + if (sub_0807BD14(&gPlayerEntity, r6 >> 3) != 0) { + super->direction = (u8)r6; + sub_08085E74(this); + } + } + } + return; + } + } + } + super->flags &= ~ENT_PERSIST; +} +END_NONMATCH + +void sub_08085E74(LilypadLargeEntity* this) { + super->flags |= ENT_PERSIST; + super->updatePriority = 6; + super->action = 3; + switch (super->direction) { + case DirectionNorth: + super->speed = 0x120; + break; + case DirectionSouth: + super->speed = 0x138; + break; + case DirectionEast: + case DirectionWest: + super->speed = 0x100; + break; + } + this->unk_70 = 0; + this->unk_6c = 0; + super->x.HALF.LO = 0; + super->y.HALF.LO = 0; + gPlayerEntity.x.HALF.LO = 0; + gPlayerEntity.y.HALF.LO = 0; + gPlayerEntity.direction = super->direction; + gPlayerState.animation = 0x100; + gRoomControls.camera_target = super; + if (gPlayerState.item != NULL) { + DeleteEntity(gPlayerState.item); + } + ResetPlayer(); +} + +void sub_08085EFC(LilypadLargeEntity* this) { + this->unk_76 = super->x.HALF.HI - gPlayerEntity.x.HALF.HI; + this->unk_74 = super->y.HALF.HI - gPlayerEntity.y.HALF.HI; +} + +void sub_08085F1C(LilypadLargeEntity* this) { + gPlayerEntity.x.HALF.HI = super->x.HALF.HI - this->unk_76; + gPlayerEntity.y.HALF.HI = super->y.HALF.HI - this->unk_74; + sub_0807A5B8(super->direction); +} + +void sub_08085F48(LilypadLargeEntity* this) { + u32 tmp = super->actionDelay & 0x80; + if (tmp != 0) { + if (gPlayerState.floor_type == 0x17) { + ResetPlayerVelocity(); + gPlayerState.floor_type = 0x19; + } + SoundReq(SFX_WATER_WALK); + if (this->unk_78.WORD_U < 0x1280000) { + this->unk_78.WORD_U += 0x80000; + } else { + super->actionDelay = 0; + } + } else { + if ((gPlayerState.flags & 2) != 0) { + if (super->actionDelay != 0) { + if (this->unk_78.WORD_U < 0x1200000) { + this->unk_78.WORD_U += 0x8000; + } else { + super->actionDelay = tmp; + } + } else { + if (this->unk_78.WORD_U > 0x1100000) { + this->unk_78.WORD_U -= 0x8000; + } else { + super->actionDelay = 1; + } + } + } else { + if (super->actionDelay != 0) { + if (this->unk_78.WORD_U < 0x1100000) { + this->unk_78.WORD_U += 0x4000; + } else { + super->actionDelay = 0; + } + } else { + if (this->unk_78.WORD_U > 0x1060000) { + this->unk_78.WORD_U -= 0x4000; + } else { + super->actionDelay = 1; + } + } + } + } + sub_0805EC9C(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); +} diff --git a/src/object/lockedDoor.c b/src/object/lockedDoor.c index 5ebe073f..74cb0e55 100644 --- a/src/object/lockedDoor.c +++ b/src/object/lockedDoor.c @@ -37,7 +37,6 @@ void LockedDoor(Entity* this) { extern Hitbox gHitbox_2; -extern u32 sub_080001DA(u32, u32); extern void sub_08078850(Entity*, u32, u32, u32); typedef struct PACKED { @@ -102,7 +101,7 @@ void sub_08083338(Entity* this) { this->spritePriority.b0 = 5; this->frame = this->type & 0xF; this->field_0x76.HWORD = TILE(this->x.HALF.HI, this->y.HALF.HI); - this->field_0x74.HWORD = sub_080001DA(this->field_0x76.HWORD, this->collisionLayer); + this->field_0x74.HWORD = GetTileIndex(this->field_0x76.HWORD, this->collisionLayer); switch (this->type2) { case 0: if (!CheckFlags(this->field_0x86.HWORD)) { @@ -149,7 +148,7 @@ void sub_080834B4(Entity* this) { this->action = 2; this->actionDelay = 7; SetTile(this->field_0x74.HWORD, this->field_0x76.HWORD, this->collisionLayer); - EnqueueSFX(0x10b); + EnqueueSFX(SFX_10B); } } @@ -185,7 +184,7 @@ void sub_08083540(Entity* this) { } } sub_08083814(this, this->field_0x7c.BYTES.byte2); - EnqueueSFX(0x10b); + EnqueueSFX(SFX_10B); } } diff --git a/src/object/mask.c b/src/object/mask.c index 4e9810c3..00c9e957 100644 --- a/src/object/mask.c +++ b/src/object/mask.c @@ -4,8 +4,6 @@ extern void (*MaskActionFuncs[])(Entity*); extern void sub_08000148(u16, u16, u32); -extern s16 sub_080001DA(u16, u32); -extern u16 sub_080002E0(u16, u32); extern void sub_0805457C(Entity*, s32); @@ -40,7 +38,7 @@ void sub_080929A4(Entity* this) { } this->action = 1; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->field_0x78.HWORD = ((Random() & 7) << 10) | 0x2000; @@ -49,10 +47,10 @@ void sub_080929A4(Entity* this) { this->frameIndex = this->type2 & 0x3f; - this->field_0x7c.HALF.HI = COORD_TO_TILE(this); - this->field_0x7c.HALF.LO = sub_080001DA(this->field_0x7c.HALF.HI, 1); + this->field_0x7c.HALF_U.HI = COORD_TO_TILE(this); + this->field_0x7c.HALF_U.LO = GetTileIndex(this->field_0x7c.HALF_U.HI, 1); - this->field_0x7a.HWORD = sub_080002E0(this->field_0x7c.HALF.HI, 1); + this->field_0x7a.HWORD = sub_080002E0((u16)this->field_0x7c.HALF.HI, 1); SetTile(0x4022, this->field_0x7c.HALF_U.HI, 1); } @@ -60,7 +58,7 @@ void sub_080929A4(Entity* this) { // Probably related to knocking it down void sub_08092A94(Entity* this) { // Check for the first frame of bonking animation - if (gPlayerEntity.action != 6) { + if (gPlayerEntity.action != PLAYER_BOUNCE) { return; } @@ -99,7 +97,7 @@ void sub_08092B0C(Entity* this) { this->actionDelay = 0; switch (this->type2 & 0xC0) { case 0x80: - EnqueueSFX(0x72); + EnqueueSFX(SFX_SECRET); case 0x40: SetFlag(this->field_0x86.HWORD); break; diff --git a/src/object/metalDoor.c b/src/object/metalDoor.c index ed89d276..2146a801 100644 --- a/src/object/metalDoor.c +++ b/src/object/metalDoor.c @@ -10,7 +10,6 @@ extern u32 sub_08083734(Entity*, u32); extern void sub_080A080C(Entity*); extern void sub_080A0870(Entity*); -extern u32 sub_080001DA(u32, u32); extern void (*const gUnk_0812493C[])(Entity*); @@ -68,7 +67,7 @@ void sub_080A074C(Entity* this) { ent->x.HALF.HI -= 0xc; ent->y.HALF.HI -= 0xc; } - EnqueueSFX(0x10b); + EnqueueSFX(SFX_10B); } } @@ -93,9 +92,9 @@ void sub_080A07F0(Entity* this) { } void sub_080A080C(Entity* this) { - this->field_0x76.HWORD = sub_080001DA(this->field_0x74.HWORD - 1, this->collisionLayer); - this->field_0x78.HWORD = sub_080001DA(this->field_0x74.HWORD, this->collisionLayer); - this->field_0x7a.HWORD = sub_080001DA(this->field_0x74.HWORD + 1, this->collisionLayer); + this->field_0x76.HWORD = GetTileIndex(this->field_0x74.HWORD - 1, this->collisionLayer); + this->field_0x78.HWORD = GetTileIndex(this->field_0x74.HWORD, this->collisionLayer); + this->field_0x7a.HWORD = GetTileIndex(this->field_0x74.HWORD + 1, this->collisionLayer); SetTile(0x4022, this->field_0x74.HWORD - 1, this->collisionLayer); SetTile(0x4022, this->field_0x74.HWORD, this->collisionLayer); SetTile(0x4022, this->field_0x74.HWORD + 1, this->collisionLayer); diff --git a/src/object/minecart.c b/src/object/minecart.c index fee9da56..0de7e4c3 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -2,7 +2,6 @@ #include "functions.h" extern u32 sub_08091DDC(Entity*); -extern u32 sub_080002B4(Entity*, u32, u32); extern u32 sub_08007DD6(u32, u32); extern void sub_08017744(Entity*); extern void sub_08091C0C(Entity*); @@ -46,7 +45,7 @@ void sub_080916EC(Entity* this) { void sub_080917DC(Entity* this) { if ((this->bitfield & 0x7f) == 0x1d) { - this->zVelocity = 0x2a000; + this->zVelocity = Q_16_16(2.625); this->action = 7; InitAnimationForceUpdate(this, this->type2 + 4 + this->animationState); SoundReq(SFX_13B); @@ -66,7 +65,7 @@ void sub_080917DC(Entity* this) { this->action++; gPlayerState.jump_status = 0x81; gPlayerState.flags |= PL_ENTER_MINECART; - gPlayerEntity.zVelocity = 0x20000; + gPlayerEntity.zVelocity = Q_16_16(2.0); gPlayerEntity.speed = 0x100; gPlayerEntity.flags &= ~PL_MINISH; ResetPlayer(); @@ -161,7 +160,7 @@ void sub_080919AC(Entity* this) { sub_08017744(this); gPlayerState.jump_status = 0x41; gPlayerState.flags = (gPlayerState.flags ^ PL_IN_MINECART) | PL_ENTER_MINECART; - gPlayerEntity.zVelocity = 0x20000; + gPlayerEntity.zVelocity = Q_16_16(2.0); gPlayerEntity.speed = 0x200; gPlayerEntity.animationState = this->animationState << 1; gPlayerEntity.direction = this->direction; diff --git a/src/object/object2A.c b/src/object/object2A.c index 5ef7ba3e..743eb305 100644 --- a/src/object/object2A.c +++ b/src/object/object2A.c @@ -4,13 +4,15 @@ #include "functions.h" #include "flags.h" -extern void (*const gUnk_08120DD0[])(Entity*); +extern void sub_0807AB44(Entity*, s32, s32); + +void (*const gUnk_08120DD0[])(Entity*); void Object2A(Entity* this) { gUnk_08120DD0[this->action](this); } -void sub_08089B18(Entity* this) { +void Object2A_Init(Entity* this) { this->action = 1; this->spriteSettings.draw = TRUE; if (this->type2 != 0) { @@ -36,5 +38,61 @@ void sub_08089B18(Entity* this) { return; } } - EnqueueSFX(0x124); + EnqueueSFX(SFX_124); } + +void sub_08089BA0(Entity* this) { + u32 val; + GetNextFrame(this); + + switch (this->type) { + case 0: + default: + if (this->type2 == 0) + return; + case 1: + case 2: + if (--this->actionDelay != 0xff) + return; + if (this->type == 2) { + sub_0807B7D8(((u16*)this->child)[3], COORD_TO_TILE(this), this->collisionLayer); + sub_0807AB44(this, 0, 0x10); + sub_0807AB44(this, 0, -0x10); + sub_0807AB44(this, 0x10, 0); + sub_0807AB44(this, -0x10, 0); + } + DeleteThisEntity(); + break; + case 3: + if (this->parent->next == NULL) { + DeleteThisEntity(); + } + if (--this->actionDelay == 0) { + DeleteThisEntity(); + } + + CopyPosition(this->parent, this); + break; + case 4: + val = CheckFlags(this->field_0x86.HWORD); + if (this->subAction == 0) { + if (val) + return; + this->subAction = 1; + this->spriteSettings.draw = 0; + } else { + if (!val) + return; + this->subAction = 0; + this->spriteSettings.draw = 1; + InitializeAnimation(this, 0); + EnqueueSFX(SFX_124); + } + break; + } +} + +void (*const gUnk_08120DD0[])(Entity*) = { + Object2A_Init, + sub_08089BA0, +}; diff --git a/src/object/object49.c b/src/object/object49.c index f1873fc2..c65b41bf 100644 --- a/src/object/object49.c +++ b/src/object/object49.c @@ -178,14 +178,14 @@ void sub_0808F3DC(Entity* this) { // TODO: This block of code might supposed to be a switch statement. if (this->type != 8) { if (this->type == 7) { - ResolveEntityBelow(this->child, this); + SortEntityBelow(this->child, this); return; } } else { this->hitType = this->child->hitType; this->child->hitType = 0x7E; } - ResolveEntityOnTop(this->child, this); + SortEntityAbove(this->child, this); } else { if (*(u32*)&this->parent->field_0x74 == 0) { if (this->type == 8) { diff --git a/src/object/object6A.c b/src/object/object6A.c index 6813f69c..e3750c43 100644 --- a/src/object/object6A.c +++ b/src/object/object6A.c @@ -212,7 +212,7 @@ void sub_08094C30(Object6AEntity* this) { DeleteThisEntity(); if (super->action == 0) { super->action++; - SetDefaultPriority(super, 2); + SetDefaultPriority(super, PRIO_MESSAGE); super->spriteRendering.b3 = gUnk_08114F30[p->spriteRendering.b3]; InitAnimationForceUpdate(super, 1); } @@ -231,13 +231,13 @@ void sub_08094C88(Object6AEntity* this) { } else { super->action++; super->spriteSettings.draw = 1; - SetDefaultPriority(super, 3); + SetDefaultPriority(super, PRIO_NO_BLOCK); switch (super->type2) { case 0x40: case 0x41: case 0x42: case 0x43: - ResolveEntityBelow(super, super); + SortEntityBelow(super, super); } } @@ -250,8 +250,8 @@ void sub_08094C88(Object6AEntity* this) { void sub_08094CDC(Object6AEntity* this) { Entity* e = CreateObject(0x6a, 3, 0x62); if (e != NULL) { - e->x.HALF.HI = gRoomControls.origin_x + 224; - e->y.HALF.HI = gRoomControls.origin_y + 600; + e->x.HALF.HI = gRoomControls.origin_x + Q_8_8(7.0 / 8.0); + e->y.HALF.HI = gRoomControls.origin_y + Q_8_8(2.345); SoundReq(324); } } @@ -266,8 +266,8 @@ void sub_08094D10(Object6AEntity* this) { void sub_08094D34(Object6AEntity* this) { Entity* e = CreateObject(0x6a, 0x15, 0xd); if (e != NULL) { - e->x.HALF.HI = gRoomControls.origin_x + 256; - e->y.HALF.HI = gRoomControls.origin_y + 600; + e->x.HALF.HI = gRoomControls.origin_x + Q_8_8(1.0); + e->y.HALF.HI = gRoomControls.origin_y + Q_8_8(2.345); SoundReq(324); } } @@ -290,7 +290,7 @@ void sub_08094D94(Object6AEntity* this) { } else { super->action++; super->spriteSettings.draw = 1; - SetDefaultPriority(super, 3); + SetDefaultPriority(super, PRIO_NO_BLOCK); InitAnimationForceUpdate(super, 0); } UpdateAnimationSingleFrame(super); @@ -299,8 +299,8 @@ void sub_08094D94(Object6AEntity* this) { void sub_08094DD8(Object6AEntity* this) { Entity* e = CreateObject(0x6a, 0x4, 0); if (e != NULL) { - e->x.HALF.HI = gRoomControls.origin_x + 240; - e->y.HALF.HI = gRoomControls.origin_y + 600; + e->x.HALF.HI = gRoomControls.origin_x + Q_8_8(15.0 / 16.0); + e->y.HALF.HI = gRoomControls.origin_y + Q_8_8(2.345); SoundReq(324); } } @@ -330,7 +330,7 @@ void sub_08094E30(Object6AEntity* this) { super->action++; super->z.WORD = -0xA00000; super->zVelocity = 0; - SetDefaultPriority(super, 6); + SetDefaultPriority(super, PRIO_PLAYER_EVENT); InitializeAnimation(super, 0); if (sub_080002B8(super) == 13) { super->action = 3; @@ -338,13 +338,13 @@ void sub_08094E30(Object6AEntity* this) { break; case 1: super->z.WORD -= super->zVelocity; - super->zVelocity -= 0x2000; + super->zVelocity -= Q_8_8(32.0); if (super->z.WORD > 0) { super->action++; super->z.WORD = 0; super->zVelocity = 0; InitializeAnimation(super, 1); - EnqueueSFX(382); + EnqueueSFX(SFX_LAVA_TILE_FLIP); } break; case 2: @@ -355,7 +355,7 @@ void sub_08094E30(Object6AEntity* this) { break; case 3: super->z.WORD -= super->zVelocity; - super->zVelocity -= 0x2000; + super->zVelocity -= Q_8_8(32.0); if (!CheckOnScreen(super)) { DeleteThisEntity(); } @@ -413,7 +413,7 @@ void sub_08094FA8(Object6AEntity* this) { } break; case 3: - if (gPlayerEntity.action != 12) { + if (gPlayerEntity.action != PLAYER_EMPTYBOTTLE) { super->action = 4; #ifndef EU if (!CheckGlobalFlag(BIN_DOGFOOD)) { @@ -472,8 +472,8 @@ void sub_08095088(Object6AEntity* this) { void sub_08095120(Object6AEntity* this) { if (super->action == 0) { super->action = 1; - SetDefaultPriority(super, 3); - ResolveEntityBelow(super, super); + SetDefaultPriority(super, PRIO_NO_BLOCK); + SortEntityBelow(super, super); sub_0807DD64(super); InitAnimationForceUpdate(super, 2); } @@ -492,8 +492,8 @@ void sub_08095164(Object6AEntity* this) { void sub_08095188(Object6AEntity* this) { if (super->action == 0) { super->action = 1; - SetDefaultPriority(super, 3); - ResolveEntityBelow(super, super); + SetDefaultPriority(super, PRIO_NO_BLOCK); + SortEntityBelow(super, super); sub_0807DD64(super); InitAnimationForceUpdate(super, 0); } @@ -535,7 +535,7 @@ void sub_08095244(Object6AEntity* this) { Entity* e = CreateObject(OBJECT_6A, 0xA, 0); if (e != NULL) { e->parent = super; - PositionRelative(super, e, 0x100000, -0x100000); + PositionRelative(super, e, Q_16_16(16.0), -Q_16_16(16.0)); ((Object6AEntity*)e)->ctx = StartCutscene(e, &script_Object6ASwordInChest); } } @@ -547,7 +547,7 @@ void sub_08095288(Object6AEntity* this) { if (super->action == 0) { super->action++; super->subAction = 0; - SetDefaultPriority(super, 3); + SetDefaultPriority(super, PRIO_NO_BLOCK); InitAnimationForceUpdate(super, 0); } if (super->subAction != 0) { @@ -583,7 +583,7 @@ void sub_08095330(Object6AEntity* this) { e->parent = super; CopyPosition(super, e); e->z.HALF.HI = -16; - ResolveEntityOnTop(e, e); + SortEntityAbove(e, e); } } @@ -597,7 +597,7 @@ void sub_08095364(Object6AEntity* this) { e->subAction = 1; e->z.HALF.HI = -16; e->direction = 7; - e->zVelocity = 0x30000; + e->zVelocity = Q_16_16(3.0); e->speed = 128; InitAnimationForceUpdate(e, 1); } @@ -607,9 +607,9 @@ void sub_080953A4(Object6AEntity* this) { if (super->action == 0) { super->action++; super->z.HALF.HI = -16; - SetDefaultPriority(super, 2); + SetDefaultPriority(super, PRIO_MESSAGE); super->spriteRendering.b3 = gUnk_08114F30[super->spriteRendering.b3]; - ResolveEntityOnTop(super, super); + SortEntityAbove(super, super); sub_0807DD64(super); } ExecuteScriptForEntity(super, 0); @@ -625,7 +625,7 @@ void sub_080953A4(Object6AEntity* this) { void sub_08095420(Object6AEntity* this, ScriptExecutionContext* ctx) { Entity* e = CreateObject(OBJECT_6A, 0xC, 0); if (e != NULL) { - PositionRelative(super, e, 0, -0x100000); + PositionRelative(super, e, 0, Q_16_16(-16)); ((Object6AEntity*)e)->ctx = StartCutscene(e, (u16*)ctx->intVariable); } } @@ -637,7 +637,7 @@ void sub_0809545C(Object6AEntity* this, ScriptExecutionContext* ctx) { Entity* p = CreateObject(OBJECT_6A, 0xD, 0); Entity* e; if (p != NULL) { - PositionRelative(super, p, 0, -0x100000); + PositionRelative(super, p, 0, Q_16_16(-16)); ((Object6AEntity*)p)->ctx = StartCutscene(p, (u16*)ctx->intVariable); e = CreateObject(OBJECT_6A, 2, 0); if (e != NULL) { @@ -692,7 +692,7 @@ void sub_080954DC(Object6AEntity* this) { super->y.HALF.HI += this->py; break; case 3: - sub_0806F62C(super, super->speed, super->direction); + LinearMoveAngle(super, super->speed, super->direction); break; } this->off += 4; @@ -764,7 +764,7 @@ void sub_08095754(Object6AEntity* this) { if (e != NULL) { e->parent = super; CopyPosition(super, e); - ResolveEntityBelow(super, e); + SortEntityBelow(super, e); } } @@ -784,7 +784,7 @@ void sub_080957B4(Object6AEntity* this) { if (e != NULL) { e->parent = super; CopyPosition(super, e); - ResolveEntityBelow(super, e); + SortEntityBelow(super, e); } } @@ -804,7 +804,7 @@ void sub_08095810(Object6AEntity* this) { if (e != NULL) { e->parent = super; CopyPosition(super, e); - ResolveEntityOnTop(super, e); + SortEntityAbove(super, e); ((Object6AEntity*)e)->ctx = StartCutscene(e, &script_ZeldaMagic); } } @@ -847,7 +847,7 @@ void sub_080958D8(Object6AEntity* this) { void sub_08095918(Object6AEntity* this) { if (super->action == 0) { super->action++; - SetDefaultPriority(super, 6); + SetDefaultPriority(super, PRIO_PLAYER_EVENT); sub_0807DD64(super); InitializeAnimation(super, 0); } @@ -871,7 +871,7 @@ void sub_08095954(Object6AEntity* this) { PositionRelative(super, e, x, y); e->z.HALF.HI = -3; ((Object6AEntity*)e)->ctx = StartCutscene(e, &script_08012C48); - EnqueueSFX(292); + EnqueueSFX(SFX_124); super->frame &= ~1; } else { gActiveScriptInfo.syncFlags |= 0x100; @@ -882,7 +882,7 @@ void sub_080959CC(Object6AEntity* this) { if (super->action == 0) { super->action++; super->spriteSettings.draw = 0; - SetDefaultPriority(super, 3); + SetDefaultPriority(super, PRIO_NO_BLOCK); sub_0807DD64(super); } ExecuteScriptForEntity(super, 0); @@ -1038,7 +1038,7 @@ void sub_08095CE0(Object6AEntity* this) { if (super->action == 0) { super->action++; super->spriteSettings.draw = 0; - SetDefaultPriority(super, 6); + SetDefaultPriority(super, PRIO_PLAYER_EVENT); sub_0807DD64(super); } ExecuteScriptForEntity(super, 0); @@ -1084,12 +1084,12 @@ void sub_08095DBC(Object6AEntity* this) { super->spriteSettings.draw = 1; InitializeAnimation(super, 75); super->spriteRendering.b3 = gUnk_08114F30[super->spriteRendering.b3]; - ResolveEntityOnTop(super, super); + SortEntityAbove(super, super); } if ((super->type2 & 0x80) == 0 && gActiveScriptInfo.syncFlags & 0x20000) { super->type2 = -1; - super->zVelocity = 0x40000; - super->speed = 0xC000; + super->zVelocity = Q_16_16(4.0); + super->speed = Q_8_8(192); } GravityUpdate(super, super->speed); GetNextFrame(super); @@ -1128,7 +1128,7 @@ NONMATCH("asm/non_matching/object6A/sub_08095EAC.inc", x = a - (Random() & b); y = a - (Random() & b); - PositionRelative(super, e, x << 16, y << 16); + PositionRelative(super, e, Q_16_16(x), Q_16_16(y)); super->zVelocity = vel; super->speed = speed; } @@ -1220,7 +1220,7 @@ void sub_080960C4(Object6AEntity* this, ScriptExecutionContext* ctx) { e->parent = super; CopyPosition(super, e); e->spriteRendering.b3 = gUnk_08114F34[super->spriteRendering.b3]; - ResolveEntityBelow(super, e); + SortEntityBelow(super, e); ((Object6AEntity*)e)->ctx = StartCutscene(e, (u16*)ctx->intVariable); } e = CreateObject(OBJECT_6A, 0x24, 0x4A); @@ -1228,7 +1228,7 @@ void sub_080960C4(Object6AEntity* this, ScriptExecutionContext* ctx) { e->parent = super; CopyPosition(super, e); e->spriteRendering.b3 = gUnk_08114F30[super->spriteRendering.b3]; - ResolveEntityOnTop(super, e); + SortEntityAbove(super, e); e->collisionLayer = 2; ((Object6AEntity*)e)->ctx = StartCutscene(e, (u16*)ctx->intVariable); } @@ -1241,7 +1241,7 @@ void sub_08096168(Object6AEntity* this) { InitializeAnimation(super, 75); } GetNextFrame(super); - sub_0806F62C(super, super->speed, super->direction); + LinearMoveAngle(super, super->speed, super->direction); if (!CheckOnScreen(super)) DeleteThisEntity(); } @@ -1267,21 +1267,21 @@ void sub_08096208(Object6AEntity* this, u32 x) { s8* p = &gUnk_08122B2E[x * 2]; Entity* e = CreateObject(OBJECT_6A, 0x26, 0); if (e != NULL) { - PositionRelative(super, e, p[0] << 16, p[1] << 16); + PositionRelative(super, e, Q_16_16(p[0]), Q_16_16(p[1])); } } void sub_0809623C(Object6AEntity* this) { Entity* e = CreateObject(OBJECT_6A, 0x27, 0); if (e != NULL) { - PositionRelative(super, e, 0, -0x100000); + PositionRelative(super, e, 0, Q_16_16(-16.0)); } } void sub_08096260(Object6AEntity* this) { Entity* e = CreateObject(OBJECT_6A, 0x28, 0); if (e != NULL) { - PositionRelative(super, e, 0, -0x100000); + PositionRelative(super, e, 0, Q_16_16(-16.0)); } } diff --git a/src/object/object7E.c b/src/object/object7E.c index 15785d8f..a23b0e5c 100644 --- a/src/object/object7E.c +++ b/src/object/object7E.c @@ -17,7 +17,7 @@ void Object7E(Entity* this) { this->spriteSettings.flipX = TRUE; } } - PositionRelative(this->parent, this, 0, 0x80000); + PositionRelative(this->parent, this, 0, Q_16_16(8.0)); this->z.HALF.HI = 0; if (this->type != 0) { this->spriteSettings.draw = this->child->spriteSettings.draw; diff --git a/src/object/objectA2.c b/src/object/objectA2.c index cc0e350a..e529794c 100644 --- a/src/object/objectA2.c +++ b/src/object/objectA2.c @@ -25,14 +25,16 @@ void ObjectA2(Entity* this) { GetNextFrame(this); } +#define fp(n) ((n) << 8) + void sub_0809F318(Entity* this) { InitializeAnimation(this, 0); if (Random() & 0x10) { this->spriteSettings.flipX = 1; } - this->x.HALF.HI = 0x28; - this->y.HALF.HI = 0x48; - this->z.HALF.HI = 0xFFB0; + this->x.HALF.HI = Q_8_8(0.16); + this->y.HALF.HI = Q_8_8(0.285); + this->z.HALF.HI = Q_8_8(-0.315); this->spriteOrientation.flipY = 2; this->action = 1; ChangeObjPalette(this, gUnk_08124704[this->type]); diff --git a/src/object/objectAF.c b/src/object/objectAF.c index f34ff4f2..8aa2c9ed 100644 --- a/src/object/objectAF.c +++ b/src/object/objectAF.c @@ -47,7 +47,7 @@ void sub_080A0624(Entity* this) { void sub_080A0640(Entity* this) { if (this->type == 0) { - PositionRelative(*(((Entity**)this->parent->myHeap) + 4), this, 0, 0x80000); + PositionRelative(*(((Entity**)this->parent->myHeap) + 4), this, 0, Q_16_16(8.0)); } else { CopyPosition(this->parent, this); } diff --git a/src/object/objectB5.c b/src/object/objectB5.c index a93011ed..e23779b2 100644 --- a/src/object/objectB5.c +++ b/src/object/objectB5.c @@ -10,5 +10,5 @@ void ObjectB5(Entity* this) { #ifndef EU gRoomControls.camera_target = this; #endif - PositionRelative(&gPlayerEntity, this, 0, -0x280000); + PositionRelative(&gPlayerEntity, this, 0, Q_16_16(-40.0)); } diff --git a/src/object/octorokBossObject.c b/src/object/octorokBossObject.c index a6e3a625..cd527a72 100644 --- a/src/object/octorokBossObject.c +++ b/src/object/octorokBossObject.c @@ -40,8 +40,6 @@ enum OctorokBossObjectType { }; #define GET_HELPER(this) (*(HelperStruct**)&(this)->cutsceneBeh) -extern u32 sub_0806FC80(Entity*, Entity*, s32); - void OctorokBossObject(Entity* this) { OctorokBossObject_Actions[this->action](this); } @@ -78,14 +76,14 @@ void OctorokBossObject_Init(Entity* this) { } this->speed = 0xf0 - (Random() & 0x3f); - sub_0806F62C(this, ((s16)this->speed >> 1) << 8, (u32)this->direction); - sub_0806F62C(this, ((s16)this->speed >> 1) << 8, (u32)this->direction); + LinearMoveAngle(this, ((s16)this->speed >> 1) << 8, (u32)this->direction); + LinearMoveAngle(this, ((s16)this->speed >> 1) << 8, (u32)this->direction); InitializeAnimation(this, 5); SoundReq(SFX_14C); break; case 3: this->direction = -(this->parent->field_0x7a.HALF.HI + -0x80); - sub_0806F62C(this, 0x4800, (u32)this->direction); + LinearMoveAngle(this, 0x4800, (u32)this->direction); if ((Random() & 1) != 0) { this->direction = (Random() & 0x3f) + this->direction; } else { @@ -94,7 +92,7 @@ void OctorokBossObject_Init(Entity* this) { InitializeAnimation(this, 6); break; case 6: - sub_0806F62C(this, (0x30 - (Random() & 0x2f)) * 0x100, Random() & 0xff); + LinearMoveAngle(this, (0x30 - (Random() & 0x2f)) * 0x100, Random() & 0xff); if ((Random() & 1) != 0) { this->direction = (Random() & 0x3f) + this->direction; } else { @@ -111,10 +109,10 @@ void OctorokBossObject_Init(Entity* this) { this->field_0x76.HWORD = 0x400; this->field_0x74.HWORD = 0x400; this->field_0x7a.HWORD = 0; - sub_0806F62C(this, - ((-(u32)this->parent->field_0x7a.HALF.HI << 0x18) >> 0x18) + - (u32)gUnk_0812388C[(u32)this->type2 * 2 + 1], - (u32)gUnk_0812388C[(u32)this->type2 * 2]); + LinearMoveAngle(this, + ((-(u32)this->parent->field_0x7a.HALF.HI << 0x18) >> 0x18) + + (u32)gUnk_0812388C[(u32)this->type2 * 2 + 1], + (u32)gUnk_0812388C[(u32)this->type2 * 2]); sub_0805EC9C(this, this->field_0x76.HWORD, this->field_0x74.HWORD, this->field_0x7a.HWORD); InitializeAnimation(this, 7); break; @@ -172,7 +170,7 @@ NONMATCH("asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc", case 1: this->direction = sub_080045DA(GET_HELPER(this)->tailObjects[this->actionDelay]->x.WORD - this->x.WORD, GET_HELPER(this)->tailObjects[this->actionDelay]->y.WORD - this->y.WORD); - sub_0806F62C(this, this->speed, this->direction); + LinearMoveAngle(this, this->speed, this->direction); if (EntityInRectRadius(this, GET_HELPER(this)->tailObjects[this->actionDelay], 2, 2) == 0) { return; } @@ -197,7 +195,7 @@ NONMATCH("asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc", if (this->parent->type2 == 3) { Entity* object = GET_HELPER(this->parent)->mouthObject; this->direction = sub_080045DA(object->x.WORD - this->x.WORD, object->y.WORD - this->y.WORD); - sub_0806F62C(this, 0x280, this->direction); + LinearMoveAngle(this, 0x280, this->direction); if (sub_0806FC80(this, this->parent, 0x48) == 0) { return; } @@ -206,7 +204,7 @@ NONMATCH("asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc", break; case 3: case 6: - sub_0806F62C(this, 0x80, this->direction); + LinearMoveAngle(this, 0x80, this->direction); if (this->frame != 0) { DeleteThisEntity(); } @@ -249,8 +247,9 @@ NONMATCH("asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc", *(int*)&this->field_0x78 -= 1; } CopyPosition(this->parent, this); - sub_0806F62C(this, (u32)gUnk_0812388C[(u32)this->type2 * 2 + 1], - ((u8) - this->parent->field_0x7a.HALF.HI & 0xff) + (u32)gUnk_0812388C[(u32)this->type2 * 2]); + LinearMoveAngle(this, (u32)gUnk_0812388C[(u32)this->type2 * 2 + 1], + ((u8) - this->parent->field_0x7a.HALF.HI & 0xff) + + (u32)gUnk_0812388C[(u32)this->type2 * 2]); return; case 7: if (this->actionDelay == 0) { diff --git a/src/object/pot.c b/src/object/pot.c index bf94a8be..4e47144f 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -18,7 +18,6 @@ extern void (*const gUnk_0811F0C4[])(Entity*); extern Hitbox gHitbox_18; // TODO: should be const extern Hitbox gUnk_080FD340; // TODO: should be const -extern u32 sub_080001DA(u32, u32); extern void sub_08078930(Entity*); extern void sub_08016A6C(Entity*); @@ -47,7 +46,7 @@ void sub_0808222C(Entity* this) { ResolveCollisionLayer(this); } - this->field_0x70.HALF.LO = sub_080001DA(COORD_TO_TILE(this), this->collisionLayer); + this->field_0x70.HALF.LO = GetTileIndex(COORD_TO_TILE(this), this->collisionLayer); if ((u16)this->field_0x70.HALF.LO == 0x4000) { DeleteThisEntity(); } @@ -67,7 +66,7 @@ void sub_08082310(Entity* this) { case 0x1D: SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); this->action = 5; - this->zVelocity = 0x2A000; + this->zVelocity = Q_16_16(2.625); this->spriteOffsetY = 0; this->spriteSettings.shadow = 1; this->spritePriority.b1 = 3; @@ -90,7 +89,7 @@ void sub_08082310(Entity* this) { this->actionDelay = 64; } SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); - EnqueueSFX(0x10F); + EnqueueSFX(SFX_10F); break; case 0x4067: SetTile((u16)this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); @@ -188,7 +187,7 @@ void sub_08082614(Entity* this) { this->speed <<= 1; } - this->field_0x70.HALF.LO = sub_080001DA(COORD_TO_TILE(this), this->collisionLayer); + this->field_0x70.HALF.LO = GetTileIndex(COORD_TO_TILE(this), this->collisionLayer); tileType = GetTileTypeByEntity(this); switch (tileType) { case 0x71: diff --git a/src/object/pressurePlate.c b/src/object/pressurePlate.c new file mode 100644 index 00000000..bef003fe --- /dev/null +++ b/src/object/pressurePlate.c @@ -0,0 +1,185 @@ +#define NENT_DEPRECATED +#include "object.h" +#include "functions.h" + +u32 IsColliding(Entity*, Entity*); + +typedef struct { + Entity base; + /*0x68*/ union SplitHWord field_0x68; + /*0x6a*/ union SplitHWord field_0x6a; + /*0x6c*/ union SplitHWord field_0x6c; + /*0x6e*/ union SplitHWord field_0x6e; + /*0x70*/ u16 canToggle; + /*0x72*/ u8 dir; + /*0x73*/ u8 filler73[0x86 - 0x73]; + /*0x86*/ u16 flag; +} PressurePlateEntity; + +typedef void(PressurePlateAction)(PressurePlateEntity*); + +PressurePlateAction sub_08088840; +PressurePlateAction sub_0808886C; +PressurePlateAction sub_080888F4; + +extern Hitbox gUnk_080FD1D4; + +static u32 sub_08088938(PressurePlateEntity*); +static u32 get_standing_count(PressurePlateEntity*); + +static const u8 sSpriteOffsets[]; + +void PressurePlate(PressurePlateEntity* this) { + static PressurePlateAction* const sActions[] = { + sub_08088840, + sub_0808886C, + sub_080888F4, + }; + + if (super->field_0xf) { + if (--super->field_0xf == 0) { + this->dir = super->animationState; + InitializeAnimation(super, super->animationState); + } + } + + sActions[super->action](this); +} + +void sub_08088840(PressurePlateEntity* this) { + super->action = 1; + super->spriteSettings.draw = 1; + super->spritePriority.b0 = 7; + super->hitbox = &gUnk_080FD1D4; + this->dir = super->animationState; +} + +void sub_0808886C(PressurePlateEntity* this) { + u8 weight; + + weight = sub_08088938(this) + get_standing_count(this); + if (super->type + 2 <= weight) { + super->action = 2; + super->field_0xf = 0; + super->animationState = 4; + super->z.HALF.HI = 0; + InitializeAnimation(super, 4); + SetFlag(this->flag); + EnqueueSFX(SFX_PRESSURE_PLATE); + } else { + if (weight > super->animationState) { + if (super->type + 1 == weight) { + super->field_0xf = 4; + InitializeAnimation(super, weight + 1); + } else { + InitializeAnimation(super, weight); + } + EnqueueSFX(SFX_BUTTON_PRESS); + } else if (weight < super->animationState) { + InitializeAnimation(super, weight); + } + super->animationState = weight; + } +} + +void sub_080888F4(PressurePlateEntity* this) { + u8 weight; + + if (this->canToggle) { + weight = sub_08088938(this) + get_standing_count(this); + if (super->type + 2 > weight) { + super->action = 1; + super->animationState = weight; + ClearFlag(this->flag); + InitializeAnimation(super, weight); + } + } +} + +static NONMATCH("asm/non_matching/pressurePlate/sub_08088938.inc", u32 sub_08088938(PressurePlateEntity* this)) { + u16 x, y; + s32 num; + u8* tmp; + u32 i; + + num = 0; + x = super->x.HALF.HI - 8; + y = super->y.HALF.HI - 8; + + tmp = &this->dir; + for (i = 0; i < 8; ++i) { + Entity* e = gRoomVars.field_0x8c[8 + i]; + if (e != NULL) { + if ((u16)(e->x.HALF.HI - x) < 0x11 && ((u16)(e->y.HALF_U.HI - y) < 0x11)) { + e->spriteOffsetY = sSpriteOffsets[*tmp]; + num++; + } + } + } + return num; +} +END_NONMATCH + +static u32 get_standing_count(PressurePlateEntity* this) { + u32 num; + + num = 0; + if (IsCollidingPlayer(super) != 0) { + gPlayerEntity.spriteOffsetY = sSpriteOffsets[this->dir]; + num = 1; + } + if ((gPlayerState.flags & PL_CLONING) != 0) { + if (IsColliding(super, gPlayerClones[0]) != 0) { + gPlayerClones[0]->spriteOffsetY = sSpriteOffsets[this->dir]; + num++; + } + if (IsColliding(super, gPlayerClones[1]) != 0) { + gPlayerClones[1]->spriteOffsetY = sSpriteOffsets[this->dir]; + num++; + } + if (IsColliding(super, gPlayerClones[2]) != 0) { + gPlayerClones[2]->spriteOffsetY = sSpriteOffsets[this->dir]; + num++; + } + } + return num; +} + +static const u8 sSpriteOffsets[] = { + -4, -3, -2, -1, 0, +}; + +static const Frame gSpriteAnimations_PressurePlate_0 = { + .index = 0, + .duration = 0xFF, + .frameSettings = { .b = { .endOfAnimation = 1 } }, +}; + +static const Frame gSpriteAnimations_PressurePlate_1 = { + .index = 1, + .duration = 0xFF, + .frameSettings = { .b = { .endOfAnimation = 1 } }, +}; + +static const Frame gSpriteAnimations_PressurePlate_2 = { + .index = 2, + .duration = 0xFF, + .frameSettings = { .b = { .endOfAnimation = 1 } }, +}; + +static const Frame gSpriteAnimations_PressurePlate_3 = { + .index = 3, + .duration = 0xFF, + .frameSettings = { .b = { .endOfAnimation = 1 } }, +}; + +static const Frame gSpriteAnimations_PressurePlate_4 = { + .index = 4, + .duration = 0xFF, + .frameSettings = { .b = { .endOfAnimation = 1 } }, +}; + +const Frame* const gSpriteAnimations_PressurePlate[] = { + &gSpriteAnimations_PressurePlate_0, &gSpriteAnimations_PressurePlate_1, &gSpriteAnimations_PressurePlate_2, + &gSpriteAnimations_PressurePlate_3, &gSpriteAnimations_PressurePlate_4, +}; diff --git a/src/object/pullableLever.c b/src/object/pullableLever.c new file mode 100644 index 00000000..56acc72d --- /dev/null +++ b/src/object/pullableLever.c @@ -0,0 +1,284 @@ +/** + * @file pullableLever.c + * @ingroup Objects + * + * @brief Pullable Lever object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" +#include "sound.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68[8]; + /*0x70*/ u16 pullLength; + /*0x72*/ u16 leverPart; // lever part number? [0,1,2] + /*0x74*/ u8 actionDelay; + /*0x75*/ u8 unk_75; + /*0x76*/ u16 necessaryPullLength; + /*0x78*/ u8 unk_78[6]; + /*0x7e*/ u8 unk_7e; + /*0x7f*/ u8 unk_7f; + /*0x80*/ u16 initialX; + /*0x82*/ u16 initialY; + /*0x84*/ u8 unk_84[2]; + /*0x86*/ u16 pulledFlag; +} PullableLeverEntity; + +enum PullableLeverPart { HANDLE, MIDDLE, SOCKET }; + +extern u16 gUnk_02021F00[]; +extern Hitbox gUnk_080FD270; +extern Hitbox gUnk_080FD278; + +extern void (*const PullableLever_HandleActions[])(PullableLeverEntity*); +extern void (*const PullableLever_MiddleActions[])(PullableLeverEntity*); +extern const s8 PullableLever_InitialOffsets[]; +extern void (*const PullableLever_HandleSubActions[])(PullableLeverEntity*); +extern const s8 gUnk_081222B8[]; +extern const u8 gUnk_081222C0[]; + +void sub_08091504(PullableLeverEntity*); +void PullableLever_UpdateLength(PullableLeverEntity*); +void sub_0809153C(PullableLeverEntity*); + +void PullableLever(PullableLeverEntity* this) { + switch (this->leverPart) { + case HANDLE: + PullableLever_HandleActions[super->action](this); + sub_0800445C(super); + gUnk_02021F00[this->actionDelay] = this->pullLength; + break; + case MIDDLE: + PullableLever_MiddleActions[super->action](this); + break; + case SOCKET: + if (super->action == 0) { + sub_08091504(this); + } + break; + } +} + +void PullableLever_HandleInit(PullableLeverEntity* this) { + if (gEntCount < 0x46) { + PullableLeverEntity* entity1 = (PullableLeverEntity*)CreateObject(PULLABLE_LEVER, super->type, super->type2); + PullableLeverEntity* entity2 = (PullableLeverEntity*)CreateObject(PULLABLE_LEVER, super->type, super->type2); + (entity1->base).parent = super; + (entity2->base).parent = super; + entity1->leverPart = 1; + entity2->leverPart = 2; + CopyPosition(super, &entity2->base); + super->action = 1; + super->spriteSettings.draw = 1; + super->speed = 0x60; + if ((super->type2 & 1)) { + super->hitbox = &gUnk_080FD278; + } else { + super->hitbox = &gUnk_080FD270; + } + super->field_0x16 = 1; + super->x.HALF.HI += PullableLever_InitialOffsets[super->type2 * 2]; + this->initialX = super->x.HALF.HI; + super->y.HALF.HI += PullableLever_InitialOffsets[super->type2 * 2 + 1]; + this->initialY = super->y.HALF.HI; + CopyPosition(super, &entity1->base); + this->necessaryPullLength = this->unk_7e; + this->actionDelay = super->actionDelay; + InitializeAnimation(super, super->type2); + } +} + +void PullableLever_HandleAction1(PullableLeverEntity* this) { + sub_08078930(super); + if (this->pullLength != 0) { + super->direction = super->type2 << 3; + LinearMoveUpdate(super); + PullableLever_UpdateLength(this); + } +} + +void PullableLever_HandleAction2(PullableLeverEntity* this) { + sub_0806FBB4(super); + PullableLever_HandleSubActions[super->subAction - 5](this); +} + +void PullableLever_HandleSubAction0(PullableLeverEntity* this) { + u16 y; + u16 x; + Entity* player = &gPlayerEntity; + + if (this->unk_75 == 0) { + if (-player->animationState + super->type2 * 2 == 0) { + x = gUnk_081222B8[super->type2 * 2] + super->x.HALF_U.HI; + y = gUnk_081222B8[super->type2 * 2 + 1] + super->y.HALF_U.HI; + if (0x10 < sub_080002D4(x, y, player->collisionLayer) - 0xf) { + player->x.HALF.HI = x; + player->y.HALF.HI = y; + } + } + this->unk_75 = 1; + super->field_0xf = 2; + } + if (player->animationState >> 1 == super->type2) { + if (gPlayerState.framestate == PL_STATE_PULL) { + if (gPlayerState.heldObject & 2) { + if (gPlayerEntity.frame & 2) { + sub_0809153C(this); + if (this->unk_75 == 1) { + this->unk_75 = 2; + EnqueueSFX(SFX_19E); + } + } + } + } + } +} + +void PullableLever_HandleSubAction1(PullableLeverEntity* this) { + super->action = 1; + this->unk_75 = 0; +} + +void PullableLever_MiddleInit(PullableLeverEntity* this) { + super->action = 1; + super->spritePriority.b0 = 5; + InitializeAnimation(super, super->parent->type2 + 8); + UpdateSpriteForCollisionLayer(super); +} + +void PullableLever_MiddleAction1(PullableLeverEntity* this) { + u16 tmp; + PullableLeverEntity* parent = ((PullableLeverEntity*)super->parent); + if (parent->pullLength < 8) { + super->spriteSettings.draw = 0; + } else { + super->spriteSettings.draw = 1; + tmp = (((PullableLeverEntity*)super->parent)->pullLength - 8) & 7; + switch (super->type2) { + case 0: + super->y.HALF.HI = (super->parent->y.HALF.HI - tmp) - 0x11; + break; + case 1: + super->x.HALF.HI = tmp + super->parent->x.HALF.HI + 0x11; + break; + case 2: + super->y.HALF.HI = tmp + super->parent->y.HALF.HI + 0x11; + break; + case 3: + super->x.HALF.HI = (super->parent->x.HALF.HI - tmp) - 0x11; + break; + } + tmp = (parent->pullLength - 8) >> 4; + if (tmp != super->animationState) { + super->animationState = tmp; + InitializeAnimation(super, tmp * 4 + super->type2 + 8); + } + } +} + +void sub_08091504(PullableLeverEntity* this) { + super->action = 1; + super->spriteSettings.draw = 1; + super->spritePriority.b0 = 6; + InitializeAnimation(super, super->type2 + 4); + UpdateSpriteForCollisionLayer(super); +} + +void sub_0809153C(PullableLeverEntity* this) { + s16 prevX; + s16 prevY; + u32 dir; + s16 diff; + s32 radius; + + Entity* player = &gPlayerEntity; + dir = gUnk_081222C0[super->type2]; + if (this->necessaryPullLength <= this->pullLength) { + return; + } + prevX = player->x.HALF.HI; + prevY = player->y.HALF.HI; + sub_080044AE(&gPlayerEntity, super->speed, dir); + if ((prevX == gPlayerEntity.x.HALF.HI) && (prevY == gPlayerEntity.y.HALF.HI)) { + return; + } + + switch (super->type2) { + case 0: + diff = player->y.HALF.HI - prevY; + break; + case 1: + diff = prevX - gPlayerEntity.x.HALF.HI; + break; + case 2: + diff = prevY - gPlayerEntity.y.HALF.HI; + break; + case 3: + diff = gPlayerEntity.x.HALF.HI - prevX; + break; + } + radius = (diff << 0x18); + super->x.WORD += gSineTable[dir * 8] * (radius >> 0x10); + super->y.WORD -= gSineTable[dir * 8 + 0x40] * (radius >> 0x10); + PullableLever_UpdateLength(this); + if (this->necessaryPullLength <= this->pullLength) { + EnqueueSFX(SFX_BUTTON_PRESS); + SetFlag(this->pulledFlag); + } else { + if (--super->field_0xf == 0) { + super->field_0xf = 0x10; + EnqueueSFX(SFX_10F); + } + } +} + +void PullableLever_UpdateLength(PullableLeverEntity* this) { + switch (super->type2) { + case 0: + this->pullLength = super->y.HALF.HI - this->initialY; + break; + case 1: + this->pullLength = this->initialX - super->x.HALF.HI; + break; + case 2: + this->pullLength = this->initialY - super->y.HALF.HI; + break; + case 3: + this->pullLength = super->x.HALF.HI - this->initialX; + break; + } + + if (CheckFlags(this->pulledFlag) && (this->pullLength == 0)) { + ClearFlag(this->pulledFlag); + } +} + +void (*const PullableLever_HandleActions[])(PullableLeverEntity*) = { + PullableLever_HandleInit, + PullableLever_HandleAction1, + PullableLever_HandleAction2, +}; +void (*const PullableLever_MiddleActions[])(PullableLeverEntity*) = { + PullableLever_MiddleInit, + PullableLever_MiddleAction1, +}; +const s8 PullableLever_InitialOffsets[] = { + 0, 9, -9, 0, 0, -9, 9, 0, +}; +void (*const PullableLever_HandleSubActions[])(PullableLeverEntity*) = { + PullableLever_HandleSubAction0, + PullableLever_HandleSubAction1, +}; +const s8 gUnk_081222B8[] = { + 0, 10, -8, 0, 0, -10, 8, 0, +}; +const u8 gUnk_081222C0[] = { + 16, + 24, + 0, + 8, +}; diff --git a/src/object/pushableLever.c b/src/object/pushableLever.c new file mode 100644 index 00000000..dff5ed9a --- /dev/null +++ b/src/object/pushableLever.c @@ -0,0 +1,148 @@ +/** + * @file pushableLever.c + * @ingroup Objects + * + * @brief Pushable Lever object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68[8]; + /*0x70*/ u16 tilePosition; + /*0x72*/ u16 tileIndex; + /*0x74*/ u16 timer; + /*0x76*/ u8 unk_76[16]; + /*0x86*/ u16 pushedFlag; +} PushableLeverEntity; + +enum PushableLeverAction { + INIT, + IDLE, + PUSHING, +}; + +extern void (*const PushableLever_Actions[])(PushableLeverEntity*); +extern const u16 PushableLever_Tiles[]; +extern const u8 PushableLever_InitialOffsets[]; +extern const u8 PushableLever_PushedOffsets[]; + +void PushableLever_SetIdle(PushableLeverEntity*); +bool32 PushableLever_ShouldStartPushing(PushableLeverEntity* this); +void PushableLever_SetTiles(PushableLeverEntity*); +void PushableLever_CalculateSpriteOffsets(PushableLeverEntity*); + +#define TILE_INITIAL 0x4053 +#define TILE_PUSHED 0x4052 + +void PushableLever(PushableLeverEntity* this) { + PushableLever_Actions[super->action](this); +} + +void PushableLever_Init(PushableLeverEntity* this) { + super->spritePriority.b0 = 5; + PushableLever_SetIdle(this); +} + +void PushableLever_Idle(PushableLeverEntity* this) { + if (PushableLever_ShouldStartPushing(this)) { + super->action = PUSHING; + super->spriteOffsetX = 0; + super->spriteOffsetY = 0; + SetTile(this->tileIndex, this->tilePosition, super->collisionLayer); + EnqueueSFX(SFX_16A); + RequestPriorityDuration(super, 0x1e); + if (sub_08079F8C()) { + gPlayerState.pushedObject = 0x90; + gPlayerState.queued_action = 5; + gPlayerState.flags |= 1; + gPlayerEntity.x.HALF.LO = 0; + gPlayerEntity.y.HALF.LO = 0; + gPlayerEntity.direction = gPlayerEntity.animationState << 2; + } + } +} + +void PushableLever_Pushing(PushableLeverEntity* this) { + GetNextFrame(super); + if ((super->frame & 0x80) != 0) { + if (super->type2 == 0) { + SetFlag(this->pushedFlag); + } else { + ClearFlag(this->pushedFlag); + } + PushableLever_SetIdle(this); + } +} + +void PushableLever_SetIdle(PushableLeverEntity* this) { + super->action = IDLE; + this->timer = 0x3c; + PushableLever_SetTiles(this); +} + +void PushableLever_SetTiles(PushableLeverEntity* this) { + if (CheckFlags(this->pushedFlag) == FALSE) { + super->type2 = 0; + this->tilePosition = COORD_TO_TILE_OFFSET(super, 0, 0x10); + this->tileIndex = GetTileIndex(this->tilePosition, super->collisionLayer); + SetTile(TILE_INITIAL, this->tilePosition, super->collisionLayer); + InitializeAnimation(super, 1); + } else { + super->type2 = 1; + this->tilePosition = COORD_TO_TILE_OFFSET(super, 0x10, 0); + this->tileIndex = GetTileIndex(this->tilePosition, super->collisionLayer); + SetTile(TILE_PUSHED, this->tilePosition, super->collisionLayer); + InitializeAnimation(super, 0); + } +} + +bool32 PushableLever_ShouldStartPushing(PushableLeverEntity* this) { + if (GetTileIndex(this->tilePosition, super->collisionLayer) == 0x4054) { + if (--this->timer == 0) { + return TRUE; + } + PushableLever_CalculateSpriteOffsets(this); + SetTile(PushableLever_Tiles[super->type2], this->tilePosition, super->collisionLayer); + } else { + this->timer = 0x3c; + super->spriteOffsetX = 0; + super->spriteOffsetY = 0; + } + return FALSE; +} + +void PushableLever_CalculateSpriteOffsets(PushableLeverEntity* this) { + const u8* offsets; + if (super->type2 == 0) { + offsets = PushableLever_InitialOffsets; + } else { + offsets = PushableLever_PushedOffsets; + } + offsets = &offsets[(this->timer / 4) & 6]; + super->spriteOffsetX = offsets[0]; + super->spriteOffsetY = offsets[1]; + if ((this->timer & 3) == 0) { + EnqueueSFX(SFX_104); + } +} + +void (*const PushableLever_Actions[])(PushableLeverEntity*) = { + PushableLever_Init, + PushableLever_Idle, + PushableLever_Pushing, +}; +const u16 PushableLever_Tiles[] = { + TILE_INITIAL, + TILE_PUSHED, +}; +const u8 PushableLever_InitialOffsets[] = { + 0, 0, 0, 0, 255, 0, 0, 0, +}; +const u8 PushableLever_PushedOffsets[] = { + 0, 0, 0, 0, 0, 255, 0, 0, +}; diff --git a/src/object/railtrack.c b/src/object/railtrack.c index d92a9546..303d279d 100644 --- a/src/object/railtrack.c +++ b/src/object/railtrack.c @@ -55,7 +55,7 @@ void sub_08085264(Entity* this) { this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3; InitializeAnimation(this, this->animationState); sub_0808543C(this); - EnqueueSFX(0x151); + EnqueueSFX(SFX_151); } } @@ -67,7 +67,7 @@ void sub_080852B4(Entity* this) { this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3; InitializeAnimation(this, this->animationState); sub_08085394(this); - EnqueueSFX(0x151); + EnqueueSFX(SFX_151); } } @@ -97,7 +97,7 @@ void sub_08085308(Entity* this) { this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3; InitializeAnimation(this, this->animationState); sub_0808543C(this); - EnqueueSFX(0x151); + EnqueueSFX(SFX_151); } } } diff --git a/src/object/rupee.c b/src/object/rupee.c index 4c9b8aa0..f4119600 100644 --- a/src/object/rupee.c +++ b/src/object/rupee.c @@ -51,7 +51,7 @@ void sub_08086A6C(Entity* ent) { u32 uVar1; uVar1 = Random(); - ent->zVelocity = 163840; + ent->zVelocity = Q_16_16(2.5); ent->direction = DirectionNormalize(uVar1 >> 16); ent->speed = uVar1 & 480; } diff --git a/src/object/warpPoint.c b/src/object/warpPoint.c index 065b9fcc..1098d131 100644 --- a/src/object/warpPoint.c +++ b/src/object/warpPoint.c @@ -56,7 +56,7 @@ void sub_0808B474(Entity* this) { gPlayerEntity.x.HALF.HI = this->x.HALF.HI; gPlayerEntity.y.HALF.HI = this->y.HALF.HI; gPlayerEntity.animationState = 4; - EnqueueSFX(0x112); + EnqueueSFX(SFX_112); RequestPriorityDuration(this, this->field_0xf + 0x10); } @@ -68,7 +68,7 @@ void sub_0808B530(Entity* this) { } this->action = 2; this->field_0xf = 60; - EnqueueSFX(0x112); + EnqueueSFX(SFX_112); } } @@ -91,7 +91,7 @@ void sub_0808B590(Entity* this) { gPlayerEntity.x.HALF.HI = this->x.HALF.HI; gPlayerEntity.y.HALF.HI = this->y.HALF.HI; gPlayerEntity.animationState = 4; - gPlayerEntity.flags &= ~0x80; + gPlayerEntity.flags &= ~ENT_COLLIDE; RequestPriorityDuration(this, this->field_0xf + 0x10); SoundReq(SFX_113); } else { @@ -152,7 +152,7 @@ void sub_0808B684(Entity* this) { gRoomTransition.player_status.start_pos_y = ((this->cutsceneBeh.HWORD & 0xfc0) >> 2) + 8; gRoomTransition.player_status.layer = 0; gRoomTransition.player_status.start_anim = 4; - gRoomTransition.player_status.spawn_type = 0; + gRoomTransition.player_status.spawn_type = PL_SPAWN_DEFAULT; if (this->type == 2) { gRoomTransition.type = TRANSITION_FADE_WHITE_SLOW; } @@ -192,10 +192,10 @@ void sub_0808B73C(Entity* this) { this->palette.b.b0 = this->parent->palette.b.b0; InitializeAnimation(this, 1); } - if (sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28)) { + if (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28)) { this->spriteSettings.draw = 1; } else { - if (sub_0806FCB8(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x2e)) { + if (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x2e)) { this->spriteSettings.draw ^= 1; } else { this->spriteSettings.draw = 0; |
