My First NES Homebrew
One of my gifts to my wife, Nancy, for her birthday this year was the Happy Birthday song, chiptune style. It’s an actual NES program, hand-coded in 6502 assembly. This is the first original NES program I’ve written, and could be considered my first homebrew or even demo. While you can download the ROM and run it yourself, here’s a video of it running in Nestopia, an NES emulator [YouTube link]:
Some interesting stats about this program:
- The song data is 485 bytes for 42 seconds of music.
- The assembled code is 575 bytes.
- It uses 32 bytes of RAM at runtime, not including stack.
- It uses probably 10 bytes of stack.
- The graphics are 8 kilobytes.
- The ROM file is 24 kilobytes (mostly zeroes, though).
- The video file I uploaded to YouTube was 784 kilobytes.
Much thanks to BunnyBoy and MetalSlime for their “Nerdy Nights” NES coding tutorials on Nintedo Age. The NES sound engine is all MetalSlime’s genius. I just plugged in the notes. The music itself was adapted from some sheet music I found. The lame “graphics” are all mine. I don’t know how to do much other than scroll the background and change the color palette, at the moment.
Also, the NesDev archive and wiki were invaluable as a technical references. For the toolchain, I used cc65, which includes a very nice assembler and linker for 6502. It would be nice to run this on actual hardware at some point using flash cartridge like the PowerPak.
I started learning NES programming only a few months ago. It’s just one of those useless skills I’ve wanted to learn for a while now. I probably had a bit of head start since I learned 6502 assembly back in the day on an Apple ][. Granted, that was a long time ago, but it’s a very simple CPU architecture so it comes back pretty fast.