[4.5.x] Move doLoadScreen to Bank 16

After sharing it with CluckFox and Bucket Mouse in the Discord, we figured out that moving a big chunk of doLoadScreen.asm into Bank 16 is possible and saves a ton of space in the static bank (like 15%).

First you need to copy out the middle section of doLoadScreen.asm. By default it's line 50:

Code:
LoadBackgroundPalettes newPal
    JSR doWaitFrame
        ;; We wait this frame because the LoadBackgroundPalettes routine
        ;; sets bckpal variables and activates the update palette.
        ;; waiting this frame holds up on the next routine until the
        ;; background palettes are loaded into the PPU.
    ;LoadObjectPalettes #$00
   
    LoadObjectSubPalettes spriteSubPal1, #$00
    LoadObjectSubPalettes spriteSubPal2, #$04
    LoadObjectSubPalettes spriteSubPal3, #$08
    LoadObjectSubPalettes spriteSubPal4, #$0C

...

to just past line 414:

Code:
...
        LoadChrData temp, #$08, #$00, #$80, MonsterAddressLo, MonsterAddressHi, monsterTableOffset
        ;arg0 - bank where graphics live
        ;arg1 - row
        ;arg2 - column (by 10s...must end in zero)
        ;arg3 - how many tiles to load.  If 00, will load whole sheet.
        ;arg4 - Label in bank 16 table, low.
        ;arg5 - Label in bank 16 table, hi.
        ;arg6 - Bank 16 table offset
            JSR doWaitFrame

Paste this into a new file, adding

Code:
doLoadScreen16:

to the top of the file, and putting an RTS at the bottom. Save it in your project directory as doLoadScreen16.asm.

Back in doLoadScreen.asm, add this at line 39, where you removed all the code:

Code:
    SwitchBank #$16
    JSR doLoadScreen16
    ReturnBank

Next you need to include the new file in Bank 16.

In NES Maker, go to Project Settings -> Script Settings -> Add, then fill it out like this:

Name: Load Screen Bank 16
Define: SCR_LOADSCREEN16

Then hit okay. On the right, navigate to where you saved the doLoadScreen16.asm and double click it.

Next open bank 16, which is toward the top in the script list.

You want to add

Code:
.include SCR_LOADSCREEN16

in here. I add it with the other includes at line 494 so they're together, but I don't think it matters.

That should be it. The only issue we've found is if your screenbytes are loaded in Post Screen Load, you need to move them into Extra Screen Load, ie somewhere before the switch to bank 16.
Amazing! Where do I find doLoadScreen.asm? Or doubt, do you know if you can increase the player's frame count?
 

dale_coop

Moderator
Staff member
The doLoadScreen.asm script is in the "GameEngineData\Routines\BASE_4_5\Game\Subroutines" folder.

What do you mean by "player's frame count"?
 

dozer8383

New member
I can't seem to find doLoadScreen.asm in the project settings. Is there a different way to get to it?
Edit: Just realized someone asked the exact same thing.
Edit 2: I really can't find that file in my project settings. Nor the Scripts tab.
 
Last edited:
Não consigo encontrar doLoadScreen.asm nas configurações do projeto. Existe uma maneira diferente de fazer isso?
Edit: Acabei de perceber que alguém perguntou exatamente a mesma coisa.
Edição 2: Eu realmente não consigo encontrar esse arquivo nas configurações do meu projeto. Nem a guia Scripts.
Este é o caminho. Ele está na pasta de sub-rotinas na versão 4.5.9.
exemplo: NESmaker_4_5_9 \ GameEngineData \ Routines \ BASE_4_5 \ Game \ Subroutines
1639649417900.png
 
Não consigo encontrar doLoadScreen.asm nas configurações do projeto. Existe uma maneira diferente de fazer isso?
Edit: Acabei de perceber que alguém perguntou exatamente a mesma coisa.
Edição 2: Eu realmente não consigo encontrar esse arquivo nas configurações do meu projeto. Nem a guia Scripts.
Se precisar de mais ajuda, me envie uma mensagem. Do you have a website with your project?
 

