I put this in newbie help because I'm assuming I'm just being stupid and missing something. But I've searched for more detailed documentation on $2006 and didn't find much outside of NEStech doc, it directs you to Loopy's $2006/2007 documentation but I could find that anywhere...
So I've been working through nerdy nights but I've found something weird that I can't find reasoning for.
So to be clear here's my code, Just the standard stuff
So first off I'm testing on the NESDEV1 and not an emu or powerpak.
The issue is usually when I power up the console with the standard two vblank waits (one before clearing mem and one after) before loading palettes and NT they fail. I get the sprites (makes sense), but both palettes and full NT aren't loaded. If I hit reset, no problem everything is fixed. Keep in mind this isn't EVERYTIME I power on the console but it's most of the time.
I was able to easily fix the problem by adding and extra vblank wait (commented out in the code above). It didn't really matter if I put it before or after disabling rendering, I still fixed the problem.
Some things I wondered: Maybe there is some sort of bug with the NESDEV1, I've never seen this problem with a standard NES rom though. Also according to nesprgmn doc if you want to write a bunch to VRAM you can just turn off the PPU and turn it back on when your done. That's basically what's being done here except there are also a few extra vblank waits and large clear mem loop added and there is still a problem. Out of curiosity I tried just having one vblankwait and I usually had the same problem. But sometimes I could get the NT to load but not palettes which I though was interesting since I'm doing palettes first.
So the only thing I can think of is the PPU needs some more time to start up or something before using $2006. But I would imagine other people have seen this if that's the case. However if most people aren't testing simple programs like this on the NES (or are using a powerpak which wouldn't show the problem) no one really sees it. So what's the deal?
So I've been working through nerdy nights but I've found something weird that I can't find reasoning for.
So to be clear here's my code, Just the standard stuff
Code:
.bank 0
.org $C000
vblank_wait: ; wait for vblank to make sure PPU is ready
BIT $2002
BPL vblank_wait
RTS
RESET:
SEI ; disable IRQs
CLD ; disable decimal mode
LDX #$40
STX $4017 ; disable APU frame IRQ
LDX #$FF
TXS ; Set up stack
INX ; now X = 0
STX $2000 ; disable NMI
STX $2001 ; disable rendering
STX $4010 ; disable DMC IRQs
JSR vblank_wait
clear_mem:
LDA #$00
STA $0000, x
STA $0100, x
STA $0300, x
STA $0400, x
STA $0500, x
STA $0600, x
STA $0700, x
LDA #$FE ;clear sprite mem by placing them off screen
STA $0200, x
INX
BNE clear_mem
JSR vblank_wait
; JSR vblank_wait ;two vblank waits are appaently not sufficient...
;;;LOAD PALETTES, sprites, then NT
.org $C000
vblank_wait: ; wait for vblank to make sure PPU is ready
BIT $2002
BPL vblank_wait
RTS
RESET:
SEI ; disable IRQs
CLD ; disable decimal mode
LDX #$40
STX $4017 ; disable APU frame IRQ
LDX #$FF
TXS ; Set up stack
INX ; now X = 0
STX $2000 ; disable NMI
STX $2001 ; disable rendering
STX $4010 ; disable DMC IRQs
JSR vblank_wait
clear_mem:
LDA #$00
STA $0000, x
STA $0100, x
STA $0300, x
STA $0400, x
STA $0500, x
STA $0600, x
STA $0700, x
LDA #$FE ;clear sprite mem by placing them off screen
STA $0200, x
INX
BNE clear_mem
JSR vblank_wait
; JSR vblank_wait ;two vblank waits are appaently not sufficient...
;;;LOAD PALETTES, sprites, then NT
So first off I'm testing on the NESDEV1 and not an emu or powerpak.
The issue is usually when I power up the console with the standard two vblank waits (one before clearing mem and one after) before loading palettes and NT they fail. I get the sprites (makes sense), but both palettes and full NT aren't loaded. If I hit reset, no problem everything is fixed. Keep in mind this isn't EVERYTIME I power on the console but it's most of the time.
I was able to easily fix the problem by adding and extra vblank wait (commented out in the code above). It didn't really matter if I put it before or after disabling rendering, I still fixed the problem.
Some things I wondered: Maybe there is some sort of bug with the NESDEV1, I've never seen this problem with a standard NES rom though. Also according to nesprgmn doc if you want to write a bunch to VRAM you can just turn off the PPU and turn it back on when your done. That's basically what's being done here except there are also a few extra vblank waits and large clear mem loop added and there is still a problem. Out of curiosity I tried just having one vblankwait and I usually had the same problem. But sometimes I could get the NT to load but not palettes which I though was interesting since I'm doing palettes first.
So the only thing I can think of is the PPU needs some more time to start up or something before using $2006. But I would imagine other people have seen this if that's the case. However if most people aren't testing simple programs like this on the NES (or are using a powerpak which wouldn't show the problem) no one really sees it. So what's the deal?