Porting my game to NES, some newbie questions

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Porting my game to NES, some newbie questions

Post by Pokun »

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.
Haplo
Posts: 16
Joined: Wed Jan 18, 2023 1:14 am

Re: Porting my game to NES, some newbie questions

Post by Haplo »

Progress update...Level loading+dynamic illumination+animation works now:

Image

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.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Porting my game to NES, some newbie questions

Post by rainwarrior »

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?
Haplo
Posts: 16
Joined: Wed Jan 18, 2023 1:14 am

Re: Porting my game to NES, some newbie questions

Post by Haplo »

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?
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Porting my game to NES, some newbie questions

Post by Oziphantom »

Haplo
Posts: 16
Joined: Wed Jan 18, 2023 1:14 am

Re: Porting my game to NES, some newbie questions

Post by Haplo »

Oziphantom wrote: Fri Jan 27, 2023 3:08 am viewforum.php?f=22
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.
Fiskbit
Posts: 891
Joined: Sat Nov 18, 2017 9:15 pm

Re: Porting my game to NES, some newbie questions

Post by Fiskbit »

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.
Haplo
Posts: 16
Joined: Wed Jan 18, 2023 1:14 am

Re: Porting my game to NES, some newbie questions

Post by Haplo »

Thanks! I'll contact you privately.
Haplo
Posts: 16
Joined: Wed Jan 18, 2023 1:14 am

Re: Porting my game to NES, some newbie questions

Post by Haplo »

The game is released!

viewtopic.php?t=24421

Thanks everyone for your help.
Post Reply