I've heard it is good practice to wait a while longer than 1 VBlank before doing PPU operations, so it can warm up or something. I'd suggest you call this routine like, 1 or 2 more times.lynxsolaris wrote:Code: Select all
jsr wait_vblank
This seems fine, but... why LDX here? You haven't done anything with it afterwards...Code: Select all
palette: lda #$3F sta $2006 lda #$00 sta $2006 ldx #$00
I'd make the call to wait_vblank the first thing in this routine. Not that it REALLY matters in this case, 'cause you had the PPU off for a really short time (you wrote only 2 tiles), so the VBlank probably hasn't ended by now. But if you wrote more stuff, like a whole screen, we would be in the middle of rendering by now, and if you turned the screen on you'd actually see only part of it on the screen and it'd be probably pretty messed up.Code: Select all
ppuinit: lda #%00000000 ; background at $0000 sta $2000 lda #%00001000 ; show backgrounds sta $2001 jsr wait_vblank lda #$0 sta $2005 lda #$0 sta $2005 rts
It would be messed up for the rest of the frame, when you'd then write 0's to $2005. Well, just kick the VBlank waiting up and the rest is fine in this order.
One small note: there is no need to load A with #$0 twice, just load it once and write twice in a row. Not that there is an error here or anything, only loading once is faster. =)
I think that's it. I see no reason for it not to work. What do you see when you run this? Still the same 1 tile repeated all over?
You know what just crossed my mind? Some emulators cut the first and the last rows of the screen, wich means you'll not be able to see the stuff you wrote... try writing to the second or third row, preferably more to the middle... Try writing your tiles to address $2070 for example, instead of $2000.