From 2f85b4c7820d919497878d54dea530fe73a486c9 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Mon, 2 Mar 2026 23:18:55 +0100 Subject: Move enemy initialization into its own function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will be useful whenever we implement the re-appearance of enemies. Signed-off-by: Miquel Sabaté Solà --- src/enemies.s | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/enemies.s') 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 -- cgit v1.2.3