diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-03-04 23:44:47 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-03-04 23:44:47 +0100 |
| commit | dbcbd43287a28bf087e20e660edd5ba40b5c27ec (patch) | |
| tree | ae69b710c3b06bae58c18273af105855b3071ded | |
| parent | 0c5af85cc0cb9bb39a3a72548e735b92daf0a28f (diff) | |
| download | jetpac.nes-dbcbd43287a28bf087e20e660edd5ba40b5c27ec.tar.gz jetpac.nes-dbcbd43287a28bf087e20e660edd5ba40b5c27ec.zip | |
Update lifes left for player 1
The whole handling of player 2 will come whenever I set to implement
multi-player for this game.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
| -rw-r--r-- | .nasm/memory.txt | 3 | ||||
| -rw-r--r-- | .nasm/segments.txt | 2 | ||||
| -rw-r--r-- | src/driver.s | 8 | ||||
| -rw-r--r-- | src/interrupts.s | 22 | ||||
| -rw-r--r-- | src/jetpac.s | 1 | ||||
| -rw-r--r-- | src/player.s | 23 |
6 files changed, 55 insertions, 4 deletions
diff --git a/.nasm/memory.txt b/.nasm/memory.txt index 9f9f561..9461474 100644 --- a/.nasm/memory.txt +++ b/.nasm/memory.txt @@ -29,6 +29,7 @@ $46-$47: zp_position_x $49: zp_velocity_x $50: zp_state $51: zp_walk_counter +$53-$54: zp_lifes $60-$6B: zp_enemies_pool_base $70-$7B: zp_pool_base $7C: zp_active @@ -64,4 +65,4 @@ $4016: m_joypad1 $4017: m_frame_counter --- Summary (in bytes) --- -- Internal RAM: 373/2048 (18.21%) +- Internal RAM: 375/2048 (18.31%) diff --git a/.nasm/segments.txt b/.nasm/segments.txt index a9fd7db..b4e56dc 100644 --- a/.nasm/segments.txt +++ b/.nasm/segments.txt @@ -1,4 +1,4 @@ - HEADER: 16/16 (100%) -- ROM0: 6085/32762 (18.57%) +- ROM0: 6149/32762 (18.77%) - ROMV: 6/6 (100%) - ROM2: 8192/8192 (100%) diff --git a/src/driver.s b/src/driver.s index 8a0d452..b90cabe 100644 --- a/src/driver.s +++ b/src/driver.s @@ -80,6 +80,14 @@ lda #PLAYER_TIMER_VALUE sta zp_player_timer + ;; Initialize lifes for both players. + lda #4 + sta Player::zp_lifes + sta Player::zp_lifes + 1 + lda Player::zp_state + ora #%00001000 + sta Player::zp_state + ;; Mark the state of the game as "game". That is, the player has ;; started. Also set the `ppu` flag and unset the `title over` one. lda #%01000001 diff --git a/src/interrupts.s b/src/interrupts.s index 8c53af7..b5120b4 100644 --- a/src/interrupts.s +++ b/src/interrupts.s @@ -34,6 +34,28 @@ jsr Driver::pal_handler .endif + ;; Do we need to update the lifes from players on the HUD? + lda Player::zp_state + and #%00001000 + beq @global_flags + + ;; Yeah! TODO: this is only done for player 1. + bit PPU::m_status + lda #$28 + sta PPU::m_address + lda #$4B + sta PPU::m_address + lda Player::zp_lifes + clc + adc #$10 + sta PPU::m_data + + ;; And unset the 'life' flag from the player. + lda Player::zp_state + and #%11110111 + sta Player::zp_state + +@global_flags: ;; TODO: some actions here will depend on the status of the game... lda Globals::zp_flags and #%00000001 diff --git a/src/jetpac.s b/src/jetpac.s index b6b44e2..2e55771 100644 --- a/src/jetpac.s +++ b/src/jetpac.s @@ -122,6 +122,7 @@ sta Globals::zp_flags sta Joypad::zp_buttons1 sta Joypad::zp_buttons2 + sta Player::zp_state ;; Initialize the level. We allow the build system to pass its own value for ;; this in `LEVEL`, just in case we want to debug the enemy of a specific diff --git a/src/player.s b/src/player.s index a821f0e..73ff20e 100644 --- a/src/player.s +++ b/src/player.s @@ -86,7 +86,8 @@ ;; |-----+------------+-----------------------------------------------| ;; | 7 | thrust | Player is hitting the thrust | ;; | 6 | heading | heading right | - ;; | 5-3 | - | Unused | + ;; | 5-4 | - | Unused | + ;; | 3 | life | Lifes should be updated on screen | ;; | 2 | update | Sprite (animation or heading) must be updated | ;; | 1-0 | walk | 0: still; 1: animation 1; 2: animation 2 | zp_state = $50 @@ -102,6 +103,9 @@ zp_step_on_pal = $52 .endif + ;; Lifes for both players. + zp_lifes = $53 ; asan:reserve $02 + ;; How many animations are there for walking? WALK_ANIMATION_NR = 3 @@ -830,7 +834,13 @@ ;; That's just german for "the Bart, the". .proc die_bart_die - ;; TODO: dec lifes + ;; Decrement the life. + ;; TODO: this is just considering the first player only!. + dec Player::zp_lifes + beq @over + lda Player::zp_state + ora #%00001000 + sta Player::zp_state ;; Move the player's sprites out of the screen. ldx #0 @@ -853,5 +863,14 @@ lda Player::zp_screen_x sta Globals::zp_arg3 JAL Explosions::create + + @over: + ;; Set the proper flag for game over. + ;; TODO: game over (coin) + lda Globals::zp_flags + ora #%00000010 + sta Globals::zp_flags + + rts .endproc .endscope |
