From e2ad9075e0c9d00b41872e335a34c6e0cd924223 Mon Sep 17 00:00:00 2001 From: Forest Belton <65484+forestbelton@users.noreply.github.com> Date: Tue, 6 Jul 2021 01:56:20 -0400 Subject: [PATCH] Use fixed-point number to store Y coordinate --- src/player.s | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/player.s b/src/player.s index 161af50..6a857cf 100644 --- a/src/player.s +++ b/src/player.s @@ -10,7 +10,7 @@ playerWorldY: dw ; player data PLAYER_X:: db -PLAYER_Y:: db +PLAYER_Y:: dw PLAYER_DIR:: db PLAYER_JUMPING:: db @@ -44,6 +44,8 @@ Player_Init:: ld [hl], 0 inc hl ld [hl], 0 + inc hl + ld [hl], 0 ; Copy sprite to VRAM ld bc, _VRAM8000 + SPRITE_IDX * 16 @@ -104,9 +106,12 @@ Player_Update:: STORE16 bc ; y -= floor(vy) - ld hl, PLAYER_Y + ld hl, PLAYER_Y + 1 + ld a, [hl] + sub c + ld [hl-], a ld a, [hl] - sub b + sbc b ld [hl], a ; roll back jump if there was a collision @@ -216,6 +221,7 @@ update_oam: and OAMF_XFLIP ld c, a + dec hl ; skip fractional part ld a, [hl-] ; y add 16