blargg in another thread wrote:
Yeah, the basic idea is that an iNES music file is a totally standard iNES ROM whose reset handler reads the track number to play, etc. from zero-page bytes. This way an emulator doesn't need any special handling, other than doctoring the initial values of those zero-page locations before powering up the emulated NES. To change tracks, you repeat the above process. So you never need to know anything about how the music code works, where its routines are, etc. and the music code has full flexibility in how it works, and what mapper it uses. This of course would supplement NSF, rather than replace it, since NSF works fine for most music.
That covers the essential functionality. You could also have the info strings at the beginning of PRG data, so that they are always at offset $10 in the file. And you could have some way of plugging in a NES-based UI, so that it can be booted standalone on a NES. Perhaps the reset code would check for a signature in zero-page; if not present, it jumps to an area where the NES-based front-end can be plugged in, and also specifies routines similar to NSF for changing the track while running.
That covers the essential functionality. You could also have the info strings at the beginning of PRG data, so that they are always at offset $10 in the file. And you could have some way of plugging in a NES-based UI, so that it can be booted standalone on a NES. Perhaps the reset code would check for a signature in zero-page; if not present, it jumps to an area where the NES-based front-end can be plugged in, and also specifies routines similar to NSF for changing the track while running.
I want to make this happen. I have been trying to get my tracker (Pornotracker) to a state where I could release it (I was supposed to release it 3 years ago). It supports raw PCM so exporting to NSF alone isn't going to work. I'll ship the specification with it so hopefully more people will adopt the format in the future.
Let's see what we have here:
- the emulator (or PowerPak or whatever) and the ROM communicate through zero page variables
- the music header sits at the beginning of the ROM ($10 in the file)
- before reset the emulator sets the track number and a signature on ZP, allowing the ROM to know if the emulator supplies an interface for playback control
- when the user changes the CPU is reset (after rewriting the signature and track number)
- use the .nes file extension or define a new one?
What's in the header:
- a signature string (to tell the emulator it's a music file)
- version number
- number of songs
- starting song
- PAL/NTSC/both flag
- title of the song/artist/other info in string format
- track names/length information
Some of the header info should be optional.
Suggestions/comments? Can you think of something else that should be included in the header?