diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-03-02 23:18:55 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-03-02 23:18:55 +0100 |
| commit | 2f85b4c7820d919497878d54dea530fe73a486c9 (patch) | |
| tree | a7e06700a1bcdf7b4ab11282980f86966a718e93 /src | |
| parent | b7c41567892a7b3bd3782128926c6a223658a034 (diff) | |
| download | jetpac.nes-2f85b4c7820d919497878d54dea530fe73a486c9.tar.gz jetpac.nes-2f85b4c7820d919497878d54dea530fe73a486c9.zip | |
Move enemy initialization into its own function
This will be useful whenever we implement the re-appearance of enemies.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/enemies.s | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/enemies.s b/src/enemies.s index 7aa8df1..53f6685 100644 --- a/src/enemies.s +++ b/src/enemies.s @@ -116,6 +116,21 @@ sty zp_enemies_pool_size @enemies_init_loop: + jsr init_enemy_x + + ;; Next enemy! + dey + bne @enemies_init_loop + + rts + .endproc + + ;; Initialize the enemy from the pool as indexed by the 'x' register. + ;; + ;; NOTE: the 'x' register will be advanced by the amount of bytes it takes + ;; to store an enemy on the poll (i.e. 4 bytes). + ;; NOTE: the 'y' register is not touched. + .proc init_enemy_x ;; The state is set at random. stx Globals::zp_tmp0 jsr Prng::random_valid_y_coordinate @@ -148,10 +163,8 @@ inx sta zp_enemies_pool_base, x - ;; Next enemy! + ;; And point to the next enemy. inx - dey - bne @enemies_init_loop rts .endproc |
