tepples wrote:
But because all NSFs use the same mapper (4 KiB PRG banks in $8000-$FFFF controlled by $5FF8-$5FFF), and this mapper supports switching the entire PRG area, it's not as hard as one might think. NSFs that don't bankswitch would just need a front-end that bankswitches to the right NSF during init, but NSFs that do bankswitch would need their $5FFx writes patched to add a constant.
No offense, but I'd like to make a small addendum to what you said so that others know. If you also use the FDS setting in the NSF header, you can use $6000 - $FFFF. Which includes the following registers; $5FF6 and $5FF7 to control $6000 - $6FFF and $7000 - $7FFF respectively. This feature can also be used for NSFs that are not specifically FDS or those that do not have FDS sound.
-----------------------------------------------
As far as merging other NSFs together, be it one song each or more.
What you want to do is designate a hardwired bank that is always loaded. There is where you would keep your initialization code. Also, if the NSFs have different play entry points, you need to designate a variable to switch the play address entry point. Using this variable and checking it for certain numbers and then load the appropriate play entry point address.
For example;
If you want to merge many Megaman tunes together from various games 1-6. The music code and data is located at $8000 - $BFFF. Init: $8003, play: $8000, load $8000.
Each NSF bank is 4KB. So we'll do the following;
0- $8000 - $8FFF
1- $9000 - $9FFF
2- $A000 - $AFFF
3- $B000 - $BFFF
4- $C000 - $CFFF (hardwired bank)
Set the NSF header at 70h to $00,$01,$02,$03,$04
This is telling the player to load these banks first when the NSF is loaded or when the tune is switched. You can also eliminate other banks, whatever is not used. But that's beyond the basic description of what I'm telling for you to get started.
So, we would have Megaman 1 first. Then we want to append the Megaman 2 banks to the NSF file.
5- $8000 - $8FFF
6- $9000 - $9FFF
7- $A000 - $AFFF
8- $B000 - $BFFF
So, now you have the banks set up.
The code can be written in many different ways, but to try and keep it simple I'll do it this way.
Init:
TAX
LDA TUNE_INDEX,X
STA CORE_CHECK
CMP #$03 ; 4th song is from Megaman 2
BCS SWITCH_BANK
JMP AUDIOIN
SWITCH_BANK:
LDA #$05
STA $5FF8
LDA #$06
STA $5FF9
LDA #$07
STA $5FFA
LDA #$08
STA $5FFB
LDA CORE_CHECK
JMP AUDIOIN_1
TUNE_INDEX:
.DB $00,$01,$02,$03,$04,$05,$06,$07,etc
If there are more than one play entry point addresses, do the following or otherwise just set the play address in the header.
LDA CORE_CHECK
CMP #$03
BCS DRIVER_1
JMP AUDIOIN
DRIVER_1:
JMP AUDIOIN_1
This is just one way to do it. You'll have to get creative in dealing with NSFs that are already bankswitching and those that have banks in other address ranges than I described. I don't really feel like writing out all the possibilities. However, this is enough to get you started if you want to do other NSFs yourself. Even though, I know you asked others to do it for you and it was done.