aboutsummaryrefslogtreecommitdiff
path: root/src/player.s
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-04-02 21:32:08 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-04-02 21:32:08 +0200
commitbfb641e8bed8d33f6a3ab13870c93f0632eba9d8 (patch)
tree5271245e9f79e1b7561c30a189e4500d206853be /src/player.s
parent88728b89fed87326dae23619e2e93d4bd060a3ea (diff)
downloadjetpac.nes-bfb641e8bed8d33f6a3ab13870c93f0632eba9d8.tar.gz
jetpac.nes-bfb641e8bed8d33f6a3ab13870c93f0632eba9d8.zip
Switch to a throttle state when falling
As it's done in the original game, switch to a throttle state when falling off a platform. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'src/player.s')
-rw-r--r--src/player.s22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/player.s b/src/player.s
index ebf6dfb..b900e52 100644
--- a/src/player.s
+++ b/src/player.s
@@ -206,6 +206,28 @@
;; handle ejection logic now.
jsr background_check
+ ;; After we have a new velocity while taking the background into
+ ;; account. Are we suddently falling?
+ lda zp_velocity_y
+ beq @do_update_sprites
+ bmi @do_update_sprites
+ bit zp_state
+ bmi @do_update_sprites
+
+ ;; We are falling: we were at a walking state and now we are falling.
+ ;; This happens whenever we fall from a platform by walking. The
+ ;; original game then switched into airborne state, so let's do that. In
+ ;; particular, we reset the walking counter, the walk state, and we flip
+ ;; the `throttle` flag.
+ lda #0
+ sta zp_walk_counter
+ lda #%11111100
+ and zp_state
+ lda #%10000000
+ ora zp_state
+ sta zp_state
+
+ @do_update_sprites:
;; And with that, update all the sprites with the information we have
;; collected (i.e. heading, throttle, coordinates).
JAL update_sprites