Ah, I get it. So like:
Code: Select all
start:
.db ;bytes for screen 0
start:
.db ;bytes for screen 1
Yeah, can't be done that way. How would the assembler know what label lda start refers to when there are two "start"s? Personally, I name them screenX_Y. X is the set number, Y is the actual screen number in hex.
Displaying a screen is where it starts to get a little tough.
To update tiles in a nametable, you use $2006, and $2007. Easy mode involves no scrolling (for now).
First disable rendering and set the PPU to increment by one by writing the relevant bits to $2000.
Then write the address of a name table to $2006 in two writes.
Code: Select all
;No indentation for the instructions, but you'll get the point.
lda #$20
sta $2006;Sets the high byte of the address $2007 will write to.
lda #$00
sta $2006;Sets the low byte of the address $2007 will write to.
sta $2007;Writes #$00 to PPU address $2000. (which is the first tile of the first name table)
lda #$FF
sta $2007;Writes #$FF to PPU address $2001. (which is the tile to the right of the first tile)
You'll see that every write increases the destination address by one. This is so you don't have to keep setting $2006 which is slow. It's also possible to make the destination address increase by 32 each write. This is so you can write a column of tiles. (256/8 = 32 tiles across. So each write will give you the address of the tile below the last one written)
In any case:
You know that your metatiles contain a reference to 4 actual tiles.
After setting the name table address with $2006:
1. You load the first metatile in your screen's index number.
2. You load the top left tile of that metatile using the index.
3. You write this to $2007.
4. You load the top right tile of that metatile using the index.
5. You write this to $2007.
6. load the second metatile in your screen's index number.
(Why? Because the other two tiles in the first metatile refer to the row of tiles BELOW the one you're dealing with)
7. Repeat steps 2-5.
8. Load the third tile... etc etc etc until the entire of the first row is written
9. Load the first metatile in your screen's index number AGAIN.
10. Load the BOTTOM left tile of that metatile using the index.
11. You write this to $2007.
And from there you should be able to figure out the rest for tiles, but probably not attributes. Reenable rendering when you're done writing to $2007, and you'll see the result.
There are ways to load each metatile in the screen only once, but make some code that is easy to do and works before you get clever.
For attributes, you do kind of the same thing. Write the address of the attribute tile you want to update to $2006, then write the actual attribute to $2007. Because of your metatile format, this might actually be really easy for you to figure out. (It's hard as hell to do in my format
... I digress)
That's... about all I will say. Good luck! Try it, and post some code if you get stuck! I've never asked, will your game scroll? If yes, hopefully only in one direction at a time? If no..