From 2f140cfb7ea73e631fce086327bcb3a674758b0e Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 1 Apr 2025 16:23:34 +0200 Subject: player: First PAL implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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à --- src/driver.s | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/driver.s') 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 -- cgit v1.2.3