diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-03-03 18:47:42 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-03-03 18:47:42 +0100 |
| commit | d71a38f3223dd90ad59b706321de87d60c0ed666 (patch) | |
| tree | 0e3e580f43dd43ab8f446569f90939cf1f72300b /src/driver.s | |
| parent | f7df2b8be51936aa79a309ada059a0eecfa86796 (diff) | |
| download | jetpac.nes-d71a38f3223dd90ad59b706321de87d60c0ed666.tar.gz jetpac.nes-d71a38f3223dd90ad59b706321de87d60c0ed666.zip | |
Add a pool of explosion effects
For now this only applies to enemies, but it's general enough so it can
target any given coordinate, and hence any given object.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'src/driver.s')
| -rw-r--r-- | src/driver.s | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/driver.s b/src/driver.s index f5d20d5..8d6ee52 100644 --- a/src/driver.s +++ b/src/driver.s @@ -96,6 +96,7 @@ jsr Player::init jsr Bullets::init jsr Enemies::init + jsr Explosions::init ;; Initialize pause timer. lda #0 @@ -157,6 +158,9 @@ jsr Player::update jsr Bullets::update jsr Enemies::update + jsr Explosions::update + + ;; TODO: check if player has died __fallthrough__ sprite_cycling .endproc @@ -345,6 +349,34 @@ @rest_o_items: ;;; TODO + ;; At the very end, we allocate any active explosion. + @do_explosions: + ldx #0 + @explosions_loop: + ;; If we are already passed the amount of bytes we could allocate for + ;; explosions, then break the loop. + cpx #Explosions::EXPLOSIONS_POOL_CAPACITY_BYTES + beq @after_explosions + + @do_explosion: + ;; Is it valid? + lda Explosions::zp_pool_base, x + and #$80 + beq @next_explosion + + ;; Yes! Then call the explosion allocator with the values we have + ;; now. Note that the 'y' register will be updated as desired, but the + ;; 'x' register will become bananas. Hence, save its value before + ;; calling and restore it back after the call. + stx Globals::zp_tmp3 + jsr Explosions::allocate_x_y + ldx Globals::zp_tmp3 + + @next_explosion: + NEXT_EXPLOSION_INDEX_X + jmp @explosions_loop + + @after_explosions: ;; Are all spots already filled? As in, did the 'y' register wrap ;; around? If so, just go to the end. tya |
