aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-05-15 17:08:41 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-05-15 17:08:41 +0200
commit72894d68c4fbd8c2b843afa70244dee3b6241414 (patch)
tree3ecdb450605f1f98be280a189e79e7e866d8ce0a /src
parentf3062cb3e0dce519f6604af43b56f408537a8193 (diff)
downloadjetpac.nes-72894d68c4fbd8c2b843afa70244dee3b6241414.tar.gz
jetpac.nes-72894d68c4fbd8c2b843afa70244dee3b6241414.zip
Add the skeleton code for enemies
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/driver.s1
-rw-r--r--src/enemies.s58
-rw-r--r--src/jetpac.s1
3 files changed, 60 insertions, 0 deletions
diff --git a/src/driver.s b/src/driver.s
index 66846ac..3ed0536 100644
--- a/src/driver.s
+++ b/src/driver.s
@@ -86,6 +86,7 @@
@load_player:
jsr Player::init
jsr Bullets::init
+ jsr Enemies::init
;; Initialize pause timer.
lda #0
diff --git a/src/enemies.s b/src/enemies.s
new file mode 100644
index 0000000..ab67ccd
--- /dev/null
+++ b/src/enemies.s
@@ -0,0 +1,58 @@
+.segment "CODE"
+
+.scope Enemies
+ ;; Maximum amount of enemies allowed on screen at the same time.
+ ENEMIES_POOL_CAPACITY = 3
+
+ ;; The capacity of the bullets pool in bytes.
+ ENEMIES_POOL_CAPACITY_BYTES = ENEMIES_POOL_CAPACITY * 3
+
+ ENEMIES_INITIAL_X = $F0
+
+ ;; TODO: 3 bytes a la bullets
+ zp_enemies_pool_base = $60
+
+ zp_enemies_timer = $D0
+ zp_enemies_pool_size = $D1
+
+ .proc init
+ ldx #0
+ stx zp_enemies_timer
+
+ ldy #ENEMIES_POOL_CAPACITY
+ @enemies_init_loop:
+ lda #0
+ sta zp_enemies_pool_base, x
+
+ inx
+ lda #$80 ; TODO: random
+ sta zp_enemies_pool_base, x
+
+ inx
+ lda #ENEMIES_INITIAL_X
+ sta zp_enemies_pool_base, x
+
+ inx
+
+ dey
+ bne @enemies_init_loop
+
+ lda #ENEMIES_POOL_CAPACITY
+ sta zp_enemies_pool_size
+
+ rts
+ .endproc
+
+ ;; Definitions for all the enemy types. These are just the tile IDs for each
+ ;; case. Note that some of them have $FF, which is because they span 2
+ ;; sprites instead of 4.
+tiles:
+ .byte $26, $27, $36, $37
+ .byte $28, $29, $38, $39
+ .byte $24, $25, $34, $35
+ .byte $2A, $2B, $3A, $3B
+ .byte $31, $32, $FF, $FF
+ .byte $41, $42, $FF, $FF
+ .byte $2C, $2D, $3C, $3D
+ .byte $2E, $2F, $3E, $3F
+.endscope
diff --git a/src/jetpac.s b/src/jetpac.s
index ada5d1f..3b7ac18 100644
--- a/src/jetpac.s
+++ b/src/jetpac.s
@@ -41,6 +41,7 @@
.include "background.s"
.include "player.s"
.include "bullets.s"
+.include "enemies.s"
.include "title.s"
.include "driver.s"
.include "vectors.s"