Goal: wire together everything from Lessons 1-15 into one small, coherent, playable scene — not new material, but the first time all of it runs as a single program instead of fifteen separate demos.
A player-controlled sprite that: moves around a scrolling background, stays inside the play area via tile-based collision, can touch a collectible sprite that disappears and plays a sound when collected, and is built from files organized the way Lesson 15 described rather than one monolithic file. Concretely, every piece maps to a lesson you’ve already built:
| Piece | From |
|---|---|
| ROM skeleton, header, reset routine | Lesson 1 |
| Palette | Lesson 4 |
| Background tile + tilemap | Lessons 5-6 |
| Fast loading via DMA | Lesson 8 |
| Background scrolling | Lesson 9 |
| Player sprite + animation | Lesson 10-11 |
| Movement bounds + collectible detection | Lesson 12 |
| Collection sound effect | Lessons 13-14 |
| File layout | Lesson 15 |
main.s ; .includes everything below, HEADER/ROMINFO/VECTORS segments
regs.s ; hardware register address constants
variables.s ; direct-page variable definitions
macros.s ; write_dsp_reg and any other macros you've written
reset.s ; reset: — CPU init, palette/tile/tilemap/sprite loading (DMA)
gameplay.s ; nmi_handler: — scroll, input, movement, collision, sound
audio.s ; spc_wait_boot, spc_begin_upload, spc_upload_byte, write_dsp
lorom128.cfg ; the 4-bank linker config from Lesson 15
This is the one genuinely new piece — everything else is direct reuse. Extend Lesson 12’s wall_x/wall_y sprite into a real collectible: when check_collision reports a hit, hide it (move it off-screen, the same technique Lesson 10 used for unused sprites) and trigger Lesson 14’s sound, guarded so it only fires once:
; --- new variable ---
collected := $06 ; 0 = not yet collected, 1 = collected
; --- inside nmi_handler, after the existing check_collision call ---
lda collected
bne @already_done ; skip entirely once collected
jsr check_collision
bcc @no_hit
lda #1
sta collected
; hide the collectible sprite (same technique as Lesson 10's off-screen sprites)
stz $2102
lda #4 ; OAMADDL: sprite 1's record starts at byte 4
sta $2102
stz $2103
lda #$F0
sta $2104 ; overwrite its Y with an off-screen value
; (X/tile/attr bytes stay as previously set;
; only Y needs to change to hide it)
jsr play_hit_sfx ; from Lesson 14
@no_hit:
@already_done:This is the point where Lesson 7’s tools stop being optional. Before considering the capstone finished, use them deliberately:
collected (write access) — confirm it’s set exactly once, not repeatedly, when the sprites overlap.This tutorial stops here on purpose — not because there’s nothing left, but because everything past this point is variation and depth on the same foundations, better explored by building something you actually want to make. Some directions, each a natural extension of a specific lesson:
BG1/BG2 unused in this tutorial — a parallax layer or a HUD layer is a direct extension of Lesson 6, mindful of the shared-scroll-latch gotcha from Lesson 9.If you get stuck on any of these, or on anything in Lessons 1-16, that’s exactly the situation this tutorial’s format was built for — bring the question back, and the relevant lesson gets corrected or extended based on it.
Home | Previous: Lesson 15 — Code organization & optimization Next: Appendix — SNES Address & Register Map