4.5.9 help with better bank management

SciNEStist

Well-known member
I'm hoping someone migth have a suggestion for me that might simplify adding more to my game. It's been a bit of a struggle to keep everything fitting into the banks.

So far, I have moved screen loading to bank 16 following this tutorial, as I was advised it is good idea:

I have also followed this tutorial so I could fit more objects/ animations in after running into a limit pretty early:

I am now at the point where I only have about half of my ai behaviours used, and I can no longer add new ones or add any other code to handlegametimer. Here is what my banks are currently looking like:

space.png

I have no plans to use any of the text or hud, so I have removed a lot of stuff treferencing them in the scripts/banks, so that leaves quite a bit of space available.

the onlyother info I found is this thread:

My question is, is there anything I can do similar to that bank16 move that will give me a lot more room for programming? Is there certain banks that will work better than others for putting code? Does anyone have any other advice?
 
Last edited:

JamesNES

Well-known member
There's tons you can do to free up space!

You can move your input scripts out of the static bank into anywhere else will free up a ton in #$1F. You've seen how much crap I've jammed into my pig game, but the static bank is still 30% empty. The only thing I found doing that with default NES Maker scripts was a jump script used the player character's height which is stored in #$1C, but it's a constant anyway so I just hard coded it. If I want to change my player's height I just can't use NES Maker's interface, have to change it in code.

If you've got some particularly chunky AI scripts, check to see if they actually use anything in bank #$1C. If they don't, you can move them to another bank and jump to them via the static bank, then jump back.

I'm in the midst of redoing my vertical scrolling stuff as the first go wasn't good enough, all the logic is in bank #$15 but I have to get the nametable data from whatever screen bank it's in. So in bank #$15 I jump to the static bank which has something like:

Code:
loadRow:
  LDA prevBank
  STA tempPrevBank ;;my own variable

  SwitchBank screenBank
  ;;can do stuff in the screen bank here

  SwitchBank #$15

  LDA tempPrevBank
  STA prevBank

RTS

That way I can take up the bare minimum in #$1F and can put all my gameplay stuff in any bank I want.

And if you actually manage to fill up all the empty banks, but aren't using a chunk of the over or underworld screens, you can delete them from your project and free up more space. I'm not using the underworld so that alone is another 8 banks I can put graphics and code in.

So really the only bank that's worth worrying about is #$1F, you can always tap out of another bank into another one if it gets too tight. Feel free to DM me if you want help with something specific.
 

5kids2feed

Well-known member
@JamesNES I would DM you if i could, but for some reason I canā€™t DM anyone unless they DM me first (other member have this issue too šŸ˜¢).

But what I wanted to ask was.. How would you go about deleting the underworld screens from your project?
 

JamesNES

Well-known member
Probably better to post here anyway.

Open up the screen banks files in System/Bank from 08 to 0F, just delete everything in there. Then you load up Bank16.asm and delete all the references to "map2" addresses. I haven't actually done this yet so I don't know if there are other references you have to delete, but compiling will tell you what to get rid of. As long as you don't try warping to anywhere invalid it should be fine.
 

5kids2feed

Well-known member
Probably better to post here anyway.

Open up the screen banks files in System/Bank from 08 to 0F, just delete everything in there. Then you load up Bank16.asm and delete all the references to "map2" addresses. I haven't actually done this yet so I don't know if there are other references you have to delete, but compiling will tell you what to get rid of. As long as you don't try warping to anywhere invalid it should be fine.
Saweet! Thanks!
 

JamesNES

Well-known member
I decided I wanted to keep some rows on the underworld, as that's where I put my title screen and 8x8 stuff, and I didn't want to go and change all the references to them, but I freed up banks 08, 0A, 0B, 0C and 0F. This was fiddly, would not recommend. If you want to keep a couple of rows in the underworld make sure they are in the top rows so you don't have to do so much work rearranging the tables in bank 16. If you aren't going to use every single screen then this is a great way to get more space.

report.png
 

SciNEStist

Well-known member
Could anyone provide a rough laymans guide on how to move things between banks? like a good example would be how to put code into another bank and how to execute it.
 

JamesNES

Well-known member
Open up one of the blank banks like 1A in the system\banks folder and you can just write new subroutines in it. Then when you want to run the code there you SwitchBank #$1A and jsr to your routine, then ReturnBank in the original file. If you load up MainGameLoop.asm you can see it doing that for things like the game timer.

Looking at that now, there's something I forgot having changed that could be a big deal if you're using the Handle Game Timer script include:

Code:
        JSR doHandleInputReads
        LDA #$00
        STA spriteRamPointer
        SwitchBank #$18
            JSR doScreenPreDraw
        ReturnBank
        JSR doHandleObjects
        JSR doCamera 
        ;;;;;;;;;;;;;;;;;; SET GAME SCREEN
        ;;;;;; IN THE EVENT THERE IS NO ATTATCHED CAM SCRIPT TO DO IT

        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        SwitchBank #$18
            JSR doScreenPostDraw
            .include SCR_HANDLE_GAME_TIMER    ;;;<----- what!!
        ReturnBank
        JSR doCleanUpSpriteRam

