aboutsummaryrefslogtreecommitdiff
path: root/scroll/include/background.s
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-03-11 16:39:44 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-03-11 16:39:44 +0100
commitf05ce5d5ff7d650a439b363993f8b38b817d3efe (patch)
tree6d324e019650b1936d84e3c0935192e1fb7cbb72 /scroll/include/background.s
parent4795fcad304087a9308e024a25233873c43501be (diff)
downloadcode.nes-f05ce5d5ff7d650a439b363993f8b38b817d3efe.tar.gz
code.nes-f05ce5d5ff7d650a439b363993f8b38b817d3efe.zip
scroll: Provide an example with sprite 0 collision
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'scroll/include/background.s')
-rw-r--r--scroll/include/background.s17
1 files changed, 14 insertions, 3 deletions
diff --git a/scroll/include/background.s b/scroll/include/background.s
index f392792..69725fd 100644
--- a/scroll/include/background.s
+++ b/scroll/include/background.s
@@ -27,6 +27,15 @@
DISABLED_BACKGROUND_CYCLE = $FE
BACKGROUND_CYCLE_MAX = $02
+ ;; The offset for metatile rows. That is, from where should the engine start
+ ;; counting rows of metatiles. By default it's 0, but it could be set to
+ ;; something else to reserve so top space for a HUD or something similar.
+ ;;
+ ;; NOTE: configurable.
+ .ifndef BACKGROUND_ROW_OFFSET
+ BACKGROUND_ROW_OFFSET = 0
+ .endif
+
;; Current column (or the next to be loaded by functions like
;; `load_column`).
zp_cur_column = $75
@@ -51,9 +60,11 @@
lda #$00
sta zp_scroll
sta Buffer::zp_vram_idx
- sta zp_cur_row
sta zp_cur_column
+ lda #BACKGROUND_ROW_OFFSET
+ sta zp_cur_row
+
rts
.endproc
@@ -112,7 +123,7 @@
;; Increase the column being used and loop if we are not at the end of
;; the screen yet.
- lda #0
+ lda #BACKGROUND_ROW_OFFSET
sta zp_cur_row
inc zp_cur_column
lda zp_cur_column
@@ -418,7 +429,7 @@
;; screen/level by poking the right flags.
.proc prepare_next_column
;; The row index always has to be set to zero.
- lda #0
+ lda #BACKGROUND_ROW_OFFSET
sta zp_cur_row
;; Is this the last column? If not, just quit.