From cd7e1e5514a6fd26ec0f01960807c6f2ab6f1a5b Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 7 Apr 2026 23:02:43 +0200 Subject: Expand the explanation on memory mapped IO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- basics/sprite.s | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'basics') 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* -- cgit v1.2.3