keyboard control

This commit is contained in:
2026-07-15 21:51:45 +02:00
parent 0fb584bcd7
commit 67f498a31d
3 changed files with 24 additions and 4 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ in the original.
| Input | Action | | Input | Action |
|-------|--------| |-------|--------|
| Joystick port 2 left/right | change lane (auto-repeats while held) | | Joystick port 2 left/right, or `A` / `D` | change lane (auto-repeats while held) |
| Fire (or `SPACE`) | start / retry | | Fire (or `SPACE`) | start / retry |
## How it works ## How it works
+22 -2
View File
@@ -89,7 +89,8 @@ dr_loop:
; ---- input ---- ; ---- input ----
; read joystick port 2, return active-high bits in A and joyb ; read joystick port 2 merged with the a/d keys,
; return active-high bits in A and joyb
read_joy: read_joy:
lda #$ff ; deselect every keyboard column first lda #$ff ; deselect every keyboard column first
sta CIA1_PA sta CIA1_PA
@@ -97,6 +98,25 @@ read_joy:
eor #$ff eor #$ff
and #$1f and #$1f
sta joyb sta joyb
lda #$fd ; 'a' = left: keyboard column 1, row bit 2
sta CIA1_PA
lda CIA1_PB
and #$04
bne rj_noleft
lda joyb
ora #JOY_LEFT
sta joyb
rj_noleft:
lda #$fb ; 'd' = right: keyboard column 2, row bit 2
sta CIA1_PA
lda CIA1_PB
and #$04
bne rj_noright
lda joyb
ora #JOY_RIGHT
sta joyb
rj_noright:
lda joyb
rts rts
; fire or space held? returns A != 0 when pressed ; fire or space held? returns A != 0 when pressed
@@ -439,7 +459,7 @@ txt_miss: !scr "miss"
txt_rabbit: !scr "rabbit" txt_rabbit: !scr "rabbit"
txt_scooter: !scr "scooter" txt_scooter: !scr "scooter"
txt_press: !scr "press fire to start" txt_press: !scr "press fire to start"
txt_info: !scr "joystick 2 moves fire starts" txt_info: !scr "joystick 2 or a/d fire starts"
txt_over: !scr "game over" txt_over: !scr "game over"
txt_retry: !scr "fire = retry" txt_retry: !scr "fire = retry"
txt_blank: !fill 19, $20 txt_blank: !fill 19, $20
+1 -1
View File
@@ -10,7 +10,7 @@ title_init:
+prbig 1, 8, BLACK, txt_rabbit, 6 +prbig 1, 8, BLACK, txt_rabbit, 6
+prtext 6, 16, BLACK, txt_scooter, 7 +prtext 6, 16, BLACK, txt_scooter, 7
+prtext 17, 5, BLACK, txt_info, 30 +prtext 17, 4, BLACK, txt_info, 31
; one parked scooter per lane on sprites 0-4 ; one parked scooter per lane on sprites 0-4
ldx #4 ldx #4