aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-04-03 22:32:52 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-04-03 22:32:52 +0200
commit1963d7d8dd70ee9bc4cf9b81363aeab440a6f786 (patch)
tree9a0da613df46caf4620f58c1f06a8508d7e6fc77
parentcb1111055f7b03989daac63675d27bfd156a4e21 (diff)
downloadjetpac.nes-1963d7d8dd70ee9bc4cf9b81363aeab440a6f786.tar.gz
jetpac.nes-1963d7d8dd70ee9bc4cf9b81363aeab440a6f786.zip
Add a table with tile IDs for shuttle parts
This will allow us to select the proper shuttle depending on 'Globals::zp_shuttle_kind'. Hence, now only the actual shuttle parts on the CHR file are missing, which is why I left a couple of TODOs on the table itself. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
-rw-r--r--.nasm/segments.txt2
-rw-r--r--src/driver.s28
-rw-r--r--src/items.s46
3 files changed, 56 insertions, 20 deletions
diff --git a/.nasm/segments.txt b/.nasm/segments.txt
index 229318f..a63d9cd 100644
--- a/.nasm/segments.txt
+++ b/.nasm/segments.txt
@@ -1,4 +1,4 @@
- HEADER: 16/16 (100%)
-- ROM0: 9136/32762 (27.89%)
+- ROM0: 9187/32762 (28.04%)
- ROMV: 6/6 (100%)
- ROM2: 8192/8192 (100%)
diff --git a/src/driver.s b/src/driver.s
index 9d31604..67cba5c 100644
--- a/src/driver.s
+++ b/src/driver.s
@@ -714,34 +714,38 @@
sta OAM::m_sprites + 44
;; Tile IDs
- lda #$04
+ ldx Globals::zp_shuttle_kind
+ lda Items::shuttle_sprites, x
sta OAM::m_sprites + 1
- lda #$05
+ clc
+ adc #1
sta OAM::m_sprites + 5
- lda #$14
+ adc #$0F
sta OAM::m_sprites + 9
- lda #$15
+ adc #1
sta OAM::m_sprites + 13
- lda #$06
+ lda Items::shuttle_sprites, x
+ adc #2
sta OAM::m_sprites + 17
- lda #$07
+ adc #1
sta OAM::m_sprites + 21
- lda #$16
+ adc #$0F
sta OAM::m_sprites + 25
- lda #$17
+ adc #1
sta OAM::m_sprites + 29
- lda #$08
+ lda Items::shuttle_sprites, x
+ adc #4
sta OAM::m_sprites + 33
- lda #$09
+ adc #1
sta OAM::m_sprites + 37
- lda #$18
+ adc #$0F
sta OAM::m_sprites + 41
- lda #$19
+ adc #1
sta OAM::m_sprites + 45
;; Zero out attributes
diff --git a/src/items.s b/src/items.s
index 9ad1aba..a2f867a 100644
--- a/src/items.s
+++ b/src/items.s
@@ -294,13 +294,20 @@
;; Should we allocate a part from the shuttle?
bne @try_next_shuttle
- lda #$04
- bne @no_attributes
+ stx Globals::zp_tmp0
+ ldx Globals::zp_shuttle_kind
+ lda Items::shuttle_sprites, x
+ ldx Globals::zp_tmp0
+ jmp @no_attributes
@try_next_shuttle:
cmp #$01
bne @do_fuel_or_regular
- lda #$06
- beq @do_fuel_or_regular
+ stx Globals::zp_tmp0
+ ldx Globals::zp_shuttle_kind
+ lda Items::shuttle_sprites, x
+ clc
+ adc #2
+ ldx Globals::zp_tmp0
@no_attributes:
sta Globals::zp_arg0
@@ -1157,7 +1164,14 @@
;;
;; NOTE: this has to be called with the PPU disabled.
.proc draw_middle_part_shuttle
- ldx #$08
+ ;; Compute the tile ID for the middle part of the shuttle depending on
+ ;; the kind.
+ ldx Globals::zp_shuttle_kind
+ lda Items::shuttle_backgrounds, x
+ clc
+ adc #4
+ tax
+
ldy #$2A
bit PPU::m_status
@@ -1184,7 +1198,11 @@
;;
;; NOTE: this has to be called with the PPU disabled.
.proc draw_high_part_shuttle
- ldx #$04
+ ;; Compute the tile ID for the middle part of the shuttle depending on
+ ;; the kind.
+ ldy Globals::zp_shuttle_kind
+ ldx Items::shuttle_backgrounds, y
+
ldy #$2A
bit PPU::m_status
@@ -1211,13 +1229,20 @@
;;
;; NOTE: this has to be called with the PPU disabled.
.proc draw_low_part_shuttle
+ ;; Compute the tile ID for the low part of the shuttle depending on the
+ ;; kind.
+ ldx Globals::zp_shuttle_kind
+ lda Items::shuttle_backgrounds, x
+ clc
+ adc #8
+ tax
+
;; The low part of the rocket.
bit PPU::m_status
lda #$2A
sta PPU::m_address
lda #$F5
sta PPU::m_address
- ldx #$0C
stx PPU::m_data
inx
stx PPU::m_data
@@ -1233,4 +1258,11 @@
rts
.endproc
+
+shuttle_sprites:
+ ;; TODO: rest of IDs
+ .byte $04, $00, $00, $00
+shuttle_backgrounds:
+ ;; TODO: rest of IDs
+ .byte $04, $00, $00, $00
.endscope