This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade. View original topic
Putting NSF into code
by Link on 2004-11-22 (#237)
I'm trying to get music put into the game I'm making. I'm using MCK to make the NSFs. Is there anyway I can put the music I make with MCK unto my demo rom I'm making. thx
Yeah, first you need to get 3 things from the NSF file.
1. Load address, where in memory you put the actual NSF file (remember to either strip the 128-byte NSF header off, or subtract 128 from the load address).
2. Init address. Load A with the song #, and JSR to this to set stuff up (MCK only supports one song though, AFAIK).
3. Play address, JSR to it 60 times a second (like the the nmi routine).
Don't forget to make sure you're not using any of the RAM used by the NSF for your game. Plus I'd imagine MCK music isn't very optimized for game playback... so it'll likely eat up a lot of CPU time. You might want to consider working on your own music engine.
MCK also has less than optimal memory usage - it eats up random bytes in zeropage ($40-$41, $60-$61, $80-$81, $A0-$A1, $C0-$C1, and $DE-$DF) as well as most of page 7 AND small bits of pages 3, 5, and 6. This also doesn't take into account the incredibly bloated data format it uses for its music.
I personally would not recommend trying to use an MCK-generated NSF in an actual game.
Yeah, I do plan to write my own music engine, but for now I just want to put music into some small demos I'm going to make cause I'll have extra space. I realize MCK is very impracticle, but for now it's the only option I have since I'm not good with NT2. For now it's unneeded, but when I start making a full game I'll defintly make my own music engine. thx
MCK also has less than optimal memory usage - it eats up random bytes in zeropage ($40-$41, $60-$61, $80-$81, $A0-$A1, $C0-$C1, and $DE-$DF) as well as most of page 7 AND small bits of pages 3, 5, and 6.
Good lord, why would it be done like that.
At least that would be easy to fix in the source code, theoretically.
I got this done awhle ago. MCK is really messy. I guess the RAM usage could be changed in the source, but I never got around to check (just decided to use a different NSF). MCK takes random bytes from almost all the ram pages. And it's a huge file. I can fit 2 songs at the most (I've only ever used one though).
I decided to go with the Blaster Master NSF instead, it uses about 8 bytes of zero bage and most of 7th page, which is fine with me. It's 16KBs and has 16 songs so it works out perfect. Thanks for the help