aboutsummaryrefslogtreecommitdiff
path: root/src/driver.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/driver.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/driver.s')
-rw-r--r--src/driver.s32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/driver.s b/src/driver.s
index bb0303f..00e807c 100644
--- a/src/driver.s
+++ b/src/driver.s
@@ -9,6 +9,11 @@
zp_player_timer = $30
PLAYER_TIMER_VALUE = HZ * 2
+ .ifdef PAL
+ ;; Frame counter which resets every 5 frames.
+ zp_pal_counter = $31
+ .endif
+
;; Switch from the title screen to the main street. Note that this function
;; is to be called with the PPU disabled. If that's not the case, then it
;; will set the proper values to disable it on the next `nmi` call and set
@@ -75,4 +80,31 @@
@game:
JAL Player::update
.endproc
+
+ .ifdef PAL
+ ;; All the code that is needed to fix some values for PAL machines.
+ .proc pal_handler
+ ;; Check if 5 frames have passed since last counter reset.
+ lda Driver::zp_pal_counter
+ cmp #4
+ beq @do_handle
+
+ ;; Nope! Reset the player's step on PAL and increase the counter.
+ lda #1
+ sta Player::zp_step_on_pal
+ inc Driver::zp_pal_counter
+ bne @end
+
+ @do_handle:
+ ;; Increase the step just for this frame and reset the counter.
+ lda Player::zp_step_on_pal
+ clc
+ adc #2
+ sta Player::zp_step_on_pal
+ lda #0
+ sta Driver::zp_pal_counter
+ @end:
+ rts
+ .endproc
+ .endif
.endscope