From f7c176f0fc953d67127d64a1418d25ac39255ba9 Mon Sep 17 00:00:00 2001 From: theo3 Date: Fri, 21 Jan 2022 21:26:18 -0800 Subject: [PATCH 1/2] fixed point stuff --- asm/code_08054C04.s | 2 +- asm/code_08078778.s | 2 +- asm/code_0808091C.s | 2 +- asm/enemy/chuchuBoss.s | 10 +-- asm/enemy/cloudPiranha.s | 4 +- asm/enemy/enemy64.s | 4 +- .../castorWildsStatue/sub_080675D4.inc | 4 +- .../OctorokBossObject_Action1.inc | 8 +-- asm/object/evilSpirit.s | 4 +- asm/object/lilypadLarge.s | 2 +- asm/object/macroPlayer.s | 2 +- asm/object/object91.s | 6 +- asm/object/object96.s | 2 +- asm/object/object97.s | 2 +- asm/object/objectB4.s | 8 +-- asm/object/objectOnSpinyBeetle.s | 6 +- asm/object/specialFx.s | 2 +- asm/objectUtils.s | 4 +- include/coord.h | 4 +- include/entity.h | 8 +-- include/functions.h | 4 +- include/global.h | 4 +- src/code_0805436C.c | 2 +- src/collision.c | 6 +- src/coord.c | 44 ++++++------- src/enemy/acroBandits.c | 10 +-- src/enemy/beetle.c | 6 +- src/enemy/bobomb.c | 6 +- src/enemy/bombPeahat.c | 2 +- src/enemy/chuchu.c | 2 +- src/enemy/cuccoChickAggr.c | 6 +- src/enemy/fallingBoulder.c | 4 +- src/enemy/fireballGuy.c | 2 +- src/enemy/flyingSkull.c | 2 +- src/enemy/gyorgMale.c | 4 +- src/enemy/helmasaur.c | 12 ++-- src/enemy/keaton.c | 2 +- src/enemy/lakitu.c | 22 ++++--- src/enemy/likeLike.c | 4 +- src/enemy/mazaalBracelet.c | 16 ++--- src/enemy/mazaalHead.c | 4 +- src/enemy/miniFireballGuy.c | 2 +- src/enemy/moldworm.c | 4 +- src/enemy/octorokBoss.c | 10 +-- src/enemy/peahat.c | 4 +- src/enemy/pesto.c | 2 +- src/enemy/puffstool.c | 18 +++--- src/enemy/rollobite.c | 6 +- src/enemy/rupeeLike.c | 4 +- src/enemy/sluggula.c | 4 +- src/enemy/spikedBeetle.c | 4 +- src/enemy/spinyChuchu.c | 10 +-- src/enemy/tektiteGolden.c | 4 +- src/enemy/vaatiArm.c | 4 +- src/enemy/vaatiBall.c | 10 +-- src/enemy/vaatiProjectile.c | 4 +- src/enemy/vaatiRebornEnemy.c | 16 ++--- src/enemy/vaatiTransfigured.c | 8 +-- src/enemy/vaatiTransfiguredEye.c | 4 +- src/enemy/vaatiWrath.c | 2 +- src/enemy/vaatiWrathEye.c | 2 +- src/enemy/waterDrop.c | 2 +- src/item/itemRocsCape.c | 2 +- src/npc/bigGoron.c | 2 +- src/npc/bladeBrothers.c | 2 +- src/npc/castorWildsStatue.c | 4 +- src/npc/cuccoChick.c | 2 +- src/npc/drLeft.c | 2 +- src/npc/ezlo.c | 2 +- src/npc/goron.c | 12 ++-- src/npc/gregal.c | 4 +- src/npc/kid.c | 2 +- src/npc/malon.c | 4 +- src/npc/melari.c | 2 +- src/npc/npc4E.c | 4 +- src/npc/pita.c | 2 +- src/npc/postman.c | 2 +- src/npc/rem.c | 4 +- src/npc/townMinish.c | 4 +- src/npc/townsperson.c | 2 +- src/npc/vaatiReborn.c | 6 +- src/npc/wheaton.c | 2 +- src/npc/zelda.c | 6 +- src/object/bakerOven.c | 2 +- src/object/bigVortex.c | 6 +- src/object/bird.c | 14 ++--- src/object/book.c | 2 +- src/object/fileScreenObjects.c | 4 +- src/object/furniture.c | 4 +- src/object/greatFairy.c | 14 ++--- src/object/itemOnGround.c | 6 +- src/object/jarPortal.c | 10 +-- src/object/lilypadLarge.c | 2 +- src/object/mask.c | 2 +- src/object/minecart.c | 6 +- src/object/object49.c | 4 +- src/object/object6A.c | 62 +++++++++---------- src/object/object7E.c | 2 +- src/object/objectA2.c | 8 ++- src/object/objectAF.c | 2 +- src/object/objectB5.c | 2 +- src/object/octorokBossObject.c | 18 +++--- src/object/pot.c | 2 +- src/object/rupee.c | 2 +- src/player.c | 52 ++++++++-------- src/projectile/boneProjectile.c | 4 +- src/projectile/dirtBallProjectile.c | 10 +-- src/projectile/gleerokProjectile.c | 4 +- src/projectile/gyorgMaleEnergyProjectile.c | 4 +- src/projectile/lakituCloudProjectile.c | 4 +- src/projectile/mandiblesProjectile.c | 10 +-- src/projectile/octorokBossProjectile.c | 14 ++--- src/projectile/rockProjectile.c | 4 +- src/projectile/stalfosProjectile.c | 4 +- src/projectile/v1DarkMagicProjectile.c | 8 +-- src/projectile/v1EyeLaser.c | 2 +- src/projectile/v1FireProjectile.c | 4 +- src/projectile/v2Projectile.c | 2 +- src/roomInit.c | 8 +-- src/script.c | 16 ++--- 120 files changed, 387 insertions(+), 383 deletions(-) diff --git a/asm/code_08054C04.s b/asm/code_08054C04.s index caacf860..e8a02905 100644 --- a/asm/code_08054C04.s +++ b/asm/code_08054C04.s @@ -446,7 +446,7 @@ sub_08054EFC: @ 0x08054EFC subs r0, #0x10 strh r0, [r1, #0x32] adds r0, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow _08054F54: movs r0, #0xfd bl SoundReq diff --git a/asm/code_08078778.s b/asm/code_08078778.s index 5dd37970..b5c2c7e6 100644 --- a/asm/code_08078778.s +++ b/asm/code_08078778.s @@ -724,7 +724,7 @@ _08078DE0: strh r0, [r4, #0x32] adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove ldr r0, _08078E34 @ =gPlayerState ldrb r0, [r0, #5] cmp r0, #4 diff --git a/asm/code_0808091C.s b/asm/code_0808091C.s index c0d02198..5ab71ebf 100755 --- a/asm/code_0808091C.s +++ b/asm/code_0808091C.s @@ -419,7 +419,7 @@ _08080DB4: adds r2, #1 strb r0, [r2] adds r0, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove b _08080E00 _08080DEE: ldr r0, _08080E04 @ =gRoomTransition diff --git a/asm/enemy/chuchuBoss.s b/asm/enemy/chuchuBoss.s index 12f1451d..3d5bfb57 100644 --- a/asm/enemy/chuchuBoss.s +++ b/asm/enemy/chuchuBoss.s @@ -3676,7 +3676,7 @@ _08027676: mov r0, sl ldrb r2, [r0] adds r0, r5, #0 - bl sub_0806F62C + bl LinearMoveAngle ldrb r0, [r5, #0xa] cmp r0, #1 beq _080276D2 @@ -3692,7 +3692,7 @@ _08027676: adds r2, r0, #0 adds r2, #0x83 ldrb r2, [r2] - bl sub_0806F62C + bl LinearMoveAngle ldr r0, [r5, #0x68] ldr r1, [r5, #0x54] ldrb r2, [r1, #0xa] @@ -4033,7 +4033,7 @@ _08027934: adds r0, #0x83 ldrb r2, [r0] adds r0, r5, #0 - bl sub_0806F62C + bl LinearMoveAngle ldr r0, [r5, #0x2c] str r0, [r6, #0x2c] ldr r0, [r5, #0x30] @@ -4044,7 +4044,7 @@ _08027934: adds r0, #0x83 ldrb r2, [r0] adds r0, r6, #0 - bl sub_0806F62C + bl LinearMoveAngle ldr r0, [r6, #0x2c] str r0, [r4, #0x2c] ldr r0, [r6, #0x30] @@ -4055,7 +4055,7 @@ _08027934: adds r0, #0x83 ldrb r2, [r0] adds r0, r4, #0 - bl sub_0806F62C + bl LinearMoveAngle adds r0, r7, #0 bl sub_08027984 pop {r4, r5, r6, r7, pc} diff --git a/asm/enemy/cloudPiranha.s b/asm/enemy/cloudPiranha.s index b85843df..a8ea962d 100644 --- a/asm/enemy/cloudPiranha.s +++ b/asm/enemy/cloudPiranha.s @@ -396,7 +396,7 @@ sub_080386B8: @ 0x080386B8 cmp r1, #0 beq _08038720 adds r0, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove _08038720: pop {r4, pc} .align 2, 0 @@ -507,7 +507,7 @@ _080387D8: cmp r1, #0 beq _080387EE adds r0, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove _080387EE: pop {r4, pc} diff --git a/asm/enemy/enemy64.s b/asm/enemy/enemy64.s index 4e8c8401..ff33d73e 100644 --- a/asm/enemy/enemy64.s +++ b/asm/enemy/enemy64.s @@ -1236,7 +1236,7 @@ sub_08049998: @ 0x08049998 ldrsh r1, [r5, r0] ldrb r2, [r5, #0x15] adds r0, r5, #0 - bl sub_0806F62C + bl LinearMoveAngle adds r0, r5, #0 adds r0, #0x7c ldrb r1, [r0] @@ -1433,7 +1433,7 @@ sub_08049B20: @ 0x08049B20 ldrsh r1, [r4, r0] ldrb r2, [r4, #0x15] adds r0, r4, #0 - bl sub_0806F62C + bl LinearMoveAngle adds r0, r4, #0 adds r0, #0x7c ldrb r1, [r0] diff --git a/asm/non_matching/castorWildsStatue/sub_080675D4.inc b/asm/non_matching/castorWildsStatue/sub_080675D4.inc index f47dc575..48e73e86 100644 --- a/asm/non_matching/castorWildsStatue/sub_080675D4.inc +++ b/asm/non_matching/castorWildsStatue/sub_080675D4.inc @@ -54,7 +54,7 @@ _080675EC: strb r0, [r3, #0x19] adds r0, r4, #0 adds r1, r3, #0 - bl ResolveEntityOnTop + bl SortEntityAbove _08067646: subs r6, #1 adds r5, #2 @@ -107,7 +107,7 @@ _08067656: strb r0, [r3, #0x19] adds r0, r4, #0 adds r1, r3, #0 - bl ResolveEntityOnTop + bl SortEntityAbove _080676B0: subs r6, #1 adds r5, #2 diff --git a/asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc b/asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc index 72ca7751..fdcbb90b 100644 --- a/asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc +++ b/asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc @@ -95,7 +95,7 @@ _0809A25C: ldrsh r1, [r7, r2] ldrb r2, [r7, #0x15] adds r0, r7, #0 - bl sub_0806F62C + bl LinearMoveAngle ldr r1, [r4] ldrb r0, [r7, #0xe] lsls r0, r0, #2 @@ -206,7 +206,7 @@ _0809A33E: lsls r1, r1, #2 ldrb r2, [r7, #0x15] adds r0, r7, #0 - bl sub_0806F62C + bl LinearMoveAngle ldr r1, [r7, #0x50] adds r0, r7, #0 movs r2, #0x48 @@ -216,7 +216,7 @@ _0809A378: ldrb r2, [r7, #0x15] adds r0, r7, #0 movs r1, #0x80 - bl sub_0806F62C + bl LinearMoveAngle adds r0, r7, #0 adds r0, #0x5a ldrb r0, [r0] @@ -335,7 +335,7 @@ _0809A436: ldrh r3, [r3] adds r2, r2, r3 adds r0, r7, #0 - bl sub_0806F62C + bl LinearMoveAngle b _0809A632 .align 2, 0 _0809A468: .4byte gUnk_0812388C diff --git a/asm/object/evilSpirit.s b/asm/object/evilSpirit.s index 1baea3de..a3b0019c 100644 --- a/asm/object/evilSpirit.s +++ b/asm/object/evilSpirit.s @@ -235,7 +235,7 @@ _08086428: ldrsh r1, [r6, r0] ldrb r2, [r6, #0x15] adds r0, r6, #0 - bl sub_0806F62C + bl LinearMoveAngle b _0808654A _08086440: adds r0, r6, #0 @@ -507,7 +507,7 @@ _0808663A: ldrsh r1, [r7, r0] ldrb r2, [r7, #0x15] adds r0, r7, #0 - bl sub_0806F62C + bl LinearMoveAngle ldrb r0, [r7, #0x15] movs r1, #0x80 eors r0, r1 diff --git a/asm/object/lilypadLarge.s b/asm/object/lilypadLarge.s index c178744a..cdc6ede6 100644 --- a/asm/object/lilypadLarge.s +++ b/asm/object/lilypadLarge.s @@ -919,7 +919,7 @@ _08085BB4: lsls r1, r1, #1 ldrb r2, [r5, #0x15] adds r0, r4, #0 - bl sub_0806F5BC + bl LinearMoveDirection _08085BE8: adds r1, r5, #0 adds r1, #0x82 diff --git a/asm/object/macroPlayer.s b/asm/object/macroPlayer.s index 7c8b3e9d..c741786a 100644 --- a/asm/object/macroPlayer.s +++ b/asm/object/macroPlayer.s @@ -90,7 +90,7 @@ _0808CB70: movs r5, #0 str r5, [r4, #0x34] adds r1, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow ldrb r0, [r4, #0xd] cmp r0, #0 beq _0808CB98 diff --git a/asm/object/object91.s b/asm/object/object91.s index 6a8d37f8..f4fed50e 100644 --- a/asm/object/object91.s +++ b/asm/object/object91.s @@ -291,7 +291,7 @@ _0809C5E0: @ jump table _0809C600: ldr r0, [r5, #0x50] adds r1, r5, #0 - bl ResolveEntityBelow + bl SortEntityBelow ldr r0, [r5, #0x50] ldrb r0, [r0, #0xd] adds r6, r5, #0 @@ -382,7 +382,7 @@ _0809C6B4: .4byte gUnk_08123E1C _0809C6B8: ldr r0, [r5, #0x50] adds r1, r5, #0 - bl ResolveEntityBelow + bl SortEntityBelow ldr r0, [r5, #0x50] ldrb r0, [r0, #0xd] adds r6, r5, #0 @@ -864,7 +864,7 @@ _0809CA30: adds r2, #2 ldrb r2, [r2] rsbs r2, r2, #0 - bl sub_0806F62C + bl LinearMoveAngle ldr r1, [r4, #0x54] adds r0, r4, #0 movs r2, #0x48 diff --git a/asm/object/object96.s b/asm/object/object96.s index 5fb797f2..ddb6415e 100644 --- a/asm/object/object96.s +++ b/asm/object/object96.s @@ -223,7 +223,7 @@ sub_0809D91C: @ 0x0809D91C cmp r1, #0 beq _0809D934 adds r0, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow _0809D934: movs r0, #0x72 bl SoundReq diff --git a/asm/object/object97.s b/asm/object/object97.s index 65f2f74a..d49bbd58 100644 --- a/asm/object/object97.s +++ b/asm/object/object97.s @@ -1024,7 +1024,7 @@ _0809E170: ldrsh r1, [r5, r0] ldrb r2, [r5, #0x15] adds r0, r5, #0 - bl sub_0806F62C + bl LinearMoveAngle movs r1, #0x2e ldrsh r0, [r5, r1] mov r2, r8 diff --git a/asm/object/objectB4.s b/asm/object/objectB4.s index eb36b53e..27adbace 100644 --- a/asm/object/objectB4.s +++ b/asm/object/objectB4.s @@ -95,7 +95,7 @@ _080A0C08: strh r0, [r4, #0x32] adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow _080A0C40: ldrb r0, [r5, #0xf] adds r0, #1 @@ -136,7 +136,7 @@ _080A0C6E: strh r0, [r4, #0x32] adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow _080A0C92: ldrb r0, [r5, #0xf] adds r0, #1 @@ -159,7 +159,7 @@ _080A0CA0: strh r0, [r4, #0x32] adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove _080A0CC0: movs r0, #0xb4 movs r1, #3 @@ -174,7 +174,7 @@ _080A0CC0: strh r0, [r4, #0x32] adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove _080A0CE0: pop {r4, r5, pc} .align 2, 0 diff --git a/asm/object/objectOnSpinyBeetle.s b/asm/object/objectOnSpinyBeetle.s index bcf85560..f93fa2a3 100644 --- a/asm/object/objectOnSpinyBeetle.s +++ b/asm/object/objectOnSpinyBeetle.s @@ -67,7 +67,7 @@ _080985AC: _080985AE: ldr r1, [r4, #0x50] adds r0, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow adds r0, r4, #0 bl sub_08098918 pop {r4, r5, pc} @@ -569,7 +569,7 @@ _0809892E: strb r0, [r2] ldr r1, [r4, #0x50] adds r0, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow _08098968: ldr r2, _0809898C @ =gUnk_08123558 adds r0, r6, #0 @@ -606,7 +606,7 @@ _08098990: strb r0, [r2] ldr r1, [r4, #0x50] adds r0, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow _080989B2: strh r5, [r4, #0x36] adds r1, r4, #0 diff --git a/asm/object/specialFx.s b/asm/object/specialFx.s index 5a0f7a1b..286e0046 100644 --- a/asm/object/specialFx.s +++ b/asm/object/specialFx.s @@ -459,7 +459,7 @@ _080847F0: strh r0, [r5, #0x36] adds r0, r4, #0 adds r1, r5, #0 - bl ResolveEntityOnTop + bl SortEntityAbove adds r0, r5, #0 bl sub_080845DC pop {r4, r5, pc} diff --git a/asm/objectUtils.s b/asm/objectUtils.s index 67edbaa6..f90b70e4 100644 --- a/asm/objectUtils.s +++ b/asm/objectUtils.s @@ -167,7 +167,7 @@ _080A2BB4: bl PositionRelative adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove adds r0, r5, #0 adds r0, #0x62 ldrb r0, [r0] @@ -380,7 +380,7 @@ CreateSpeechBubble: @ 0x080A2D2C bl CopyPosition adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove str r5, [r4, #0x50] adds r0, r4, #0 adds r0, #0x62 diff --git a/include/coord.h b/include/coord.h index 85a56ce2..5ead1236 100644 --- a/include/coord.h +++ b/include/coord.h @@ -12,8 +12,8 @@ void PositionEntityOnTop(Entity*, Entity*); void PositionRelative(Entity*, Entity*, s32, s32); void CopyPositionAndSpriteOffset(Entity* param_1, Entity* param_2); void sub_0806FA90(Entity*, Entity*, s32, s32); -void ResolveEntityOnTop(Entity*, Entity*); -void ResolveEntityBelow(Entity*, Entity*); +void SortEntityAbove(Entity*, Entity*); +void SortEntityBelow(Entity*, Entity*); u32 sub_0806F5A4(u32 idx); u32 sub_0806F3E4(Entity*); diff --git a/include/entity.h b/include/entity.h index c3477e9e..5ff5dcdc 100644 --- a/include/entity.h +++ b/include/entity.h @@ -160,14 +160,14 @@ typedef struct Entity_ { /*0x1d*/ u8 field_0x1d; /*0x1e*/ u8 frameIndex; /*0x1f*/ u8 lastFrameIndex; - /*0x20*/ s32 zVelocity; /**< Z axis speed. */ + /*0x20*/ s32 zVelocity; /**< Z axis speed, measured in px/frame */ /*0x24*/ s16 speed; /**< Magnitude of speed. */ /*0x26*/ u8 spriteAnimation[3]; /*0x29*/ SpritePriority spritePriority; /*0x2a*/ u16 collisions; - /*0x2c*/ union SplitWord x; /**< X position, fixed point. */ - /*0x30*/ union SplitWord y; /**< Y position, fixed point. */ - /*0x34*/ union SplitWord z; /**< Z position, fixed point. */ + /*0x2c*/ union SplitWord x; /**< X position, fixed point Q16.16. */ + /*0x30*/ union SplitWord y; /**< Y position, fixed point Q16.16. */ + /*0x34*/ union SplitWord z; /**< Z position, fixed point Q16.16. */ /*0x38*/ u8 collisionLayer; /**< Collision layer. */ /*0x39*/ s8 interactType; /*0x3a*/ u8 field_0x3a; diff --git a/include/functions.h b/include/functions.h index 819701fa..c301b841 100644 --- a/include/functions.h +++ b/include/functions.h @@ -96,7 +96,7 @@ extern u32 sub_0805F8F8(u32); extern u32 sub_0805F7A0(u32); extern u32* sub_0805F25C(u32); u32 sub_0806FCB8(Entity*, u32, u32, u32); -extern void sub_0806F62C(Entity*, u32, u32); +extern void LinearMoveAngle(Entity*, u32, u32); extern void sub_080A1ED0(u32, u32, u32); extern u32 sub_0806F5B0(u32); extern void sub_08078790(Entity*, u32); @@ -125,7 +125,7 @@ extern bool32 sub_080806BC(u32, u32, u32, u32); extern bool32 sub_0806FC80(Entity*, Entity*, s32); extern u32 sub_080002B4(Entity*, u32, u32); extern u32 sub_080AF134(Entity*); -extern void sub_0806F5BC(Entity*, u32, u32); +extern void LinearMoveDirection(Entity*, u32, u32); extern void sub_080A2AF4(Entity*, u32, u32); extern u32 sub_080002CC(Entity*, s32, s32); extern bool32 sub_0807BD14(Entity*, u32); diff --git a/include/global.h b/include/global.h index 0f656445..c1f16094 100644 --- a/include/global.h +++ b/include/global.h @@ -59,8 +59,8 @@ // Converts a number to Q8.8 fixed-point format #define Q_8_8(n) ((s16)((n)*256)) -// Converts a number to Q4.12 fixed-point format -#define Q_4_12(n) ((s16)((n)*4096)) +// Converts a number to Q16.16 fixed-point format +#define Q_16_16(n) ((s32)((n)*(1 << 16))) #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) >= (b) ? (a) : (b)) diff --git a/src/code_0805436C.c b/src/code_0805436C.c index 6d3eb919..2cb38c6e 100644 --- a/src/code_0805436C.c +++ b/src/code_0805436C.c @@ -250,7 +250,7 @@ u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter) { } else if (arg0->id == 0x1e) { itemEntity->direction = arg0->animationState << 3 | 0x80; itemEntity->speed = 0xc0; - itemEntity->zVelocity = 0x18000; + itemEntity->zVelocity = Q_16_16(1.5); } } CopyPosition(arg0, itemEntity); diff --git a/src/collision.c b/src/collision.c index f33bcb3f..91471613 100644 --- a/src/collision.c +++ b/src/collision.c @@ -290,7 +290,7 @@ void sub_080179EC(Entity* a1, Entity* a2) { u32 rand = Random(); Entity* e = CreateFx(a2, p[rand & 3], 0); if (e != NULL) { - PositionRelative(a2, e, a2->hitbox->offset_x << 16, a2->hitbox->offset_y << 16); + PositionRelative(a2, e, Q_16_16(a2->hitbox->offset_x), Q_16_16(a2->hitbox->offset_y)); e->spritePriority.b0 = 2; e->spriteOffsetX = (a1->x.HALF.HI + a1->hitbox->offset_x - (a2->x.HALF.HI + a2->hitbox->offset_x)) >> 1; e->spriteOffsetY = (a1->y.HALF.HI + a1->hitbox->offset_y - (a2->y.HALF.HI + a2->hitbox->offset_y)) >> 1; @@ -541,9 +541,9 @@ s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) gPlayerState.jump_status = 0; if (tgt->kind == ENEMY && (tgt->id == GHINI || tgt->id == ENEMY_50)) { org->z.HALF.HI = 0; - PositionRelative(org, tgt, 0, 0x10000); + PositionRelative(org, tgt, 0, Q_16_16(1.0)); } else { - PositionRelative(tgt, org, 0, 0x10000); + PositionRelative(tgt, org, 0, Q_16_16(1.0)); } COLLISION_OFF(org); org->spriteRendering.b3 = tgt->spriteRendering.b3; diff --git a/src/coord.c b/src/coord.c index c0c370c0..864144de 100644 --- a/src/coord.c +++ b/src/coord.c @@ -75,7 +75,7 @@ u32 sub_0806F3E4(Entity* ent) { p = &gUnk_08126EE4[gPlayerEntity.animationState & 0xE]; tmp_ent.x.HALF.HI = p[0] + gPlayerEntity.x.HALF.HI; tmp_ent.y.HALF.HI = p[1] + gPlayerEntity.y.HALF.HI; - sub_0806F5BC(ent, ent->field_0x46, GetFacingDirection(ent, &tmp_ent)); + LinearMoveDirection(ent, ent->field_0x46, GetFacingDirection(ent, &tmp_ent)); if (sub_0800419C(&tmp_ent, ent, 4, 4)) { u32 state = ent->field_0x1c & 0xF; if (state == 2) { @@ -146,7 +146,7 @@ u32 sub_0806F5B0(u32 idx) { return gUnk_08114F58[idx]; } -void sub_0806F5BC(Entity* ent, u32 a, u32 b) { +void LinearMoveDirection(Entity* ent, u32 a, u32 b) { if ((b & 0x80) == 0) { u32 m1 = b; @@ -155,15 +155,15 @@ void sub_0806F5BC(Entity* ent, u32 a, u32 b) { } } -void sub_0806F62C(Entity* ent, u32 a, u32 b) { +void LinearMoveAngle(Entity* ent, u32 a, u32 b) { ent->x.WORD += FixedDiv(FixedMul(gSineTable[(u8)b], a), 256) << 8; ent->y.WORD -= FixedDiv(FixedMul(gSineTable[(u8)b + 64], a), 256) << 8; } void LinearMoveUpdate(Entity* ent) { if ((ent->direction & 0x80) == 0) { - ent->x.WORD += FixedDiv(FixedMul(gSineTable[ent->direction * 8], ent->speed), 256) << 8; - ent->y.WORD -= FixedDiv(FixedMul(gSineTable[ent->direction * 8 + 64], ent->speed), 256) << 8; + ent->x.WORD += FixedDiv(FixedMul(gSineTable[ent->direction * 8], ent->speed), (1 << 8)) << 8; + ent->y.WORD -= FixedDiv(FixedMul(gSineTable[ent->direction * 8 + 64], ent->speed), (1 << 8)) << 8; } } @@ -290,13 +290,13 @@ s16 FixedDiv(s16 r0, s16 r1) { return (r0 * 256) / r1; } -void CopyPosition(Entity* param_1, Entity* param_2) { - PositionRelative(param_1, param_2, 0, 0); +void CopyPosition(Entity* source, Entity* target) { + PositionRelative(source, target, 0, 0); } -void PositionEntityOnTop(Entity* ent, Entity* ent2) { - PositionRelative(ent, ent2, 0, 0); - ResolveEntityOnTop(ent, ent2); +void PositionEntityOnTop(Entity* source, Entity* target) { + PositionRelative(source, target, 0, 0); + SortEntityAbove(source, target); } void PositionRelative(Entity* source, Entity* target, s32 offsetX, s32 offsetY) { @@ -314,24 +314,24 @@ void PositionRelative(Entity* source, Entity* target, s32 offsetX, s32 offsetY) UpdateSpriteForCollisionLayer(target); } -void CopyPositionAndSpriteOffset(Entity* param_1, Entity* param_2) { - param_2->spriteOffsetX = param_1->spriteOffsetX; - param_2->spriteOffsetY = param_1->spriteOffsetY; - PositionRelative(param_1, param_2, 0, 0); +void CopyPositionAndSpriteOffset(Entity* source, Entity* target) { + target->spriteOffsetX = source->spriteOffsetX; + target->spriteOffsetY = source->spriteOffsetY; + PositionRelative(source, target, 0, 0); } -void sub_0806FA90(Entity* param_1, Entity* param_2, s32 offsetX, s32 offsetY) { - param_2->spriteOffsetX = param_1->spriteOffsetX; - param_2->spriteOffsetY = param_1->spriteOffsetY; - PositionRelative(param_1, param_2, offsetX * 64 * 32 * 32, offsetY * 64 * 32 * 32); +void sub_0806FA90(Entity* source, Entity* target, s32 offsetX, s32 offsetY) { + target->spriteOffsetX = source->spriteOffsetX; + target->spriteOffsetY = source->spriteOffsetY; + PositionRelative(source, target, Q_16_16(offsetX), Q_16_16(offsetY)); } -void ResolveEntityOnTop(Entity* param_1, Entity* param_2) { - param_2->spritePriority.b0 = gUnk_08114F78[param_1->spritePriority.b0]; +void SortEntityAbove(Entity* relativeTo, Entity* above) { + above->spritePriority.b0 = gUnk_08114F78[relativeTo->spritePriority.b0]; } -void ResolveEntityBelow(Entity* param_1, Entity* param_2) { - param_2->spritePriority.b0 = gUnk_08114F80[param_1->spritePriority.b0]; +void SortEntityBelow(Entity* relativeTo, Entity* below) { + below->spritePriority.b0 = gUnk_08114F80[relativeTo->spritePriority.b0]; } // Values of sin(x*(π/128)) as Q8.8 fixed-point numbers from x = 0 to x = 319 diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index 3fe81a09..8f882be1 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -104,7 +104,7 @@ void sub_080318DC(Entity* this) { void sub_08031A60(Entity* this) { if (this->iframes > 0) - GravityUpdate(this, 0x1800); + GravityUpdate(this, Q_8_8(24.0)); sub_08001324(this); } @@ -315,7 +315,7 @@ void sub_08031E90(Entity* this) { void sub_08031EA8(Entity* this) { this->action = 1; this->spritePriority.b1 = 1; - this->zVelocity = 0x40000; + this->zVelocity = Q_16_16(4.0); this->z.HALF.HI = (4 - this->type2) * 0xe; this->field_0x78.HALF.HI = Random(); InitializeAnimation(this, 4); @@ -325,7 +325,7 @@ void sub_08031EE8(Entity* this) { int draw; this->z.WORD -= this->zVelocity; - this->zVelocity -= 0x1800; + this->zVelocity -= Q_16_16(3.0 / 32.0); if (this->z.HALF.HI < 1) { draw = this->spriteSettings.draw; @@ -442,7 +442,7 @@ void sub_08032160(Entity* this) { this->spriteSettings.flipX = 0; } this->speed = 0xf0; - this->zVelocity = 0x12000; + this->zVelocity = Q_16_16(1.125); this->spritePriority.b1 = 1; InitializeAnimation(this, 12); } @@ -477,7 +477,7 @@ void sub_08032204(Entity* this) { } void sub_08032248(Entity* this) { - if (GravityUpdate(this, 0x1800) == 0) { + if (GravityUpdate(this, Q_8_8(24.0)) == 0) { if (this->frame & 0x80) { ((Entity*)this->field_0x7c.WORD)->actionDelay--; diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index c03ff919..e01f69d1 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -109,7 +109,7 @@ void sub_080218CC(Entity* this) { this->spriteSettings.draw = 1; this->direction = ((sub_08049F84(this, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & 0x1f; this->speed = 0x100; - this->zVelocity = 0x12000; + this->zVelocity = Q_16_16(1.125); } GetNextFrame(this); @@ -242,7 +242,7 @@ void sub_08021B64(Entity* this) { if (iVar4 == 0) { this->action = 6; - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); ((u8*)&this->field_0x86)[1] = 0; if (gPlayerEntity.direction != 0xff) { this->direction = 0x10 ^ gPlayerEntity.direction; @@ -303,7 +303,7 @@ u32 sub_08021D00(Entity* this) { } else { this->action = 4; this->actionDelay = 1; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); InitializeAnimation(this, 4); ret = 1; } diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index ebc47375..ef6c9dcf 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -61,7 +61,7 @@ void sub_0802C688(Entity* this) { this->action = 3; this->hitType = 0x6e; this->field_0xf = 1; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->speed = 0; this->field_0x80.HALF.HI = 1; InitializeAnimation(this, this->direction >> 4 | 6); @@ -79,7 +79,7 @@ void sub_0802C7AC(Entity* this) { if (this->field_0x82.HALF.LO != 2) { this->speed = this->field_0x82.HALF.LO ? 0x200 : 0x80; } - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->field_0x82.HALF.HI = 0; this->field_0x80.HALF.HI = 0; } else { @@ -232,7 +232,7 @@ void sub_0802CA94(Entity* this) { COLLISION_OFF(this); this->field_0xf = 1; this->spritePriority.b1 = 1; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->speed = 0; this->field_0x82.HALF.HI = 0; this->field_0x80.HALF.HI = 0; diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c index 3a7a0064..bc6367ee 100644 --- a/src/enemy/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -381,7 +381,7 @@ void sub_0802ADDC(Entity* this) { void sub_0802AE24(Entity* this) { this->action = 1; this->actionDelay = 0xf0; - this->zVelocity = 0x8000; + this->zVelocity = Q_16_16(0.5); this->hitbox = (Hitbox*)&gUnk_080CD174; this->field_0x3c = 3; this->field_0x16 = 0; diff --git a/src/enemy/chuchu.c b/src/enemy/chuchu.c index 9d8d4ff3..c8e7640e 100644 --- a/src/enemy/chuchu.c +++ b/src/enemy/chuchu.c @@ -722,7 +722,7 @@ u32 sub_0801FBD0(Entity* this) { void Chuchu_JumpAtPlayer(Entity* this) { this->speed = 0x180; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); this->direction = sub_08049F84(this, 1); InitializeAnimation(this, 3); } diff --git a/src/enemy/cuccoChickAggr.c b/src/enemy/cuccoChickAggr.c index 2b6bb47f..94326739 100644 --- a/src/enemy/cuccoChickAggr.c +++ b/src/enemy/cuccoChickAggr.c @@ -52,7 +52,7 @@ void sub_08022988(Entity* this) { return; this->frameIndex = 1; - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); EnqueueSFX(0xd6); } @@ -78,7 +78,7 @@ void sub_080229F8(Entity* this) { this->speed = 0xc0; sub_08022B44(this); } else { - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); EnqueueSFX(0xd6); } } @@ -141,7 +141,7 @@ u32 sub_08022B20(Entity* this) { } void sub_08022B44(Entity* this) { - this->zVelocity = 0xc000; + this->zVelocity = Q_16_16(0.75); this->direction = GetFacingDirection(this, &gPlayerEntity); if (this->direction & 0xf) diff --git a/src/enemy/fallingBoulder.c b/src/enemy/fallingBoulder.c index d414ce52..a9dfc7d6 100644 --- a/src/enemy/fallingBoulder.c +++ b/src/enemy/fallingBoulder.c @@ -37,7 +37,7 @@ void sub_0802C254(Entity* this) { void sub_0802C258(Entity* this) { sub_0804A720(this); - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); this->actionDelay = 2; this->field_0x7a.HWORD = Random() & 0x70; switch (this->type) { @@ -195,7 +195,7 @@ void sub_0802C4B0(Entity* this) { } rand = Random() & 7; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); if (rand & 4) { if (rand & 3) { *(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 1]; diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c index 5e81c1d6..a0546fb8 100644 --- a/src/enemy/fireballGuy.c +++ b/src/enemy/fireballGuy.c @@ -102,7 +102,7 @@ u32 sub_0804A024(Entity*, u32, u32); void sub_08045524(Entity* this) { u32 tmp, tmp1, tmp2; - this->zVelocity = 0x1c000; + this->zVelocity = Q_16_16(1.75); tmp = sub_0804A024(this, 1, 8); if (tmp != 0xff && (Random() & 3) == 0) { this->actionDelay = Random() & 3; diff --git a/src/enemy/flyingSkull.c b/src/enemy/flyingSkull.c index 9a824c35..934bfef5 100644 --- a/src/enemy/flyingSkull.c +++ b/src/enemy/flyingSkull.c @@ -46,7 +46,7 @@ void sub_08039BF8(FlyingSkullEntity* this) { if (super->bitfield == 0x9d) { super->action = 7; COLLISION_OFF(super); - super->zVelocity = 0x2A000; + super->zVelocity = Q_16_16(2.625); super->spritePriority.b1 = 1; SetTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); } else if (super->z.HALF.HI) { diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c index d2dabadb..6f06b9ac 100644 --- a/src/enemy/gyorgMale.c +++ b/src/enemy/gyorgMale.c @@ -1033,7 +1033,7 @@ void sub_08047DF0(GyorgMaleEntity* this, u32 unk1) { sub_08047EA4(this, unk1); oldX = super->x.HALF.HI; oldY = super->y.HALF.HI; - sub_0806F62C(super, super->speed, super->direction); + LinearMoveAngle(super, super->speed, super->direction); if (this->unk_7c & 1) { if (sub_08079F8C()) { gPlayerEntity.x.HALF.HI += super->x.HALF.HI - oldX; @@ -1051,7 +1051,7 @@ void sub_08047E58(GyorgMaleEntity* this) { u32 oldX, oldY; oldX = super->x.HALF.HI; oldY = super->y.HALF.HI; - sub_0806F62C(super, super->speed, super->direction); + LinearMoveAngle(super, super->speed, super->direction); if (this->unk_7c & 1) { if (sub_08079F8C()) { gPlayerEntity.x.HALF.HI += super->x.HALF.HI - oldX; diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index 3187c340..be7f9dad 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -95,7 +95,7 @@ void sub_0802BCA8(Entity* this) { this->action = 7; this->actionDelay = 0x5a; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->hitType = 0x19; this->field_0x3a = this->field_0x3a & 0xfb; this->field_0x1c = 0x12; @@ -222,7 +222,7 @@ void sub_0802BEBC(Entity* this) { this->direction ^= 0x10; sub_080AEFE0(this); this->direction ^= 0x10; - if (!sub_080044EC(this, 0x2000)) { + if (!sub_080044EC(this, Q_16_16(0.125))) { sub_0802C1C0(this); } } @@ -234,7 +234,7 @@ void sub_0802BEEC(Entity* this) { this->direction = this->animationState << 3; InitializeAnimation(this, this->animationState + 4); } - } else if (!GravityUpdate(this, 0x1c00)) { + } else if (!GravityUpdate(this, Q_16_16(0.109375))) { this->action = 8; this->actionDelay = 30; this->speed = 0x120; @@ -356,7 +356,7 @@ void sub_0802C18C(Entity* this) { if ((this->field_0x78.HALF.LO & 7) == 0) { Entity* ent = CreateObject(SPECIAL_FX, 0x11, 0x40); if (ent) { - PositionRelative(this, ent, 0, 0x10000); + PositionRelative(this, ent, 0, Q_16_16(1.0)); } } } @@ -374,8 +374,8 @@ void sub_0802C1CC(Entity* this) { void sub_0802C218(Entity* this) { this->action = 6; - this->speed = 0xe0; - this->zVelocity = 0x18000; + this->speed = Q_8_8(0.875); + this->zVelocity = Q_16_16(1.5); } // clang-format off diff --git a/src/enemy/keaton.c b/src/enemy/keaton.c index 3e1a0679..78349fbb 100644 --- a/src/enemy/keaton.c +++ b/src/enemy/keaton.c @@ -229,7 +229,7 @@ void sub_08032794(Entity* this) { target = CreateFx(this, FX_DASH, 0x40); if (target != NULL) { temp = &gUnk_080CE810[this->animationState * 2]; - PositionRelative(this, target, temp[0] << 0x10, temp[1] << 0x10); + PositionRelative(this, target, Q_16_16(temp[0]), Q_16_16(temp[1])); } } diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c index 25dd93ea..09a47a84 100644 --- a/src/enemy/lakitu.c +++ b/src/enemy/lakitu.c @@ -59,7 +59,7 @@ void Lakitu_DoAction(Entity* this) { void sub_0803C784(Entity* this) { if ((this->bitfield & 0x7f) == 0x1d) { - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); sub_0803CBAC(this); } else { @@ -316,7 +316,7 @@ void Lakitu_SpawnLightning(Entity* this) { lightning->direction = this->field_0x78.HALF.LO; - PositionRelative(this, lightning, offset->x << 16, offset->y << 16); + PositionRelative(this, lightning, Q_16_16(offset->x), Q_16_16(offset->y)); EnqueueSFX(0x193); } @@ -346,6 +346,8 @@ void sub_0803CC08(Entity* this) { Entity* cloud; Entity* fx; + const s32 diff = Q_8_8(3.0 / 128.0); + cloud = this->child; if (cloud == NULL) { return; @@ -365,26 +367,26 @@ void sub_0803CC08(Entity* this) { fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { - fx->x.HALF.HI += 6; - fx->y.HALF.HI += 6; + fx->x.HALF.HI += diff; + fx->y.HALF.HI += diff; } fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { - fx->x.HALF.HI -= 6; - fx->y.HALF.HI += 6; + fx->x.HALF.HI -= diff; + fx->y.HALF.HI += diff; } fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { - fx->x.HALF.HI += 6; - fx->y.HALF.HI -= 6; + fx->x.HALF.HI += diff; + fx->y.HALF.HI -= diff; } fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { - fx->x.HALF.HI -= 6; - fx->y.HALF.HI -= 6; + fx->x.HALF.HI -= diff; + fx->y.HALF.HI -= diff; } this->child = NULL; diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index ca5f59e0..d65a4c8a 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -193,7 +193,7 @@ void sub_0802805C(Entity* this) { } else { ResetPlayer(); gPlayerState.mobility |= 0x80; - PositionRelative(this, &gPlayerEntity, 0, 0x10000); + PositionRelative(this, &gPlayerEntity, 0, Q_16_16(1.0)); tmp = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex); gPlayerEntity.spriteOffsetX = tmp[0]; @@ -215,7 +215,7 @@ NONMATCH("asm/non_matching/likeLike/sub_0802810C.inc", void sub_0802810C(Entity* gPlayerState.field_0xa = 0; gPlayerState.flags &= 0xffffffef; gPlayerEntity.flags |= 0x80; - gPlayerEntity.zVelocity = 0x18000; + gPlayerEntity.zVelocity = Q_16_16(1.5); gPlayerEntity.iframes = -60; gPlayerEntity.direction = gPlayerEntity.animationState << 2; gPlayerEntity.spritePriority.b1 = this->field_0x82.HALF.HI; diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index b78c9b07..8c43062d 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -189,7 +189,7 @@ void sub_0803A274(Entity* this) { pEVar1 = CreateObject(OBJECT_7E, 1, 0); pEVar1->parent = this; pEVar1->child = this->child; - PositionRelative(this->parent, this, 0x100000, 0x200000); + PositionRelative(this->parent, this, Q_16_16(16.0), Q_16_16(32.0)); } else { pEVar1 = CreateEnemy(MAZAAL_HAND, 1); pEVar1->parent = this; @@ -201,7 +201,7 @@ void sub_0803A274(Entity* this) { pEVar1->parent = this; pEVar1->child = this->child; this->spriteSettings.flipX = 1; - PositionRelative(this->parent, this, -0x100000, 0x200000); + PositionRelative(this->parent, this, Q_16_16(-16.0), Q_16_16(32.0)); } if (gRoomTransition.field_0x38 != 0) { this->action = 3; @@ -917,7 +917,7 @@ void sub_0803B100(Entity* this) { Entity* temp; this->action = 0x29; - this->zVelocity = 0x14000; + this->zVelocity = Q_16_16(1.25); if (this->type == 0) { this->hitbox = &gUnk_080FD364; } else { @@ -974,7 +974,7 @@ void sub_0803B1B8(Entity* this) { if (temp != (Entity*)0x0) { temp->actionDelay = 0; temp->direction = 0x90; - PositionRelative(this, temp, this->hitbox->offset_x << 0x10, this->hitbox->offset_y << 0x10); + PositionRelative(this, temp, Q_16_16(this->hitbox->offset_x), Q_16_16(this->hitbox->offset_y)); } temp = *(Entity**)&this->field_0x74; temp->field_0x74.HALF.LO = 0x40; @@ -1086,7 +1086,7 @@ void sub_0803B480(Entity* this) { Entity* target; if (((this->field_0x7c.HALF.HI & 0x1f) == 0) && (target = CreateObject(SMOKE, 1, 0), target != (Entity*)0x0)) { - PositionRelative(this, target, gUnk_080CFD08[this->type] << 0x10, 0); + PositionRelative(this, target, Q_16_16(gUnk_080CFD08[this->type]), 0); } if (--this->field_0x7c.HALF.HI == 0) { sub_0803B6A4(this); @@ -1115,8 +1115,8 @@ u32 sub_0803B4E4(Entity* this) { } void sub_0803B538(Entity* this) { - PositionRelative(this, this->child, 0, -0x10000); - PositionRelative(this, *(Entity**)&this->field_0x74, 0, -0x20000); + PositionRelative(this, this->child, 0, Q_16_16(-1.0)); + PositionRelative(this, *(Entity**)&this->field_0x74, 0, Q_16_16(-2.0)); } void sub_0803B55C(Entity* this) { @@ -1230,7 +1230,7 @@ void sub_0803B798(void) { gPlayerState.field_0xa = 0; gPlayerState.flags &= ~(0xffff0000 | PL_CAPTURED); gPlayerEntity.flags |= 0x80; - gPlayerEntity.zVelocity = 0x18000; + gPlayerEntity.zVelocity = Q_16_16(1.5); gPlayerEntity.z.HALF.HI = -10; gPlayerEntity.direction = 0x10; gPlayerEntity.animationState = 4; diff --git a/src/enemy/mazaalHead.c b/src/enemy/mazaalHead.c index af37d745..fa44a8d4 100644 --- a/src/enemy/mazaalHead.c +++ b/src/enemy/mazaalHead.c @@ -741,7 +741,7 @@ void sub_08034A84(Entity* this) { } void sub_08034AC4(Entity* this) { - PositionRelative(this->parent, this, 0, 0x10000); + PositionRelative(this->parent, this, 0, Q_16_16(1.0)); gUnk_080CED74[this->action](this); } @@ -782,7 +782,7 @@ void sub_08034B38(Entity* this) { target->direction = this->actionDelay + 0x58; } ptr = &gUnk_080CED84[target->type * 2]; - PositionRelative(this, target, *(ptr++) << 0x10, *ptr << 0x10); + PositionRelative(this, target, Q_16_16(*(ptr++)), Q_16_16(*ptr)); } } } diff --git a/src/enemy/miniFireballGuy.c b/src/enemy/miniFireballGuy.c index b9a64caf..fd6f54e2 100644 --- a/src/enemy/miniFireballGuy.c +++ b/src/enemy/miniFireballGuy.c @@ -57,7 +57,7 @@ void sub_08045654(Entity* this) { void sub_08045678(Entity* this) { - this->zVelocity = 0x1c000; + this->zVelocity = Q_16_16(1.75); if (this->actionDelay != 0) { this->actionDelay--; } else { diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c index cb055f0b..80d1a055 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -87,7 +87,7 @@ void sub_080230E4(Entity* this) { CopyPosition(this, &gPlayerEntity); gPlayerEntity.flags = gPlayerEntity.flags | 0x80; gPlayerEntity.spriteSettings.draw = 1; - gPlayerEntity.zVelocity = 0x18000; + gPlayerEntity.zVelocity = Q_16_16(1.5); gPlayerEntity.direction = 0xff; gPlayerEntity.iframes = -0x14; gPlayerState.jump_status = 0x41; @@ -270,7 +270,7 @@ void sub_0802351C(Entity* this) { if (this->type2 == 0) { gPlayerEntity.animationState = this->animationState & 7; gPlayerState.flags |= PL_MOLDWORM_CAPTURED; - PositionRelative(this, &gPlayerEntity, 0, gUnk_080CBC90[this->animationState & 7] << 0x10); + PositionRelative(this, &gPlayerEntity, 0, Q_16_16(gUnk_080CBC90[this->animationState & 7])); gPlayerEntity.spriteOffsetY = -gUnk_080CBC90[this->animationState & 7]; } } else { diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c index c0aa2b65..f603afd8 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -617,7 +617,7 @@ void OctorokBoss_Action1(Entity* this) { this->field_0x74.HWORD += 4; } } - ResolveEntityBelow(this->parent, this); + SortEntityBelow(this->parent, this); if (((GET_HELPER(this)->field_0x2 != 0) || (this->parent->action == INTRO)) || (1 < (u8)(this->parent->subAction - 3))) { if ((s8)this->field_0xf < 0) { @@ -649,9 +649,9 @@ void OctorokBoss_Action1(Entity* this) { if ((GET_HELPER(this)->tailCount - 2) < this->type2) { DeleteThisEntity(); } - ResolveEntityOnTop(this->parent, this); + SortEntityAbove(this->parent, this); if (GET_HELPER(this)->tailCount - 2 == this->type2) { - ResolveEntityOnTop(this->parent, this); + SortEntityAbove(this->parent, this); radius = 0x10000 / this->parent->field_0x74.HWORD; radius = radius << 0xd >> 0x8; angle = -this->parent->field_0x7a.HALF.HI; @@ -693,7 +693,7 @@ void OctorokBoss_Action1(Entity* this) { if (this->health == 1) { this->health = 0; } else { - ResolveEntityBelow(this->parent, this); + SortEntityBelow(this->parent, this); if ((this->parent->subAction != 4) && (this->health != 1)) { if (GET_TIMER(this) > 0x1c) { GET_TIMER(this)--; @@ -939,7 +939,7 @@ void OctorokBoss_ExecuteAttackVacuum(Entity* this) { if (sub_0806FC80(this, &gPlayerEntity, 0xf0) != 0) { if ((gPlayerState.flags & PL_FROZEN) == 0) { if ((gPlayerEntity.flags & PL_MINISH) != 0) { - sub_0806F62C(&gPlayerEntity, 0x280, -GET_ANGLE_HI(this)); + LinearMoveAngle(&gPlayerEntity, 0x280, -GET_ANGLE_HI(this)); if (sub_0806FC80(this, &gPlayerEntity, 0x48) != 0) { this->field_0x80.HALF.LO = 1; GET_TIMER(this) = 2; diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index 2f08e47a..6389b179 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -265,7 +265,7 @@ void Peahat_RepairPropeller(Entity* this) { return; this->action = 9; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->direction = Random() & 0x1f; sub_0804AA1C(this); this->animationState = PeahatAnimation_RepairPropeller; @@ -291,7 +291,7 @@ void Peahat_Hop(Entity* this) { if (--this->actionDelay == 0) { if (this->frame & 0x80) { this->action = 9; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->animationState = PeahatAnimation_NewPropeller; InitializeAnimation(this, this->animationState); } else { diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index 34e316cc..b52a69fc 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -811,7 +811,7 @@ void sub_08024E4C(Entity* this) { gPlayerState.field_0x38 = 0x14; gPlayerState.field_0x39 = 1; *(u8*)&gPlayerState.field_0x3a = 0; - PositionRelative(this, player, 0, 0x10000); + PositionRelative(this, player, 0, Q_16_16(1.0)); player->spriteOffsetY = 0x1a; player->animationState = 4; player->spritePriority.b1 = 0; diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c index 6e35dbfc..e4763610 100644 --- a/src/enemy/puffstool.c +++ b/src/enemy/puffstool.c @@ -198,7 +198,7 @@ void sub_080252E0(Entity* this) { this->action = 3; this->actionDelay = 0x1e; this->field_0xf = 0; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); InitializeAnimation(this, 1); } } @@ -210,8 +210,8 @@ void sub_0802538C(Entity* this) { if (this->frame == 0) { GetNextFrame(this); } else { - GravityUpdate(this, 0x2000); - if (this->zVelocity < 0x2000) { + GravityUpdate(this, Q_16_16(0.125)); + if (this->zVelocity < Q_16_16(0.125)) { this->action = 4; InitializeAnimation(this, 2); } @@ -240,7 +240,7 @@ void sub_0802541C(Entity* this) { if (this->frame & 0x80) { this->action = 3; this->field_0xf = 1; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2); InitializeAnimation(this, 1); } } @@ -257,7 +257,7 @@ void sub_0802544C(Entity* this) { } void sub_0802547C(Entity* this) { - GravityUpdate(this, 0x2000); + GravityUpdate(this, Q_16_16(0.125)); GetNextFrame(this); if ((this->actionDelay & 7) == 0) { sub_08025BD4(this); @@ -269,7 +269,7 @@ void sub_0802547C(Entity* this) { } void sub_080254B4(Entity* this) { - GravityUpdate(this, 0x2000); + GravityUpdate(this, Q_16_16(0.125)); if (this->frame & 0x80) { if (this->z.HALF.HI == 0) { if (this->cutsceneBeh.HWORD == 0) { @@ -553,7 +553,7 @@ void sub_08025B18(Entity* this) { ent = CreateObject(OBJECT_21, 2, 0); if (ent) { - PositionRelative(this, ent, offset[0] * 0x10000, offset[1] * 0x10000); + PositionRelative(this, ent, Q_16_16(offset[0]), Q_16_16(offset[1])); ent->x.HALF.HI &= -0x10; ent->x.HALF.HI += 8; ent->y.HALF.HI &= -0x10; @@ -567,8 +567,8 @@ void sub_08025BD4(Entity* this) { if (this->field_0x82.HALF.LO && (this->frame & 1) == 0) { Entity* ent = CreateObject(OBJECT_21, 0, 0); if (ent) { - PositionRelative(this, ent, gUnk_080CC0BA[this->animationState * 2 + 0] * 0x10000, - gUnk_080CC0BA[this->animationState * 2 + 1] * 0x10000); + PositionRelative(this, ent, Q_16_16(gUnk_080CC0BA[this->animationState * 2 + 0]), + Q_16_16(gUnk_080CC0BA[this->animationState * 2 + 1])); ent->z.HALF.HI = -10; } } diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index 9a86c115..c80786d3 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -37,7 +37,7 @@ void Rollobite_OnTick(Entity* this) { void sub_08020668(Entity* this) { if (this->hitType == 34 && this->health != 0xff) { this->action = 4; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); this->direction = 0xff; this->health = 0xff; this->hitType = 35; @@ -107,7 +107,7 @@ void sub_080207A8(Entity* this) { this->spritePriority.b0 = 4; this->field_0x3a &= 0xfb; this->direction ^= 0x10; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->speed = 0x80; InitializeAnimation(this, this->animationState + 0x10); } @@ -267,7 +267,7 @@ bool32 Rollobite_TryToHoleUp(Entity* this) { this->x.HALF.HI += 8; this->y.HALF.HI &= 0xfff0; this->y.HALF.HI += 13; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); InitializeAnimation(this, this->animationState + 0x14); SetTile(0x4034, tile, this->collisionLayer); return TRUE; diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index d2393187..bb8e176f 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -171,7 +171,7 @@ void sub_0802953C(Entity* this) { } else { ResetPlayer(); gPlayerState.mobility |= 0x80; - PositionRelative(this, &gPlayerEntity, 0, 0x10000); + PositionRelative(this, &gPlayerEntity, 0, Q_16_16(1.0)); pbVar3 = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex); gPlayerEntity.spriteOffsetX = pbVar3[0]; gPlayerEntity.spriteOffsetY = pbVar3[1] - 1; @@ -240,7 +240,7 @@ void sub_080296D8(Entity* this) { gPlayerState.jump_status = 0x41; gPlayerState.flags &= ~PL_CAPTURED; gPlayerEntity.flags |= 0x80; - gPlayerEntity.zVelocity = 0x18000; + gPlayerEntity.zVelocity = Q_16_16(1.5); gPlayerEntity.iframes = 0xa6; gPlayerEntity.z.HALF.HI = -2; gPlayerEntity.direction = gPlayerEntity.animationState << 2; diff --git a/src/enemy/sluggula.c b/src/enemy/sluggula.c index 308d914f..720b3a50 100644 --- a/src/enemy/sluggula.c +++ b/src/enemy/sluggula.c @@ -124,7 +124,7 @@ void sub_08023CE0(Entity* this) { EnqueueSFX(0x12d); InitializeAnimation(this, 4); } - } else if (!GravityUpdate(this, 0x1800)) { + } else if (!GravityUpdate(this, Q_8_8(24))) { this->action = 3; this->spriteSettings.draw = 1; EnqueueSFX(0x84); @@ -169,7 +169,7 @@ void sub_08023E54(Entity* this) { ent = CreateEnemy(SLUGGULA, 2); if (ent) { const s8* ptr = &gUnk_080CBDF7[this->animationState * 2]; - PositionRelative(this, ent, ptr[0] << 0x10, ptr[1] << 0x10); + PositionRelative(this, ent, Q_16_16(ptr[0]), Q_16_16(ptr[1])); } } } diff --git a/src/enemy/spikedBeetle.c b/src/enemy/spikedBeetle.c index a6fa4ae6..f4f6792e 100644 --- a/src/enemy/spikedBeetle.c +++ b/src/enemy/spikedBeetle.c @@ -54,7 +54,7 @@ void sub_0802B628(Entity* this) { case 0x1d: if (this->action < 6) { this->action = 6; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->speed = 0xc0; this->direction = this->knockbackDirection; this->knockbackDuration = 0; @@ -171,7 +171,7 @@ void sub_0802B8E0(Entity* this) { } } else { this->action = 8; - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); this->speed = 0x60; this->hitType = 99; InitializeAnimation(this, this->animationState); diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c index a51c8ac4..c6db356b 100644 --- a/src/enemy/spinyChuchu.c +++ b/src/enemy/spinyChuchu.c @@ -93,7 +93,7 @@ void sub_080225A0(Entity* this) { } void sub_080225BC(Entity* this) { - GravityUpdate(this, 0x1800); + GravityUpdate(this, Q_8_8(24.0)); if (this->frame & 1) { sub_0804A7D4(this); } else { @@ -132,7 +132,7 @@ void sub_08022654(Entity* this) { InitializeAnimation(this, 0); /* fallthrough */ case 1: - if (GravityUpdate(this, 0x1800)) + if (GravityUpdate(this, Q_8_8(24.0))) return; this->subAction = 2; @@ -163,7 +163,7 @@ void sub_080226EC(Entity* this) { if (sub_080228F0(this)) { this->action = 6; - this->zVelocity = 0x12000; + this->zVelocity = Q_16_16(1.125); this->speed = 0x140; this->direction = GetFacingDirection(this, gUnk_020000B0); this->hitType = 0x5a; @@ -211,7 +211,7 @@ void sub_080227AC(Entity* this) { } void sub_0802281C(Entity* this) { - GravityUpdate(this, 0x1800); + GravityUpdate(this, Q_8_8(24.0)); GetNextFrame(this); if (this->frame & 0x80) { this->action = 2; @@ -225,7 +225,7 @@ void sub_08022854(Entity* this) { GetNextFrame(this); if (this->frame & 1) { sub_080AEFE0(this); - if (GravityUpdate(this, 0x1800) == 0) { + if (GravityUpdate(this, Q_8_8(24.0)) == 0) { this->action = 7; this->hitType = 0x5c; InitializeAnimation(this, 5); diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c index 4c63076d..3841377e 100644 --- a/src/enemy/tektiteGolden.c +++ b/src/enemy/tektiteGolden.c @@ -89,7 +89,7 @@ void sub_08037Fe0(Entity* this) { this->action = 2; this->actionDelay = 6; this->field_0xf = 0; - this->zVelocity = 0x38000; + this->zVelocity = Q_16_16(3.5); sub_08038168(this); InitializeAnimation(this, 2); } @@ -145,7 +145,7 @@ void sub_08038110(Entity* this) { if (this->field_0x80.HALF.LO < 5) { this->action = 2; this->actionDelay = 8; - this->zVelocity = 0x38000; + this->zVelocity = Q_16_16(3.5); sub_08038168(this); InitializeAnimation(this, 2); } else { diff --git a/src/enemy/vaatiArm.c b/src/enemy/vaatiArm.c index b4e2100b..c4344868 100644 --- a/src/enemy/vaatiArm.c +++ b/src/enemy/vaatiArm.c @@ -951,7 +951,7 @@ void sub_08043490(Entity* this) { entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[4]; if (entity->z.HALF.HI < -4) { - entity->zVelocity = 0x18000; + entity->zVelocity = Q_16_16(1.5); this->subAction = 2; this->field_0x7c.BYTES.byte2 = 0; ((VaatiArm_HeapStruct*)this->myHeap)->parent->subAction = 2; @@ -976,7 +976,7 @@ void sub_08043520(Entity* this) { Entity* entity; entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[4]; - GravityUpdate(entity, 0x1a00); + GravityUpdate(entity, Q_8_8(26.0)); if ((entity->zVelocity < 0) && (-6 < entity->z.HALF.HI)) { entity->z.HALF.HI = -6; this->subAction = 3; diff --git a/src/enemy/vaatiBall.c b/src/enemy/vaatiBall.c index 760bcb5d..ff441bc4 100644 --- a/src/enemy/vaatiBall.c +++ b/src/enemy/vaatiBall.c @@ -71,7 +71,7 @@ void sub_0804468C(Entity* this) { this->field_0x82.HALF.HI = 0; this->spriteSettings.draw = 0; off = &gUnk_080D1620[this->field_0x78.HALF.HI & 3]; - PositionRelative(this->parent, this, off->h << 0x10, (off->v - 0x10) * 0x10000); + PositionRelative(this->parent, this, Q_16_16(off->h), Q_16_16(off->v - 0x10)); this->z.HALF.HI = this->parent->z.HALF.HI; InitAnimationForceUpdate(this, 0); break; @@ -397,7 +397,7 @@ void sub_08044B04(Entity* this) { this->field_0x74.HALF.LO = 1; this->actionDelay = 80; COLLISION_OFF(this); - PositionRelative(vaati, this, 0, -0x100000); + PositionRelative(vaati, this, 0, Q_16_16(-16.0)); if (this->field_0xf) this->spriteSettings.draw = 0; break; @@ -463,7 +463,7 @@ void sub_08044DEC(Entity* this) { this->speed = 0x300; off = this->parent->field_0x80.HALF.LO - 1; this->direction = gUnk_080D1628[off][this->field_0x78.HALF.HI]; - PositionRelative(this->parent, this, 0, -0x100000); + PositionRelative(this->parent, this, 0, Q_16_16(-16.0)); } void sub_08044E74(Entity* this, u32 state) { @@ -475,7 +475,7 @@ void sub_08044E74(Entity* this, u32 state) { this->action = 2; this->direction += 0x18; this->direction &= 0x1f; - PositionRelative(this->parent, this, 0, -0x100000); + PositionRelative(this->parent, this, 0, Q_16_16(-16.0)); this->speed = 12288; LinearMoveUpdate(this); this->direction += 0x8; @@ -509,5 +509,5 @@ void sub_08044E74(Entity* this, u32 state) { } this->actionDelay = 1; this->field_0x78.HALF.LO = 0; - this->speed = 1280; + this->speed = Q_8_8(5); } diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c index c9d1fbbf..39e68307 100644 --- a/src/enemy/vaatiProjectile.c +++ b/src/enemy/vaatiProjectile.c @@ -121,7 +121,7 @@ void VaatiProjectileFunction0Action0(Entity* this) { this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY; this->spriteRendering.b3 = this->parent->spriteRendering.b3; this->spritePriority.b1 = 0; - PositionRelative(this->parent, this, 0, -0x10000); + PositionRelative(this->parent, this, 0, Q_16_16(-1.0)); InitializeAnimation(this, 1); } } @@ -207,7 +207,7 @@ void VaatiProjectileFunction0Action8(Entity* this) { if (this->parent->next == NULL) { DeleteThisEntity(); } - PositionRelative(this->parent, this, 0, -0x10000); + PositionRelative(this->parent, this, 0, Q_16_16(-1.0)); GetNextFrame(this); } diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index 612e3af4..99f1777b 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -135,7 +135,7 @@ void VaatiRebornEnemyType0Action0(Entity* this) { entity->parent = this; entity->spriteSettings.flipX = i; ptr = &gUnk_080D04A8[i]; - PositionRelative(this, entity, ptr->x << 0x10, ptr->y << 0x10); + PositionRelative(this, entity, Q_16_16(ptr->x), Q_16_16(ptr->y)); } InitAnimationForceUpdate(this, 0); } @@ -292,7 +292,7 @@ void VaatiRebornEnemyType0Action3(Entity* this) { break; case 0xff: if (this->z.HALF.HI != -4) { - this->z.WORD -= 0x2000; + this->z.WORD -= Q_16_16(0.125); } if (this->actionDelay == 2) { this->field_0x74.HALF.LO = 0xfe; @@ -442,7 +442,7 @@ void VaatiRebornEnemyType0Action6(Entity* this) { SoundReq(SFX_150); target = CreateProjectileWithParent(this, 0x18, 0); if (target != NULL) { - PositionRelative(this, target, 0, -0x100000); + PositionRelative(this, target, 0, Q_16_16(-16.0)); target->parent = this; } } else if (this->actionDelay == 0x40) { @@ -500,7 +500,7 @@ void VaatiRebornEnemyType1Action0(Entity* this) { this->field_0x74.HALF.HI = 1; this->actionDelay = 0; this->spriteOffsetY = -1; - PositionRelative(this->parent, this, 0, 0x10000); + PositionRelative(this->parent, this, 0, Q_16_16(1.0)); enemy = CreateEnemy(VAATI_REBORN_ENEMY, 2); enemy->parent = this; enemy->child = this->parent; @@ -546,7 +546,7 @@ void VaatiRebornEnemyType1Action1(Entity* this) { } this->spriteSettings.draw = parent->spriteSettings.draw; this->spriteOffsetX = parent->spriteOffsetX; - PositionRelative(this->parent, this, 0, 0x10000); + PositionRelative(this->parent, this, 0, Q_16_16(1.0)); UpdateAnimationSingleFrame(this); } @@ -559,7 +559,7 @@ void VaatiRebornEnemyType2Action0(Entity* this) { this->field_0x74.HALF.HI = 0; this->spriteOffsetY = -2; this->direction = 0xff; - PositionRelative(source, this, 0, 0x20000); + PositionRelative(source, this, 0, Q_16_16(2.0)); InitAnimationForceUpdate(this, 2); } @@ -595,7 +595,7 @@ void VaatiRebornEnemyType2Action1(Entity* this) { } this->spriteSettings.draw = parent->spriteSettings.draw; this->spriteOffsetX = parent->spriteOffsetX; - PositionRelative(parent->parent, this, 0, 0x20000); + PositionRelative(parent->parent, this, 0, Q_16_16(2.0)); UpdateAnimationSingleFrame(this); } @@ -637,7 +637,7 @@ void sub_0803DC0C(Entity* this) { tmp = &gUnk_080D04C8[this->actionDelay]; this->spriteSettings.draw = parent->spriteSettings.draw; this->spriteOffsetX = parent->spriteOffsetX; - PositionRelative(parent, this, tmp->x << 0x10, (tmp->y + 1) * 0x10000); + PositionRelative(parent, this, Q_16_16(tmp->x), Q_16_16(tmp->y + 1)); UpdateAnimationSingleFrame(this); } diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index 62ac8918..97cfa5cf 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -314,7 +314,7 @@ void VaatiTransfiguredType0Action3(Entity* this) { if (this->actionDelay != 0) { if (--this->actionDelay == 0) { COLLISION_OFF(this); - this->zVelocity = 0x38000; + this->zVelocity = Q_16_16(3.5); this->field_0xf = 0x10; } break; @@ -380,12 +380,12 @@ void VaatiTransfiguredType0Action4(Entity* this) { this->field_0x74.HALF.LO = 0; this->actionDelay = 0x80; this->field_0xf = 0; - this->zVelocity = 0x24000; + this->zVelocity = Q_16_16(2.25); SoundReq(SFX_12B); } break; case 1: - if (GravityUpdate(this, 0x2800) != 0) + if (GravityUpdate(this, Q_8_8(40)) != 0) break; this->field_0x80.HALF.LO += 1; switch (this->cutsceneBeh.HALF.LO) { @@ -1062,7 +1062,7 @@ void sub_080409B0(Entity* this) { this->field_0x80.HALF.HI = 3; COLLISION_OFF(this); this->hitType = 0x36; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); SoundReq(SFX_164); } } diff --git a/src/enemy/vaatiTransfiguredEye.c b/src/enemy/vaatiTransfiguredEye.c index 80fbb07f..e02f2f1b 100644 --- a/src/enemy/vaatiTransfiguredEye.c +++ b/src/enemy/vaatiTransfiguredEye.c @@ -215,7 +215,7 @@ void VaatiTransfiguredEyeFunction0Action4(Entity* this) { void sub_08045A00(Entity* this) { const struct xy* t = &gUnk_080D18B4[this->type2]; - PositionRelative(this->parent, this, t->x << 0x10, (t->y + 3) * 0x10000); + PositionRelative(this->parent, this, Q_16_16(t->x), Q_16_16(t->y + 3)); } void sub_08045A28(Entity* this) { @@ -291,7 +291,7 @@ void sub_08045A28(Entity* this) { break; } } else { - PositionRelative(this->parent, this, 0, -0x10000); + PositionRelative(this->parent, this, 0, Q_16_16(-1.0)); switch (this->field_0x82.HALF.HI) { case 0: switch (this->frame & 0x70) { diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index e77a11cd..58f8f83f 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -453,7 +453,7 @@ void VaatiWrathType0ActionA(Entity* this) { this->subAction = 0; this->direction = 0; this->speed = 0x100; - this->zVelocity = 0x12000; + this->zVelocity = Q_16_16(1.125); ChangeObjPalette(this, 0x16b); InitAnimationForceUpdate(this, 5); type1 = ((VaatiWrathHeapStruct*)this->myHeap)->type1; diff --git a/src/enemy/vaatiWrathEye.c b/src/enemy/vaatiWrathEye.c index 3a076bb6..360ba2eb 100644 --- a/src/enemy/vaatiWrathEye.c +++ b/src/enemy/vaatiWrathEye.c @@ -148,7 +148,7 @@ void VaatiWrathEyeAction6(Entity* this) { if (pEVar3 != NULL) { pEVar3->parent = this; this->child = pEVar3; - PositionRelative(this, pEVar3, 0, 0xc0000); + PositionRelative(this, pEVar3, 0, Q_16_16(12.0)); } } } diff --git a/src/enemy/waterDrop.c b/src/enemy/waterDrop.c index 3ce0985c..d964ab45 100644 --- a/src/enemy/waterDrop.c +++ b/src/enemy/waterDrop.c @@ -26,7 +26,7 @@ void sub_0802A250(Entity* this) { this->action = 1; this->actionDelay = 0; - this->zVelocity = -0x30000; + this->zVelocity = Q_16_16(-3.0); this->speed = gUnk_080CD03C[Random() & 3]; this->direction = gUnk_080CD040[Random() & 3] + 0x18; this->collisionLayer = 2; diff --git a/src/item/itemRocsCape.c b/src/item/itemRocsCape.c index ddba77c5..c3af396c 100644 --- a/src/item/itemRocsCape.c +++ b/src/item/itemRocsCape.c @@ -68,7 +68,7 @@ void sub_08076758(ItemBehavior* this, u32 arg1) { if ((gPlayerEntity.zVelocity < 1) && ((gPlayerState.jump_status & 0x10) == 0)) { this->stateID = 2; gPlayerEntity.field_0x7a.HWORD = 2; - gPlayerEntity.zVelocity = 0x20000; + gPlayerEntity.zVelocity = Q_16_16(2.0); gPlayerState.jump_status |= 0x10; gPlayerState.animation = 0x288; SoundReq(SFX_172); diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index 7bb9f3e3..0245c49c 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -275,7 +275,7 @@ void sub_0806D4C0(Entity* this, u32 param) { if (npc != NULL) { npc->parent = this; CopyPosition(this, npc); - ResolveEntityOnTop(this, npc); + SortEntityAbove(this, npc); SetDefaultPriority(npc, PRIO_MESSAGE); } } diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index 0b7de9f5..5d2ddca1 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -167,7 +167,7 @@ static void sub_08068BEC(Entity* this, u32 unused) { target = CreateFx(this, FX_WHITE_SPLASH, 0); if (target) { target->spritePriority.b0 = 1; - PositionRelative(this, target, 0, -0x100000); + PositionRelative(this, target, 0, Q_16_16(-16.0)); SoundReq(SFX_FA); } } diff --git a/src/npc/castorWildsStatue.c b/src/npc/castorWildsStatue.c index f3614564..2c388a08 100644 --- a/src/npc/castorWildsStatue.c +++ b/src/npc/castorWildsStatue.c @@ -134,7 +134,7 @@ void sub_080675D4(Entity* this) { ent->collisionLayer = this->collisionLayer; ent->spriteOrientation.flipY = this->spriteOrientation.flipY; ent->spriteRendering.b3 = this->spriteRendering.b3; - ResolveEntityOnTop(this, ent); + SortEntityAbove(this, ent); } }; gUnk = gUnk_08110E8A; @@ -147,7 +147,7 @@ void sub_080675D4(Entity* this) { ent->collisionLayer = this->collisionLayer; ent->spriteOrientation.flipY = this->spriteOrientation.flipY; ent->spriteRendering.b3 = this->spriteRendering.b3; - ResolveEntityOnTop(this, ent); + SortEntityAbove(this, ent); } }; if (this->subAction > 2) { diff --git a/src/npc/cuccoChick.c b/src/npc/cuccoChick.c index 0ccc0d17..46b564ad 100644 --- a/src/npc/cuccoChick.c +++ b/src/npc/cuccoChick.c @@ -75,7 +75,7 @@ void CuccoChick_Fusion(Entity* this) { this->frameIndex = 1; } else { if (GravityUpdate(this, 0x3000) == 0) { - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); } } } diff --git a/src/npc/drLeft.c b/src/npc/drLeft.c index a4942f0f..65eabde0 100644 --- a/src/npc/drLeft.c +++ b/src/npc/drLeft.c @@ -22,7 +22,7 @@ void DrLeft(Entity* this) { if (this->action == 0) { this->action += 1; this->frameIndex = 0; - ResolveEntityBelow(this, this); + SortEntityBelow(this, this); } } } diff --git a/src/npc/ezlo.c b/src/npc/ezlo.c index 77a69331..872a99c6 100644 --- a/src/npc/ezlo.c +++ b/src/npc/ezlo.c @@ -54,7 +54,7 @@ void sub_0806D96C(Entity* this) { Entity* fx = CreateFx(this, FX_STEAM_EFC, 0); if (fx != NULL) { fx->spritePriority.b0 = 1; - PositionRelative(this, fx, 0, 0xFFE80000); + PositionRelative(this, fx, 0, Q_16_16(-24.0)); } } diff --git a/src/npc/goron.c b/src/npc/goron.c index 22a217ca..baada241 100644 --- a/src/npc/goron.c +++ b/src/npc/goron.c @@ -70,11 +70,11 @@ void sub_080693D0(Entity* this) { if (this->frame == 1) { this->frame = 0; - sub_08069428(this, 0xFFF80000, createFx65); + sub_08069428(this, Q_16_16(-8.0), createFx65); } if (this->frame == 2) { this->frame = 0; - sub_08069428(this, 0x80 << 12, createFx65); + sub_08069428(this, Q_16_16(8.0), createFx65); } } } @@ -82,14 +82,14 @@ void sub_080693D0(Entity* this) { void sub_08069428(Entity* this, s32 offsetX, bool32 createFx65) { Entity* fx = CreateFx(this, FX_ROCK, 0); if (fx) { - PositionRelative(this, fx, offsetX, 0xFFF00000); - ResolveEntityOnTop(this, fx); + PositionRelative(this, fx, offsetX, Q_16_16(-16.0)); + SortEntityAbove(this, fx); } if (createFx65 != 0) { fx = CreateFx(this, FX_REFLECT4, 0); if (fx) { - PositionRelative(this, fx, offsetX, 0xFFF00000); - ResolveEntityOnTop(this, fx); + PositionRelative(this, fx, offsetX, Q_16_16(-16.0)); + SortEntityAbove(this, fx); } } } diff --git a/src/npc/gregal.c b/src/npc/gregal.c index f7038e95..5769c8ac 100644 --- a/src/npc/gregal.c +++ b/src/npc/gregal.c @@ -22,13 +22,13 @@ void sub_0806CAF4(Entity* this) { if (npc != NULL) { npc->parent = this; CopyPosition(this, npc); - ResolveEntityBelow(this, npc); + SortEntityBelow(this, npc); } npc = CreateNPC(0x4a, 2, 0); if (npc != NULL) { npc->parent = this; CopyPosition(this, npc); - ResolveEntityOnTop(this, npc); + SortEntityAbove(this, npc); } sub_0807DD64(this); sub_08078778(this); diff --git a/src/npc/kid.c b/src/npc/kid.c index 7e08592c..02910850 100644 --- a/src/npc/kid.c +++ b/src/npc/kid.c @@ -243,7 +243,7 @@ void sub_080626E0(Entity* this, ScriptExecutionContext* context) { uVar4 = Random(); this->direction = (this->direction + uVar4 % 0xb) - 5; } - sub_0806F62C(this, (s32)this->speed, (u32)this->direction); + LinearMoveAngle(this, (s32)this->speed, (u32)this->direction); if ((u32)((this->x.HALF.HI - context->x.HALF.HI) * 0x100 + ((s32)((u32)(u16)this->speed << 0x10) >> 0x11)) <= (u32)(s32)this->speed) { this->x.HALF.HI = context->x.HALF.HI; diff --git a/src/npc/malon.c b/src/npc/malon.c index deb17fe7..cff3828f 100644 --- a/src/npc/malon.c +++ b/src/npc/malon.c @@ -58,12 +58,12 @@ void sub_08065914(Entity* this) { target = FindEntityByID(7, 0x1F, 7); if (target != NULL) { - PositionRelative(this, target, 0x180000, -0x10000); + PositionRelative(this, target, Q_16_16(24.0), Q_16_16(-1.0)); target->parent = this; } target = FindEntityByID(7, 0x20, 7); if (target != NULL) { - PositionRelative(this, target, 0x280000, 0); + PositionRelative(this, target, Q_16_16(40.0), 0); target->parent = this; } } diff --git a/src/npc/melari.c b/src/npc/melari.c index f2d408b2..7b28d0e2 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -86,7 +86,7 @@ void sub_08068780(Entity* this) { } ent = CreateFx(this, FX_STARS2, 0x20); if (ent != NULL) { - PositionRelative(this, ent, 0x180000, -0xa0000); + PositionRelative(this, ent, Q_16_16(24.0), Q_16_16(-10.0)); } } } diff --git a/src/npc/npc4E.c b/src/npc/npc4E.c index 2d59b83e..b842076f 100644 --- a/src/npc/npc4E.c +++ b/src/npc/npc4E.c @@ -140,12 +140,12 @@ void sub_0806DB84(Entity* this, ScriptExecutionContext* context) { this->hitbox = (Hitbox*)&gUnk_08114154; ent = CreateObject(OBJECT_3E, 4, 0); if (ent != NULL) { - PositionRelative(this, ent, -0x80000, 0); + PositionRelative(this, ent, Q_16_16(-8.0), 0); *(ScriptExecutionContext**)&ent->cutsceneBeh = StartCutscene(ent, &script_Object3ELeftStoneOpening); } ent = CreateObject(OBJECT_3E, 5, 0); if (ent != NULL) { - PositionRelative(this, ent, 0x80000, 0); + PositionRelative(this, ent, Q_16_16(8.0), 0); *(ScriptExecutionContext**)&ent->cutsceneBeh = StartCutscene(ent, &script_Object3ERightStoneOpening); } } diff --git a/src/npc/pita.c b/src/npc/pita.c index b5a2e065..1f1f2308 100644 --- a/src/npc/pita.c +++ b/src/npc/pita.c @@ -12,7 +12,7 @@ void Pita(Entity* this) { if (this->action == 0) { this->action += 1; SetDefaultPriority(this, PRIO_MESSAGE); - ResolveEntityOnTop(this, this); + SortEntityAbove(this, this); this->hitbox = &gUnk_0810C428; sub_0807DD64(this); } diff --git a/src/npc/postman.c b/src/npc/postman.c index 48e7aa9e..3629950c 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -143,7 +143,7 @@ void sub_08060528(Entity* this) { if (0 < (s16)this->field_0x6a.HWORD) { if ((s16)this->field_0x6a.HWORD > 0x12b) { this->field_0x6a.HWORD = 0; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); this->field_0x6c.HALF.HI = 1; sub_080788E0(this); EnqueueSFX(0x7c); diff --git a/src/npc/rem.c b/src/npc/rem.c index b846ab31..84fca459 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -235,7 +235,7 @@ void sub_0806A914(Entity* this) { Entity* npc = CreateNPC(0x37, 1, 0); if (npc != NULL) { CopyPosition(this, npc); - ResolveEntityOnTop(this, npc); + SortEntityAbove(this, npc); } } @@ -279,7 +279,7 @@ void sub_0806A9E8(Entity* this) { Entity* npc = CreateNPC(0x37, 4, 0); if (npc != NULL) { CopyPosition(this, npc); - ResolveEntityBelow(this, npc); + SortEntityBelow(this, npc); } } diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index 50045270..04638c22 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -216,7 +216,7 @@ void sub_0806AF60(Entity* this, ScriptExecutionContext* context) { } void sub_0806AF70(Entity* this, ScriptExecutionContext* context) { - this->zVelocity = 0x24000; + this->zVelocity = Q_16_16(2.25); } void sub_0806AF78(Entity* this, ScriptExecutionContext* context) { @@ -229,7 +229,7 @@ void sub_0806AF78(Entity* this, ScriptExecutionContext* context) { void sub_0806AFA0(Entity* this) { if (sub_0806ED78(this)) { - sub_0806F62C(this, -this->speed, this->direction); + LinearMoveAngle(this, -this->speed, this->direction); } } diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index 17cd48e5..edb1b694 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -220,7 +220,7 @@ void sub_08061F94(Entity* this) { ent = CreateFx(this, FX_BIG_EXPLOSION, 0); if (ent != NULL) { - ResolveEntityOnTop(this, ent); + SortEntityAbove(this, ent); } } diff --git a/src/npc/vaatiReborn.c b/src/npc/vaatiReborn.c index 3ed28ca8..fb59284e 100644 --- a/src/npc/vaatiReborn.c +++ b/src/npc/vaatiReborn.c @@ -44,7 +44,7 @@ void VaatiRebornAction0(Entity* this) { entity = CreateNPC(VAATI_REBORN, 1, 0); entity->parent = this; entity->spriteOffsetY = -1; - PositionRelative(this, entity, 0, 0x10000); + PositionRelative(this, entity, 0, Q_16_16(1.0)); InitAnimationForceUpdate(this, 0); break; case 1: @@ -115,7 +115,7 @@ void VaatiRebornAction1(Entity* this) { if (entity == NULL) { DeleteThisEntity(); } - PositionRelative(entity, this, 0, 0x210000); + PositionRelative(entity, this, 0, Q_16_16(33.0)); UpdateAnimationSingleFrame(this); break; case 2: @@ -194,7 +194,7 @@ void sub_0806B96C(Entity* this) { } ptr = &gUnk_08112F80[this->type2]; this->spriteSettings.draw = entity->spriteSettings.draw; - PositionRelative(entity, this, ptr->x << 0x10, (ptr->y + 0x21) << 0x10); + PositionRelative(entity, this, Q_16_16(ptr->x), Q_16_16(ptr->y + 0x21)); UpdateAnimationSingleFrame(this); } diff --git a/src/npc/wheaton.c b/src/npc/wheaton.c index 3182eda3..e7c5e69b 100644 --- a/src/npc/wheaton.c +++ b/src/npc/wheaton.c @@ -7,7 +7,7 @@ void Wheaton(Entity* this) { this->action++; SetDefaultPriority(this, PRIO_MESSAGE); - ResolveEntityOnTop(this, this); + SortEntityAbove(this, this); this->hitbox = &gUnk_0810C3C0; this->spriteOffsetY = 0xfe; sub_0807DD64(this); diff --git a/src/npc/zelda.c b/src/npc/zelda.c index b0ac945f..f0bc5b77 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -127,13 +127,13 @@ void sub_08066E80(Entity* this, ScriptExecutionContext* context) { UpdateAnimationSingleFrame(this); if (this->frame & 1) { context->unk_18++; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); this->frame &= 0xFE; SoundReq(SFX_PLY_JUMP); } break; case 2: - sub_0806F62C(this, 0x100, 0x80); + LinearMoveAngle(this, 0x100, 0x80); GravityUpdate(this, 0x2000); if (!(this->frame & 1)) { UpdateAnimationSingleFrame(this); @@ -143,7 +143,7 @@ void sub_08066E80(Entity* this, ScriptExecutionContext* context) { } break; case 3: - sub_0806F62C(this, 0x100, 0x80); + LinearMoveAngle(this, 0x100, 0x80); UpdateAnimationSingleFrame(this); if (GravityUpdate(this, 0x2000) == 0) { context->unk_18++; diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c index 51c50ca4..be636d81 100644 --- a/src/object/bakerOven.c +++ b/src/object/bakerOven.c @@ -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); 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..efd3ce74 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); } } } diff --git a/src/object/book.c b/src/object/book.c index 7c3bf57e..811ca4ae 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -134,7 +134,7 @@ void sub_0809B56C(Entity* this) { fx = CreateFx(this, FX_DEATH, 0); if (fx) { - ResolveEntityOnTop(this, fx); + SortEntityAbove(this, fx); } } diff --git a/src/object/fileScreenObjects.c b/src/object/fileScreenObjects.c index 004f98d5..c3d217f6 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; diff --git a/src/object/furniture.c b/src/object/furniture.c index c625d1fb..05e7f7ca 100644 --- a/src/object/furniture.c +++ b/src/object/furniture.c @@ -220,7 +220,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; } @@ -451,7 +451,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/itemOnGround.c b/src/object/itemOnGround.c index 35cb741b..910764a2 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -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) { @@ -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/lilypadLarge.c b/src/object/lilypadLarge.c index 91f13635..96b4dff9 100644 --- a/src/object/lilypadLarge.c +++ b/src/object/lilypadLarge.c @@ -163,7 +163,7 @@ void sub_08085B40(LilypadLargeEntity* this) { ResetCollisionLayer(&gPlayerEntity); sub_08085CDC(this); super->direction = GetFacingDirection(&gPlayerEntity, super); - sub_0806F5BC(&gPlayerEntity, 0x100, super->direction); + LinearMoveDirection(&gPlayerEntity, 0x100, super->direction); } } diff --git a/src/object/mask.c b/src/object/mask.c index 73b42095..384c59f4 100644 --- a/src/object/mask.c +++ b/src/object/mask.c @@ -39,7 +39,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; diff --git a/src/object/minecart.c b/src/object/minecart.c index c39a4931..0de7e4c3 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -45,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); @@ -65,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(); @@ -160,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/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..29dcb2ef 100644 --- a/src/object/object6A.c +++ b/src/object/object6A.c @@ -237,7 +237,7 @@ void sub_08094C88(Object6AEntity* this) { 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); } } @@ -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); } } @@ -338,7 +338,7 @@ 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; @@ -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(); } @@ -473,7 +473,7 @@ void sub_08095120(Object6AEntity* this) { if (super->action == 0) { super->action = 1; SetDefaultPriority(super, 3); - ResolveEntityBelow(super, super); + SortEntityBelow(super, super); sub_0807DD64(super); InitAnimationForceUpdate(super, 2); } @@ -493,7 +493,7 @@ void sub_08095188(Object6AEntity* this) { if (super->action == 0) { super->action = 1; SetDefaultPriority(super, 3); - ResolveEntityBelow(super, super); + 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); } } @@ -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); } @@ -609,7 +609,7 @@ void sub_080953A4(Object6AEntity* this) { super->z.HALF.HI = -16; SetDefaultPriority(super, 2); 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); } } @@ -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 7eac6c78..1e7d1811 100644 --- a/src/object/octorokBossObject.c +++ b/src/object/octorokBossObject.c @@ -76,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 { @@ -92,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 { @@ -109,7 +109,7 @@ void OctorokBossObject_Init(Entity* this) { this->field_0x76.HWORD = 0x400; this->field_0x74.HWORD = 0x400; this->field_0x7a.HWORD = 0; - sub_0806F62C(this, + 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]); @@ -170,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; } @@ -195,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; } @@ -204,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(); } @@ -247,7 +247,7 @@ 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], + 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: diff --git a/src/object/pot.c b/src/object/pot.c index bf94a8be..cde45bc6 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -67,7 +67,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; 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/player.c b/src/player.c index 6c2772d6..4c1d2d43 100644 --- a/src/player.c +++ b/src/player.c @@ -22,26 +22,26 @@ #include "screen.h" #include "main.h" -#define GRAVITY_RATE 0x2000 +#define GRAVITY_RATE Q_8_8(32) #define SLOPE_SPEED_MODIFIER 0x50 -#define WALK_SPEED 0x140 -#define ROLL_SPEED 0x200 -#define SHIELDING_SPEED 0xC0 -#define GUST_JAR_SPEED 0x80 -#define SWORD_CHARGE_SPEED 0xE0 -#define BURNING_SPEED 0x300 +#define WALK_SPEED Q_8_8(1.25) +#define ROLL_SPEED Q_8_8(2.0) +#define GUST_JAR_SPEED Q_8_8(0.5) +#define SHIELDING_SPEED Q_8_8(0.75) +#define SWORD_CHARGE_SPEED Q_8_8(0.875) +#define BURNING_SPEED Q_8_8(3) -#define JUMP_SPEED_FWD 0x100 +#define JUMP_SPEED_FWD Q_8_8(1) /* Jumping out of a hole */ -#define JUMP_SPEED_HOLE_FWD 0x78 -#define JUMP_SPEED_HOLE_Z 0x1a000 +#define JUMP_SPEED_HOLE_FWD Q_8_8(0.46875) +#define JUMP_SPEED_HOLE_Z Q_16_16(1.625) /* Bouncing off a wall */ -#define BOUNCE_SPEED_FWD 0x100 -#define BOUNCE_SPEED_Z 0x20000 +#define BOUNCE_SPEED_FWD Q_8_8(1.0) +#define BOUNCE_SPEED_Z Q_16_16(2.0) -#define PULL_SPEED 0x80 -#define PUSH_SPEED 0x80 +#define PULL_SPEED Q_8_8(0.5) +#define PUSH_SPEED Q_8_8(0.5) #define PIT_DAMAGE 0x2 @@ -724,7 +724,7 @@ static NONMATCH("asm/non_matching/player/PlayerBounceUpdate.inc", void PlayerBou } if (--this->actionDelay != 0xFF) { - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); return; } @@ -1118,7 +1118,7 @@ static void PortalStandUpdate(Entity* this) { if (--this->actionDelay == 0xff) { this->direction = gPlayerState.field_0xd; this->animationState = Direction8ToAnimationState(this->direction); - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); this->speed = JUMP_SPEED_FWD; this->action = PLAYER_MINISH; this->subAction = 7; @@ -1531,7 +1531,7 @@ static void sub_08071D04(Entity* this) { gPlayerState.field_0x3c[0] = 0; this->direction = 0xff; this->speed = 0; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); gPlayerState.jump_status = 1; gPlayerState.swim_state = 0; return; @@ -1849,7 +1849,7 @@ static void PlayerLavaInit(Entity* this) { COLLISION_OFF(this); if ((gPlayerState.flags & PL_MINISH) == 0) { this->subAction = 1; - this->zVelocity = 0x28000; + this->zVelocity = Q_16_16(2.5); ent = CreateObject(OBJECT_42, 0x80, 0); if (ent != NULL) { ent->child = this; @@ -2224,7 +2224,7 @@ static void sub_08072B5C(Entity* this) { COLLISION_ON(this); this->spritePriority.b0 = 4; this->speed = 0x40; - this->zVelocity = 0x39000; + this->zVelocity = Q_16_16(3.5625); this->z.WORD--; gPlayerState.jump_status = 0x41; sub_0806F854(this, 0, -12); @@ -2240,7 +2240,7 @@ static void sub_08072B5C(Entity* this) { temp -= 4; temp <<= 12; this->zVelocity = temp; - this->speed = 0x100; + this->speed = Q_8_8(1.0); gPlayerState.animation = 0x810; SoundReq(SFX_PLY_JUMP); } @@ -2679,7 +2679,7 @@ static void PlayerParachute(Entity* this) { static void sub_08073468(Entity* this) { gPlayerState.animation = 1792; gPlayerState.jump_status = 0; - this->zVelocity = -0x10000; + this->zVelocity = Q_16_16(-1.0); this->subAction++; this->field_0x7c.WORD = 480; this->direction = Direction8FromAnimationState(this->animationState); @@ -2695,7 +2695,7 @@ static void sub_08073468(Entity* this) { static void sub_080734D4(Entity* this) { GravityUpdate(this, -(GRAVITY_RATE / 2)); if (this->zVelocity > 0 || gPlayerState.field_0x38 == 1) { - this->zVelocity = 0x49000; + this->zVelocity = Q_16_16(4.5625); this->subAction++; } } @@ -2872,7 +2872,7 @@ static void sub_0807380C(Entity* this) { if (--this->actionDelay == 0) { this->subAction = 7; this->actionDelay = 60; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); } } UpdateAnimationSingleFrame(this); @@ -2965,7 +2965,7 @@ static void sub_080739EC(Entity* this) { } if ((gPlayerState.jump_status & 0xC0) == 0) { if ((gPlayerState.jump_status & 0x20) && this->zVelocity == 0) { - this->zVelocity = 0x28000; + this->zVelocity = Q_16_16(2.5); this->actionDelay = 10; this->direction = 0xff; gPlayerState.jump_status += 2; @@ -3176,7 +3176,7 @@ static void sub_08073F04(Entity* this) { this->spritePriority.b1 = 2; this->spriteSettings.draw = 0; this->subAction++; - this->zVelocity = 0x28000; + this->zVelocity = Q_16_16(2.5); this->speed = 0x100; gPlayerState.flags &= ~PL_MINISH; ResetPlayer(); @@ -3240,7 +3240,7 @@ static void sub_08074060(Entity* this) { this->spriteSettings.shadow = 1; this->field_0xf = 0; this->subAction++; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); gPlayerState.animation = 2060; sub_0805EC60(this); } else { diff --git a/src/projectile/boneProjectile.c b/src/projectile/boneProjectile.c index 20c6e090..33677de2 100644 --- a/src/projectile/boneProjectile.c +++ b/src/projectile/boneProjectile.c @@ -75,7 +75,7 @@ void BoneProjectile_Action3(Entity* this) { void BoneProjectile_Action4(Entity* this) { GetNextFrame(this); LinearMoveUpdate(this); - if (GravityUpdate(this, 0x1800) == 0) { + if (GravityUpdate(this, Q_8_8(24.0)) == 0) { DeleteEntity(this); } } @@ -83,7 +83,7 @@ void BoneProjectile_Action4(Entity* this) { void sub_080A82D8(Entity* this) { this->action = 4; COLLISION_OFF(this); - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); this->direction ^= 0x10; this->speed = 0x80; } diff --git a/src/projectile/dirtBallProjectile.c b/src/projectile/dirtBallProjectile.c index a4a0d8e1..df383b15 100644 --- a/src/projectile/dirtBallProjectile.c +++ b/src/projectile/dirtBallProjectile.c @@ -48,7 +48,7 @@ void DirtBallProjectile_Init(Entity* this) { this->action = 1; this->subAction = 0; this->spriteSettings.shadow = 1; - this->zVelocity = 0x8000; + this->zVelocity = Q_16_16(0.5); this->hitbox = (Hitbox*)&gUnk_08129764; this->field_0x3c |= 0x10; switch (this->type) { @@ -76,13 +76,13 @@ void DirtBallProjectile_Action1(Entity* this) { if (parent->next == NULL) { this->action = 2; } - PositionRelative(parent, this, 0, -0x10000); + PositionRelative(parent, this, 0, Q_16_16(-1.0)); switch (this->type) { case 0: - this->z.HALF.HI += 0x10; + this->z.HALF.HI += Q_8_8(1.0 / 16.0); break; case 1: - this->z.HALF.HI += 0xe; + this->z.HALF.HI += Q_8_8(1.0 / 16.0 - 1.0 / 128.0); sub_08078954(this->child); CopyPosition(this, this->child); if ((0xf < (u8)(this->actionDelay++ + 1)) && (entity = this->child, entity->actionDelay == 0)) { @@ -96,7 +96,7 @@ void DirtBallProjectile_Action1(Entity* this) { } break; case 2: - this->z.HALF.HI += 0xe; + this->z.HALF.HI += Q_8_8(1.0 / 16.0 - 1.0 / 128.0); if (EntityInRectRadius(this, &gPlayerEntity, 0xe, 0xe) != 0) { this->action = 2; parent->field_0x82.HALF.HI = 0xc0; diff --git a/src/projectile/gleerokProjectile.c b/src/projectile/gleerokProjectile.c index 5b63e25f..128e32f7 100644 --- a/src/projectile/gleerokProjectile.c +++ b/src/projectile/gleerokProjectile.c @@ -32,10 +32,10 @@ void GleerokProjectile_Init(Entity* this) { s32 iVar2; this->action = 1; - this->zVelocity = -0x10000; + this->zVelocity = Q_16_16(-1.0); if (this->type != 3) { CopyPosition(this->parent, this); - sub_0806F5BC(this, 0x1000, this->direction); + LinearMoveDirection(this, 0x1000, this->direction); this->z.WORD = this->parent->y.WORD - this->child->y.WORD; this->y.WORD -= this->z.WORD; InitializeAnimation(this, 0x51); diff --git a/src/projectile/gyorgMaleEnergyProjectile.c b/src/projectile/gyorgMaleEnergyProjectile.c index 8e9983cc..cfcfed29 100644 --- a/src/projectile/gyorgMaleEnergyProjectile.c +++ b/src/projectile/gyorgMaleEnergyProjectile.c @@ -60,8 +60,8 @@ void GyorgMaleEnergyProjectile_Action1(Entity* this) { DeleteThisEntity(); } animationState = this->parent->animationState; - PositionRelative(this->parent, this, gSineTable[animationState] * 0x2800, - gSineTable[animationState + 0x40] * -0x2800); + PositionRelative(this->parent, this, gSineTable[animationState] * Q_16_16(5.0 / 32.0), + gSineTable[animationState + 0x40] * Q_16_16(-5.0 / 32.0)); GetNextFrame(this); if (--this->actionDelay == 0) { this->action = 2; diff --git a/src/projectile/lakituCloudProjectile.c b/src/projectile/lakituCloudProjectile.c index ce7d2d21..0175653f 100644 --- a/src/projectile/lakituCloudProjectile.c +++ b/src/projectile/lakituCloudProjectile.c @@ -57,8 +57,8 @@ void LakituCloudProjectile_Init(Entity* this) { } void LakituCloudProjectile_Action1(Entity* this) { - PositionRelative(this->parent, this, 0, -0x10000); - this->z.HALF.HI = 0xfffe; + PositionRelative(this->parent, this, 0, Q_16_16(-1.0)); + this->z.HALF.HI = -2; UpdateAnimationSingleFrame(this); } diff --git a/src/projectile/mandiblesProjectile.c b/src/projectile/mandiblesProjectile.c index 6e261021..a69c493b 100644 --- a/src/projectile/mandiblesProjectile.c +++ b/src/projectile/mandiblesProjectile.c @@ -77,7 +77,7 @@ void MandiblesProjectile_Init(Entity* this) { this->animationState = 0xff; this->field_0x82.HALF.LO = 0; this->spritePriority.b0 = 4; - ResolveEntityBelow(this, this->parent); + SortEntityBelow(this, this->parent); sub_080AA270(this); } @@ -125,9 +125,9 @@ void MandiblesProjectile_Action3(Entity* this) { } else { tmp = GetSpriteSubEntryOffsetDataPointer((u16)entity->spriteIndex, entity->frameIndex); if ((entity->animationState & 4) != 0) { - PositionRelative(entity, this, -tmp[0] * 0x10000, tmp[1] << 0x10); + PositionRelative(entity, this, Q_16_16(-tmp[0]), Q_16_16(tmp[1])); } else { - PositionRelative(entity, this, tmp[0] << 0x10, tmp[1] << 0x10); + PositionRelative(entity, this, Q_16_16(tmp[0]), Q_16_16(tmp[1])); } } if (entity->field_0x43 == 0) { @@ -212,9 +212,9 @@ void sub_080AA1D8(Entity* this) { if ((parent->frameIndex & 0x20) == 0) { tmp = GetSpriteSubEntryOffsetDataPointer((u16)parent->spriteIndex, parent->frameIndex); if ((parent->animationState & 4) != 0) { - PositionRelative(parent, this, -tmp[0] * 0x10000, tmp[1] << 0x10); + PositionRelative(parent, this, Q_16_16(-tmp[0]), Q_16_16(tmp[1])); } else { - PositionRelative(parent, this, tmp[0] << 0x10, tmp[1] << 0x10); + PositionRelative(parent, this, Q_16_16(tmp[0]), Q_16_16(tmp[1])); } if (parent->field_0x43 != 0) { if ((this->flags & ENT_COLLIDE) != 0) { diff --git a/src/projectile/octorokBossProjectile.c b/src/projectile/octorokBossProjectile.c index 1ca08f9d..1f5c8ddd 100644 --- a/src/projectile/octorokBossProjectile.c +++ b/src/projectile/octorokBossProjectile.c @@ -33,7 +33,7 @@ void OctorokBossProjectile_Init(Entity* this) { switch (this->type) { case 0: - sub_0806F62C(this, 0x4800, this->direction); + LinearMoveAngle(this, 0x4800, this->direction); this->speed = 0x200; this->actionDelay = 0; this->field_0xf = this->direction; @@ -44,11 +44,11 @@ void OctorokBossProjectile_Init(Entity* this) { this->spriteRendering.b3 = 3; this->spritePriority.b0 = 6; this->speed = (Random() & 0x1ff) + 0x200; - this->zVelocity = (Random() & 0x1fff) + 0x18000; + this->zVelocity = (Random() & 0x1fff) + Q_16_16(1.5); uVar1 = (((u8)Random() & 7) - 4); this->direction -= uVar1; *(u32*)&this->field_0x78 = 600; - sub_0806F62C(this, this->speed, this->direction); + LinearMoveAngle(this, this->speed, this->direction); InitializeAnimation(this, 4); break; case 2: @@ -59,7 +59,7 @@ void OctorokBossProjectile_Init(Entity* this) { } this->speed = 0x200; this->actionDelay = 0x30; - sub_0806F62C(this, 0x5000, this->direction); + LinearMoveAngle(this, 0x5000, this->direction); InitializeAnimation(this, 5); break; case 3: @@ -113,7 +113,7 @@ void OctorokBossProjectile_Action1(Entity* this) { } UpdateAnimationSingleFrame(this); this->field_0x78.HWORD--; - sub_0806F62C(this, this->speed, this->direction); + LinearMoveAngle(this, this->speed, this->direction); sub_080AE58C(this, this->direction >> 3, 0); if ((this->collisions & 0xee00) != 0) { this->direction = -this->direction; @@ -153,7 +153,7 @@ void OctorokBossProjectile_Action1(Entity* this) { if (GravityUpdate(this, 0x1800) != 0) { sub_080AE58C(this, this->direction >> 3, 0); if (this->collisions == 0) { - sub_0806F62C(this, (s32)this->speed, (u32)this->direction); + LinearMoveAngle(this, (s32)this->speed, (u32)this->direction); } else { OctorokBossProjectile_Action2(this); } @@ -176,7 +176,7 @@ void OctorokBossProjectile_Action1(Entity* this) { case 2: GetNextFrame(this); if (--this->actionDelay != 0xff) { - sub_0806F62C(this, this->speed, this->direction); + LinearMoveAngle(this, this->speed, this->direction); return; } if (this->child != NULL) { diff --git a/src/projectile/rockProjectile.c b/src/projectile/rockProjectile.c index 7254631b..66e8388f 100644 --- a/src/projectile/rockProjectile.c +++ b/src/projectile/rockProjectile.c @@ -31,7 +31,7 @@ void sub_080A8064(Entity* this) { void RockProjectile_Init(Entity* this) { this->action = 1; this->actionDelay = 0x30; - this->zVelocity = 0xa000; + this->zVelocity = Q_16_16(0.625); InitializeAnimation(this, 0); } @@ -86,7 +86,7 @@ void sub_080A8178(Entity* this) { this->action = 2; COLLISION_OFF(this); this->speed = 0x40; - this->zVelocity = 0x14000; + this->zVelocity = Q_16_16(1.25); } void (*const RockProjectile_Functions[])(Entity*) = { diff --git a/src/projectile/stalfosProjectile.c b/src/projectile/stalfosProjectile.c index 709907e0..841a68e3 100644 --- a/src/projectile/stalfosProjectile.c +++ b/src/projectile/stalfosProjectile.c @@ -32,7 +32,7 @@ void sub_080A9A34(Entity* this) { if (this->bitfield == 0x9d) { this->action = 3; COLLISION_OFF(this); - this->zVelocity = 0x2a000; + this->zVelocity = Q_16_16(2.625); this->spritePriority.b1 = 1; } } @@ -76,7 +76,7 @@ void StalfosProjectile_Init(Entity* this) { break; case 2: this->action = 3; - this->zVelocity = 0x2a000; + this->zVelocity = Q_16_16(2.625); this->spritePriority.b1 = 1; break; default: diff --git a/src/projectile/v1DarkMagicProjectile.c b/src/projectile/v1DarkMagicProjectile.c index c9a3d281..dbc770a1 100644 --- a/src/projectile/v1DarkMagicProjectile.c +++ b/src/projectile/v1DarkMagicProjectile.c @@ -31,9 +31,9 @@ void sub_080AAC44(Entity* this) { this->action = 2; COLLISION_OFF(this); if (this->type == 0) { - ResolveEntityOnTop(&gPlayerEntity, this); + SortEntityAbove(&gPlayerEntity, this); } else { - ResolveEntityOnTop(this->parent, this); + SortEntityAbove(this->parent, this); } ResetPlayer(); gPlayerState.mobility |= 0x80; @@ -114,7 +114,7 @@ void V1DarkMagicProjectile_Init(Entity* this) { } else { this->action = 3; this->hitType = 0x2c; - ResolveEntityOnTop(this->parent, this); + SortEntityAbove(this->parent, this); } if (this->type == 0) { this->actionDelay = 0; @@ -136,7 +136,7 @@ void V1DarkMagicProjectile_Init(Entity* this) { entity->parent = this; } } else { - ResolveEntityOnTop(this->parent, this); + SortEntityAbove(this->parent, this); COLLISION_OFF(this); CopyPosition(this->parent, this); } diff --git a/src/projectile/v1EyeLaser.c b/src/projectile/v1EyeLaser.c index 8bdb0652..de642d5d 100644 --- a/src/projectile/v1EyeLaser.c +++ b/src/projectile/v1EyeLaser.c @@ -99,7 +99,7 @@ void sub_080AB844(Entity* this, s32 param_1, s32 param_2) { entity->type = 1; entity->actionDelay = param_1; entity->parent = this->parent; - PositionRelative(this, entity, 0, param_2 << 0x10); + PositionRelative(this, entity, 0, Q_16_16(param_2)); if (param_1 != 1) { entity->hitbox = (Hitbox*)&gUnk_0812A61C; } else { diff --git a/src/projectile/v1FireProjectile.c b/src/projectile/v1FireProjectile.c index 90bdc5fd..2823d563 100644 --- a/src/projectile/v1FireProjectile.c +++ b/src/projectile/v1FireProjectile.c @@ -39,10 +39,10 @@ void V1FireProjectile_Init(Entity* this) { s8* data; this->action = 1; - this->zVelocity = -0x10000; + this->zVelocity = Q_16_16(-1.0); this->field_0x76.HWORD = TILE(this->x.HALF.HI, this->y.HALF.HI); CopyPosition(this->parent, this); - sub_0806F5BC(this, 0x1000, this->direction); + LinearMoveDirection(this, 0x1000, this->direction); this->spritePriority.b0 = 1; this->z = this->parent->z; InitializeAnimation(this, 0x51); diff --git a/src/projectile/v2Projectile.c b/src/projectile/v2Projectile.c index 5d9f6eb2..fc7f09d2 100644 --- a/src/projectile/v2Projectile.c +++ b/src/projectile/v2Projectile.c @@ -138,7 +138,7 @@ void sub_080ABE04(Entity* this) { u32 rand = Random() & 0xff; u32 newX; this->action = 1; - this->zVelocity = 0xffff0000; + this->zVelocity = Q_16_16(-1.0); this->z.HALF.HI -= 0xa0; this->x.HALF.HI = (gRoomControls.origin_x & 0x7ff0) | 0x8; this->y.HALF.HI = (gRoomControls.origin_y & 0x7ff0) | 0x8; diff --git a/src/roomInit.c b/src/roomInit.c index e4fd06fa..3cb07870 100644 --- a/src/roomInit.c +++ b/src/roomInit.c @@ -5798,14 +5798,14 @@ void sub_0804F79C(Entity* parent) { fx = CreateFx(parent, FX_BIG_EXPLOSION, 0); if (fx != NULL) { fx->spriteRendering.b3 = 0; - fx->x.HALF.HI = gRoomControls.origin_x + 0x1b8; - fx->y.HALF.HI = gRoomControls.origin_y + 0x148; + fx->x.HALF.HI = gRoomControls.origin_x + Q_8_8(1.72); + fx->y.HALF.HI = gRoomControls.origin_y + Q_8_8(1.285); } fx = CreateFx(parent, FX_BIG_EXPLOSION, 0); if (fx != NULL) { fx->spriteRendering.b3 = 0; - fx->x.HALF.HI = gRoomControls.origin_x + 0x238; - fx->y.HALF.HI = gRoomControls.origin_y + 0x148; + fx->x.HALF.HI = gRoomControls.origin_x + Q_8_8(2.22); + fx->y.HALF.HI = gRoomControls.origin_y + Q_8_8(1.285); } } diff --git a/src/script.c b/src/script.c index 02cf220a..f6cb795f 100644 --- a/src/script.c +++ b/src/script.c @@ -258,7 +258,7 @@ void HandlePostScriptActions(Entity* entity, ScriptExecutionContext* context) { case 1 << 0x02: break; case 1 << 0x03: - entity->zVelocity = 0x18000; + entity->zVelocity = Q_16_16(1.5); break; case 1 << 0x04: CreateSpeechBubbleExclamationMark(entity, 8, -0x18); @@ -1396,7 +1396,7 @@ void ScriptCommand_0807EE30(Entity* entity, ScriptExecutionContext* context) { } tmp = entity->x.HALF.HI - context->x.HALF.HI; tmp2 = entity->y.HALF.HI - context->y.HALF.HI; - sub_0806F62C(entity, entity->speed, entity->direction); + LinearMoveAngle(entity, entity->speed, entity->direction); tmp *= entity->x.HALF.HI - context->x.HALF.HI; tmp2 *= entity->y.HALF.HI - context->y.HALF.HI; if (tmp <= 0 && tmp2 <= 0) { @@ -1685,7 +1685,7 @@ void sub_0807F36C(Entity* entity, ScriptExecutionContext* context) { fx = CreateFx(entity, FX_REFLECT4, 0); if (fx != NULL) { fx->spritePriority.b0 = 1; - PositionRelative(entity, fx, 0, -0x80000); + PositionRelative(entity, fx, 0, Q_16_16(-8.0)); if (Random() & 1) fx->spriteSettings.flipX = 1; if (Random() & 1) @@ -1749,7 +1749,7 @@ void sub_0807F464(Entity* entity, ScriptExecutionContext* context) { entity->animationState = (entity->animationState & 0x80) | 6; } } - sub_0806F62C(entity, entity->speed, entity->direction); + LinearMoveAngle(entity, entity->speed, entity->direction); if (((context->x.HALF.HI - entity->x.HALF.HI) ^ ((entity->direction & 0x80) << 24)) < 0) entity->x.HALF.HI = context->x.HALF.HI; else @@ -1773,7 +1773,7 @@ void sub_0807F4F8(Entity* entity, ScriptExecutionContext* context) { entity->animationState = (entity->animationState & 0x80); } } - sub_0806F62C(entity, entity->speed, entity->direction); + LinearMoveAngle(entity, entity->speed, entity->direction); if (((context->y.HALF.HI - entity->y.HALF.HI) ^ ((entity->direction & 0x80) << 24)) >= 0) entity->y.HALF.HI = context->y.HALF.HI; else @@ -1853,12 +1853,12 @@ void sub_0807F708(Entity* entity, ScriptExecutionContext* context) { void sub_0807F714(Entity* entity, ScriptExecutionContext* context) { entity->spriteRendering.b3 = gUnk_08114F30[entity->spriteRendering.b3]; - ResolveEntityOnTop(entity, entity); + SortEntityAbove(entity, entity); } void sub_0807F738(Entity* entity, ScriptExecutionContext* context) { entity->spriteRendering.b3 = gUnk_08114F34[entity->spriteRendering.b3]; - ResolveEntityBelow(entity, entity); + SortEntityBelow(entity, entity); } void SetPlayerPos(Entity* entity, ScriptExecutionContext* context) { @@ -2121,7 +2121,7 @@ void sub_0807FBCC(Entity* entity, ScriptExecutionContext* context) { } void sub_0807FBD4(Entity* entity, ScriptExecutionContext* context) { - sub_0806F62C(entity, entity->speed, entity->direction); + LinearMoveAngle(entity, entity->speed, entity->direction); if (CheckOnScreen(entity)) gActiveScriptInfo.commandSize = 0; } From a6f8dabcea39c6e7679b75aaaa06319c6577d000 Mon Sep 17 00:00:00 2001 From: theo3 Date: Fri, 21 Jan 2022 21:26:18 -0800 Subject: [PATCH 2/2] fixed point stuff --- asm/code_08054C04.s | 2 +- asm/code_08078778.s | 2 +- asm/code_0808091C.s | 2 +- asm/enemy/chuchuBoss.s | 10 +-- asm/enemy/cloudPiranha.s | 4 +- asm/enemy/enemy64.s | 4 +- .../castorWildsStatue/sub_080675D4.inc | 4 +- .../OctorokBossObject_Action1.inc | 8 +-- asm/object/evilSpirit.s | 4 +- asm/object/lilypadLarge.s | 2 +- asm/object/macroPlayer.s | 2 +- asm/object/object91.s | 6 +- asm/object/object96.s | 2 +- asm/object/object97.s | 2 +- asm/object/objectB4.s | 8 +-- asm/object/objectOnSpinyBeetle.s | 6 +- asm/object/specialFx.s | 2 +- asm/objectUtils.s | 4 +- include/coord.h | 4 +- include/entity.h | 8 +-- include/functions.h | 4 +- include/global.h | 4 +- src/code_0805436C.c | 2 +- src/collision.c | 6 +- src/coord.c | 44 ++++++------- src/enemy/acroBandits.c | 10 +-- src/enemy/beetle.c | 6 +- src/enemy/bobomb.c | 6 +- src/enemy/bombPeahat.c | 2 +- src/enemy/chuchu.c | 2 +- src/enemy/cuccoChickAggr.c | 6 +- src/enemy/fallingBoulder.c | 4 +- src/enemy/fireballGuy.c | 2 +- src/enemy/flyingSkull.c | 2 +- src/enemy/gyorgMale.c | 4 +- src/enemy/helmasaur.c | 12 ++-- src/enemy/keaton.c | 2 +- src/enemy/lakitu.c | 22 ++++--- src/enemy/likeLike.c | 4 +- src/enemy/mazaalBracelet.c | 16 ++--- src/enemy/mazaalHead.c | 4 +- src/enemy/miniFireballGuy.c | 2 +- src/enemy/moldworm.c | 4 +- src/enemy/octorokBoss.c | 10 +-- src/enemy/peahat.c | 4 +- src/enemy/pesto.c | 2 +- src/enemy/puffstool.c | 18 +++--- src/enemy/rollobite.c | 6 +- src/enemy/rupeeLike.c | 4 +- src/enemy/sluggula.c | 4 +- src/enemy/spikedBeetle.c | 4 +- src/enemy/spinyChuchu.c | 10 +-- src/enemy/tektiteGolden.c | 4 +- src/enemy/vaatiArm.c | 4 +- src/enemy/vaatiBall.c | 10 +-- src/enemy/vaatiProjectile.c | 4 +- src/enemy/vaatiRebornEnemy.c | 16 ++--- src/enemy/vaatiTransfigured.c | 8 +-- src/enemy/vaatiTransfiguredEye.c | 4 +- src/enemy/vaatiWrath.c | 2 +- src/enemy/vaatiWrathEye.c | 2 +- src/enemy/waterDrop.c | 2 +- src/item/itemRocsCape.c | 2 +- src/npc/bigGoron.c | 2 +- src/npc/bladeBrothers.c | 2 +- src/npc/castorWildsStatue.c | 4 +- src/npc/cuccoChick.c | 2 +- src/npc/drLeft.c | 2 +- src/npc/ezlo.c | 2 +- src/npc/goron.c | 12 ++-- src/npc/gregal.c | 4 +- src/npc/kid.c | 2 +- src/npc/malon.c | 4 +- src/npc/melari.c | 2 +- src/npc/npc4E.c | 4 +- src/npc/pita.c | 2 +- src/npc/postman.c | 2 +- src/npc/rem.c | 4 +- src/npc/townMinish.c | 4 +- src/npc/townsperson.c | 2 +- src/npc/vaatiReborn.c | 6 +- src/npc/wheaton.c | 2 +- src/npc/zelda.c | 6 +- src/object/bakerOven.c | 2 +- src/object/bigVortex.c | 6 +- src/object/bird.c | 14 ++--- src/object/book.c | 2 +- src/object/fileScreenObjects.c | 4 +- src/object/furniture.c | 4 +- src/object/greatFairy.c | 14 ++--- src/object/itemOnGround.c | 6 +- src/object/jarPortal.c | 10 +-- src/object/lilypadLarge.c | 2 +- src/object/mask.c | 2 +- src/object/minecart.c | 6 +- src/object/object49.c | 4 +- src/object/object6A.c | 62 +++++++++---------- src/object/object7E.c | 2 +- src/object/objectA2.c | 8 ++- src/object/objectAF.c | 2 +- src/object/objectB5.c | 2 +- src/object/octorokBossObject.c | 27 ++++---- src/object/pot.c | 2 +- src/object/rupee.c | 2 +- src/player.c | 52 ++++++++-------- src/projectile/boneProjectile.c | 4 +- src/projectile/dirtBallProjectile.c | 10 +-- src/projectile/gleerokProjectile.c | 4 +- src/projectile/gyorgMaleEnergyProjectile.c | 4 +- src/projectile/lakituCloudProjectile.c | 4 +- src/projectile/mandiblesProjectile.c | 10 +-- src/projectile/octorokBossProjectile.c | 14 ++--- src/projectile/rockProjectile.c | 4 +- src/projectile/stalfosProjectile.c | 4 +- src/projectile/v1DarkMagicProjectile.c | 8 +-- src/projectile/v1EyeLaser.c | 2 +- src/projectile/v1FireProjectile.c | 4 +- src/projectile/v2Projectile.c | 2 +- src/roomInit.c | 8 +-- src/script.c | 16 ++--- 120 files changed, 392 insertions(+), 387 deletions(-) diff --git a/asm/code_08054C04.s b/asm/code_08054C04.s index caacf860..e8a02905 100644 --- a/asm/code_08054C04.s +++ b/asm/code_08054C04.s @@ -446,7 +446,7 @@ sub_08054EFC: @ 0x08054EFC subs r0, #0x10 strh r0, [r1, #0x32] adds r0, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow _08054F54: movs r0, #0xfd bl SoundReq diff --git a/asm/code_08078778.s b/asm/code_08078778.s index 5dd37970..b5c2c7e6 100644 --- a/asm/code_08078778.s +++ b/asm/code_08078778.s @@ -724,7 +724,7 @@ _08078DE0: strh r0, [r4, #0x32] adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove ldr r0, _08078E34 @ =gPlayerState ldrb r0, [r0, #5] cmp r0, #4 diff --git a/asm/code_0808091C.s b/asm/code_0808091C.s index c0d02198..5ab71ebf 100755 --- a/asm/code_0808091C.s +++ b/asm/code_0808091C.s @@ -419,7 +419,7 @@ _08080DB4: adds r2, #1 strb r0, [r2] adds r0, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove b _08080E00 _08080DEE: ldr r0, _08080E04 @ =gRoomTransition diff --git a/asm/enemy/chuchuBoss.s b/asm/enemy/chuchuBoss.s index 12f1451d..3d5bfb57 100644 --- a/asm/enemy/chuchuBoss.s +++ b/asm/enemy/chuchuBoss.s @@ -3676,7 +3676,7 @@ _08027676: mov r0, sl ldrb r2, [r0] adds r0, r5, #0 - bl sub_0806F62C + bl LinearMoveAngle ldrb r0, [r5, #0xa] cmp r0, #1 beq _080276D2 @@ -3692,7 +3692,7 @@ _08027676: adds r2, r0, #0 adds r2, #0x83 ldrb r2, [r2] - bl sub_0806F62C + bl LinearMoveAngle ldr r0, [r5, #0x68] ldr r1, [r5, #0x54] ldrb r2, [r1, #0xa] @@ -4033,7 +4033,7 @@ _08027934: adds r0, #0x83 ldrb r2, [r0] adds r0, r5, #0 - bl sub_0806F62C + bl LinearMoveAngle ldr r0, [r5, #0x2c] str r0, [r6, #0x2c] ldr r0, [r5, #0x30] @@ -4044,7 +4044,7 @@ _08027934: adds r0, #0x83 ldrb r2, [r0] adds r0, r6, #0 - bl sub_0806F62C + bl LinearMoveAngle ldr r0, [r6, #0x2c] str r0, [r4, #0x2c] ldr r0, [r6, #0x30] @@ -4055,7 +4055,7 @@ _08027934: adds r0, #0x83 ldrb r2, [r0] adds r0, r4, #0 - bl sub_0806F62C + bl LinearMoveAngle adds r0, r7, #0 bl sub_08027984 pop {r4, r5, r6, r7, pc} diff --git a/asm/enemy/cloudPiranha.s b/asm/enemy/cloudPiranha.s index b85843df..a8ea962d 100644 --- a/asm/enemy/cloudPiranha.s +++ b/asm/enemy/cloudPiranha.s @@ -396,7 +396,7 @@ sub_080386B8: @ 0x080386B8 cmp r1, #0 beq _08038720 adds r0, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove _08038720: pop {r4, pc} .align 2, 0 @@ -507,7 +507,7 @@ _080387D8: cmp r1, #0 beq _080387EE adds r0, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove _080387EE: pop {r4, pc} diff --git a/asm/enemy/enemy64.s b/asm/enemy/enemy64.s index 4e8c8401..ff33d73e 100644 --- a/asm/enemy/enemy64.s +++ b/asm/enemy/enemy64.s @@ -1236,7 +1236,7 @@ sub_08049998: @ 0x08049998 ldrsh r1, [r5, r0] ldrb r2, [r5, #0x15] adds r0, r5, #0 - bl sub_0806F62C + bl LinearMoveAngle adds r0, r5, #0 adds r0, #0x7c ldrb r1, [r0] @@ -1433,7 +1433,7 @@ sub_08049B20: @ 0x08049B20 ldrsh r1, [r4, r0] ldrb r2, [r4, #0x15] adds r0, r4, #0 - bl sub_0806F62C + bl LinearMoveAngle adds r0, r4, #0 adds r0, #0x7c ldrb r1, [r0] diff --git a/asm/non_matching/castorWildsStatue/sub_080675D4.inc b/asm/non_matching/castorWildsStatue/sub_080675D4.inc index f47dc575..48e73e86 100644 --- a/asm/non_matching/castorWildsStatue/sub_080675D4.inc +++ b/asm/non_matching/castorWildsStatue/sub_080675D4.inc @@ -54,7 +54,7 @@ _080675EC: strb r0, [r3, #0x19] adds r0, r4, #0 adds r1, r3, #0 - bl ResolveEntityOnTop + bl SortEntityAbove _08067646: subs r6, #1 adds r5, #2 @@ -107,7 +107,7 @@ _08067656: strb r0, [r3, #0x19] adds r0, r4, #0 adds r1, r3, #0 - bl ResolveEntityOnTop + bl SortEntityAbove _080676B0: subs r6, #1 adds r5, #2 diff --git a/asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc b/asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc index 72ca7751..fdcbb90b 100644 --- a/asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc +++ b/asm/non_matching/octorokBossObject/OctorokBossObject_Action1.inc @@ -95,7 +95,7 @@ _0809A25C: ldrsh r1, [r7, r2] ldrb r2, [r7, #0x15] adds r0, r7, #0 - bl sub_0806F62C + bl LinearMoveAngle ldr r1, [r4] ldrb r0, [r7, #0xe] lsls r0, r0, #2 @@ -206,7 +206,7 @@ _0809A33E: lsls r1, r1, #2 ldrb r2, [r7, #0x15] adds r0, r7, #0 - bl sub_0806F62C + bl LinearMoveAngle ldr r1, [r7, #0x50] adds r0, r7, #0 movs r2, #0x48 @@ -216,7 +216,7 @@ _0809A378: ldrb r2, [r7, #0x15] adds r0, r7, #0 movs r1, #0x80 - bl sub_0806F62C + bl LinearMoveAngle adds r0, r7, #0 adds r0, #0x5a ldrb r0, [r0] @@ -335,7 +335,7 @@ _0809A436: ldrh r3, [r3] adds r2, r2, r3 adds r0, r7, #0 - bl sub_0806F62C + bl LinearMoveAngle b _0809A632 .align 2, 0 _0809A468: .4byte gUnk_0812388C diff --git a/asm/object/evilSpirit.s b/asm/object/evilSpirit.s index 1baea3de..a3b0019c 100644 --- a/asm/object/evilSpirit.s +++ b/asm/object/evilSpirit.s @@ -235,7 +235,7 @@ _08086428: ldrsh r1, [r6, r0] ldrb r2, [r6, #0x15] adds r0, r6, #0 - bl sub_0806F62C + bl LinearMoveAngle b _0808654A _08086440: adds r0, r6, #0 @@ -507,7 +507,7 @@ _0808663A: ldrsh r1, [r7, r0] ldrb r2, [r7, #0x15] adds r0, r7, #0 - bl sub_0806F62C + bl LinearMoveAngle ldrb r0, [r7, #0x15] movs r1, #0x80 eors r0, r1 diff --git a/asm/object/lilypadLarge.s b/asm/object/lilypadLarge.s index c178744a..cdc6ede6 100644 --- a/asm/object/lilypadLarge.s +++ b/asm/object/lilypadLarge.s @@ -919,7 +919,7 @@ _08085BB4: lsls r1, r1, #1 ldrb r2, [r5, #0x15] adds r0, r4, #0 - bl sub_0806F5BC + bl LinearMoveDirection _08085BE8: adds r1, r5, #0 adds r1, #0x82 diff --git a/asm/object/macroPlayer.s b/asm/object/macroPlayer.s index 7c8b3e9d..c741786a 100644 --- a/asm/object/macroPlayer.s +++ b/asm/object/macroPlayer.s @@ -90,7 +90,7 @@ _0808CB70: movs r5, #0 str r5, [r4, #0x34] adds r1, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow ldrb r0, [r4, #0xd] cmp r0, #0 beq _0808CB98 diff --git a/asm/object/object91.s b/asm/object/object91.s index 6a8d37f8..f4fed50e 100644 --- a/asm/object/object91.s +++ b/asm/object/object91.s @@ -291,7 +291,7 @@ _0809C5E0: @ jump table _0809C600: ldr r0, [r5, #0x50] adds r1, r5, #0 - bl ResolveEntityBelow + bl SortEntityBelow ldr r0, [r5, #0x50] ldrb r0, [r0, #0xd] adds r6, r5, #0 @@ -382,7 +382,7 @@ _0809C6B4: .4byte gUnk_08123E1C _0809C6B8: ldr r0, [r5, #0x50] adds r1, r5, #0 - bl ResolveEntityBelow + bl SortEntityBelow ldr r0, [r5, #0x50] ldrb r0, [r0, #0xd] adds r6, r5, #0 @@ -864,7 +864,7 @@ _0809CA30: adds r2, #2 ldrb r2, [r2] rsbs r2, r2, #0 - bl sub_0806F62C + bl LinearMoveAngle ldr r1, [r4, #0x54] adds r0, r4, #0 movs r2, #0x48 diff --git a/asm/object/object96.s b/asm/object/object96.s index 5fb797f2..ddb6415e 100644 --- a/asm/object/object96.s +++ b/asm/object/object96.s @@ -223,7 +223,7 @@ sub_0809D91C: @ 0x0809D91C cmp r1, #0 beq _0809D934 adds r0, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow _0809D934: movs r0, #0x72 bl SoundReq diff --git a/asm/object/object97.s b/asm/object/object97.s index 65f2f74a..d49bbd58 100644 --- a/asm/object/object97.s +++ b/asm/object/object97.s @@ -1024,7 +1024,7 @@ _0809E170: ldrsh r1, [r5, r0] ldrb r2, [r5, #0x15] adds r0, r5, #0 - bl sub_0806F62C + bl LinearMoveAngle movs r1, #0x2e ldrsh r0, [r5, r1] mov r2, r8 diff --git a/asm/object/objectB4.s b/asm/object/objectB4.s index eb36b53e..27adbace 100644 --- a/asm/object/objectB4.s +++ b/asm/object/objectB4.s @@ -95,7 +95,7 @@ _080A0C08: strh r0, [r4, #0x32] adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow _080A0C40: ldrb r0, [r5, #0xf] adds r0, #1 @@ -136,7 +136,7 @@ _080A0C6E: strh r0, [r4, #0x32] adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow _080A0C92: ldrb r0, [r5, #0xf] adds r0, #1 @@ -159,7 +159,7 @@ _080A0CA0: strh r0, [r4, #0x32] adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove _080A0CC0: movs r0, #0xb4 movs r1, #3 @@ -174,7 +174,7 @@ _080A0CC0: strh r0, [r4, #0x32] adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove _080A0CE0: pop {r4, r5, pc} .align 2, 0 diff --git a/asm/object/objectOnSpinyBeetle.s b/asm/object/objectOnSpinyBeetle.s index bcf85560..f93fa2a3 100644 --- a/asm/object/objectOnSpinyBeetle.s +++ b/asm/object/objectOnSpinyBeetle.s @@ -67,7 +67,7 @@ _080985AC: _080985AE: ldr r1, [r4, #0x50] adds r0, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow adds r0, r4, #0 bl sub_08098918 pop {r4, r5, pc} @@ -569,7 +569,7 @@ _0809892E: strb r0, [r2] ldr r1, [r4, #0x50] adds r0, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow _08098968: ldr r2, _0809898C @ =gUnk_08123558 adds r0, r6, #0 @@ -606,7 +606,7 @@ _08098990: strb r0, [r2] ldr r1, [r4, #0x50] adds r0, r4, #0 - bl ResolveEntityBelow + bl SortEntityBelow _080989B2: strh r5, [r4, #0x36] adds r1, r4, #0 diff --git a/asm/object/specialFx.s b/asm/object/specialFx.s index 5a0f7a1b..286e0046 100644 --- a/asm/object/specialFx.s +++ b/asm/object/specialFx.s @@ -459,7 +459,7 @@ _080847F0: strh r0, [r5, #0x36] adds r0, r4, #0 adds r1, r5, #0 - bl ResolveEntityOnTop + bl SortEntityAbove adds r0, r5, #0 bl sub_080845DC pop {r4, r5, pc} diff --git a/asm/objectUtils.s b/asm/objectUtils.s index 67edbaa6..f90b70e4 100644 --- a/asm/objectUtils.s +++ b/asm/objectUtils.s @@ -167,7 +167,7 @@ _080A2BB4: bl PositionRelative adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove adds r0, r5, #0 adds r0, #0x62 ldrb r0, [r0] @@ -380,7 +380,7 @@ CreateSpeechBubble: @ 0x080A2D2C bl CopyPosition adds r0, r5, #0 adds r1, r4, #0 - bl ResolveEntityOnTop + bl SortEntityAbove str r5, [r4, #0x50] adds r0, r4, #0 adds r0, #0x62 diff --git a/include/coord.h b/include/coord.h index 85a56ce2..5ead1236 100644 --- a/include/coord.h +++ b/include/coord.h @@ -12,8 +12,8 @@ void PositionEntityOnTop(Entity*, Entity*); void PositionRelative(Entity*, Entity*, s32, s32); void CopyPositionAndSpriteOffset(Entity* param_1, Entity* param_2); void sub_0806FA90(Entity*, Entity*, s32, s32); -void ResolveEntityOnTop(Entity*, Entity*); -void ResolveEntityBelow(Entity*, Entity*); +void SortEntityAbove(Entity*, Entity*); +void SortEntityBelow(Entity*, Entity*); u32 sub_0806F5A4(u32 idx); u32 sub_0806F3E4(Entity*); diff --git a/include/entity.h b/include/entity.h index c3477e9e..5ff5dcdc 100644 --- a/include/entity.h +++ b/include/entity.h @@ -160,14 +160,14 @@ typedef struct Entity_ { /*0x1d*/ u8 field_0x1d; /*0x1e*/ u8 frameIndex; /*0x1f*/ u8 lastFrameIndex; - /*0x20*/ s32 zVelocity; /**< Z axis speed. */ + /*0x20*/ s32 zVelocity; /**< Z axis speed, measured in px/frame */ /*0x24*/ s16 speed; /**< Magnitude of speed. */ /*0x26*/ u8 spriteAnimation[3]; /*0x29*/ SpritePriority spritePriority; /*0x2a*/ u16 collisions; - /*0x2c*/ union SplitWord x; /**< X position, fixed point. */ - /*0x30*/ union SplitWord y; /**< Y position, fixed point. */ - /*0x34*/ union SplitWord z; /**< Z position, fixed point. */ + /*0x2c*/ union SplitWord x; /**< X position, fixed point Q16.16. */ + /*0x30*/ union SplitWord y; /**< Y position, fixed point Q16.16. */ + /*0x34*/ union SplitWord z; /**< Z position, fixed point Q16.16. */ /*0x38*/ u8 collisionLayer; /**< Collision layer. */ /*0x39*/ s8 interactType; /*0x3a*/ u8 field_0x3a; diff --git a/include/functions.h b/include/functions.h index 819701fa..c301b841 100644 --- a/include/functions.h +++ b/include/functions.h @@ -96,7 +96,7 @@ extern u32 sub_0805F8F8(u32); extern u32 sub_0805F7A0(u32); extern u32* sub_0805F25C(u32); u32 sub_0806FCB8(Entity*, u32, u32, u32); -extern void sub_0806F62C(Entity*, u32, u32); +extern void LinearMoveAngle(Entity*, u32, u32); extern void sub_080A1ED0(u32, u32, u32); extern u32 sub_0806F5B0(u32); extern void sub_08078790(Entity*, u32); @@ -125,7 +125,7 @@ extern bool32 sub_080806BC(u32, u32, u32, u32); extern bool32 sub_0806FC80(Entity*, Entity*, s32); extern u32 sub_080002B4(Entity*, u32, u32); extern u32 sub_080AF134(Entity*); -extern void sub_0806F5BC(Entity*, u32, u32); +extern void LinearMoveDirection(Entity*, u32, u32); extern void sub_080A2AF4(Entity*, u32, u32); extern u32 sub_080002CC(Entity*, s32, s32); extern bool32 sub_0807BD14(Entity*, u32); diff --git a/include/global.h b/include/global.h index 0f656445..8521b77c 100644 --- a/include/global.h +++ b/include/global.h @@ -59,8 +59,8 @@ // Converts a number to Q8.8 fixed-point format #define Q_8_8(n) ((s16)((n)*256)) -// Converts a number to Q4.12 fixed-point format -#define Q_4_12(n) ((s16)((n)*4096)) +// Converts a number to Q16.16 fixed-point format +#define Q_16_16(n) ((s32)((n) * (1 << 16))) #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) >= (b) ? (a) : (b)) diff --git a/src/code_0805436C.c b/src/code_0805436C.c index 6d3eb919..2cb38c6e 100644 --- a/src/code_0805436C.c +++ b/src/code_0805436C.c @@ -250,7 +250,7 @@ u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter) { } else if (arg0->id == 0x1e) { itemEntity->direction = arg0->animationState << 3 | 0x80; itemEntity->speed = 0xc0; - itemEntity->zVelocity = 0x18000; + itemEntity->zVelocity = Q_16_16(1.5); } } CopyPosition(arg0, itemEntity); diff --git a/src/collision.c b/src/collision.c index f33bcb3f..91471613 100644 --- a/src/collision.c +++ b/src/collision.c @@ -290,7 +290,7 @@ void sub_080179EC(Entity* a1, Entity* a2) { u32 rand = Random(); Entity* e = CreateFx(a2, p[rand & 3], 0); if (e != NULL) { - PositionRelative(a2, e, a2->hitbox->offset_x << 16, a2->hitbox->offset_y << 16); + PositionRelative(a2, e, Q_16_16(a2->hitbox->offset_x), Q_16_16(a2->hitbox->offset_y)); e->spritePriority.b0 = 2; e->spriteOffsetX = (a1->x.HALF.HI + a1->hitbox->offset_x - (a2->x.HALF.HI + a2->hitbox->offset_x)) >> 1; e->spriteOffsetY = (a1->y.HALF.HI + a1->hitbox->offset_y - (a2->y.HALF.HI + a2->hitbox->offset_y)) >> 1; @@ -541,9 +541,9 @@ s32 sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) gPlayerState.jump_status = 0; if (tgt->kind == ENEMY && (tgt->id == GHINI || tgt->id == ENEMY_50)) { org->z.HALF.HI = 0; - PositionRelative(org, tgt, 0, 0x10000); + PositionRelative(org, tgt, 0, Q_16_16(1.0)); } else { - PositionRelative(tgt, org, 0, 0x10000); + PositionRelative(tgt, org, 0, Q_16_16(1.0)); } COLLISION_OFF(org); org->spriteRendering.b3 = tgt->spriteRendering.b3; diff --git a/src/coord.c b/src/coord.c index c0c370c0..864144de 100644 --- a/src/coord.c +++ b/src/coord.c @@ -75,7 +75,7 @@ u32 sub_0806F3E4(Entity* ent) { p = &gUnk_08126EE4[gPlayerEntity.animationState & 0xE]; tmp_ent.x.HALF.HI = p[0] + gPlayerEntity.x.HALF.HI; tmp_ent.y.HALF.HI = p[1] + gPlayerEntity.y.HALF.HI; - sub_0806F5BC(ent, ent->field_0x46, GetFacingDirection(ent, &tmp_ent)); + LinearMoveDirection(ent, ent->field_0x46, GetFacingDirection(ent, &tmp_ent)); if (sub_0800419C(&tmp_ent, ent, 4, 4)) { u32 state = ent->field_0x1c & 0xF; if (state == 2) { @@ -146,7 +146,7 @@ u32 sub_0806F5B0(u32 idx) { return gUnk_08114F58[idx]; } -void sub_0806F5BC(Entity* ent, u32 a, u32 b) { +void LinearMoveDirection(Entity* ent, u32 a, u32 b) { if ((b & 0x80) == 0) { u32 m1 = b; @@ -155,15 +155,15 @@ void sub_0806F5BC(Entity* ent, u32 a, u32 b) { } } -void sub_0806F62C(Entity* ent, u32 a, u32 b) { +void LinearMoveAngle(Entity* ent, u32 a, u32 b) { ent->x.WORD += FixedDiv(FixedMul(gSineTable[(u8)b], a), 256) << 8; ent->y.WORD -= FixedDiv(FixedMul(gSineTable[(u8)b + 64], a), 256) << 8; } void LinearMoveUpdate(Entity* ent) { if ((ent->direction & 0x80) == 0) { - ent->x.WORD += FixedDiv(FixedMul(gSineTable[ent->direction * 8], ent->speed), 256) << 8; - ent->y.WORD -= FixedDiv(FixedMul(gSineTable[ent->direction * 8 + 64], ent->speed), 256) << 8; + ent->x.WORD += FixedDiv(FixedMul(gSineTable[ent->direction * 8], ent->speed), (1 << 8)) << 8; + ent->y.WORD -= FixedDiv(FixedMul(gSineTable[ent->direction * 8 + 64], ent->speed), (1 << 8)) << 8; } } @@ -290,13 +290,13 @@ s16 FixedDiv(s16 r0, s16 r1) { return (r0 * 256) / r1; } -void CopyPosition(Entity* param_1, Entity* param_2) { - PositionRelative(param_1, param_2, 0, 0); +void CopyPosition(Entity* source, Entity* target) { + PositionRelative(source, target, 0, 0); } -void PositionEntityOnTop(Entity* ent, Entity* ent2) { - PositionRelative(ent, ent2, 0, 0); - ResolveEntityOnTop(ent, ent2); +void PositionEntityOnTop(Entity* source, Entity* target) { + PositionRelative(source, target, 0, 0); + SortEntityAbove(source, target); } void PositionRelative(Entity* source, Entity* target, s32 offsetX, s32 offsetY) { @@ -314,24 +314,24 @@ void PositionRelative(Entity* source, Entity* target, s32 offsetX, s32 offsetY) UpdateSpriteForCollisionLayer(target); } -void CopyPositionAndSpriteOffset(Entity* param_1, Entity* param_2) { - param_2->spriteOffsetX = param_1->spriteOffsetX; - param_2->spriteOffsetY = param_1->spriteOffsetY; - PositionRelative(param_1, param_2, 0, 0); +void CopyPositionAndSpriteOffset(Entity* source, Entity* target) { + target->spriteOffsetX = source->spriteOffsetX; + target->spriteOffsetY = source->spriteOffsetY; + PositionRelative(source, target, 0, 0); } -void sub_0806FA90(Entity* param_1, Entity* param_2, s32 offsetX, s32 offsetY) { - param_2->spriteOffsetX = param_1->spriteOffsetX; - param_2->spriteOffsetY = param_1->spriteOffsetY; - PositionRelative(param_1, param_2, offsetX * 64 * 32 * 32, offsetY * 64 * 32 * 32); +void sub_0806FA90(Entity* source, Entity* target, s32 offsetX, s32 offsetY) { + target->spriteOffsetX = source->spriteOffsetX; + target->spriteOffsetY = source->spriteOffsetY; + PositionRelative(source, target, Q_16_16(offsetX), Q_16_16(offsetY)); } -void ResolveEntityOnTop(Entity* param_1, Entity* param_2) { - param_2->spritePriority.b0 = gUnk_08114F78[param_1->spritePriority.b0]; +void SortEntityAbove(Entity* relativeTo, Entity* above) { + above->spritePriority.b0 = gUnk_08114F78[relativeTo->spritePriority.b0]; } -void ResolveEntityBelow(Entity* param_1, Entity* param_2) { - param_2->spritePriority.b0 = gUnk_08114F80[param_1->spritePriority.b0]; +void SortEntityBelow(Entity* relativeTo, Entity* below) { + below->spritePriority.b0 = gUnk_08114F80[relativeTo->spritePriority.b0]; } // Values of sin(x*(π/128)) as Q8.8 fixed-point numbers from x = 0 to x = 319 diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index 3fe81a09..8f882be1 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -104,7 +104,7 @@ void sub_080318DC(Entity* this) { void sub_08031A60(Entity* this) { if (this->iframes > 0) - GravityUpdate(this, 0x1800); + GravityUpdate(this, Q_8_8(24.0)); sub_08001324(this); } @@ -315,7 +315,7 @@ void sub_08031E90(Entity* this) { void sub_08031EA8(Entity* this) { this->action = 1; this->spritePriority.b1 = 1; - this->zVelocity = 0x40000; + this->zVelocity = Q_16_16(4.0); this->z.HALF.HI = (4 - this->type2) * 0xe; this->field_0x78.HALF.HI = Random(); InitializeAnimation(this, 4); @@ -325,7 +325,7 @@ void sub_08031EE8(Entity* this) { int draw; this->z.WORD -= this->zVelocity; - this->zVelocity -= 0x1800; + this->zVelocity -= Q_16_16(3.0 / 32.0); if (this->z.HALF.HI < 1) { draw = this->spriteSettings.draw; @@ -442,7 +442,7 @@ void sub_08032160(Entity* this) { this->spriteSettings.flipX = 0; } this->speed = 0xf0; - this->zVelocity = 0x12000; + this->zVelocity = Q_16_16(1.125); this->spritePriority.b1 = 1; InitializeAnimation(this, 12); } @@ -477,7 +477,7 @@ void sub_08032204(Entity* this) { } void sub_08032248(Entity* this) { - if (GravityUpdate(this, 0x1800) == 0) { + if (GravityUpdate(this, Q_8_8(24.0)) == 0) { if (this->frame & 0x80) { ((Entity*)this->field_0x7c.WORD)->actionDelay--; diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index c03ff919..e01f69d1 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -109,7 +109,7 @@ void sub_080218CC(Entity* this) { this->spriteSettings.draw = 1; this->direction = ((sub_08049F84(this, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & 0x1f; this->speed = 0x100; - this->zVelocity = 0x12000; + this->zVelocity = Q_16_16(1.125); } GetNextFrame(this); @@ -242,7 +242,7 @@ void sub_08021B64(Entity* this) { if (iVar4 == 0) { this->action = 6; - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); ((u8*)&this->field_0x86)[1] = 0; if (gPlayerEntity.direction != 0xff) { this->direction = 0x10 ^ gPlayerEntity.direction; @@ -303,7 +303,7 @@ u32 sub_08021D00(Entity* this) { } else { this->action = 4; this->actionDelay = 1; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); InitializeAnimation(this, 4); ret = 1; } diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index ebc47375..ef6c9dcf 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -61,7 +61,7 @@ void sub_0802C688(Entity* this) { this->action = 3; this->hitType = 0x6e; this->field_0xf = 1; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->speed = 0; this->field_0x80.HALF.HI = 1; InitializeAnimation(this, this->direction >> 4 | 6); @@ -79,7 +79,7 @@ void sub_0802C7AC(Entity* this) { if (this->field_0x82.HALF.LO != 2) { this->speed = this->field_0x82.HALF.LO ? 0x200 : 0x80; } - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->field_0x82.HALF.HI = 0; this->field_0x80.HALF.HI = 0; } else { @@ -232,7 +232,7 @@ void sub_0802CA94(Entity* this) { COLLISION_OFF(this); this->field_0xf = 1; this->spritePriority.b1 = 1; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->speed = 0; this->field_0x82.HALF.HI = 0; this->field_0x80.HALF.HI = 0; diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c index 3a7a0064..bc6367ee 100644 --- a/src/enemy/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -381,7 +381,7 @@ void sub_0802ADDC(Entity* this) { void sub_0802AE24(Entity* this) { this->action = 1; this->actionDelay = 0xf0; - this->zVelocity = 0x8000; + this->zVelocity = Q_16_16(0.5); this->hitbox = (Hitbox*)&gUnk_080CD174; this->field_0x3c = 3; this->field_0x16 = 0; diff --git a/src/enemy/chuchu.c b/src/enemy/chuchu.c index 9d8d4ff3..c8e7640e 100644 --- a/src/enemy/chuchu.c +++ b/src/enemy/chuchu.c @@ -722,7 +722,7 @@ u32 sub_0801FBD0(Entity* this) { void Chuchu_JumpAtPlayer(Entity* this) { this->speed = 0x180; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); this->direction = sub_08049F84(this, 1); InitializeAnimation(this, 3); } diff --git a/src/enemy/cuccoChickAggr.c b/src/enemy/cuccoChickAggr.c index 2b6bb47f..94326739 100644 --- a/src/enemy/cuccoChickAggr.c +++ b/src/enemy/cuccoChickAggr.c @@ -52,7 +52,7 @@ void sub_08022988(Entity* this) { return; this->frameIndex = 1; - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); EnqueueSFX(0xd6); } @@ -78,7 +78,7 @@ void sub_080229F8(Entity* this) { this->speed = 0xc0; sub_08022B44(this); } else { - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); EnqueueSFX(0xd6); } } @@ -141,7 +141,7 @@ u32 sub_08022B20(Entity* this) { } void sub_08022B44(Entity* this) { - this->zVelocity = 0xc000; + this->zVelocity = Q_16_16(0.75); this->direction = GetFacingDirection(this, &gPlayerEntity); if (this->direction & 0xf) diff --git a/src/enemy/fallingBoulder.c b/src/enemy/fallingBoulder.c index d414ce52..a9dfc7d6 100644 --- a/src/enemy/fallingBoulder.c +++ b/src/enemy/fallingBoulder.c @@ -37,7 +37,7 @@ void sub_0802C254(Entity* this) { void sub_0802C258(Entity* this) { sub_0804A720(this); - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); this->actionDelay = 2; this->field_0x7a.HWORD = Random() & 0x70; switch (this->type) { @@ -195,7 +195,7 @@ void sub_0802C4B0(Entity* this) { } rand = Random() & 7; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); if (rand & 4) { if (rand & 3) { *(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 1]; diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c index 5e81c1d6..a0546fb8 100644 --- a/src/enemy/fireballGuy.c +++ b/src/enemy/fireballGuy.c @@ -102,7 +102,7 @@ u32 sub_0804A024(Entity*, u32, u32); void sub_08045524(Entity* this) { u32 tmp, tmp1, tmp2; - this->zVelocity = 0x1c000; + this->zVelocity = Q_16_16(1.75); tmp = sub_0804A024(this, 1, 8); if (tmp != 0xff && (Random() & 3) == 0) { this->actionDelay = Random() & 3; diff --git a/src/enemy/flyingSkull.c b/src/enemy/flyingSkull.c index 9a824c35..934bfef5 100644 --- a/src/enemy/flyingSkull.c +++ b/src/enemy/flyingSkull.c @@ -46,7 +46,7 @@ void sub_08039BF8(FlyingSkullEntity* this) { if (super->bitfield == 0x9d) { super->action = 7; COLLISION_OFF(super); - super->zVelocity = 0x2A000; + super->zVelocity = Q_16_16(2.625); super->spritePriority.b1 = 1; SetTile(this->unk_0x74, COORD_TO_TILE(super), super->collisionLayer); } else if (super->z.HALF.HI) { diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c index d2dabadb..6f06b9ac 100644 --- a/src/enemy/gyorgMale.c +++ b/src/enemy/gyorgMale.c @@ -1033,7 +1033,7 @@ void sub_08047DF0(GyorgMaleEntity* this, u32 unk1) { sub_08047EA4(this, unk1); oldX = super->x.HALF.HI; oldY = super->y.HALF.HI; - sub_0806F62C(super, super->speed, super->direction); + LinearMoveAngle(super, super->speed, super->direction); if (this->unk_7c & 1) { if (sub_08079F8C()) { gPlayerEntity.x.HALF.HI += super->x.HALF.HI - oldX; @@ -1051,7 +1051,7 @@ void sub_08047E58(GyorgMaleEntity* this) { u32 oldX, oldY; oldX = super->x.HALF.HI; oldY = super->y.HALF.HI; - sub_0806F62C(super, super->speed, super->direction); + LinearMoveAngle(super, super->speed, super->direction); if (this->unk_7c & 1) { if (sub_08079F8C()) { gPlayerEntity.x.HALF.HI += super->x.HALF.HI - oldX; diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index 3187c340..be7f9dad 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -95,7 +95,7 @@ void sub_0802BCA8(Entity* this) { this->action = 7; this->actionDelay = 0x5a; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->hitType = 0x19; this->field_0x3a = this->field_0x3a & 0xfb; this->field_0x1c = 0x12; @@ -222,7 +222,7 @@ void sub_0802BEBC(Entity* this) { this->direction ^= 0x10; sub_080AEFE0(this); this->direction ^= 0x10; - if (!sub_080044EC(this, 0x2000)) { + if (!sub_080044EC(this, Q_16_16(0.125))) { sub_0802C1C0(this); } } @@ -234,7 +234,7 @@ void sub_0802BEEC(Entity* this) { this->direction = this->animationState << 3; InitializeAnimation(this, this->animationState + 4); } - } else if (!GravityUpdate(this, 0x1c00)) { + } else if (!GravityUpdate(this, Q_16_16(0.109375))) { this->action = 8; this->actionDelay = 30; this->speed = 0x120; @@ -356,7 +356,7 @@ void sub_0802C18C(Entity* this) { if ((this->field_0x78.HALF.LO & 7) == 0) { Entity* ent = CreateObject(SPECIAL_FX, 0x11, 0x40); if (ent) { - PositionRelative(this, ent, 0, 0x10000); + PositionRelative(this, ent, 0, Q_16_16(1.0)); } } } @@ -374,8 +374,8 @@ void sub_0802C1CC(Entity* this) { void sub_0802C218(Entity* this) { this->action = 6; - this->speed = 0xe0; - this->zVelocity = 0x18000; + this->speed = Q_8_8(0.875); + this->zVelocity = Q_16_16(1.5); } // clang-format off diff --git a/src/enemy/keaton.c b/src/enemy/keaton.c index 3e1a0679..78349fbb 100644 --- a/src/enemy/keaton.c +++ b/src/enemy/keaton.c @@ -229,7 +229,7 @@ void sub_08032794(Entity* this) { target = CreateFx(this, FX_DASH, 0x40); if (target != NULL) { temp = &gUnk_080CE810[this->animationState * 2]; - PositionRelative(this, target, temp[0] << 0x10, temp[1] << 0x10); + PositionRelative(this, target, Q_16_16(temp[0]), Q_16_16(temp[1])); } } diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c index 25dd93ea..09a47a84 100644 --- a/src/enemy/lakitu.c +++ b/src/enemy/lakitu.c @@ -59,7 +59,7 @@ void Lakitu_DoAction(Entity* this) { void sub_0803C784(Entity* this) { if ((this->bitfield & 0x7f) == 0x1d) { - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); sub_0803CBAC(this); } else { @@ -316,7 +316,7 @@ void Lakitu_SpawnLightning(Entity* this) { lightning->direction = this->field_0x78.HALF.LO; - PositionRelative(this, lightning, offset->x << 16, offset->y << 16); + PositionRelative(this, lightning, Q_16_16(offset->x), Q_16_16(offset->y)); EnqueueSFX(0x193); } @@ -346,6 +346,8 @@ void sub_0803CC08(Entity* this) { Entity* cloud; Entity* fx; + const s32 diff = Q_8_8(3.0 / 128.0); + cloud = this->child; if (cloud == NULL) { return; @@ -365,26 +367,26 @@ void sub_0803CC08(Entity* this) { fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { - fx->x.HALF.HI += 6; - fx->y.HALF.HI += 6; + fx->x.HALF.HI += diff; + fx->y.HALF.HI += diff; } fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { - fx->x.HALF.HI -= 6; - fx->y.HALF.HI += 6; + fx->x.HALF.HI -= diff; + fx->y.HALF.HI += diff; } fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { - fx->x.HALF.HI += 6; - fx->y.HALF.HI -= 6; + fx->x.HALF.HI += diff; + fx->y.HALF.HI -= diff; } fx = CreateFx(this, FX_DEATH, 0); if (fx != NULL) { - fx->x.HALF.HI -= 6; - fx->y.HALF.HI -= 6; + fx->x.HALF.HI -= diff; + fx->y.HALF.HI -= diff; } this->child = NULL; diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index ca5f59e0..d65a4c8a 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -193,7 +193,7 @@ void sub_0802805C(Entity* this) { } else { ResetPlayer(); gPlayerState.mobility |= 0x80; - PositionRelative(this, &gPlayerEntity, 0, 0x10000); + PositionRelative(this, &gPlayerEntity, 0, Q_16_16(1.0)); tmp = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex); gPlayerEntity.spriteOffsetX = tmp[0]; @@ -215,7 +215,7 @@ NONMATCH("asm/non_matching/likeLike/sub_0802810C.inc", void sub_0802810C(Entity* gPlayerState.field_0xa = 0; gPlayerState.flags &= 0xffffffef; gPlayerEntity.flags |= 0x80; - gPlayerEntity.zVelocity = 0x18000; + gPlayerEntity.zVelocity = Q_16_16(1.5); gPlayerEntity.iframes = -60; gPlayerEntity.direction = gPlayerEntity.animationState << 2; gPlayerEntity.spritePriority.b1 = this->field_0x82.HALF.HI; diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index b78c9b07..8c43062d 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -189,7 +189,7 @@ void sub_0803A274(Entity* this) { pEVar1 = CreateObject(OBJECT_7E, 1, 0); pEVar1->parent = this; pEVar1->child = this->child; - PositionRelative(this->parent, this, 0x100000, 0x200000); + PositionRelative(this->parent, this, Q_16_16(16.0), Q_16_16(32.0)); } else { pEVar1 = CreateEnemy(MAZAAL_HAND, 1); pEVar1->parent = this; @@ -201,7 +201,7 @@ void sub_0803A274(Entity* this) { pEVar1->parent = this; pEVar1->child = this->child; this->spriteSettings.flipX = 1; - PositionRelative(this->parent, this, -0x100000, 0x200000); + PositionRelative(this->parent, this, Q_16_16(-16.0), Q_16_16(32.0)); } if (gRoomTransition.field_0x38 != 0) { this->action = 3; @@ -917,7 +917,7 @@ void sub_0803B100(Entity* this) { Entity* temp; this->action = 0x29; - this->zVelocity = 0x14000; + this->zVelocity = Q_16_16(1.25); if (this->type == 0) { this->hitbox = &gUnk_080FD364; } else { @@ -974,7 +974,7 @@ void sub_0803B1B8(Entity* this) { if (temp != (Entity*)0x0) { temp->actionDelay = 0; temp->direction = 0x90; - PositionRelative(this, temp, this->hitbox->offset_x << 0x10, this->hitbox->offset_y << 0x10); + PositionRelative(this, temp, Q_16_16(this->hitbox->offset_x), Q_16_16(this->hitbox->offset_y)); } temp = *(Entity**)&this->field_0x74; temp->field_0x74.HALF.LO = 0x40; @@ -1086,7 +1086,7 @@ void sub_0803B480(Entity* this) { Entity* target; if (((this->field_0x7c.HALF.HI & 0x1f) == 0) && (target = CreateObject(SMOKE, 1, 0), target != (Entity*)0x0)) { - PositionRelative(this, target, gUnk_080CFD08[this->type] << 0x10, 0); + PositionRelative(this, target, Q_16_16(gUnk_080CFD08[this->type]), 0); } if (--this->field_0x7c.HALF.HI == 0) { sub_0803B6A4(this); @@ -1115,8 +1115,8 @@ u32 sub_0803B4E4(Entity* this) { } void sub_0803B538(Entity* this) { - PositionRelative(this, this->child, 0, -0x10000); - PositionRelative(this, *(Entity**)&this->field_0x74, 0, -0x20000); + PositionRelative(this, this->child, 0, Q_16_16(-1.0)); + PositionRelative(this, *(Entity**)&this->field_0x74, 0, Q_16_16(-2.0)); } void sub_0803B55C(Entity* this) { @@ -1230,7 +1230,7 @@ void sub_0803B798(void) { gPlayerState.field_0xa = 0; gPlayerState.flags &= ~(0xffff0000 | PL_CAPTURED); gPlayerEntity.flags |= 0x80; - gPlayerEntity.zVelocity = 0x18000; + gPlayerEntity.zVelocity = Q_16_16(1.5); gPlayerEntity.z.HALF.HI = -10; gPlayerEntity.direction = 0x10; gPlayerEntity.animationState = 4; diff --git a/src/enemy/mazaalHead.c b/src/enemy/mazaalHead.c index af37d745..fa44a8d4 100644 --- a/src/enemy/mazaalHead.c +++ b/src/enemy/mazaalHead.c @@ -741,7 +741,7 @@ void sub_08034A84(Entity* this) { } void sub_08034AC4(Entity* this) { - PositionRelative(this->parent, this, 0, 0x10000); + PositionRelative(this->parent, this, 0, Q_16_16(1.0)); gUnk_080CED74[this->action](this); } @@ -782,7 +782,7 @@ void sub_08034B38(Entity* this) { target->direction = this->actionDelay + 0x58; } ptr = &gUnk_080CED84[target->type * 2]; - PositionRelative(this, target, *(ptr++) << 0x10, *ptr << 0x10); + PositionRelative(this, target, Q_16_16(*(ptr++)), Q_16_16(*ptr)); } } } diff --git a/src/enemy/miniFireballGuy.c b/src/enemy/miniFireballGuy.c index b9a64caf..fd6f54e2 100644 --- a/src/enemy/miniFireballGuy.c +++ b/src/enemy/miniFireballGuy.c @@ -57,7 +57,7 @@ void sub_08045654(Entity* this) { void sub_08045678(Entity* this) { - this->zVelocity = 0x1c000; + this->zVelocity = Q_16_16(1.75); if (this->actionDelay != 0) { this->actionDelay--; } else { diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c index cb055f0b..80d1a055 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -87,7 +87,7 @@ void sub_080230E4(Entity* this) { CopyPosition(this, &gPlayerEntity); gPlayerEntity.flags = gPlayerEntity.flags | 0x80; gPlayerEntity.spriteSettings.draw = 1; - gPlayerEntity.zVelocity = 0x18000; + gPlayerEntity.zVelocity = Q_16_16(1.5); gPlayerEntity.direction = 0xff; gPlayerEntity.iframes = -0x14; gPlayerState.jump_status = 0x41; @@ -270,7 +270,7 @@ void sub_0802351C(Entity* this) { if (this->type2 == 0) { gPlayerEntity.animationState = this->animationState & 7; gPlayerState.flags |= PL_MOLDWORM_CAPTURED; - PositionRelative(this, &gPlayerEntity, 0, gUnk_080CBC90[this->animationState & 7] << 0x10); + PositionRelative(this, &gPlayerEntity, 0, Q_16_16(gUnk_080CBC90[this->animationState & 7])); gPlayerEntity.spriteOffsetY = -gUnk_080CBC90[this->animationState & 7]; } } else { diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c index c0aa2b65..f603afd8 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -617,7 +617,7 @@ void OctorokBoss_Action1(Entity* this) { this->field_0x74.HWORD += 4; } } - ResolveEntityBelow(this->parent, this); + SortEntityBelow(this->parent, this); if (((GET_HELPER(this)->field_0x2 != 0) || (this->parent->action == INTRO)) || (1 < (u8)(this->parent->subAction - 3))) { if ((s8)this->field_0xf < 0) { @@ -649,9 +649,9 @@ void OctorokBoss_Action1(Entity* this) { if ((GET_HELPER(this)->tailCount - 2) < this->type2) { DeleteThisEntity(); } - ResolveEntityOnTop(this->parent, this); + SortEntityAbove(this->parent, this); if (GET_HELPER(this)->tailCount - 2 == this->type2) { - ResolveEntityOnTop(this->parent, this); + SortEntityAbove(this->parent, this); radius = 0x10000 / this->parent->field_0x74.HWORD; radius = radius << 0xd >> 0x8; angle = -this->parent->field_0x7a.HALF.HI; @@ -693,7 +693,7 @@ void OctorokBoss_Action1(Entity* this) { if (this->health == 1) { this->health = 0; } else { - ResolveEntityBelow(this->parent, this); + SortEntityBelow(this->parent, this); if ((this->parent->subAction != 4) && (this->health != 1)) { if (GET_TIMER(this) > 0x1c) { GET_TIMER(this)--; @@ -939,7 +939,7 @@ void OctorokBoss_ExecuteAttackVacuum(Entity* this) { if (sub_0806FC80(this, &gPlayerEntity, 0xf0) != 0) { if ((gPlayerState.flags & PL_FROZEN) == 0) { if ((gPlayerEntity.flags & PL_MINISH) != 0) { - sub_0806F62C(&gPlayerEntity, 0x280, -GET_ANGLE_HI(this)); + LinearMoveAngle(&gPlayerEntity, 0x280, -GET_ANGLE_HI(this)); if (sub_0806FC80(this, &gPlayerEntity, 0x48) != 0) { this->field_0x80.HALF.LO = 1; GET_TIMER(this) = 2; diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index 2f08e47a..6389b179 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -265,7 +265,7 @@ void Peahat_RepairPropeller(Entity* this) { return; this->action = 9; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->direction = Random() & 0x1f; sub_0804AA1C(this); this->animationState = PeahatAnimation_RepairPropeller; @@ -291,7 +291,7 @@ void Peahat_Hop(Entity* this) { if (--this->actionDelay == 0) { if (this->frame & 0x80) { this->action = 9; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->animationState = PeahatAnimation_NewPropeller; InitializeAnimation(this, this->animationState); } else { diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index 34e316cc..b52a69fc 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -811,7 +811,7 @@ void sub_08024E4C(Entity* this) { gPlayerState.field_0x38 = 0x14; gPlayerState.field_0x39 = 1; *(u8*)&gPlayerState.field_0x3a = 0; - PositionRelative(this, player, 0, 0x10000); + PositionRelative(this, player, 0, Q_16_16(1.0)); player->spriteOffsetY = 0x1a; player->animationState = 4; player->spritePriority.b1 = 0; diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c index 6e35dbfc..e4763610 100644 --- a/src/enemy/puffstool.c +++ b/src/enemy/puffstool.c @@ -198,7 +198,7 @@ void sub_080252E0(Entity* this) { this->action = 3; this->actionDelay = 0x1e; this->field_0xf = 0; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); InitializeAnimation(this, 1); } } @@ -210,8 +210,8 @@ void sub_0802538C(Entity* this) { if (this->frame == 0) { GetNextFrame(this); } else { - GravityUpdate(this, 0x2000); - if (this->zVelocity < 0x2000) { + GravityUpdate(this, Q_16_16(0.125)); + if (this->zVelocity < Q_16_16(0.125)) { this->action = 4; InitializeAnimation(this, 2); } @@ -240,7 +240,7 @@ void sub_0802541C(Entity* this) { if (this->frame & 0x80) { this->action = 3; this->field_0xf = 1; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2); InitializeAnimation(this, 1); } } @@ -257,7 +257,7 @@ void sub_0802544C(Entity* this) { } void sub_0802547C(Entity* this) { - GravityUpdate(this, 0x2000); + GravityUpdate(this, Q_16_16(0.125)); GetNextFrame(this); if ((this->actionDelay & 7) == 0) { sub_08025BD4(this); @@ -269,7 +269,7 @@ void sub_0802547C(Entity* this) { } void sub_080254B4(Entity* this) { - GravityUpdate(this, 0x2000); + GravityUpdate(this, Q_16_16(0.125)); if (this->frame & 0x80) { if (this->z.HALF.HI == 0) { if (this->cutsceneBeh.HWORD == 0) { @@ -553,7 +553,7 @@ void sub_08025B18(Entity* this) { ent = CreateObject(OBJECT_21, 2, 0); if (ent) { - PositionRelative(this, ent, offset[0] * 0x10000, offset[1] * 0x10000); + PositionRelative(this, ent, Q_16_16(offset[0]), Q_16_16(offset[1])); ent->x.HALF.HI &= -0x10; ent->x.HALF.HI += 8; ent->y.HALF.HI &= -0x10; @@ -567,8 +567,8 @@ void sub_08025BD4(Entity* this) { if (this->field_0x82.HALF.LO && (this->frame & 1) == 0) { Entity* ent = CreateObject(OBJECT_21, 0, 0); if (ent) { - PositionRelative(this, ent, gUnk_080CC0BA[this->animationState * 2 + 0] * 0x10000, - gUnk_080CC0BA[this->animationState * 2 + 1] * 0x10000); + PositionRelative(this, ent, Q_16_16(gUnk_080CC0BA[this->animationState * 2 + 0]), + Q_16_16(gUnk_080CC0BA[this->animationState * 2 + 1])); ent->z.HALF.HI = -10; } } diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index 9a86c115..c80786d3 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -37,7 +37,7 @@ void Rollobite_OnTick(Entity* this) { void sub_08020668(Entity* this) { if (this->hitType == 34 && this->health != 0xff) { this->action = 4; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); this->direction = 0xff; this->health = 0xff; this->hitType = 35; @@ -107,7 +107,7 @@ void sub_080207A8(Entity* this) { this->spritePriority.b0 = 4; this->field_0x3a &= 0xfb; this->direction ^= 0x10; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->speed = 0x80; InitializeAnimation(this, this->animationState + 0x10); } @@ -267,7 +267,7 @@ bool32 Rollobite_TryToHoleUp(Entity* this) { this->x.HALF.HI += 8; this->y.HALF.HI &= 0xfff0; this->y.HALF.HI += 13; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); InitializeAnimation(this, this->animationState + 0x14); SetTile(0x4034, tile, this->collisionLayer); return TRUE; diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index d2393187..bb8e176f 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -171,7 +171,7 @@ void sub_0802953C(Entity* this) { } else { ResetPlayer(); gPlayerState.mobility |= 0x80; - PositionRelative(this, &gPlayerEntity, 0, 0x10000); + PositionRelative(this, &gPlayerEntity, 0, Q_16_16(1.0)); pbVar3 = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex); gPlayerEntity.spriteOffsetX = pbVar3[0]; gPlayerEntity.spriteOffsetY = pbVar3[1] - 1; @@ -240,7 +240,7 @@ void sub_080296D8(Entity* this) { gPlayerState.jump_status = 0x41; gPlayerState.flags &= ~PL_CAPTURED; gPlayerEntity.flags |= 0x80; - gPlayerEntity.zVelocity = 0x18000; + gPlayerEntity.zVelocity = Q_16_16(1.5); gPlayerEntity.iframes = 0xa6; gPlayerEntity.z.HALF.HI = -2; gPlayerEntity.direction = gPlayerEntity.animationState << 2; diff --git a/src/enemy/sluggula.c b/src/enemy/sluggula.c index 308d914f..720b3a50 100644 --- a/src/enemy/sluggula.c +++ b/src/enemy/sluggula.c @@ -124,7 +124,7 @@ void sub_08023CE0(Entity* this) { EnqueueSFX(0x12d); InitializeAnimation(this, 4); } - } else if (!GravityUpdate(this, 0x1800)) { + } else if (!GravityUpdate(this, Q_8_8(24))) { this->action = 3; this->spriteSettings.draw = 1; EnqueueSFX(0x84); @@ -169,7 +169,7 @@ void sub_08023E54(Entity* this) { ent = CreateEnemy(SLUGGULA, 2); if (ent) { const s8* ptr = &gUnk_080CBDF7[this->animationState * 2]; - PositionRelative(this, ent, ptr[0] << 0x10, ptr[1] << 0x10); + PositionRelative(this, ent, Q_16_16(ptr[0]), Q_16_16(ptr[1])); } } } diff --git a/src/enemy/spikedBeetle.c b/src/enemy/spikedBeetle.c index a6fa4ae6..f4f6792e 100644 --- a/src/enemy/spikedBeetle.c +++ b/src/enemy/spikedBeetle.c @@ -54,7 +54,7 @@ void sub_0802B628(Entity* this) { case 0x1d: if (this->action < 6) { this->action = 6; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); this->speed = 0xc0; this->direction = this->knockbackDirection; this->knockbackDuration = 0; @@ -171,7 +171,7 @@ void sub_0802B8E0(Entity* this) { } } else { this->action = 8; - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); this->speed = 0x60; this->hitType = 99; InitializeAnimation(this, this->animationState); diff --git a/src/enemy/spinyChuchu.c b/src/enemy/spinyChuchu.c index a51c8ac4..c6db356b 100644 --- a/src/enemy/spinyChuchu.c +++ b/src/enemy/spinyChuchu.c @@ -93,7 +93,7 @@ void sub_080225A0(Entity* this) { } void sub_080225BC(Entity* this) { - GravityUpdate(this, 0x1800); + GravityUpdate(this, Q_8_8(24.0)); if (this->frame & 1) { sub_0804A7D4(this); } else { @@ -132,7 +132,7 @@ void sub_08022654(Entity* this) { InitializeAnimation(this, 0); /* fallthrough */ case 1: - if (GravityUpdate(this, 0x1800)) + if (GravityUpdate(this, Q_8_8(24.0))) return; this->subAction = 2; @@ -163,7 +163,7 @@ void sub_080226EC(Entity* this) { if (sub_080228F0(this)) { this->action = 6; - this->zVelocity = 0x12000; + this->zVelocity = Q_16_16(1.125); this->speed = 0x140; this->direction = GetFacingDirection(this, gUnk_020000B0); this->hitType = 0x5a; @@ -211,7 +211,7 @@ void sub_080227AC(Entity* this) { } void sub_0802281C(Entity* this) { - GravityUpdate(this, 0x1800); + GravityUpdate(this, Q_8_8(24.0)); GetNextFrame(this); if (this->frame & 0x80) { this->action = 2; @@ -225,7 +225,7 @@ void sub_08022854(Entity* this) { GetNextFrame(this); if (this->frame & 1) { sub_080AEFE0(this); - if (GravityUpdate(this, 0x1800) == 0) { + if (GravityUpdate(this, Q_8_8(24.0)) == 0) { this->action = 7; this->hitType = 0x5c; InitializeAnimation(this, 5); diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c index 4c63076d..3841377e 100644 --- a/src/enemy/tektiteGolden.c +++ b/src/enemy/tektiteGolden.c @@ -89,7 +89,7 @@ void sub_08037Fe0(Entity* this) { this->action = 2; this->actionDelay = 6; this->field_0xf = 0; - this->zVelocity = 0x38000; + this->zVelocity = Q_16_16(3.5); sub_08038168(this); InitializeAnimation(this, 2); } @@ -145,7 +145,7 @@ void sub_08038110(Entity* this) { if (this->field_0x80.HALF.LO < 5) { this->action = 2; this->actionDelay = 8; - this->zVelocity = 0x38000; + this->zVelocity = Q_16_16(3.5); sub_08038168(this); InitializeAnimation(this, 2); } else { diff --git a/src/enemy/vaatiArm.c b/src/enemy/vaatiArm.c index b4e2100b..c4344868 100644 --- a/src/enemy/vaatiArm.c +++ b/src/enemy/vaatiArm.c @@ -951,7 +951,7 @@ void sub_08043490(Entity* this) { entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[4]; if (entity->z.HALF.HI < -4) { - entity->zVelocity = 0x18000; + entity->zVelocity = Q_16_16(1.5); this->subAction = 2; this->field_0x7c.BYTES.byte2 = 0; ((VaatiArm_HeapStruct*)this->myHeap)->parent->subAction = 2; @@ -976,7 +976,7 @@ void sub_08043520(Entity* this) { Entity* entity; entity = ((VaatiArm_HeapStruct*)this->myHeap)->entities[4]; - GravityUpdate(entity, 0x1a00); + GravityUpdate(entity, Q_8_8(26.0)); if ((entity->zVelocity < 0) && (-6 < entity->z.HALF.HI)) { entity->z.HALF.HI = -6; this->subAction = 3; diff --git a/src/enemy/vaatiBall.c b/src/enemy/vaatiBall.c index 760bcb5d..ff441bc4 100644 --- a/src/enemy/vaatiBall.c +++ b/src/enemy/vaatiBall.c @@ -71,7 +71,7 @@ void sub_0804468C(Entity* this) { this->field_0x82.HALF.HI = 0; this->spriteSettings.draw = 0; off = &gUnk_080D1620[this->field_0x78.HALF.HI & 3]; - PositionRelative(this->parent, this, off->h << 0x10, (off->v - 0x10) * 0x10000); + PositionRelative(this->parent, this, Q_16_16(off->h), Q_16_16(off->v - 0x10)); this->z.HALF.HI = this->parent->z.HALF.HI; InitAnimationForceUpdate(this, 0); break; @@ -397,7 +397,7 @@ void sub_08044B04(Entity* this) { this->field_0x74.HALF.LO = 1; this->actionDelay = 80; COLLISION_OFF(this); - PositionRelative(vaati, this, 0, -0x100000); + PositionRelative(vaati, this, 0, Q_16_16(-16.0)); if (this->field_0xf) this->spriteSettings.draw = 0; break; @@ -463,7 +463,7 @@ void sub_08044DEC(Entity* this) { this->speed = 0x300; off = this->parent->field_0x80.HALF.LO - 1; this->direction = gUnk_080D1628[off][this->field_0x78.HALF.HI]; - PositionRelative(this->parent, this, 0, -0x100000); + PositionRelative(this->parent, this, 0, Q_16_16(-16.0)); } void sub_08044E74(Entity* this, u32 state) { @@ -475,7 +475,7 @@ void sub_08044E74(Entity* this, u32 state) { this->action = 2; this->direction += 0x18; this->direction &= 0x1f; - PositionRelative(this->parent, this, 0, -0x100000); + PositionRelative(this->parent, this, 0, Q_16_16(-16.0)); this->speed = 12288; LinearMoveUpdate(this); this->direction += 0x8; @@ -509,5 +509,5 @@ void sub_08044E74(Entity* this, u32 state) { } this->actionDelay = 1; this->field_0x78.HALF.LO = 0; - this->speed = 1280; + this->speed = Q_8_8(5); } diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c index c9d1fbbf..39e68307 100644 --- a/src/enemy/vaatiProjectile.c +++ b/src/enemy/vaatiProjectile.c @@ -121,7 +121,7 @@ void VaatiProjectileFunction0Action0(Entity* this) { this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY; this->spriteRendering.b3 = this->parent->spriteRendering.b3; this->spritePriority.b1 = 0; - PositionRelative(this->parent, this, 0, -0x10000); + PositionRelative(this->parent, this, 0, Q_16_16(-1.0)); InitializeAnimation(this, 1); } } @@ -207,7 +207,7 @@ void VaatiProjectileFunction0Action8(Entity* this) { if (this->parent->next == NULL) { DeleteThisEntity(); } - PositionRelative(this->parent, this, 0, -0x10000); + PositionRelative(this->parent, this, 0, Q_16_16(-1.0)); GetNextFrame(this); } diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index 612e3af4..99f1777b 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -135,7 +135,7 @@ void VaatiRebornEnemyType0Action0(Entity* this) { entity->parent = this; entity->spriteSettings.flipX = i; ptr = &gUnk_080D04A8[i]; - PositionRelative(this, entity, ptr->x << 0x10, ptr->y << 0x10); + PositionRelative(this, entity, Q_16_16(ptr->x), Q_16_16(ptr->y)); } InitAnimationForceUpdate(this, 0); } @@ -292,7 +292,7 @@ void VaatiRebornEnemyType0Action3(Entity* this) { break; case 0xff: if (this->z.HALF.HI != -4) { - this->z.WORD -= 0x2000; + this->z.WORD -= Q_16_16(0.125); } if (this->actionDelay == 2) { this->field_0x74.HALF.LO = 0xfe; @@ -442,7 +442,7 @@ void VaatiRebornEnemyType0Action6(Entity* this) { SoundReq(SFX_150); target = CreateProjectileWithParent(this, 0x18, 0); if (target != NULL) { - PositionRelative(this, target, 0, -0x100000); + PositionRelative(this, target, 0, Q_16_16(-16.0)); target->parent = this; } } else if (this->actionDelay == 0x40) { @@ -500,7 +500,7 @@ void VaatiRebornEnemyType1Action0(Entity* this) { this->field_0x74.HALF.HI = 1; this->actionDelay = 0; this->spriteOffsetY = -1; - PositionRelative(this->parent, this, 0, 0x10000); + PositionRelative(this->parent, this, 0, Q_16_16(1.0)); enemy = CreateEnemy(VAATI_REBORN_ENEMY, 2); enemy->parent = this; enemy->child = this->parent; @@ -546,7 +546,7 @@ void VaatiRebornEnemyType1Action1(Entity* this) { } this->spriteSettings.draw = parent->spriteSettings.draw; this->spriteOffsetX = parent->spriteOffsetX; - PositionRelative(this->parent, this, 0, 0x10000); + PositionRelative(this->parent, this, 0, Q_16_16(1.0)); UpdateAnimationSingleFrame(this); } @@ -559,7 +559,7 @@ void VaatiRebornEnemyType2Action0(Entity* this) { this->field_0x74.HALF.HI = 0; this->spriteOffsetY = -2; this->direction = 0xff; - PositionRelative(source, this, 0, 0x20000); + PositionRelative(source, this, 0, Q_16_16(2.0)); InitAnimationForceUpdate(this, 2); } @@ -595,7 +595,7 @@ void VaatiRebornEnemyType2Action1(Entity* this) { } this->spriteSettings.draw = parent->spriteSettings.draw; this->spriteOffsetX = parent->spriteOffsetX; - PositionRelative(parent->parent, this, 0, 0x20000); + PositionRelative(parent->parent, this, 0, Q_16_16(2.0)); UpdateAnimationSingleFrame(this); } @@ -637,7 +637,7 @@ void sub_0803DC0C(Entity* this) { tmp = &gUnk_080D04C8[this->actionDelay]; this->spriteSettings.draw = parent->spriteSettings.draw; this->spriteOffsetX = parent->spriteOffsetX; - PositionRelative(parent, this, tmp->x << 0x10, (tmp->y + 1) * 0x10000); + PositionRelative(parent, this, Q_16_16(tmp->x), Q_16_16(tmp->y + 1)); UpdateAnimationSingleFrame(this); } diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index 62ac8918..97cfa5cf 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -314,7 +314,7 @@ void VaatiTransfiguredType0Action3(Entity* this) { if (this->actionDelay != 0) { if (--this->actionDelay == 0) { COLLISION_OFF(this); - this->zVelocity = 0x38000; + this->zVelocity = Q_16_16(3.5); this->field_0xf = 0x10; } break; @@ -380,12 +380,12 @@ void VaatiTransfiguredType0Action4(Entity* this) { this->field_0x74.HALF.LO = 0; this->actionDelay = 0x80; this->field_0xf = 0; - this->zVelocity = 0x24000; + this->zVelocity = Q_16_16(2.25); SoundReq(SFX_12B); } break; case 1: - if (GravityUpdate(this, 0x2800) != 0) + if (GravityUpdate(this, Q_8_8(40)) != 0) break; this->field_0x80.HALF.LO += 1; switch (this->cutsceneBeh.HALF.LO) { @@ -1062,7 +1062,7 @@ void sub_080409B0(Entity* this) { this->field_0x80.HALF.HI = 3; COLLISION_OFF(this); this->hitType = 0x36; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); SoundReq(SFX_164); } } diff --git a/src/enemy/vaatiTransfiguredEye.c b/src/enemy/vaatiTransfiguredEye.c index 80fbb07f..e02f2f1b 100644 --- a/src/enemy/vaatiTransfiguredEye.c +++ b/src/enemy/vaatiTransfiguredEye.c @@ -215,7 +215,7 @@ void VaatiTransfiguredEyeFunction0Action4(Entity* this) { void sub_08045A00(Entity* this) { const struct xy* t = &gUnk_080D18B4[this->type2]; - PositionRelative(this->parent, this, t->x << 0x10, (t->y + 3) * 0x10000); + PositionRelative(this->parent, this, Q_16_16(t->x), Q_16_16(t->y + 3)); } void sub_08045A28(Entity* this) { @@ -291,7 +291,7 @@ void sub_08045A28(Entity* this) { break; } } else { - PositionRelative(this->parent, this, 0, -0x10000); + PositionRelative(this->parent, this, 0, Q_16_16(-1.0)); switch (this->field_0x82.HALF.HI) { case 0: switch (this->frame & 0x70) { diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index e77a11cd..58f8f83f 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -453,7 +453,7 @@ void VaatiWrathType0ActionA(Entity* this) { this->subAction = 0; this->direction = 0; this->speed = 0x100; - this->zVelocity = 0x12000; + this->zVelocity = Q_16_16(1.125); ChangeObjPalette(this, 0x16b); InitAnimationForceUpdate(this, 5); type1 = ((VaatiWrathHeapStruct*)this->myHeap)->type1; diff --git a/src/enemy/vaatiWrathEye.c b/src/enemy/vaatiWrathEye.c index 3a076bb6..360ba2eb 100644 --- a/src/enemy/vaatiWrathEye.c +++ b/src/enemy/vaatiWrathEye.c @@ -148,7 +148,7 @@ void VaatiWrathEyeAction6(Entity* this) { if (pEVar3 != NULL) { pEVar3->parent = this; this->child = pEVar3; - PositionRelative(this, pEVar3, 0, 0xc0000); + PositionRelative(this, pEVar3, 0, Q_16_16(12.0)); } } } diff --git a/src/enemy/waterDrop.c b/src/enemy/waterDrop.c index 3ce0985c..d964ab45 100644 --- a/src/enemy/waterDrop.c +++ b/src/enemy/waterDrop.c @@ -26,7 +26,7 @@ void sub_0802A250(Entity* this) { this->action = 1; this->actionDelay = 0; - this->zVelocity = -0x30000; + this->zVelocity = Q_16_16(-3.0); this->speed = gUnk_080CD03C[Random() & 3]; this->direction = gUnk_080CD040[Random() & 3] + 0x18; this->collisionLayer = 2; diff --git a/src/item/itemRocsCape.c b/src/item/itemRocsCape.c index ddba77c5..c3af396c 100644 --- a/src/item/itemRocsCape.c +++ b/src/item/itemRocsCape.c @@ -68,7 +68,7 @@ void sub_08076758(ItemBehavior* this, u32 arg1) { if ((gPlayerEntity.zVelocity < 1) && ((gPlayerState.jump_status & 0x10) == 0)) { this->stateID = 2; gPlayerEntity.field_0x7a.HWORD = 2; - gPlayerEntity.zVelocity = 0x20000; + gPlayerEntity.zVelocity = Q_16_16(2.0); gPlayerState.jump_status |= 0x10; gPlayerState.animation = 0x288; SoundReq(SFX_172); diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index 7bb9f3e3..0245c49c 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -275,7 +275,7 @@ void sub_0806D4C0(Entity* this, u32 param) { if (npc != NULL) { npc->parent = this; CopyPosition(this, npc); - ResolveEntityOnTop(this, npc); + SortEntityAbove(this, npc); SetDefaultPriority(npc, PRIO_MESSAGE); } } diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index 0b7de9f5..5d2ddca1 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -167,7 +167,7 @@ static void sub_08068BEC(Entity* this, u32 unused) { target = CreateFx(this, FX_WHITE_SPLASH, 0); if (target) { target->spritePriority.b0 = 1; - PositionRelative(this, target, 0, -0x100000); + PositionRelative(this, target, 0, Q_16_16(-16.0)); SoundReq(SFX_FA); } } diff --git a/src/npc/castorWildsStatue.c b/src/npc/castorWildsStatue.c index f3614564..2c388a08 100644 --- a/src/npc/castorWildsStatue.c +++ b/src/npc/castorWildsStatue.c @@ -134,7 +134,7 @@ void sub_080675D4(Entity* this) { ent->collisionLayer = this->collisionLayer; ent->spriteOrientation.flipY = this->spriteOrientation.flipY; ent->spriteRendering.b3 = this->spriteRendering.b3; - ResolveEntityOnTop(this, ent); + SortEntityAbove(this, ent); } }; gUnk = gUnk_08110E8A; @@ -147,7 +147,7 @@ void sub_080675D4(Entity* this) { ent->collisionLayer = this->collisionLayer; ent->spriteOrientation.flipY = this->spriteOrientation.flipY; ent->spriteRendering.b3 = this->spriteRendering.b3; - ResolveEntityOnTop(this, ent); + SortEntityAbove(this, ent); } }; if (this->subAction > 2) { diff --git a/src/npc/cuccoChick.c b/src/npc/cuccoChick.c index 0ccc0d17..46b564ad 100644 --- a/src/npc/cuccoChick.c +++ b/src/npc/cuccoChick.c @@ -75,7 +75,7 @@ void CuccoChick_Fusion(Entity* this) { this->frameIndex = 1; } else { if (GravityUpdate(this, 0x3000) == 0) { - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); } } } diff --git a/src/npc/drLeft.c b/src/npc/drLeft.c index a4942f0f..65eabde0 100644 --- a/src/npc/drLeft.c +++ b/src/npc/drLeft.c @@ -22,7 +22,7 @@ void DrLeft(Entity* this) { if (this->action == 0) { this->action += 1; this->frameIndex = 0; - ResolveEntityBelow(this, this); + SortEntityBelow(this, this); } } } diff --git a/src/npc/ezlo.c b/src/npc/ezlo.c index 77a69331..872a99c6 100644 --- a/src/npc/ezlo.c +++ b/src/npc/ezlo.c @@ -54,7 +54,7 @@ void sub_0806D96C(Entity* this) { Entity* fx = CreateFx(this, FX_STEAM_EFC, 0); if (fx != NULL) { fx->spritePriority.b0 = 1; - PositionRelative(this, fx, 0, 0xFFE80000); + PositionRelative(this, fx, 0, Q_16_16(-24.0)); } } diff --git a/src/npc/goron.c b/src/npc/goron.c index 22a217ca..baada241 100644 --- a/src/npc/goron.c +++ b/src/npc/goron.c @@ -70,11 +70,11 @@ void sub_080693D0(Entity* this) { if (this->frame == 1) { this->frame = 0; - sub_08069428(this, 0xFFF80000, createFx65); + sub_08069428(this, Q_16_16(-8.0), createFx65); } if (this->frame == 2) { this->frame = 0; - sub_08069428(this, 0x80 << 12, createFx65); + sub_08069428(this, Q_16_16(8.0), createFx65); } } } @@ -82,14 +82,14 @@ void sub_080693D0(Entity* this) { void sub_08069428(Entity* this, s32 offsetX, bool32 createFx65) { Entity* fx = CreateFx(this, FX_ROCK, 0); if (fx) { - PositionRelative(this, fx, offsetX, 0xFFF00000); - ResolveEntityOnTop(this, fx); + PositionRelative(this, fx, offsetX, Q_16_16(-16.0)); + SortEntityAbove(this, fx); } if (createFx65 != 0) { fx = CreateFx(this, FX_REFLECT4, 0); if (fx) { - PositionRelative(this, fx, offsetX, 0xFFF00000); - ResolveEntityOnTop(this, fx); + PositionRelative(this, fx, offsetX, Q_16_16(-16.0)); + SortEntityAbove(this, fx); } } } diff --git a/src/npc/gregal.c b/src/npc/gregal.c index f7038e95..5769c8ac 100644 --- a/src/npc/gregal.c +++ b/src/npc/gregal.c @@ -22,13 +22,13 @@ void sub_0806CAF4(Entity* this) { if (npc != NULL) { npc->parent = this; CopyPosition(this, npc); - ResolveEntityBelow(this, npc); + SortEntityBelow(this, npc); } npc = CreateNPC(0x4a, 2, 0); if (npc != NULL) { npc->parent = this; CopyPosition(this, npc); - ResolveEntityOnTop(this, npc); + SortEntityAbove(this, npc); } sub_0807DD64(this); sub_08078778(this); diff --git a/src/npc/kid.c b/src/npc/kid.c index 7e08592c..02910850 100644 --- a/src/npc/kid.c +++ b/src/npc/kid.c @@ -243,7 +243,7 @@ void sub_080626E0(Entity* this, ScriptExecutionContext* context) { uVar4 = Random(); this->direction = (this->direction + uVar4 % 0xb) - 5; } - sub_0806F62C(this, (s32)this->speed, (u32)this->direction); + LinearMoveAngle(this, (s32)this->speed, (u32)this->direction); if ((u32)((this->x.HALF.HI - context->x.HALF.HI) * 0x100 + ((s32)((u32)(u16)this->speed << 0x10) >> 0x11)) <= (u32)(s32)this->speed) { this->x.HALF.HI = context->x.HALF.HI; diff --git a/src/npc/malon.c b/src/npc/malon.c index deb17fe7..cff3828f 100644 --- a/src/npc/malon.c +++ b/src/npc/malon.c @@ -58,12 +58,12 @@ void sub_08065914(Entity* this) { target = FindEntityByID(7, 0x1F, 7); if (target != NULL) { - PositionRelative(this, target, 0x180000, -0x10000); + PositionRelative(this, target, Q_16_16(24.0), Q_16_16(-1.0)); target->parent = this; } target = FindEntityByID(7, 0x20, 7); if (target != NULL) { - PositionRelative(this, target, 0x280000, 0); + PositionRelative(this, target, Q_16_16(40.0), 0); target->parent = this; } } diff --git a/src/npc/melari.c b/src/npc/melari.c index f2d408b2..7b28d0e2 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -86,7 +86,7 @@ void sub_08068780(Entity* this) { } ent = CreateFx(this, FX_STARS2, 0x20); if (ent != NULL) { - PositionRelative(this, ent, 0x180000, -0xa0000); + PositionRelative(this, ent, Q_16_16(24.0), Q_16_16(-10.0)); } } } diff --git a/src/npc/npc4E.c b/src/npc/npc4E.c index 2d59b83e..b842076f 100644 --- a/src/npc/npc4E.c +++ b/src/npc/npc4E.c @@ -140,12 +140,12 @@ void sub_0806DB84(Entity* this, ScriptExecutionContext* context) { this->hitbox = (Hitbox*)&gUnk_08114154; ent = CreateObject(OBJECT_3E, 4, 0); if (ent != NULL) { - PositionRelative(this, ent, -0x80000, 0); + PositionRelative(this, ent, Q_16_16(-8.0), 0); *(ScriptExecutionContext**)&ent->cutsceneBeh = StartCutscene(ent, &script_Object3ELeftStoneOpening); } ent = CreateObject(OBJECT_3E, 5, 0); if (ent != NULL) { - PositionRelative(this, ent, 0x80000, 0); + PositionRelative(this, ent, Q_16_16(8.0), 0); *(ScriptExecutionContext**)&ent->cutsceneBeh = StartCutscene(ent, &script_Object3ERightStoneOpening); } } diff --git a/src/npc/pita.c b/src/npc/pita.c index b5a2e065..1f1f2308 100644 --- a/src/npc/pita.c +++ b/src/npc/pita.c @@ -12,7 +12,7 @@ void Pita(Entity* this) { if (this->action == 0) { this->action += 1; SetDefaultPriority(this, PRIO_MESSAGE); - ResolveEntityOnTop(this, this); + SortEntityAbove(this, this); this->hitbox = &gUnk_0810C428; sub_0807DD64(this); } diff --git a/src/npc/postman.c b/src/npc/postman.c index 48e7aa9e..3629950c 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -143,7 +143,7 @@ void sub_08060528(Entity* this) { if (0 < (s16)this->field_0x6a.HWORD) { if ((s16)this->field_0x6a.HWORD > 0x12b) { this->field_0x6a.HWORD = 0; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); this->field_0x6c.HALF.HI = 1; sub_080788E0(this); EnqueueSFX(0x7c); diff --git a/src/npc/rem.c b/src/npc/rem.c index b846ab31..84fca459 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -235,7 +235,7 @@ void sub_0806A914(Entity* this) { Entity* npc = CreateNPC(0x37, 1, 0); if (npc != NULL) { CopyPosition(this, npc); - ResolveEntityOnTop(this, npc); + SortEntityAbove(this, npc); } } @@ -279,7 +279,7 @@ void sub_0806A9E8(Entity* this) { Entity* npc = CreateNPC(0x37, 4, 0); if (npc != NULL) { CopyPosition(this, npc); - ResolveEntityBelow(this, npc); + SortEntityBelow(this, npc); } } diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index 50045270..04638c22 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -216,7 +216,7 @@ void sub_0806AF60(Entity* this, ScriptExecutionContext* context) { } void sub_0806AF70(Entity* this, ScriptExecutionContext* context) { - this->zVelocity = 0x24000; + this->zVelocity = Q_16_16(2.25); } void sub_0806AF78(Entity* this, ScriptExecutionContext* context) { @@ -229,7 +229,7 @@ void sub_0806AF78(Entity* this, ScriptExecutionContext* context) { void sub_0806AFA0(Entity* this) { if (sub_0806ED78(this)) { - sub_0806F62C(this, -this->speed, this->direction); + LinearMoveAngle(this, -this->speed, this->direction); } } diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index 17cd48e5..edb1b694 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -220,7 +220,7 @@ void sub_08061F94(Entity* this) { ent = CreateFx(this, FX_BIG_EXPLOSION, 0); if (ent != NULL) { - ResolveEntityOnTop(this, ent); + SortEntityAbove(this, ent); } } diff --git a/src/npc/vaatiReborn.c b/src/npc/vaatiReborn.c index 3ed28ca8..fb59284e 100644 --- a/src/npc/vaatiReborn.c +++ b/src/npc/vaatiReborn.c @@ -44,7 +44,7 @@ void VaatiRebornAction0(Entity* this) { entity = CreateNPC(VAATI_REBORN, 1, 0); entity->parent = this; entity->spriteOffsetY = -1; - PositionRelative(this, entity, 0, 0x10000); + PositionRelative(this, entity, 0, Q_16_16(1.0)); InitAnimationForceUpdate(this, 0); break; case 1: @@ -115,7 +115,7 @@ void VaatiRebornAction1(Entity* this) { if (entity == NULL) { DeleteThisEntity(); } - PositionRelative(entity, this, 0, 0x210000); + PositionRelative(entity, this, 0, Q_16_16(33.0)); UpdateAnimationSingleFrame(this); break; case 2: @@ -194,7 +194,7 @@ void sub_0806B96C(Entity* this) { } ptr = &gUnk_08112F80[this->type2]; this->spriteSettings.draw = entity->spriteSettings.draw; - PositionRelative(entity, this, ptr->x << 0x10, (ptr->y + 0x21) << 0x10); + PositionRelative(entity, this, Q_16_16(ptr->x), Q_16_16(ptr->y + 0x21)); UpdateAnimationSingleFrame(this); } diff --git a/src/npc/wheaton.c b/src/npc/wheaton.c index 3182eda3..e7c5e69b 100644 --- a/src/npc/wheaton.c +++ b/src/npc/wheaton.c @@ -7,7 +7,7 @@ void Wheaton(Entity* this) { this->action++; SetDefaultPriority(this, PRIO_MESSAGE); - ResolveEntityOnTop(this, this); + SortEntityAbove(this, this); this->hitbox = &gUnk_0810C3C0; this->spriteOffsetY = 0xfe; sub_0807DD64(this); diff --git a/src/npc/zelda.c b/src/npc/zelda.c index b0ac945f..f0bc5b77 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -127,13 +127,13 @@ void sub_08066E80(Entity* this, ScriptExecutionContext* context) { UpdateAnimationSingleFrame(this); if (this->frame & 1) { context->unk_18++; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); this->frame &= 0xFE; SoundReq(SFX_PLY_JUMP); } break; case 2: - sub_0806F62C(this, 0x100, 0x80); + LinearMoveAngle(this, 0x100, 0x80); GravityUpdate(this, 0x2000); if (!(this->frame & 1)) { UpdateAnimationSingleFrame(this); @@ -143,7 +143,7 @@ void sub_08066E80(Entity* this, ScriptExecutionContext* context) { } break; case 3: - sub_0806F62C(this, 0x100, 0x80); + LinearMoveAngle(this, 0x100, 0x80); UpdateAnimationSingleFrame(this); if (GravityUpdate(this, 0x2000) == 0) { context->unk_18++; diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c index 51c50ca4..be636d81 100644 --- a/src/object/bakerOven.c +++ b/src/object/bakerOven.c @@ -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); 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..efd3ce74 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); } } } diff --git a/src/object/book.c b/src/object/book.c index 7c3bf57e..811ca4ae 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -134,7 +134,7 @@ void sub_0809B56C(Entity* this) { fx = CreateFx(this, FX_DEATH, 0); if (fx) { - ResolveEntityOnTop(this, fx); + SortEntityAbove(this, fx); } } diff --git a/src/object/fileScreenObjects.c b/src/object/fileScreenObjects.c index 004f98d5..c3d217f6 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; diff --git a/src/object/furniture.c b/src/object/furniture.c index c625d1fb..05e7f7ca 100644 --- a/src/object/furniture.c +++ b/src/object/furniture.c @@ -220,7 +220,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; } @@ -451,7 +451,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/itemOnGround.c b/src/object/itemOnGround.c index 35cb741b..910764a2 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -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) { @@ -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/lilypadLarge.c b/src/object/lilypadLarge.c index 91f13635..96b4dff9 100644 --- a/src/object/lilypadLarge.c +++ b/src/object/lilypadLarge.c @@ -163,7 +163,7 @@ void sub_08085B40(LilypadLargeEntity* this) { ResetCollisionLayer(&gPlayerEntity); sub_08085CDC(this); super->direction = GetFacingDirection(&gPlayerEntity, super); - sub_0806F5BC(&gPlayerEntity, 0x100, super->direction); + LinearMoveDirection(&gPlayerEntity, 0x100, super->direction); } } diff --git a/src/object/mask.c b/src/object/mask.c index 73b42095..384c59f4 100644 --- a/src/object/mask.c +++ b/src/object/mask.c @@ -39,7 +39,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; diff --git a/src/object/minecart.c b/src/object/minecart.c index c39a4931..0de7e4c3 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -45,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); @@ -65,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(); @@ -160,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/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..29dcb2ef 100644 --- a/src/object/object6A.c +++ b/src/object/object6A.c @@ -237,7 +237,7 @@ void sub_08094C88(Object6AEntity* this) { 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); } } @@ -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); } } @@ -338,7 +338,7 @@ 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; @@ -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(); } @@ -473,7 +473,7 @@ void sub_08095120(Object6AEntity* this) { if (super->action == 0) { super->action = 1; SetDefaultPriority(super, 3); - ResolveEntityBelow(super, super); + SortEntityBelow(super, super); sub_0807DD64(super); InitAnimationForceUpdate(super, 2); } @@ -493,7 +493,7 @@ void sub_08095188(Object6AEntity* this) { if (super->action == 0) { super->action = 1; SetDefaultPriority(super, 3); - ResolveEntityBelow(super, super); + 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); } } @@ -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); } @@ -609,7 +609,7 @@ void sub_080953A4(Object6AEntity* this) { super->z.HALF.HI = -16; SetDefaultPriority(super, 2); 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); } } @@ -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 7eac6c78..cd527a72 100644 --- a/src/object/octorokBossObject.c +++ b/src/object/octorokBossObject.c @@ -76,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 { @@ -92,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 { @@ -109,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; @@ -170,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; } @@ -195,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; } @@ -204,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(); } @@ -247,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..cde45bc6 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -67,7 +67,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; 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/player.c b/src/player.c index 6c2772d6..4c1d2d43 100644 --- a/src/player.c +++ b/src/player.c @@ -22,26 +22,26 @@ #include "screen.h" #include "main.h" -#define GRAVITY_RATE 0x2000 +#define GRAVITY_RATE Q_8_8(32) #define SLOPE_SPEED_MODIFIER 0x50 -#define WALK_SPEED 0x140 -#define ROLL_SPEED 0x200 -#define SHIELDING_SPEED 0xC0 -#define GUST_JAR_SPEED 0x80 -#define SWORD_CHARGE_SPEED 0xE0 -#define BURNING_SPEED 0x300 +#define WALK_SPEED Q_8_8(1.25) +#define ROLL_SPEED Q_8_8(2.0) +#define GUST_JAR_SPEED Q_8_8(0.5) +#define SHIELDING_SPEED Q_8_8(0.75) +#define SWORD_CHARGE_SPEED Q_8_8(0.875) +#define BURNING_SPEED Q_8_8(3) -#define JUMP_SPEED_FWD 0x100 +#define JUMP_SPEED_FWD Q_8_8(1) /* Jumping out of a hole */ -#define JUMP_SPEED_HOLE_FWD 0x78 -#define JUMP_SPEED_HOLE_Z 0x1a000 +#define JUMP_SPEED_HOLE_FWD Q_8_8(0.46875) +#define JUMP_SPEED_HOLE_Z Q_16_16(1.625) /* Bouncing off a wall */ -#define BOUNCE_SPEED_FWD 0x100 -#define BOUNCE_SPEED_Z 0x20000 +#define BOUNCE_SPEED_FWD Q_8_8(1.0) +#define BOUNCE_SPEED_Z Q_16_16(2.0) -#define PULL_SPEED 0x80 -#define PUSH_SPEED 0x80 +#define PULL_SPEED Q_8_8(0.5) +#define PUSH_SPEED Q_8_8(0.5) #define PIT_DAMAGE 0x2 @@ -724,7 +724,7 @@ static NONMATCH("asm/non_matching/player/PlayerBounceUpdate.inc", void PlayerBou } if (--this->actionDelay != 0xFF) { - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); return; } @@ -1118,7 +1118,7 @@ static void PortalStandUpdate(Entity* this) { if (--this->actionDelay == 0xff) { this->direction = gPlayerState.field_0xd; this->animationState = Direction8ToAnimationState(this->direction); - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); this->speed = JUMP_SPEED_FWD; this->action = PLAYER_MINISH; this->subAction = 7; @@ -1531,7 +1531,7 @@ static void sub_08071D04(Entity* this) { gPlayerState.field_0x3c[0] = 0; this->direction = 0xff; this->speed = 0; - this->zVelocity = 0x18000; + this->zVelocity = Q_16_16(1.5); gPlayerState.jump_status = 1; gPlayerState.swim_state = 0; return; @@ -1849,7 +1849,7 @@ static void PlayerLavaInit(Entity* this) { COLLISION_OFF(this); if ((gPlayerState.flags & PL_MINISH) == 0) { this->subAction = 1; - this->zVelocity = 0x28000; + this->zVelocity = Q_16_16(2.5); ent = CreateObject(OBJECT_42, 0x80, 0); if (ent != NULL) { ent->child = this; @@ -2224,7 +2224,7 @@ static void sub_08072B5C(Entity* this) { COLLISION_ON(this); this->spritePriority.b0 = 4; this->speed = 0x40; - this->zVelocity = 0x39000; + this->zVelocity = Q_16_16(3.5625); this->z.WORD--; gPlayerState.jump_status = 0x41; sub_0806F854(this, 0, -12); @@ -2240,7 +2240,7 @@ static void sub_08072B5C(Entity* this) { temp -= 4; temp <<= 12; this->zVelocity = temp; - this->speed = 0x100; + this->speed = Q_8_8(1.0); gPlayerState.animation = 0x810; SoundReq(SFX_PLY_JUMP); } @@ -2679,7 +2679,7 @@ static void PlayerParachute(Entity* this) { static void sub_08073468(Entity* this) { gPlayerState.animation = 1792; gPlayerState.jump_status = 0; - this->zVelocity = -0x10000; + this->zVelocity = Q_16_16(-1.0); this->subAction++; this->field_0x7c.WORD = 480; this->direction = Direction8FromAnimationState(this->animationState); @@ -2695,7 +2695,7 @@ static void sub_08073468(Entity* this) { static void sub_080734D4(Entity* this) { GravityUpdate(this, -(GRAVITY_RATE / 2)); if (this->zVelocity > 0 || gPlayerState.field_0x38 == 1) { - this->zVelocity = 0x49000; + this->zVelocity = Q_16_16(4.5625); this->subAction++; } } @@ -2872,7 +2872,7 @@ static void sub_0807380C(Entity* this) { if (--this->actionDelay == 0) { this->subAction = 7; this->actionDelay = 60; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); } } UpdateAnimationSingleFrame(this); @@ -2965,7 +2965,7 @@ static void sub_080739EC(Entity* this) { } if ((gPlayerState.jump_status & 0xC0) == 0) { if ((gPlayerState.jump_status & 0x20) && this->zVelocity == 0) { - this->zVelocity = 0x28000; + this->zVelocity = Q_16_16(2.5); this->actionDelay = 10; this->direction = 0xff; gPlayerState.jump_status += 2; @@ -3176,7 +3176,7 @@ static void sub_08073F04(Entity* this) { this->spritePriority.b1 = 2; this->spriteSettings.draw = 0; this->subAction++; - this->zVelocity = 0x28000; + this->zVelocity = Q_16_16(2.5); this->speed = 0x100; gPlayerState.flags &= ~PL_MINISH; ResetPlayer(); @@ -3240,7 +3240,7 @@ static void sub_08074060(Entity* this) { this->spriteSettings.shadow = 1; this->field_0xf = 0; this->subAction++; - this->zVelocity = 0x20000; + this->zVelocity = Q_16_16(2.0); gPlayerState.animation = 2060; sub_0805EC60(this); } else { diff --git a/src/projectile/boneProjectile.c b/src/projectile/boneProjectile.c index 20c6e090..33677de2 100644 --- a/src/projectile/boneProjectile.c +++ b/src/projectile/boneProjectile.c @@ -75,7 +75,7 @@ void BoneProjectile_Action3(Entity* this) { void BoneProjectile_Action4(Entity* this) { GetNextFrame(this); LinearMoveUpdate(this); - if (GravityUpdate(this, 0x1800) == 0) { + if (GravityUpdate(this, Q_8_8(24.0)) == 0) { DeleteEntity(this); } } @@ -83,7 +83,7 @@ void BoneProjectile_Action4(Entity* this) { void sub_080A82D8(Entity* this) { this->action = 4; COLLISION_OFF(this); - this->zVelocity = 0x10000; + this->zVelocity = Q_16_16(1.0); this->direction ^= 0x10; this->speed = 0x80; } diff --git a/src/projectile/dirtBallProjectile.c b/src/projectile/dirtBallProjectile.c index a4a0d8e1..df383b15 100644 --- a/src/projectile/dirtBallProjectile.c +++ b/src/projectile/dirtBallProjectile.c @@ -48,7 +48,7 @@ void DirtBallProjectile_Init(Entity* this) { this->action = 1; this->subAction = 0; this->spriteSettings.shadow = 1; - this->zVelocity = 0x8000; + this->zVelocity = Q_16_16(0.5); this->hitbox = (Hitbox*)&gUnk_08129764; this->field_0x3c |= 0x10; switch (this->type) { @@ -76,13 +76,13 @@ void DirtBallProjectile_Action1(Entity* this) { if (parent->next == NULL) { this->action = 2; } - PositionRelative(parent, this, 0, -0x10000); + PositionRelative(parent, this, 0, Q_16_16(-1.0)); switch (this->type) { case 0: - this->z.HALF.HI += 0x10; + this->z.HALF.HI += Q_8_8(1.0 / 16.0); break; case 1: - this->z.HALF.HI += 0xe; + this->z.HALF.HI += Q_8_8(1.0 / 16.0 - 1.0 / 128.0); sub_08078954(this->child); CopyPosition(this, this->child); if ((0xf < (u8)(this->actionDelay++ + 1)) && (entity = this->child, entity->actionDelay == 0)) { @@ -96,7 +96,7 @@ void DirtBallProjectile_Action1(Entity* this) { } break; case 2: - this->z.HALF.HI += 0xe; + this->z.HALF.HI += Q_8_8(1.0 / 16.0 - 1.0 / 128.0); if (EntityInRectRadius(this, &gPlayerEntity, 0xe, 0xe) != 0) { this->action = 2; parent->field_0x82.HALF.HI = 0xc0; diff --git a/src/projectile/gleerokProjectile.c b/src/projectile/gleerokProjectile.c index 5b63e25f..128e32f7 100644 --- a/src/projectile/gleerokProjectile.c +++ b/src/projectile/gleerokProjectile.c @@ -32,10 +32,10 @@ void GleerokProjectile_Init(Entity* this) { s32 iVar2; this->action = 1; - this->zVelocity = -0x10000; + this->zVelocity = Q_16_16(-1.0); if (this->type != 3) { CopyPosition(this->parent, this); - sub_0806F5BC(this, 0x1000, this->direction); + LinearMoveDirection(this, 0x1000, this->direction); this->z.WORD = this->parent->y.WORD - this->child->y.WORD; this->y.WORD -= this->z.WORD; InitializeAnimation(this, 0x51); diff --git a/src/projectile/gyorgMaleEnergyProjectile.c b/src/projectile/gyorgMaleEnergyProjectile.c index 8e9983cc..cfcfed29 100644 --- a/src/projectile/gyorgMaleEnergyProjectile.c +++ b/src/projectile/gyorgMaleEnergyProjectile.c @@ -60,8 +60,8 @@ void GyorgMaleEnergyProjectile_Action1(Entity* this) { DeleteThisEntity(); } animationState = this->parent->animationState; - PositionRelative(this->parent, this, gSineTable[animationState] * 0x2800, - gSineTable[animationState + 0x40] * -0x2800); + PositionRelative(this->parent, this, gSineTable[animationState] * Q_16_16(5.0 / 32.0), + gSineTable[animationState + 0x40] * Q_16_16(-5.0 / 32.0)); GetNextFrame(this); if (--this->actionDelay == 0) { this->action = 2; diff --git a/src/projectile/lakituCloudProjectile.c b/src/projectile/lakituCloudProjectile.c index ce7d2d21..0175653f 100644 --- a/src/projectile/lakituCloudProjectile.c +++ b/src/projectile/lakituCloudProjectile.c @@ -57,8 +57,8 @@ void LakituCloudProjectile_Init(Entity* this) { } void LakituCloudProjectile_Action1(Entity* this) { - PositionRelative(this->parent, this, 0, -0x10000); - this->z.HALF.HI = 0xfffe; + PositionRelative(this->parent, this, 0, Q_16_16(-1.0)); + this->z.HALF.HI = -2; UpdateAnimationSingleFrame(this); } diff --git a/src/projectile/mandiblesProjectile.c b/src/projectile/mandiblesProjectile.c index 6e261021..a69c493b 100644 --- a/src/projectile/mandiblesProjectile.c +++ b/src/projectile/mandiblesProjectile.c @@ -77,7 +77,7 @@ void MandiblesProjectile_Init(Entity* this) { this->animationState = 0xff; this->field_0x82.HALF.LO = 0; this->spritePriority.b0 = 4; - ResolveEntityBelow(this, this->parent); + SortEntityBelow(this, this->parent); sub_080AA270(this); } @@ -125,9 +125,9 @@ void MandiblesProjectile_Action3(Entity* this) { } else { tmp = GetSpriteSubEntryOffsetDataPointer((u16)entity->spriteIndex, entity->frameIndex); if ((entity->animationState & 4) != 0) { - PositionRelative(entity, this, -tmp[0] * 0x10000, tmp[1] << 0x10); + PositionRelative(entity, this, Q_16_16(-tmp[0]), Q_16_16(tmp[1])); } else { - PositionRelative(entity, this, tmp[0] << 0x10, tmp[1] << 0x10); + PositionRelative(entity, this, Q_16_16(tmp[0]), Q_16_16(tmp[1])); } } if (entity->field_0x43 == 0) { @@ -212,9 +212,9 @@ void sub_080AA1D8(Entity* this) { if ((parent->frameIndex & 0x20) == 0) { tmp = GetSpriteSubEntryOffsetDataPointer((u16)parent->spriteIndex, parent->frameIndex); if ((parent->animationState & 4) != 0) { - PositionRelative(parent, this, -tmp[0] * 0x10000, tmp[1] << 0x10); + PositionRelative(parent, this, Q_16_16(-tmp[0]), Q_16_16(tmp[1])); } else { - PositionRelative(parent, this, tmp[0] << 0x10, tmp[1] << 0x10); + PositionRelative(parent, this, Q_16_16(tmp[0]), Q_16_16(tmp[1])); } if (parent->field_0x43 != 0) { if ((this->flags & ENT_COLLIDE) != 0) { diff --git a/src/projectile/octorokBossProjectile.c b/src/projectile/octorokBossProjectile.c index 1ca08f9d..1f5c8ddd 100644 --- a/src/projectile/octorokBossProjectile.c +++ b/src/projectile/octorokBossProjectile.c @@ -33,7 +33,7 @@ void OctorokBossProjectile_Init(Entity* this) { switch (this->type) { case 0: - sub_0806F62C(this, 0x4800, this->direction); + LinearMoveAngle(this, 0x4800, this->direction); this->speed = 0x200; this->actionDelay = 0; this->field_0xf = this->direction; @@ -44,11 +44,11 @@ void OctorokBossProjectile_Init(Entity* this) { this->spriteRendering.b3 = 3; this->spritePriority.b0 = 6; this->speed = (Random() & 0x1ff) + 0x200; - this->zVelocity = (Random() & 0x1fff) + 0x18000; + this->zVelocity = (Random() & 0x1fff) + Q_16_16(1.5); uVar1 = (((u8)Random() & 7) - 4); this->direction -= uVar1; *(u32*)&this->field_0x78 = 600; - sub_0806F62C(this, this->speed, this->direction); + LinearMoveAngle(this, this->speed, this->direction); InitializeAnimation(this, 4); break; case 2: @@ -59,7 +59,7 @@ void OctorokBossProjectile_Init(Entity* this) { } this->speed = 0x200; this->actionDelay = 0x30; - sub_0806F62C(this, 0x5000, this->direction); + LinearMoveAngle(this, 0x5000, this->direction); InitializeAnimation(this, 5); break; case 3: @@ -113,7 +113,7 @@ void OctorokBossProjectile_Action1(Entity* this) { } UpdateAnimationSingleFrame(this); this->field_0x78.HWORD--; - sub_0806F62C(this, this->speed, this->direction); + LinearMoveAngle(this, this->speed, this->direction); sub_080AE58C(this, this->direction >> 3, 0); if ((this->collisions & 0xee00) != 0) { this->direction = -this->direction; @@ -153,7 +153,7 @@ void OctorokBossProjectile_Action1(Entity* this) { if (GravityUpdate(this, 0x1800) != 0) { sub_080AE58C(this, this->direction >> 3, 0); if (this->collisions == 0) { - sub_0806F62C(this, (s32)this->speed, (u32)this->direction); + LinearMoveAngle(this, (s32)this->speed, (u32)this->direction); } else { OctorokBossProjectile_Action2(this); } @@ -176,7 +176,7 @@ void OctorokBossProjectile_Action1(Entity* this) { case 2: GetNextFrame(this); if (--this->actionDelay != 0xff) { - sub_0806F62C(this, this->speed, this->direction); + LinearMoveAngle(this, this->speed, this->direction); return; } if (this->child != NULL) { diff --git a/src/projectile/rockProjectile.c b/src/projectile/rockProjectile.c index 7254631b..66e8388f 100644 --- a/src/projectile/rockProjectile.c +++ b/src/projectile/rockProjectile.c @@ -31,7 +31,7 @@ void sub_080A8064(Entity* this) { void RockProjectile_Init(Entity* this) { this->action = 1; this->actionDelay = 0x30; - this->zVelocity = 0xa000; + this->zVelocity = Q_16_16(0.625); InitializeAnimation(this, 0); } @@ -86,7 +86,7 @@ void sub_080A8178(Entity* this) { this->action = 2; COLLISION_OFF(this); this->speed = 0x40; - this->zVelocity = 0x14000; + this->zVelocity = Q_16_16(1.25); } void (*const RockProjectile_Functions[])(Entity*) = { diff --git a/src/projectile/stalfosProjectile.c b/src/projectile/stalfosProjectile.c index 709907e0..841a68e3 100644 --- a/src/projectile/stalfosProjectile.c +++ b/src/projectile/stalfosProjectile.c @@ -32,7 +32,7 @@ void sub_080A9A34(Entity* this) { if (this->bitfield == 0x9d) { this->action = 3; COLLISION_OFF(this); - this->zVelocity = 0x2a000; + this->zVelocity = Q_16_16(2.625); this->spritePriority.b1 = 1; } } @@ -76,7 +76,7 @@ void StalfosProjectile_Init(Entity* this) { break; case 2: this->action = 3; - this->zVelocity = 0x2a000; + this->zVelocity = Q_16_16(2.625); this->spritePriority.b1 = 1; break; default: diff --git a/src/projectile/v1DarkMagicProjectile.c b/src/projectile/v1DarkMagicProjectile.c index c9a3d281..dbc770a1 100644 --- a/src/projectile/v1DarkMagicProjectile.c +++ b/src/projectile/v1DarkMagicProjectile.c @@ -31,9 +31,9 @@ void sub_080AAC44(Entity* this) { this->action = 2; COLLISION_OFF(this); if (this->type == 0) { - ResolveEntityOnTop(&gPlayerEntity, this); + SortEntityAbove(&gPlayerEntity, this); } else { - ResolveEntityOnTop(this->parent, this); + SortEntityAbove(this->parent, this); } ResetPlayer(); gPlayerState.mobility |= 0x80; @@ -114,7 +114,7 @@ void V1DarkMagicProjectile_Init(Entity* this) { } else { this->action = 3; this->hitType = 0x2c; - ResolveEntityOnTop(this->parent, this); + SortEntityAbove(this->parent, this); } if (this->type == 0) { this->actionDelay = 0; @@ -136,7 +136,7 @@ void V1DarkMagicProjectile_Init(Entity* this) { entity->parent = this; } } else { - ResolveEntityOnTop(this->parent, this); + SortEntityAbove(this->parent, this); COLLISION_OFF(this); CopyPosition(this->parent, this); } diff --git a/src/projectile/v1EyeLaser.c b/src/projectile/v1EyeLaser.c index 8bdb0652..de642d5d 100644 --- a/src/projectile/v1EyeLaser.c +++ b/src/projectile/v1EyeLaser.c @@ -99,7 +99,7 @@ void sub_080AB844(Entity* this, s32 param_1, s32 param_2) { entity->type = 1; entity->actionDelay = param_1; entity->parent = this->parent; - PositionRelative(this, entity, 0, param_2 << 0x10); + PositionRelative(this, entity, 0, Q_16_16(param_2)); if (param_1 != 1) { entity->hitbox = (Hitbox*)&gUnk_0812A61C; } else { diff --git a/src/projectile/v1FireProjectile.c b/src/projectile/v1FireProjectile.c index 90bdc5fd..2823d563 100644 --- a/src/projectile/v1FireProjectile.c +++ b/src/projectile/v1FireProjectile.c @@ -39,10 +39,10 @@ void V1FireProjectile_Init(Entity* this) { s8* data; this->action = 1; - this->zVelocity = -0x10000; + this->zVelocity = Q_16_16(-1.0); this->field_0x76.HWORD = TILE(this->x.HALF.HI, this->y.HALF.HI); CopyPosition(this->parent, this); - sub_0806F5BC(this, 0x1000, this->direction); + LinearMoveDirection(this, 0x1000, this->direction); this->spritePriority.b0 = 1; this->z = this->parent->z; InitializeAnimation(this, 0x51); diff --git a/src/projectile/v2Projectile.c b/src/projectile/v2Projectile.c index 5d9f6eb2..fc7f09d2 100644 --- a/src/projectile/v2Projectile.c +++ b/src/projectile/v2Projectile.c @@ -138,7 +138,7 @@ void sub_080ABE04(Entity* this) { u32 rand = Random() & 0xff; u32 newX; this->action = 1; - this->zVelocity = 0xffff0000; + this->zVelocity = Q_16_16(-1.0); this->z.HALF.HI -= 0xa0; this->x.HALF.HI = (gRoomControls.origin_x & 0x7ff0) | 0x8; this->y.HALF.HI = (gRoomControls.origin_y & 0x7ff0) | 0x8; diff --git a/src/roomInit.c b/src/roomInit.c index e4fd06fa..3cb07870 100644 --- a/src/roomInit.c +++ b/src/roomInit.c @@ -5798,14 +5798,14 @@ void sub_0804F79C(Entity* parent) { fx = CreateFx(parent, FX_BIG_EXPLOSION, 0); if (fx != NULL) { fx->spriteRendering.b3 = 0; - fx->x.HALF.HI = gRoomControls.origin_x + 0x1b8; - fx->y.HALF.HI = gRoomControls.origin_y + 0x148; + fx->x.HALF.HI = gRoomControls.origin_x + Q_8_8(1.72); + fx->y.HALF.HI = gRoomControls.origin_y + Q_8_8(1.285); } fx = CreateFx(parent, FX_BIG_EXPLOSION, 0); if (fx != NULL) { fx->spriteRendering.b3 = 0; - fx->x.HALF.HI = gRoomControls.origin_x + 0x238; - fx->y.HALF.HI = gRoomControls.origin_y + 0x148; + fx->x.HALF.HI = gRoomControls.origin_x + Q_8_8(2.22); + fx->y.HALF.HI = gRoomControls.origin_y + Q_8_8(1.285); } } diff --git a/src/script.c b/src/script.c index 02cf220a..f6cb795f 100644 --- a/src/script.c +++ b/src/script.c @@ -258,7 +258,7 @@ void HandlePostScriptActions(Entity* entity, ScriptExecutionContext* context) { case 1 << 0x02: break; case 1 << 0x03: - entity->zVelocity = 0x18000; + entity->zVelocity = Q_16_16(1.5); break; case 1 << 0x04: CreateSpeechBubbleExclamationMark(entity, 8, -0x18); @@ -1396,7 +1396,7 @@ void ScriptCommand_0807EE30(Entity* entity, ScriptExecutionContext* context) { } tmp = entity->x.HALF.HI - context->x.HALF.HI; tmp2 = entity->y.HALF.HI - context->y.HALF.HI; - sub_0806F62C(entity, entity->speed, entity->direction); + LinearMoveAngle(entity, entity->speed, entity->direction); tmp *= entity->x.HALF.HI - context->x.HALF.HI; tmp2 *= entity->y.HALF.HI - context->y.HALF.HI; if (tmp <= 0 && tmp2 <= 0) { @@ -1685,7 +1685,7 @@ void sub_0807F36C(Entity* entity, ScriptExecutionContext* context) { fx = CreateFx(entity, FX_REFLECT4, 0); if (fx != NULL) { fx->spritePriority.b0 = 1; - PositionRelative(entity, fx, 0, -0x80000); + PositionRelative(entity, fx, 0, Q_16_16(-8.0)); if (Random() & 1) fx->spriteSettings.flipX = 1; if (Random() & 1) @@ -1749,7 +1749,7 @@ void sub_0807F464(Entity* entity, ScriptExecutionContext* context) { entity->animationState = (entity->animationState & 0x80) | 6; } } - sub_0806F62C(entity, entity->speed, entity->direction); + LinearMoveAngle(entity, entity->speed, entity->direction); if (((context->x.HALF.HI - entity->x.HALF.HI) ^ ((entity->direction & 0x80) << 24)) < 0) entity->x.HALF.HI = context->x.HALF.HI; else @@ -1773,7 +1773,7 @@ void sub_0807F4F8(Entity* entity, ScriptExecutionContext* context) { entity->animationState = (entity->animationState & 0x80); } } - sub_0806F62C(entity, entity->speed, entity->direction); + LinearMoveAngle(entity, entity->speed, entity->direction); if (((context->y.HALF.HI - entity->y.HALF.HI) ^ ((entity->direction & 0x80) << 24)) >= 0) entity->y.HALF.HI = context->y.HALF.HI; else @@ -1853,12 +1853,12 @@ void sub_0807F708(Entity* entity, ScriptExecutionContext* context) { void sub_0807F714(Entity* entity, ScriptExecutionContext* context) { entity->spriteRendering.b3 = gUnk_08114F30[entity->spriteRendering.b3]; - ResolveEntityOnTop(entity, entity); + SortEntityAbove(entity, entity); } void sub_0807F738(Entity* entity, ScriptExecutionContext* context) { entity->spriteRendering.b3 = gUnk_08114F34[entity->spriteRendering.b3]; - ResolveEntityBelow(entity, entity); + SortEntityBelow(entity, entity); } void SetPlayerPos(Entity* entity, ScriptExecutionContext* context) { @@ -2121,7 +2121,7 @@ void sub_0807FBCC(Entity* entity, ScriptExecutionContext* context) { } void sub_0807FBD4(Entity* entity, ScriptExecutionContext* context) { - sub_0806F62C(entity, entity->speed, entity->direction); + LinearMoveAngle(entity, entity->speed, entity->direction); if (CheckOnScreen(entity)) gActiveScriptInfo.commandSize = 0; }