Right now I am working on updating a small number of tiles in a nametable, and have ran into a couple of snags.
What I have are two tables that I would like to use. One table represents the address to be used in $2006:
... where each byte would be stored in $2006 one at a time (I might be able to simplify this part by just writing $20 to the first one, and having the none-$20 values in the table).
The next table is for the tiles that I want to fill those areas of the PPU:
Now, I can get a few to show up, but the code is OBVIOUSLY not going to be optimal, because I can't figure out a good way to get both to index. For my initial tests, I did this:
I have 12 different tiles that will need to be updated upon a button press (this is in NMI, as was recommended to me earlier in IRC), so it would be really bad to do that 12 times. I cannot figure out a good way to do it though :/ If anyone can give me some direction, or some addressing modes to look into, I'd appreciate it.
My second snag is the original nametable itself. After manipulating it as above, the whole nametable seems to shift down a couple/few pixels. I found a post by Disch that says to write to the scroll after doing the updates, which helped to stop the entire original nametable from shifting WAY off from the original placement, but it still shifts a tad now. I'm not sure how to keep it stable. If there are any ideas on what I'm not doing correctly, any insight would be appreciated!
What I have are two tables that I would like to use. One table represents the address to be used in $2006:
Code:
filltopleft:
.byte $20,$66,$20,$67,$20,$68,$20,$69
.byte $20,$86,$20,$87,$20,$88,$20,$89
.byte $20,$a6,$20,$a7,$20,$a8,$20,$a9
.byte $20,$c6,$20,$c7,$20,$c8,$20,$c9
.byte $20,$66,$20,$67,$20,$68,$20,$69
.byte $20,$86,$20,$87,$20,$88,$20,$89
.byte $20,$a6,$20,$a7,$20,$a8,$20,$a9
.byte $20,$c6,$20,$c7,$20,$c8,$20,$c9
... where each byte would be stored in $2006 one at a time (I might be able to simplify this part by just writing $20 to the first one, and having the none-$20 values in the table).
The next table is for the tiles that I want to fill those areas of the PPU:
Code:
x_tiles:
.byte $80,$81,$00,$83
.byte $00,$91,$92,$93
.byte $00,$a1,$a2,$a3
.byte $b0,$b1,$00,$b3
.byte $80,$81,$00,$83
.byte $00,$91,$92,$93
.byte $00,$a1,$a2,$a3
.byte $b0,$b1,$00,$b3
Now, I can get a few to show up, but the code is OBVIOUSLY not going to be optimal, because I can't figure out a good way to get both to index. For my initial tests, I did this:
Code:
lda filltopleft
sta $2006
lda filltopleft+1
sta $2006
lda x_tiles
sta $2007
sta $2006
lda filltopleft+1
sta $2006
lda x_tiles
sta $2007
I have 12 different tiles that will need to be updated upon a button press (this is in NMI, as was recommended to me earlier in IRC), so it would be really bad to do that 12 times. I cannot figure out a good way to do it though :/ If anyone can give me some direction, or some addressing modes to look into, I'd appreciate it.
My second snag is the original nametable itself. After manipulating it as above, the whole nametable seems to shift down a couple/few pixels. I found a post by Disch that says to write to the scroll after doing the updates, which helped to stop the entire original nametable from shifting WAY off from the original placement, but it still shifts a tad now. I'm not sure how to keep it stable. If there are any ideas on what I'm not doing correctly, any insight would be appreciated!