From f1d1d0efee9faa3067f7b0fc8b9a2aebb17f1ccd Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Sun, 8 Mar 2026 22:09:31 +0100 Subject: Support reading from the second controller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- src/bullets.s | 2 +- src/driver.s | 2 +- src/jetpac.s | 10 +++++++--- src/player.s | 8 ++++---- src/title.s | 8 ++++---- 5 files changed, 17 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/bullets.s b/src/bullets.s index 58b6a4a..3cc74b9 100644 --- a/src/bullets.s +++ b/src/bullets.s @@ -104,7 +104,7 @@ @check_bullets_pressed: ;; Is the B button pressed? If not go to `@move_bullets` directly. lda #(Joypad::BUTTON_B) - and Joypad::zp_buttons1 + and Joypad::zp_buttons beq @move_bullets ;; The B button was pressed. Reset the bullet timer. diff --git a/src/driver.s b/src/driver.s index 3bf4399..942bf82 100644 --- a/src/driver.s +++ b/src/driver.s @@ -179,7 +179,7 @@ ;; Check if the player is toggling the `pause` state. lda #(Joypad::BUTTON_START | Joypad::BUTTON_SELECT) - and Joypad::zp_buttons1 + and Joypad::zp_buttons beq @skip_pause_handling ;; What does the timer say, is the player allowed to do it? diff --git a/src/jetpac.s b/src/jetpac.s index 25fdf5a..5fdd01f 100644 --- a/src/jetpac.s +++ b/src/jetpac.s @@ -125,8 +125,8 @@ ;; variables defined before sta Globals::zp_flags sta Globals::zp_multiplayer - sta Joypad::zp_buttons1 - sta Joypad::zp_buttons2 + sta Joypad::zp_buttons + sta Joypad::zp_prev sta Player::zp_state ;; Initialize the level. We allow the build system to pass its own value for @@ -187,7 +187,11 @@ sta PPU::m_mask @main_game_loop: - READ_JOYPAD1 + ;; Select the joypad from the active player and read it. + lda Globals::zp_multiplayer + and #$01 + tax + READ_JOYPAD_X lda Globals::zp_flags and #%00000011 diff --git a/src/player.s b/src/player.s index 53695b4..60005af 100644 --- a/src/player.s +++ b/src/player.s @@ -249,7 +249,7 @@ bit zp_state bpl @check_thrust lda #Joypad::BUTTON_DOWN - and Joypad::zp_buttons1 + and Joypad::zp_buttons beq @check_thrust lda #0 sta zp_velocity_y @@ -258,7 +258,7 @@ @check_thrust: ;; Check if the player is asking to thrust, otherwise apply gravity. lda #(Joypad::BUTTON_UP | Joypad::BUTTON_A) - and Joypad::zp_buttons1 + and Joypad::zp_buttons beq @set_gravity ;; Player is throttling, reflect that on the player's state. @@ -349,7 +349,7 @@ .proc update_horizontal_position lda #Joypad::BUTTON_LEFT - and Joypad::zp_buttons1 + and Joypad::zp_buttons beq @check_right ;; We are facing left, reflect that on the state and the sprite. @@ -374,7 +374,7 @@ ;; Same as the part above but applied to going right. @check_right: lda #Joypad::BUTTON_RIGHT - and Joypad::zp_buttons1 + and Joypad::zp_buttons beq @nothing lda #%01000100 diff --git a/src/title.s b/src/title.s index 06ca1cb..d091922 100644 --- a/src/title.s +++ b/src/title.s @@ -38,7 +38,7 @@ bne @end lda #Joypad::BUTTON_UP - and Joypad::zp_buttons1 + and Joypad::zp_buttons beq @check_down lda #SPRITE_Y_POSITION0 @@ -49,7 +49,7 @@ @check_down: lda #Joypad::BUTTON_DOWN - and Joypad::zp_buttons1 + and Joypad::zp_buttons beq @check_select lda #SPRITE_Y_POSITION1 @@ -60,13 +60,13 @@ @check_select: lda #Joypad::BUTTON_SELECT - and Joypad::zp_buttons1 + and Joypad::zp_buttons bne @do_select ;; If none of the above has been pressed, our only possibility is the ;; start button. If that's the case, jump there, otherwise quit. lda #(Joypad::BUTTON_START | Joypad::BUTTON_A) - and Joypad::zp_buttons1 + and Joypad::zp_buttons beq @end JAL start -- cgit v1.2.3