The include is there, so it's wasting space in the static bank. If you take ".include SCR_HANDLE_GAME_TIMER" and put that anywhere in Bank18.asm, it'll free up space in the static bank. You won't be able to switch to other banks in the script then but I use handle game timer for a ton of logic stuff and work around that, so this would be costly to leave there.

You can only switch banks like that though from the static bank, that's what my code further up was about.

So if you've got a huge AI script that doesn't need anything at all in bank 1C (I don't think many would), you can instead copy it out to a different bank.

If this is still too vague I could write up how to do it for an AI script as an example. I've been wanting to write up how to get inputs out of the static bank too cos that's just crazy they're in there, but I haven't got around to it quite yet.
 

SciNEStist

Well-known member
Thank you very much!, that does clear up some of the idea for me.

Player inputs do indeed take up a lot in my game since I have 2 players, and for player 1 I have 2 game states. (MultiPlayer and SinglePlayer). I already figured out a way to not have to add the scripts 4 times each (one for each of my 4 characters you can play as) , I think a lot of people might benefit from a tutorial on moving the inputs to another bank though.
 

JamesNES

Well-known member
Once you get your head around it you'll be like damn... 512kb is pretty much infinite space! I've got at least a dozen extra "full size" graphics files in there at the moment and if you're just using it for code, you'll run out of ideas before space.

I moved my input scripts to the text bank, so now I can go nuts. I'll have to write it up soon, or I'll forget how to do it myself. I probably read my old tutorials more than anybody haha
 
Open up one of the blank banks like 1A in the system\banks folder and you can just write new subroutines in it. Then when you want to run the code there you SwitchBank #$1A and jsr to your routine, then ReturnBank in the original file. If you load up MainGameLoop.asm you can see it doing that for things like the game timer.

Looking at that now, there's something I forgot having changed that could be a big deal if you're using the Handle Game Timer script include:

Code:
        JSR doHandleInputReads
        LDA #$00
        STA spriteRamPointer
        SwitchBank #$18
            JSR doScreenPreDraw
        ReturnBank
        JSR doHandleObjects
        JSR doCamera 
        ;;;;;;;;;;;;;;;;;; SET GAME SCREEN
        ;;;;;; IN THE EVENT THERE IS NO ATTATCHED CAM SCRIPT TO DO IT

        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        SwitchBank #$18
            JSR doScreenPostDraw
            .include SCR_HANDLE_GAME_TIMER    ;;;<----- what!!
        ReturnBank
        JSR doCleanUpSpriteRam

The include is there, so it's wasting space in the static bank. If you take ".include SCR_HANDLE_GAME_TIMER" and put that anywhere in Bank18.asm, it'll free up space in the static bank. You won't be able to switch to other banks in the script then but I use handle game timer for a ton of logic stuff and work around that, so this would be costly to leave there.

You can only switch banks like that though from the static bank, that's what my code further up was about.

So if you've got a huge AI script that doesn't need anything at all in bank 1C (I don't think many would), you can instead copy it out to a different bank.

If this is still too vague I could write up how to do it for an AI script as an example. I've been wanting to write up how to get inputs out of the static bank too cos that's just crazy they're in there, but I haven't got around to it quite yet.

I haven't been able to get bank switching to work.

In the MainGameLoop.asm, I tried adding the following code: as a test

SwitchBank #$18
JSR testBankSwitch
ReturnBank

I then added the following code to the Bank18.asm:

testBankSwitch:
RTS

But when I tried to compile, it said the "JSR testBankSwitch" code in MainGameLoop.asm was an "Unknown Label".
 

JamesNES

Well-known member
There are separate bank18 files for adventure/maze modules so if you put it in Bank18.asm it won't work :p

You can find which one your project is using in the script settings window.
 

Vasyan

New member
There's tons you can do to free up space!

You can move your input scripts out of the static bank into anywhere else will free up a ton in #$1F. You've seen how much crap I've jammed into my pig game, but the static bank is still 30% empty. The only thing I found doing that with default NES Maker scripts was a jump script used the player character's height which is stored in #$1C, but it's a constant anyway so I just hard coded it. If I want to change my player's height I just can't use NES Maker's interface, have to change it in code.

If you've got some particularly chunky AI scripts, check to see if they actually use anything in bank #$1C. If they don't, you can move them to another bank and jump to them via the static bank, then jump back.

I'm in the midst of redoing my vertical scrolling stuff as the first go wasn't good enough, all the logic is in bank #$15 but I have to get the nametable data from whatever screen bank it's in. So in bank #$15 I jump to the static bank which has something like:

Code:
loadRow:
  LDA prevBank
  STA tempPrevBank ;;my own variable

  SwitchBank screenBank
  ;;can do stuff in the screen bank here

  SwitchBank #$15

  LDA tempPrevBank
  STA prevBank

RTS

That way I can take up the bare minimum in #$1F and can put all my gameplay stuff in any bank I want.

And if you actually manage to fill up all the empty banks, but aren't using a chunk of the over or underworld screens, you can delete them from your project and free up more space. I'm not using the underworld so that alone is another 8 banks I can put graphics and code in.

So really the only bank that's worth worrying about is #$1F, you can always tap out of another bank into another one if it gets too tight. Feel free to DM me if you want help with something specific.
Do you have instructions on how to do this?
 
Top Bottom