aboutsummaryrefslogtreecommitdiff
path: root/src/player.s
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-04-01 16:23:34 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-04-02 21:22:42 +0200
commit2f140cfb7ea73e631fce086327bcb3a674758b0e (patch)
treea9b218b25342392a7541932d5649834ecf186987 /src/player.s
parentbcece25da4af0d4f47dc279dd5e1a67cb553186f (diff)
downloadjetpac.nes-2f140cfb7ea7.tar.gz
jetpac.nes-2f140cfb7ea7.zip
player: First PAL implementation
The steps by which a player increases its current velocity to reach the target one has been adapted on PAL, so every five frames it takes an extra step compared to NTSC. This at least brings PAL to grow its values at the same rate as NTSC. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'src/player.s')
-rw-r--r--src/player.s55
1 files changed, 48 insertions, 7 deletions
diff --git a/src/player.s b/src/player.s
index 55245f6..9cb73f3 100644
--- a/src/player.s
+++ b/src/player.s
@@ -100,6 +100,14 @@
;; Simple counter for the walking animation.
zp_walk_counter = $51
+ .ifdef PAL
+ ;; The increment/decrement to be applied to the velocity on a PAL
+ ;; system. This value is updated on `driver.s` on each frame.
+ ;;
+ ;; NOTE: only used on PAL.
+ zp_step_on_pal = $52
+ .endif
+
;; How many animations are there for walking?
WALK_ANIMATION_NR = 3
@@ -113,6 +121,12 @@
lda #%01000100
sta zp_state
+ ;; Set the step to be applied on PAL.
+ .ifdef PAL
+ lda #1
+ sta zp_step_on_pal
+ .endif
+
;; Reset velocity and walking counter.
lda #0
sta zp_target_velocity_y
@@ -236,13 +250,27 @@
sbc Globals::zp_tmp0
beq @apply_velocity
- ;; Increase or decrease depending on what we have now.
- ;; TODO: inc/dec might not quite cut it in NTSC vs PAL
+ ;; Increase or decrease depending on what we have now. Note that how
+ ;; this is done depends on whether we are on NTSC or PAL.
bmi @down
- dec zp_velocity_y
+ .ifdef PAL
+ lda zp_velocity_y
+ sec
+ sbc zp_step_on_pal
+ sta zp_velocity_y
+ .else
+ dec zp_velocity_y
+ .endif
jmp @apply_velocity
@down:
- inc zp_velocity_y
+ .ifdef PAL
+ lda zp_velocity_y
+ clc
+ adc zp_step_on_pal
+ sta zp_velocity_y
+ .else
+ inc zp_velocity_y
+ .endif
jmp @apply_velocity
@blast_off:
@@ -334,17 +362,30 @@
;; and we just subtract the current velocity and see if we either have
;; to accelerate or decelerate to reach that, and we do that with steps.
@apply_acceleration:
- ;; TODO: as with vertical motion, mind NTSC vs PAL
sta Globals::zp_tmp0
lda zp_velocity_x
sec
sbc Globals::zp_tmp0
beq @apply_velocity
bmi @accelerate_left
- dec zp_velocity_x
+ .ifdef PAL
+ lda zp_velocity_x
+ sec
+ sbc zp_step_on_pal
+ sta zp_velocity_x
+ .else
+ dec zp_velocity_x
+ .endif
jmp @apply_velocity
@accelerate_left:
- inc zp_velocity_x
+ .ifdef PAL
+ lda zp_velocity_x
+ clc
+ adc zp_step_on_pal
+ sta zp_velocity_x
+ .else
+ inc zp_velocity_x
+ .endif
;; With the final velocity already at hand, update the position with it.
@apply_velocity: