nineTENdo wrote:
From what I understand the pattern table is sprites arranged in CHR files.
And im kind of confused about at CHR starting at $1000. what starts at $0000 when the bit 3 of $2000 is clear on initialization.
You can think of it like there are two pattern tables -- a "left" one ($0000-$0FFF) and a "right" one ($1000-$1FFF). Each pattern table holds 4K of CHR (which equates to 256 8x8 tiles). This means there are 512 tiles in your pattern tables at all times.
Since the BG can only select from 256 tiles, you use bit 4 of $2000 to select which pattern table the BG gets its tile graphics from. Setting the bit will make the BG use the "right" pattern table ($1xxx) and clearing it will make the BG use the "left" pattern table ($0xxx)
8x8 Sprites are in the same boat. They can only choose from 256 tiles -- so bit 3 of $2000 selects which pattern table they get their graphics from.
8x16 sprites, on the other hand, can use the whole 512 tiles -- so bit 3 of $2000 is ignored completely when using 8x16 sprites.
If you want a visual example -- load up a game like Super Mario Bros. in FCEUXD (or any emu with a pattern table viewer). Notice how all the graphics for sprites occupy the left pattern table, and all the graphics for the BG occupy the right.
Quote:
I am confused about what vRAM and CHR have to do with one another now.
VRAM is like a generic term for PPU memory. CHR is a specific area of PPU memory. I find the term "VRAM" to be somewhat misleading on the NES, since it's not always RAM (CHR is often ROM, for example).
Anyway... the term "VRAM" usually encompasses all of CHR, Nametables, Attribute tables, and Palettes.
- CHR is the actual 8x8 graphics (ie: your pattern tables)
- Nametables is how those graphics are arranged on the BG
- Attribute tables (which are like a subsection of the nametable) assign which parts of the BG get which palette
- Palettes are the colors to be displayed.
- "VRAM" could be any of the above.
Quote:
What im really trying to do is use the sprites table located at $1000-1FFF in my CHR file. to write a different nametable with different sprites, other than those located in my CHR file a $0000-0FFF.
You're getting your terms crossed. Sprites do not use name tables. Name tables are for the BG only. You're probably thinking of pattern tables.
All you have to do, in this case (assuming you're using 8x8 sprites), is set bit 3 of $2000. That's it.
LDA #%00001000
STA $2000
Just remember that writing to $2000 changes several things -- not just that one bit. The above code, for example, would also disable NMIs, switch to 8x8 sprites, set the PPU Address increment to 1, etc, etc.
If you're using 8x16 sprites -- then each sprite can pick which pattern table it gets its tiles from. The low bit of the tile ID (byte 2 in OAM/Sprite mem) selects which pattern table for each sprite. So if you want them all to use the right table -- then make sure you're using all odd tile IDs.
Quote:
What i assume is that the vRAM already points to this location ($0000) when clearing $2000 on initialization.
Right... when you write 0 to $2000, both BG and sprites will be using $0xxx for patterns. To change that you'll have to write to $2000 again with a new value.