diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/bullets.s | 3 | ||||
| -rw-r--r-- | src/driver.s | 4 | ||||
| -rw-r--r-- | src/interrupts.s | 6 | ||||
| -rw-r--r-- | src/items.s | 11 | ||||
| -rw-r--r-- | src/jetpac.s | 8 | ||||
| -rw-r--r-- | src/score.s | 72 |
6 files changed, 100 insertions, 4 deletions
diff --git a/src/bullets.s b/src/bullets.s index 3cc74b9..802edb7 100644 --- a/src/bullets.s +++ b/src/bullets.s @@ -297,8 +297,9 @@ jsr Enemies::collides beq @next_enemy_collision - ;; Yes! Kill the enemy and break the loop. + ;; Yes! Kill the enemy, keep the score and break the loop. jsr Enemies::bite_the_dust + ADD_ENEMY_SCORE jmp @save_bullet_move @next_enemy_collision: diff --git a/src/driver.s b/src/driver.s index 8e26fbe..a9a2fbd 100644 --- a/src/driver.s +++ b/src/driver.s @@ -138,6 +138,10 @@ and #%11111011 sta Globals::zp_flags + ;; And the scores should be updated on the game screen as well. + lda #$80 + sta Globals::zp_extra_flags + rts .endproc diff --git a/src/interrupts.s b/src/interrupts.s index 9c2cb45..7026223 100644 --- a/src/interrupts.s +++ b/src/interrupts.s @@ -27,6 +27,12 @@ lda #$02 sta OAM::m_dma + ;; Should scores be updated? + bit Globals::zp_extra_flags + bpl @check_pause + jsr Score::nmi_update_scores + +@check_pause: ;; Toggle pause message from the HUD. bit Driver::zp_flags bvc @increase_rand diff --git a/src/items.s b/src/items.s index 12f551f..084bd1b 100644 --- a/src/items.s +++ b/src/items.s @@ -521,6 +521,14 @@ lsr sta Items::zp_current_tiles + 1, x + ;; Account for this on the player's score. + ;; + ;; NOTE: this is in opposition as to how it was handled in the original + ;; game where the score was accounted on part/tank pickup, not + ;; dropping. I find this more reliable and easier to code, and in the + ;; end it's the same. + ADD_PART_FUEL_SCORE + jmp @next ;;; @@ -966,7 +974,8 @@ lda #$FF sta Items::zp_pool_base, x - ;; TODO: score + ;; Account for this on the player's score. + ADD_ITEM_SCORE rts .endproc diff --git a/src/jetpac.s b/src/jetpac.s index b356192..a50ba6a 100644 --- a/src/jetpac.s +++ b/src/jetpac.s @@ -107,7 +107,7 @@ bpl @vblankwait2 ;; NOTE: palettes are not initialized here as it's going to be one of the - ;; first things done on `main` code. + ;; first things done in main(). __fallthrough__ main .endproc @@ -123,6 +123,12 @@ sta Score::m_hi + 5 @init: + ;; Force the scores to appear. + lda #$80 + sta Globals::zp_extra_flags + + ;; TODO: update high score (see zp_extra_flags) + ;; Disable the PPU and zero out variables which shadow PPU registers. lda #0 sta PPU::m_mask diff --git a/src/score.s b/src/score.s index ed36283..5b5c455 100644 --- a/src/score.s +++ b/src/score.s @@ -118,9 +118,79 @@ BCD_JUST_CARRY - ;; TODO: set a flag about updating the score on the HUD. + ;;; + ;; And set the 'score' flag, signaling a need of updating the score. + + lda Globals::zp_extra_flags + ora #$80 + sta Globals::zp_extra_flags + + rts + .endproc + + ;; Update the score for both players. This might be a bit too much on single + ;; player mode but we have to show both scores on the title screen + ;; anyways. Hence, since we have all the time in the world anyways, we + ;; update both and avoid branching and stuff. + .proc nmi_update_scores + ;; The 'y' register will contain the right high byte for the PPU + ;; address. This is needed because scores are to be displayed on both + ;; the title and game screens. + lda PPU::zp_control + and #$02 + tax + ldy hi_ppu_address, x + + ;; Now we just put the numbers. The 'x' index has to go "backwards", and + ;; taking into account that both players live on the same buffer. The + ;; tile ID is basically the integer value + $10, which is the position + ;; of the '0' character on our tile set. + + bit PPU::m_status + sty PPU::m_address + lda #$62 + sta PPU::m_address + + clc + ldx #(PLAYERS_BUFF_SIZE - 2) + @player1_loop: + lda Score::m_players, x + adc #$10 + sta PPU::m_data + + dex + dex + cpx #$FE + bne @player1_loop + + ;; And the same for the second player. + + bit PPU::m_status + sty PPU::m_address + lda #$78 + sta PPU::m_address + + clc + ldx #(PLAYERS_BUFF_SIZE - 1) + @player2_loop: + lda Score::m_players, x + adc #$10 + sta PPU::m_data + + dex + dex + cpx #$FF + bne @player2_loop + + ;; Disable the 'score' flag. + lda Globals::zp_extra_flags + and #$3F + sta Globals::zp_extra_flags rts + + hi_ppu_address: + .byte $20, $00, $28, $00 .endproc .endscope |
