Exactly!
Anything RAM needs initialization and most I/O registers. OAM deosn't matter because the initialization you do to it will decay anyway (but the OAM buffer in RAM must of course be initialized, all sprites' Y-positions must be a value between $F0 and $FF so that sprites are off-screen).
Attribute tables are in VRAM so they must be initialized to all 0s (as a suggestion).
Nametables are also in VRAM and must also be initialized. I always initialize nametables to all $20s (or whatever CHR number my empty space tile has) so that it's easy to draw on without having to draw the entire screen.
If you use CHR RAM that's another part of VRAM to initialize, this time you can just upload your CHR data to fill it entirely, no need to write 0s.
The sound channel enable register $4015 is one of the few things that is initialized by the hardware at boot, but as you say it's cheap to initialize and as Oziphantom said, you never know what kind of environment your game is going to run from, so it's best to not assume a cold boot. I always disable all sound channels (write 0 to $4015) manually to make sure it's muted at boot. That also means I can soft-reset the game and everything will be reinitialized again even with a warm boot.
Porting my game to NES, some newbie questions
Moderator: Moderators
Re: Porting my game to NES, some newbie questions
Progress update...Level loading+dynamic illumination+animation works now:
I'm currently battling a strange bug. Looks like when I change the palette colour in $3F01 during vblank somehow the whole screen flickers, as if it goes blank and is redrawn again. I'll investigate it a bit more and if I can't crack it I'll write about it here with more details.
I'm currently battling a strange bug. Looks like when I change the palette colour in $3F01 during vblank somehow the whole screen flickers, as if it goes blank and is redrawn again. I'll investigate it a bit more and if I can't crack it I'll write about it here with more details.
- rainwarrior
- Posts: 8734
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Porting my game to NES, some newbie questions
Whenever the VRAM address points at a palette address, it becomes the output colour (even when rendering is off). For example, it's common to see a "rainbow" if a game writes the palette outside of vblank.
My guess is that after writing the palette entry, you aren't setting the VRAM address (writes to either $2005 or $2006) again for a long time and it's probably just displaying the colour at $3F02 during that time, causing the flash?
My guess is that after writing the palette entry, you aren't setting the VRAM address (writes to either $2005 or $2006) again for a long time and it's probably just displaying the colour at $3F02 during that time, causing the flash?
Re: Porting my game to NES, some newbie questions
Thanks, that was it. Once I set the address back to $2000 after updating the palette, the flicker disappeared. I had seen that hardware bug on the wiki before, but didn't think it applied to my case.
I'm making good progress. Once the game is ready in the coming weeks, where is correct place(s) to announce it?
I'm making good progress. Once the game is ready in the coming weeks, where is correct place(s) to announce it?
-
- Posts: 1565
- Joined: Tue Feb 07, 2017 2:03 am
Re: Porting my game to NES, some newbie questions
Thanks! Anywhere else NES folk frequently visit?
Also is there anyone here with access to the real hardware who can give my code a quick spin? I'm not doing anything fancy so I don't think there will be any problems, but it is better to make sure. Thanks.
Re: Porting my game to NES, some newbie questions
I can test across at least a few different consoles.
As for other places, the Discord server is pretty active, and a lot of NES stuff gets posted on Twitter.
As for other places, the Discord server is pretty active, and a lot of NES stuff gets posted on Twitter.
Re: Porting my game to NES, some newbie questions
Thanks! I'll contact you privately.