Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Since I asked this question, I've learned a ton of new things about the NES PPU, so I'll be answering this question myself. </p> <p>To start off, the memory map of the PPU looks like this: </p> <pre><code>$0000 - $0FFF Pattern table 0 $1000 - $1FFF Pattern table 1 $2000 - $23BF Nametable 0 $23C0 - $23FF Attribute table 0 $2400 - $27BF Nametable 1 $27C0 - $27FF Attribute table 1 $2800 - $2BBF Nametable 2 $2BC0 - $2BFF Attribute table 2 $2C00 - $2FBF Nametable 3 $2FC0 - $2FFF Attribute table 3 $3000 - $3EFF [0x2000 - 0x2EFF] mirror $3F00 - $3F09 Background palette $3F10 - $3F19 Sprite palette $3F20 - $3FFF Palette mirror </code></pre> <p>Other than that, there is a $FF (256) byte area called OAM, and there's a $20 (32) byte area called Secondary OAM. </p> <p>How are they written to?</p> <p>The pattern tables are used to hold graphics data of the NES in patterns, i.e. whatever is stored in here shows the shape of sprites used. These are generally stored in CHR ROM on a cartridge, but they can be written to the PPU memory by the programmer of the game as well. The way this happens will be explained below. </p> <p>Other than the pattern tables, everything other than OAM and Secondary OAM is written by the programmer of the game into the PPU memory. This happens by using registers <strong>$2006</strong> and <strong>$2007</strong>. How? </p> <p>Whenever the programmer wants to write to a certain address in PPU memory, he can do so by storing (sta, stx, sty, and maybe other instructions as well) the address he wants to access by writing to <strong>$2006</strong> twice through the CPU like he does in normal assembly. An example would be: </p> <pre><code>LDA #$20 STA $2006 LDA #$00 STA $2006 </code></pre> <p>The user writes the high byte of the address first, and then the low byte. Now, a PPU internal 15 bit latch (not sure if latch is the right word) has the PPU address $2000 stored in it. Whenever the programmer wants to write to this address, (which, in this case, is the starting address of the first nametable) he can do so normally by writing the value he wants to store in this memory area to memory address <strong>$2007</strong>. When writing to this address, the written value will be put into the address in the 15 bit latch, and the latch will be incremented by either 1 or 32 (decided by bit 2 of the value in address <strong>$2000</strong>). That's basically how simple it is. </p> <p>Of course, it's not that simple. Addresses <strong>$2000 - $2007</strong> are called the PPU's <strong>Memory Mapped Registers</strong>, and they're called that because they're in the CPU's memory. They're located there because the CPU and the PPU can't access each other's memory directly, so the CPU has to find some gateway to the PPU's memory, and those addresses are it. There are a lot of strange exceptions and quirks to these registers, and they're all explained <a href="http://wiki.nesdev.com/" rel="nofollow">here</a>. </p> <p>Other than those, there's still the aforementioned OAM and Secondary OAM, but those are a whole different thing, and should be explained thoroughly by reading actually viable sources, rather than a quick explanation. </p> <p>It's better to read it from the mentioned source (<a href="http://wiki.nesdev.com/" rel="nofollow">again, here</a>) to get a full understanding, but this is just a quick explanation for those who were curious and actually have a basic understanding of this kind of stuff.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload