Let's say I want to arbitrarily change tiles on the background. Intuition says that the way I would do that is to simply set the value of PPUADDR to the location I want, and then write the tile's nametable entry. Easy enough, right? So here's my attempt at a proof of concept, where I set the starting point of where to draw, and then draw the next 256 tiles.
But it doesn't work the way I would expect it to. Instead of starting in the middle of the first row of tiles, I get a weird blank space on the right of the screen, as if the background was scrolled. After puzzling over it for a while, I tried on a whim zeroing out the PPUADDR, and (wouldn't you know it) that worked! Hurrah!
However, based on what I've read, I shouldn't need to do this. Why does this behave the way it does? Is something else using PPUADDR? Where is this documented?
Code:
LDA PPUSTATUS
LDA #$20
STA PPUADDR
LDA #$30
STA PPUADDR
LDA #1
doloopy:
STA PPUDATA
INX
BNE doloopy
; omitting warmup code.
LDA #$20
STA PPUADDR
LDA #$30
STA PPUADDR
LDA #1
doloopy:
STA PPUDATA
INX
BNE doloopy
; omitting warmup code.
But it doesn't work the way I would expect it to. Instead of starting in the middle of the first row of tiles, I get a weird blank space on the right of the screen, as if the background was scrolled. After puzzling over it for a while, I tried on a whim zeroing out the PPUADDR, and (wouldn't you know it) that worked! Hurrah!
Code:
LDA PPUSTATUS
LDA #$20
STA PPUADDR
LDA #$30
STA PPUADDR
LDA #1
doloopy:
STA PPUDATA
INX
BNE doloopy
; NEW CODE
LDA PPUSTATUS
LDA #0
STA PPUADDR
STA PPUADDR
LDA #$20
STA PPUADDR
LDA #$30
STA PPUADDR
LDA #1
doloopy:
STA PPUDATA
INX
BNE doloopy
; NEW CODE
LDA PPUSTATUS
LDA #0
STA PPUADDR
STA PPUADDR
However, based on what I've read, I shouldn't need to do this. Why does this behave the way it does? Is something else using PPUADDR? Where is this documented?
Attachment:
File comment: Comparison of the two programs.
roma_vs_romb.png [ 7.81 KiB | Viewed 3395 times ]
roma_vs_romb.png [ 7.81 KiB | Viewed 3395 times ]
Attachment:
File comment: ROM A shows the undesired behavior when PPUADDR is not zero'd out.
roma.nes [24.02 KiB]
Downloaded 113 times
roma.nes [24.02 KiB]
Downloaded 113 times
Attachment: