aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-04-07 23:02:43 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-04-07 23:02:43 +0200
commitcd7e1e5514a6fd26ec0f01960807c6f2ab6f1a5b (patch)
tree95e1fb041441341d6c778335858acaf70daf94fc
parentcdf9137af1d600c27bf0750615027859c9c2415c (diff)
downloadcode.nes-cd7e1e5514a6fd26ec0f01960807c6f2ab6f1a5b.tar.gz
code.nes-cd7e1e5514a6fd26ec0f01960807c6f2ab6f1a5b.zip
Expand the explanation on memory mapped IO
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
-rw-r--r--basics/sprite.s23
1 files changed, 16 insertions, 7 deletions
diff --git a/basics/sprite.s b/basics/sprite.s
index b841053..94cc0db 100644
--- a/basics/sprite.s
+++ b/basics/sprite.s
@@ -110,13 +110,22 @@
sei
cld
- ;; Disable APU frame IRQ. This is the first instance we see of Memory-Mapped
- ;; I/O. This is a core concept in NES programming and, to sum things up, the
- ;; memory range $2000-$5FFF is reserved to I/O operations, and each address
- ;; is reserved to a specific hardware operation. This is because the NES CPU
- ;; doesn't directly control the PPU nor other chips. In this case, ranges
- ;; $4000-$4017 control the APU (Audio Processing Unit). More precisely, the
- ;; $4017 address controls what is called the "Frame counter" from the APU
+ ;; Disable APU frame IRQ.
+ ;;
+ ;; This is the first instance we see of Memory-Mapped I/O. This is a core
+ ;; concept in NES programming and, to sum things up, the memory range
+ ;; $2000-$5FFF is reserved to I/O operations, where each address is reserved
+ ;; to a specific hardware operation. This is a wide range of addresses for a
+ ;; small set of registers that can actually be touched. But this is because
+ ;; on how the NES CPU is wired with the other chips and how "chip select"
+ ;; cables were layed out. I've found the following video useful to grasp
+ ;; this visually: https://youtu.be/lkJwpdw57lo?si=rNZhIzC3Gnf9ZU7A. In
+ ;; retrospect it feels like a big waste of addressing space, but this is how
+ ;; it is.
+ ;;
+ ;; Anyways, in this case ranges $4000-$4017 control the APU (Audio
+ ;; Processing Unit). More precisely, the $4017 address controls what is
+ ;; called the "Frame counter" from the APU
;; (https://www.nesdev.org/wiki/APU#Frame_Counter_($4017)). Setting #$40 to
;; it disables it completely, so we are in a known state. If we were to use
;; sound, at the end of the reset code we should enable it back. We do *not*