[4.5.X] Bank Switching for Songs and SFX

Jonny

Well-known member
I wanted to open a discussion about bank switching to get more space for songs. Perhaps a tutorial if anyone has already done it. A big ask I know! Mugi has given some great tips and info about how this could be done. With that advise this is what I'm thinking, please correct me if I'm going down the wrong path with this...
  • New music bank will include a duplicate of the sound engine.
  • Sound effects and instruments will also be duplicated.
  • Extra songs will have identical names to those in the original bank1B. My thinking is to preserve some functionality of NM system for screen song selecting ?
  • Switch bank in doLoadScreen as done with graphics. Initialization script seems to be where it can be changed.
  • Set up screen flag for "use primary music bank / use secondary music bank" OR use overworld / underworld.
Does this seem feasible? Any help would be greatly appreciated.
 
Last edited:

dale_coop

Moderator
Staff member
Mugi did it. So, it might be feasible ;)
But... how to duplicate all the sound engine, the songs & sfx names... it might not compile (with, I presume, a ton of "label already exists" errors).
 

Jonny

Well-known member
Mugi did it. So, it might be feasible ;)
But... how to duplicate all the sound engine, the songs & sfx names... it might not compile (with, I presume, a ton of "label already exists" errors).

So far no compiling errors but I get a green screen when game loads so we'll call that a hard fail for now :( although I'm not trying to have both at the moment, just get a different bank to work.

To begin with all I'm trying to do is use bank 1A instead of 1B keeping everything the same just swapping over what is in each bank. Then the two scripts I can find which bankswitch to 1B and changed those to 1A. I can't even get that part to work atm but will keep trying. Seems pretty easy but I guess that's naive and there's a lot more to it.
 

Knietfeld

Member
Maybe you've figured this out already, but there are three scripts where it bankswitches to 1B, Initialization, MainGameLoop, and NMI. I just switched the Bank1B script with the Bank1A script in NESMaker's project settings and made new versions of those three scripts where I just changed the 1B to 1A and it didn't work... until I remembered to use project settings to swap out those three scripts for my new three scripts. Then it worked perfectly. I haven't figured out how you could store music in more than one bank and use it yet.
 

Jonny

Well-known member
Mugi has been helping me with it on discord. You should check that out because you'll understand it a lot better than I do. I was missing the NMI yeah which CutterCross explained. It's in the general help section.
 

Knietfeld

Member
I've never really looked at Discord much. I checked it out. Boy, those guys over there are downers sometimes. I understand what Mugi is talking about for the most part and I agree it would be a bit much to try to explain in a tutorial. Pre compiling the code is a good way to avoid having "label already defined" errors and would save you the trouble of changing every label in a copied file. I was messing around with it because I like to solve puzzles but if you feel like you've got the help you need I'll just step out. Good Luck!
 

dale_coop

Moderator
Staff member
@Jonny is you figure out how to use your two banks for the music, I would love you write a tutorial about that <3
This question has been asked so many times.
 

Jonny

Well-known member
@Jonny is you figure out how to use your two banks for the music, I would love you write a tutorial about that <3
This question has been asked so many times.

Mugi more or less told us how to do it on discord but I haven't attempted it yet. I'm on holiday this week but I'll try to figure it out when I get back.

@Knietfeld I think you're more likely to get it to work than I am tbh or at least quicker. Would appreciate the help if you had time. I'll let you know how I get on after my hols unless you figure it out before then which is all the better.
 

Knietfeld

Member
I'll keep trying with it then.
From what I've done so far, I don't think pre compiling the bank is going to work. The code relies on variables set up in zero page and I don't know any way to properly deal with that. It looks like changing all the labels that are already defined is going to be the possible solution for me.
 

Jonny

Well-known member
I'll keep trying with it then.
From what I've done so far, I don't think pre compiling the bank is going to work. The code relies on variables set up in zero page and I don't know any way to properly deal with that. It looks like changing all the labels that are already defined is going to be the possible solution for me.
I tried having two sound engines each with its own compiled songs/SFX (NOT named AllSongs_andSFX). Searched for all the : to replace them with B: so all the labels were different, opened up loads more errors. I gave gave up at "can't find address" errors. Pretty sure I went about some part the wrong way.
 

Knietfeld

Member
I just finished the tedious part of checking through duplicate labels in GGSound.asm, seeing if they were referenced anywhere else in the game and making accomodations for anything that was and I tried compiling it and it did compile... And also caused some major graphical glitches. If I started the game from the underworld it played my Bank1A music like I wanted and if I started in overworld it played Bank 1B music like I wanted, and if I warped to overworld from underworld it switched the song to 1B music but didn't change the tempo and the instruments were weird. But it was definitely the right song. Going from overworld to underworld just crashed. But it's progress!

I'm using two famitracker projects that aren't very similar. Totally different instruments and different number of songs and sfx. I think that's why there's weirdness with the music, as well as maybe I could add a trigger to the warp routine where it always restarts the song when you go from under to overworld or vice versa. I think the song list, sfx list, and instruments list have to at least have the same number in both lists. I suspected that from the start but I wanted to try making them real different to start.
 

Jonny

Well-known member
I was planning to keep as much as possible the same, instruments, SFX, number of songs. Did you try something like that where most things are the same?
 

Knietfeld

Member
I wanted to start with it as diverse as I could then work my way back. It's been a while since I set aside time for NESMaker. Before my break from NESMaker I got it working if the instruments are the same for the first song, but I think at the time, if the songs were even a different length it would mess up on any songs after that. Forcing any songs to restart when warping to a different map helped but it needed more.

Tonight I modified the bit that initializes song and sound lists in Initialization.asm and made it so it could load up the lists depending on whichever map you are loading with overworld loading from music bank 1B and underworld loading from 1A. And I set up the warp routine to jsr to that bit of the initialize routine every time it warps to a different screen and it's working perfectly now. I've only tested it with a few famitracker files, but it seems to be working as it should.

I will happily share my modified files and give instructions for how to utilize the changes, but I'll need a little time to pull all the files together and specify what each person will have to do for themselves (like make your own AllSongs_WithSFX_1A.asm). So please continue to be patient.
 

Jonny

Well-known member
@Knietfeld I don't know if this will be helpful but Mugi mentioned a few things on NM discord about adding a line to testbat.bat and some other info...


The furthest I got was having the music (and engine) on two different banks. I kept the .asm identical in both. When I change one of them to a file which was not identical I got pages of 'can't find address' errors and other errors.

Really appreciate your work on this. I have been attempting it but tbh I think this is out of my skillset atm. From what I can gather so far, keeping as much identical as possible is best even if its just to eliminate it from being a cause of errors. For my own project we are keeping the instruments and SFX and amount of songs the same and in the same order on both halves.

All the best with it, sounds like you're making really good progress.
 

Knietfeld

Member
Hey, I posted a new tutorial and it has a really original name.

 
Top Bottom