pub fn example_music_rom() -> Vec<u8> ⓘExpand description
A homebrew NROM with a tiny music driver, written for the ripper’s tests and docs.
No commercial code: the program is this function, assembled at $C000
of a 16 KiB image, so the board also shows it at $8000.
Reset calls INIT (A = song, ignored), which turns the channels on and
zeroes the driver’s two RAM bytes, waits two vblanks (the PPU ignores
$2000 until it has warmed up), enables the vblank NMI and spins. The NMI
handler saves the registers and calls BODY, the game’s per-frame work,
which starts an OAM DMA ($4014), strobes the controller ($4016) and
calls PLAY; the main loop calls an empty IDLE routine forever, so the
NMI often arrives just as a JSR is next. Every eighth call PLAY steps an eight-note scale on pulse 1
and, through a nested TRI routine, on the triangle. So a trace of it has
a driver that is not the NMI handler, an enclosing routine that is not the
driver, a nested routine inside it, two non-APU writes in $4000-$4017,
and reset code that falls through onto the address the IRQ vector names.
The addresses are in example.