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/player.s | |
| 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/player.s')
| -rw-r--r-- | src/player.s | 62 |
1 files changed, 55 insertions, 7 deletions
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 |
