Bucket Mouse
Active member
You know my post "Fun With Bank Switching" from a few months ago? I gave it a heavier test and it....didn't actually work for me. I was going to replace that post with this post, but then Panzer said it DID work for HIM, so....I dunno what's going on there. I guess I'll leave it up. I do know it doesn't work for the specific thing I invented it for, storing monster data in more than one bank.
The NESMaker engine has space for 64 monsters. The dirty truth is that depending on what you tell those monsters to do and how many Action Steps you use for each, you will very probably run out of space for them if you use more than half.
Sprite data is stored in three main depositories: ObjectInfo.dat, ObjectLutTable.dat and ObjectPointers.dat. All three are stored in Bank 1C, with ObjectInfo being the largest. Bank 1C fills up fast and Bank 1D, right next to it, is completely empty. If we could move ObjectInfo there, all 64 monsters with every Action Step could theoretically be used.
I spent one unpleasant, nerve-racking week trying to solve this problem and got nowhere. Fortunately Kenneth Nietfeld, creator of the Rick Starfield demo from the recent Byte Off competition, came to my rescue. He said he had solved this issue already for his own game and he knew how to cleanly split Bank 1C into two banks. He also does not really post in the forums, so he gave me permission to share this tutorial here.
The first thing you must do is move doDrawSprites.asm, currently in Bank 1C, to the static bank (Bank 1F, the One Bank to rule them all). You do that by going to System/BankData, opening Bank1C.asm and finding this:
Now open up Base 4.5/Game and find LoadAllSubroutines.asm. Bank 1F does not have a specific listing; instead you add things to the Static Bank through this script. So copy the doDrawSprites storage command from Bank 1C and paste it into LoadAllSubroutines. Then delete the original mention in Bank 1C or you'll get duplicate errors.
At the top of Bank 1C you'll notice the first two lines:
Those lines should go in Bank 1D now. Do the same procedure for them.
Save Bank 1C, Bank 1D and LoadAllSubroutines under slightly different names, like "Bank1C-New" or "LoadAllSubroutines-Extra." When you're altering NESMaker code, it's always a good idea to keep the originals around. Also, NESMaker is going to automatically overwrite anything in the System folder, which will erase what we just did in Bank 1C anyway.
To use our newly rewritten banks, we open Script Settings and redirect Bank 1C, Bank 1D and LoadAllSubroutines to our versions. Also keep in mind: any changes you make to Script Settings can be retained in future games by making those changes into your own module. That's as easy as selecting a menu item.
The last step is to go to your Subroutines folder and open up doDrawSprites.asm. We're going to do an alteration there so it can access Bank 1D to read ObjectInfo. Scroll down to around line 216, just after
LDA (tempPointer_lo),y
STA temp16
LDA (tempPointer_hi),y
STA temp16+1
and just before
LDY #$00
LDA (temp16),y
and within that space, post:
SwitchBank #$1D
Then find the line "doneDrawingThisSprite." Right below it, post:
ReturnBank
Save doDrawSprites under a new name, link to it in Script settings, and you're done. You now have all the space you need to go nuts with monsters.
The NESMaker engine has space for 64 monsters. The dirty truth is that depending on what you tell those monsters to do and how many Action Steps you use for each, you will very probably run out of space for them if you use more than half.
Sprite data is stored in three main depositories: ObjectInfo.dat, ObjectLutTable.dat and ObjectPointers.dat. All three are stored in Bank 1C, with ObjectInfo being the largest. Bank 1C fills up fast and Bank 1D, right next to it, is completely empty. If we could move ObjectInfo there, all 64 monsters with every Action Step could theoretically be used.
I spent one unpleasant, nerve-racking week trying to solve this problem and got nowhere. Fortunately Kenneth Nietfeld, creator of the Rick Starfield demo from the recent Byte Off competition, came to my rescue. He said he had solved this issue already for his own game and he knew how to cleanly split Bank 1C into two banks. He also does not really post in the forums, so he gave me permission to share this tutorial here.
The first thing you must do is move doDrawSprites.asm, currently in Bank 1C, to the static bank (Bank 1F, the One Bank to rule them all). You do that by going to System/BankData, opening Bank1C.asm and finding this:
Code:
;; do draw sprites
doDrawSprites:
.include SCR_HANDLE_DRAWING_SPRITES
rts
Now open up Base 4.5/Game and find LoadAllSubroutines.asm. Bank 1F does not have a specific listing; instead you add things to the Static Bank through this script. So copy the doDrawSprites storage command from Bank 1C and paste it into LoadAllSubroutines. Then delete the original mention in Bank 1C or you'll get duplicate errors.
At the top of Bank 1C you'll notice the first two lines:
Code:
;;; ALL THE DATA FIRST
.include "ScreenData\ObjectInfo.dat"
Those lines should go in Bank 1D now. Do the same procedure for them.
Save Bank 1C, Bank 1D and LoadAllSubroutines under slightly different names, like "Bank1C-New" or "LoadAllSubroutines-Extra." When you're altering NESMaker code, it's always a good idea to keep the originals around. Also, NESMaker is going to automatically overwrite anything in the System folder, which will erase what we just did in Bank 1C anyway.
To use our newly rewritten banks, we open Script Settings and redirect Bank 1C, Bank 1D and LoadAllSubroutines to our versions. Also keep in mind: any changes you make to Script Settings can be retained in future games by making those changes into your own module. That's as easy as selecting a menu item.
The last step is to go to your Subroutines folder and open up doDrawSprites.asm. We're going to do an alteration there so it can access Bank 1D to read ObjectInfo. Scroll down to around line 216, just after
LDA (tempPointer_lo),y
STA temp16
LDA (tempPointer_hi),y
STA temp16+1
and just before
LDY #$00
LDA (temp16),y
and within that space, post:
SwitchBank #$1D
Then find the line "doneDrawingThisSprite." Right below it, post:
ReturnBank
Save doDrawSprites under a new name, link to it in Script settings, and you're done. You now have all the space you need to go nuts with monsters.