IMBrendan

Member
Amazing! Where do I find doLoadScreen.asm? Or doubt, do you know if you can increase the player's frame count?
HEY RAY! I **THINK** I'VE FIGURED OUT WHAT WE NEED TO DO FOR THE "doLoadScreen.asm"

The doLoadScreen.asm script is in the "GameEngineData\Routines\BASE_4_5\Game\Subroutines" folder.
Dale - is there any reason we couldn't replace it reference in "LoadAllSubroutines" into a SCR_WHATEVER and add it to the scripts in NESMaker? I can see a few reasons why it would - I'm certain I am missing something however.
 

dale_coop

Moderator
Staff member
Oh sure, no problem, you can totally do a copy of LoadAllSubroutines.asm as "LoadAllSubroutines_Brendan.asm" assign that script instead of the original to your SCR_WHATEVER in "Project Settings > Script Settings"... and modify that "LoadAllSubroutines_Brendan.asm" to use a "doLoadScreen_Brendan.asm" instead ;)
Yeah, it's the best way to handle that (It's how I do for my projects)
 

5kids2feed

Well-known member
Hmm.. I followed all of this with the Maze Base.. didn't get any errors but my Bank $1F is 2%. Not 14-15% like other people. Bummer. I must've missed something but i'm not sure what. Gotta dig deeper.
 

5kids2feed

Well-known member
EDIT: NEVERMIND! Got it working! Didn't realize I had to copy and paste ALL of that text in the new file. I thought it was just those group of lines he was showing. This is a game changer!! Thanks AGAIN and as always, Dale!!

Untitled.png
 
Last edited:

GlassFrog

Member
Thanks @JamesNES, you're a legend. I've put off playing around with bank switching as I didn't want to open a Pandora's Box of errors. But the above worked seamlessly and freed up 15% of space. I'm just sorry I didn't try this sooner, as I have spent the last 6 months trying to work around it until I got to the point where I could not progress any further.

Edit: After doing a quick playthrough I have noticed screen trigger no longer seems to work. Which is a major problem as I use for one time collectables.
 
Last edited:

JamesNES

Well-known member
The one about moving inputs out the static bank is good too, and I don't think it's too hard to follow. Maybe just back up the files first, in case.

As for screen triggers, they aren't handled in doLoadScreen at all so it must be something else sorry.
 

GlassFrog

Member
For the life of me I could not find where in put the Screen Trigger code, so I just added it again, inside some item collect effect code and its working again fine.
I did try moving the inputs out of the static bank at first but I ran into quite a few problems. But 15% should be more than enough space to finish the game, thanks again dude.
 

Levty87

New member
I followed the tutorial and I got this error when compiling:

Routines\BASE_4_5\Game\LoadAllSubroutines.asm(104): PC out of range.
Routines\BASE_4_5\Game\LoadAllSubroutines.asm(107): PC out of range.
Routines\BASE_4_5\Game\LoadAllSubroutines.asm(110): PC out of range.
Routines\BASE_4_5\Game\LoadAllSubroutines.asm(113): PC out of range.
Routines\BASE_4_5\Game\LoadAllSubroutines.asm(116): PC out of range.
Routines\BASE_4_5\Game\LoadAllSubroutines.asm(119): PC out of range.

What does this mean and how do I fix this? :)
 

Bucket Mouse

Active member
PC Out Of Range means one of the banks is overflowing so it won't compile. LoadAllSubroutines is in the static bank, so that means your static bank is full, the opposite of what you're trying to do. You made a mistake somewhere, so I would retrace your steps with the tutorial.
 

Levty87

New member
Thanks Bucket Mouse.. I'll check. I'm way over my head with all the code stuff. I'm just a simple graphic designer trying to get things to work lol 😅
 
Top Bottom