aboutsummaryrefslogtreecommitdiff
path: root/src/enemies.s
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-05-15 22:06:00 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-05-16 07:55:56 +0200
commit638dfdca6e773d4b1ec573606cac90bdb1778667 (patch)
tree73f60ee0aca0c0585f0fd8063ccc7bb31881e543 /src/enemies.s
parent72894d68c4fbd8c2b843afa70244dee3b6241414 (diff)
downloadjetpac.nes-638dfdca6e773d4b1ec573606cac90bdb1778667.tar.gz
jetpac.nes-638dfdca6e773d4b1ec573606cac90bdb1778667.zip
Initialize enemies at a random Y coordinate
The randomness comes from a pre-computed table of "random" numbers. This is of course the most simple technique you can come across a code base for the NES/Famicom, but for the purposes of this game is good enough and (most importantly) fast. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'src/enemies.s')
-rw-r--r--src/enemies.s4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/enemies.s b/src/enemies.s
index ab67ccd..377a9a5 100644
--- a/src/enemies.s
+++ b/src/enemies.s
@@ -25,7 +25,9 @@
sta zp_enemies_pool_base, x
inx
- lda #$80 ; TODO: random
+ stx Globals::zp_tmp0
+ jsr Prng::random_valid_y_coordinate
+ ldx Globals::zp_tmp0
sta zp_enemies_pool_base, x
inx