diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-03-11 16:40:12 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-03-11 16:40:12 +0100 |
| commit | 6f7a0d24cfa7c767e9eee8283c65b4480a6c231b (patch) | |
| tree | 52351a9021e4d74b359d06d5fc61f8f7af20265a /scroll/README.md | |
| parent | f05ce5d5ff7d650a439b363993f8b38b817d3efe (diff) | |
| download | code.nes-6f7a0d24cfa7c767e9eee8283c65b4480a6c231b.tar.gz code.nes-6f7a0d24cfa7c767e9eee8283c65b4480a6c231b.zip | |
scroll: Provide an even more basic example
That is, just toggle between two fixed nametables.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'scroll/README.md')
| -rw-r--r-- | scroll/README.md | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/scroll/README.md b/scroll/README.md index e29186a..45c96e8 100644 --- a/scroll/README.md +++ b/scroll/README.md @@ -8,11 +8,30 @@ try to understand the concept of scrolling in NES/Famicom programming. The very basic concepts of scrolling can be seen in [toggle.s](./toggle.s), which gives you this as a result: -TBD +<div align="center"> + <img src="../docs/toggle.gif" alt="toggle.gif" /> +</div> That is, we only have filled the two nametable available, and we are modifying the [PPU scroll register](https://www.nesdev.org/wiki/PPU_registers#PPUSCROLL) -to move between one or the other. +to move between one or the other. Another important note, easily missed when +programming scrolling on the NES/Famicom for the first time, is that whenever +the PPU scroll "wraps around", you should also update the base nametable address +from the [PPU control +register](https://www.nesdev.org/wiki/PPU_registers#PPUCTRL). That happens in +two situations: + +1. If you are scrolling right and PPU scroll turns into a `$00` value, then it + means that there's nothing else to show from the origin nametable, and that + `$00` on the scroll means it's `$00` in respect to a new nametable. +2. If you are scrolling left and the PPU scroll turns into `$FF` (i.e. the first + step on scrolling left), then the base nametable address has to be updated + because it's `$FF` from the point of view of the nametable from the left. + +It's easy to miss these points, but from a PPU perspective (and hence from the +perspective of a programmer interfacing with the PPU), it really makes sense. +All in all, the scroll register is relative to whatever base nametable is set on +the control register. This looks rather simplistic but some games used this technique. For example, in Dropzone it was used to perform some effects on the title screen. Hence, |
