diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-03-08 16:10:52 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-03-08 22:14:10 +0100 |
| commit | 276515a1338feb72e38825dd920a23ac525d241b (patch) | |
| tree | 2ab5ccbaca1c019139b907419c668751e73a11d1 /src | |
| parent | 0454655006afe7f83f8de2280b758fb323487e76 (diff) | |
| download | jetpac.nes-276515a1338feb72e38825dd920a23ac525d241b.tar.gz jetpac.nes-276515a1338feb72e38825dd920a23ac525d241b.zip | |
State game over only when all players are dead
This is a bit contrary to the original game, where each player would get
its own "Game over" event.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/driver.s | 5 | ||||
| -rw-r--r-- | src/jetpac.s | 4 | ||||
| -rw-r--r-- | src/over.s | 14 | ||||
| -rw-r--r-- | src/player.s | 62 |
4 files changed, 64 insertions, 21 deletions
diff --git a/src/driver.s b/src/driver.s index 1ac5718..3bf4399 100644 --- a/src/driver.s +++ b/src/driver.s @@ -258,8 +258,9 @@ lda Explosions::zp_active bne @sprite_cycling - ;; After all the explosions have been done, do we have any life left? - lda Player::zp_lifes + ;; After all the explosions have been done, is any player alive? + lda Globals::zp_multiplayer + and #%00000110 bne @reset_timer ;; No! Toggle the game over bit. diff --git a/src/jetpac.s b/src/jetpac.s index e8d6543..4802e74 100644 --- a/src/jetpac.s +++ b/src/jetpac.s @@ -111,7 +111,7 @@ .endproc .proc main - ;; TODO: score initialization has to happen here. + ;; TODO: high score initialization has to happen here. @init: ;; Disable the PPU and zero out variables which shadow PPU registers. @@ -239,7 +239,7 @@ bit Globals::zp_flags bmi @wait_for_render_over - ;; Did the user want to start over? + ;; Can the player start over? lda Globals::zp_tmp0 beq @main_game_loop jmp @init @@ -147,15 +147,13 @@ rts .endproc - ;; Render the regular "Game over player X" screen. - ;; - ;; TODO: multiplayer support. + ;; Render the regular "Game over" screen. .proc render_regular_game_over ;; Set the position. bit PPU::m_status ldx #$29 stx PPU::m_address - ldx #$67 + ldx #$6C stx PPU::m_address ;; And just iterate over the "message" until we reach the end of string @@ -186,11 +184,7 @@ message: ;; "GAME " .byte $21, $1B, $27, $1F, $00 - ;; "OVER " - .byte $29, $30, $1F, $2C, $00 - ;; "PLAYER " - .byte $2A, $26, $1B, $33, $1F, $2C, $00 - ;; "1" - .byte $11, $FF + ;; "OVER" + .byte $29, $30, $1F, $2C, $FF .endproc .endscope diff --git a/src/player.s b/src/player.s index 7e215a5..53695b4 100644 --- a/src/player.s +++ b/src/player.s @@ -834,13 +834,25 @@ ;; That's just german for "the Bart, the". .proc die_bart_die - ;; Decrement the life. If we reach zero, then there's no point on - ;; signaling the NMI code to render this change. - ;; - ;; TODO: this is just considering the first player only!. - dec Player::zp_lifes - beq @skip_life_update - + ;; Decrement the life. + lda Globals::zp_multiplayer + and #$01 + tax + dec Player::zp_lifes, x + bne @nmi_update + + ;; If this poor guy is over, then mark it in the multiplayer bitmap. + cpx #0 + bne @player_2_over + lda #%11111101 + bne @set_multi + @player_2_over: + lda #%11111011 + @set_multi: + and Globals::zp_multiplayer + sta Globals::zp_multiplayer + + @nmi_update: ;; Notify NMI code to render lifes again, as they have changed. lda Player::zp_state ora #%00001000 @@ -862,6 +874,9 @@ ora Globals::zp_flags sta Globals::zp_flags + ;; Try to switch the player. + jsr Player::try_player_switch + ;; Create an explosion. lda Player::zp_screen_y sta Globals::zp_arg2 @@ -869,4 +884,37 @@ sta Globals::zp_arg3 JAL Explosions::create .endproc + + ;; Try to switch the active player if we are in multiplayer. + .proc try_player_switch + ;; If multiplayer is not enabled, don't even bother. + bit Globals::zp_multiplayer + bpl @end + + lda Globals::zp_multiplayer + tax + and #$01 + beq @try_player_2 + + ;; Switch to player 1 if it's still alive. + txa + and #$02 + beq @end + txa + and #$FE + bne @set_and_end + + @try_player_2: + ;; Switch to player 2 if it's still alive. + txa + and #$04 + beq @end + txa + ora #$01 + + @set_and_end: + sta Globals::zp_multiplayer + @end: + rts + .endproc .endscope |
