Browse Source

Use fixed-point number to store Y coordinate

master
Forest Belton 3 years ago
parent
commit
e2ad9075e0
1 changed files with 9 additions and 3 deletions
  1. +9
    -3
      src/player.s

+ 9
- 3
src/player.s View File

@ -10,7 +10,7 @@ playerWorldY: dw
; player data ; player data
PLAYER_X:: db PLAYER_X:: db
PLAYER_Y:: db
PLAYER_Y:: dw
PLAYER_DIR:: db PLAYER_DIR:: db
PLAYER_JUMPING:: db PLAYER_JUMPING:: db
@ -44,6 +44,8 @@ Player_Init::
ld [hl], 0 ld [hl], 0
inc hl inc hl
ld [hl], 0 ld [hl], 0
inc hl
ld [hl], 0
; Copy sprite to VRAM ; Copy sprite to VRAM
ld bc, _VRAM8000 + SPRITE_IDX * 16 ld bc, _VRAM8000 + SPRITE_IDX * 16
@ -104,9 +106,12 @@ Player_Update::
STORE16 bc STORE16 bc
; y -= floor(vy) ; y -= floor(vy)
ld hl, PLAYER_Y
ld hl, PLAYER_Y + 1
ld a, [hl]
sub c
ld [hl-], a
ld a, [hl] ld a, [hl]
sub b
sbc b
ld [hl], a ld [hl], a
; roll back jump if there was a collision ; roll back jump if there was a collision
@ -216,6 +221,7 @@ update_oam:
and OAMF_XFLIP and OAMF_XFLIP
ld c, a ld c, a
dec hl ; skip fractional part
ld a, [hl-] ; y ld a, [hl-] ; y
add 16 add 16

Loading…
Cancel
Save