aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-03-06 23:43:26 +0100
committerMiquel Sabaté Solà <mssola@mssola.com>2026-03-06 23:43:26 +0100
commit37b22275726d8a702c2168751f8af5e833fcc46d (patch)
tree3395eebeaf3baaae0912e03e33466df6f9ece9ce /src
parente602dd3707f2b6ad3198a62497ca6ee311997485 (diff)
downloadjetpac.nes-37b22275726d8a702c2168751f8af5e833fcc46d.tar.gz
jetpac.nes-37b22275726d8a702c2168751f8af5e833fcc46d.zip
Make more things operate on SIZEOF_POOL_ITEM
Out of consistency, let's use it, and this way experimenting with the amount of enemies per screen won't be as painful. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'src')
-rw-r--r--src/enemies.s16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/enemies.s b/src/enemies.s
index 33b4c33..99e8b91 100644
--- a/src/enemies.s
+++ b/src/enemies.s
@@ -29,8 +29,8 @@
ENEMIES_INITIAL_X_RIGHT = $10
;; Base address for the pool of enemies used on this game. The pool has
- ;; #ENEMIES_POOL_CAPACITY capacity of enemy objects where each one is 4
- ;; bytes long:
+ ;; #ENEMIES_POOL_CAPACITY capacity of enemy objects where each one is
+ ;; #SIZEOF_POOL_ITEM bytes long:
;; 1. State: which can have two formats:
;; - $FF: the enemy is not active.
;; - |DIxx|xxxx|: where D is the direction bit (1: right; 0: left); and
@@ -73,10 +73,10 @@
;; Checking for collision with bullets is actually way faster if after an
;; update we save tile coordinates for each enemy. For this, we only need to
- ;; save the tile coordinates, but notice that we actually span 4 bytes per
- ;; enemy. That's because of padding: we are re-using the
- ;; 'Enemies::zp_pool_index' variable to index both the pool and this
- ;; buffer. Hence, identifying an enemy by 'zp_pool_index' works in both
+ ;; save the tile coordinates, but notice that we actually span
+ ;; #SIZEOF_POOL_ITEM bytes per enemy. That's because of padding: we are
+ ;; re-using the 'Enemies::zp_pool_index' variable to index both the pool and
+ ;; this buffer. Hence, identifying an enemy by 'zp_pool_index' works in both
;; buffers. This is extremely useful so bullets don't have to work out two
;; different indeces for two different structures.
;;
@@ -91,7 +91,7 @@
;; |- tile Y/X: tile coordinates for the enemy.
;; |- palette: the color palette to be applied to the enemy.
;;
- CURRENT_TILES_BYTES = ENEMIES_POOL_CAPACITY * 4
+ CURRENT_TILES_BYTES = ENEMIES_POOL_CAPACITY * SIZEOF_POOL_ITEM
zp_current_tiles = $F0 ; asan:reserve CURRENT_TILES_BYTES
;; Cached values for the tile coordinates from the player. This is set
@@ -180,7 +180,7 @@
;; 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).
+ ;; to store an enemy on the poll (i.e. #SIZEOF_POOL_ITEM bytes).
;; NOTE: the 'y' register is not touched.
.proc init_x
;; Pick the palette to be used for the enemy.