JamesNES
Well-known member
I've seen this asked a bit and since I figured it out a while back, and wanted to put it into the thing I'm working on now, so thought it'd be a good time to do a quick walkthrough as I went. This isn't super hard or anything, but you should know how to do things in NESMaker like add scripts, I'm not going to explain basic stuff like that.
I've attached edited version of Flash.asm and FlashSave.asm since there are variable name conflicts with 4.5.9 in there by default.
Thanks heaps to Kasumi's original posts in this thread. Couldn't have figured it out without that write up.
Mesen has to be the latest version - the one that comes with NESMaker by default doesn't support flash saving. It won't crash, just nothing will happen.
Doing it this way will take up 4% of the static bank; the saving might not have to go there but I'm not up for trying at the moment.
First you want to include Flash.asm and FlashSave.asm in LoadAllSubroutines.asm. (After adding them in NESMaker's script window) Flash.asm has to be included before FlashSave.asm just like
In MemoryMap.asm, delete or comment out:
This isn't used by default in NESMaker. If you use $0300 for flashing it'll mess up your collision table.
It doesn't matter where, just that they're in that order.
I'm using bank 1E for this as it starts basically empty, so you want to put the loading part in there so it looks like this now:
For the example I'm saving your screen/map so when you load, it'll warp you to the warp in spot on the screen you saved on. It also saves screen triggers.
To test it out you can bind these scripts to start/select to save/load:
This should work off the bat.
To save different variables, you want to edit FlashSave.asm. You basically want to repeat this for each variable:
So to save the player's x position, you'd add:
and then to load it, in 1E you'd add:
The important thing is that the variables are written/read in the same order, as it's just storing them in a straight sequence.
Hopefully this is enough to get you going.
I've attached edited version of Flash.asm and FlashSave.asm since there are variable name conflicts with 4.5.9 in there by default.
Thanks heaps to Kasumi's original posts in this thread. Couldn't have figured it out without that write up.
Mesen has to be the latest version - the one that comes with NESMaker by default doesn't support flash saving. It won't crash, just nothing will happen.
Doing it this way will take up 4% of the static bank; the saving might not have to go there but I'm not up for trying at the moment.
First you want to include Flash.asm and FlashSave.asm in LoadAllSubroutines.asm. (After adding them in NESMaker's script window) Flash.asm has to be included before FlashSave.asm just like
Code:
.include SCR_FLASH
.include SCR_FLASH_SAVE
In MemoryMap.asm, delete or comment out:
Code:
FlashRamPage = $0300 ;; because collision data will not be used on saving/loading of data.
;; this should always be utilized on a non-screen, and reload the screen when saving/loading is finished.
This isn't used by default in NESMaker. If you use $0300 for flashing it'll mess up your collision table.
It doesn't matter where, just that they're in that order.
I'm using bank 1E for this as it starts basically empty, so you want to put the loading part in there so it looks like this now:
Code:
SaveSegmentStart:
.pad $8100
TriggerSegmentStart:
.pad $8FFF
userPoweredOffFlash:;This MUST be the last value saved to. It is used to detect if the user turned the game off while we were saving
.db $00
Flash_Load:
LDY #$00
LDA SaveSegmentStart,y
STA camScreen
INY
LDA SaveSegmentStart,y
STA warpMap
LDY #$00
triggerLoadLoop:
LDA TriggerSegmentStart,y
STA screenTriggers,y
INY
CPY #$20
BNE triggerLoadLoop
RTS
HudTiles:
.incbin "Graphics\Backgrounds\CHR_HudTiles.chr"
For the example I'm saving your screen/map so when you load, it'll warp you to the warp in spot on the screen you saved on. It also saves screen triggers.
To test it out you can bind these scripts to start/select to save/load:
Code:
JSR SaveSubroutine
RTS
Code:
SwitchBank #$1E
jsr Flash_Load
ReturnBank
WarpToScreen warpMap, camScreen, #$01
RTS
This should work off the bat.
To save different variables, you want to edit FlashSave.asm. You basically want to repeat this for each variable:
Code:
LDA warpMap
CallWriteByte
INY
So to save the player's x position, you'd add:
Code:
LDA Object_x_hi
CallWriteByte
INY
and then to load it, in 1E you'd add:
Code:
LDA SaveSegmentStart,y
STA Object_x_hi
INY
The important thing is that the variables are written/read in the same order, as it's just storing them in a straight sequence.
Hopefully this is enough to get you going.
Attachments
Last edited: