[4.5.9] Flash Saving

I have implemented this and it work perfectly fine in the latest version of mesen but when I flash the game on a cartridge and try it in my original nes, the game freeze when I save and I have to reflash the cartridge.
The cart I have is the one that Joe sold with the flasher as part of the dev kit, so it should be a correct mapper 30 cart.
The save is called from an input.
Any one tried this with a mapper 30 cart, does it work for you ?
 

dale_coop

Moderator
Staff member
@Francois Brodeur is it a INL cart? The new mapper30 nesmaker boards are NOT compatible witht the flash saving.
I'd suggest to get some carts from BrokeStudio.fr the price is really correct, the shipping costs are not expensive and the boards works perfectly (flash saving too). I use those boards now for ALL my productions.
 
@Francois Brodeur is it a INL cart? The new mapper30 nesmaker boards are NOT compatible witht the flash saving.
I'd suggest to get some carts from BrokeStudio.fr the price is really correct, the shipping costs are not expensive and the boards works perfectly (flash saving too). I use those boards now for ALL my productions.
Its the cart that Joe sold with the dev kit around last Christmas. I will try one from broke studio. Thank you dale.
 

dale_coop

Moderator
Staff member
Yes, Paul (INL) told me last year that the new pcbs (unrom512, the nesmaker ones) he sells are not compatible with our community flash saving script.
Paul:
About the flash save situation on the current flash chips I'm able to get in bulk. Problem being the 64KB flash sector vs 4KB sector of the chips I had been using previously.
64KB is pretty painfully big of course, and why the chip is poorly suited for flash saves even though they would work.

What he means is... flashing will replace 64KB at a time, where it's used to alter only 4KB with the older boards. So flashing will replace/erase 4 entire banks (and basically would break your game, depending of the data you had in them).

Because of that... I recommand to NOT use the current INL boards if you want to have flash saving in your game, and I suggest my fBroke Studio ones instead (choose the "Vertical Mirroring" for NESmaker-ready-to-use boards):
 

Retrofaija

Member
I did this as the original post, and I get bunch of PC out of range errors in different scripts. I wonder what's happening. I'm using adventure module as base.

I have the load subroutines includes in the start, all the way top. I wonder if they should be at some specific point in the script?

1676013976643.png
 

dale_coop

Moderator
Staff member
You're out of space in your bank.

To free up some space in the static bank, make to sure to follow that guide, before attempting to implement the flash saving:

And if not enough, another one that could be useful:
 

Retrofaija

Member
Thanks, I'll try that!

Edit: Got the thing working now, excellent! BUT: if I save on a screen that has "warp in location" set - it will always load that position and not the saved position. If I don't have warp in location set, the screen goes nuts. As in I'm using adventure module and have lot of custom warps in my screens. One thing would be to have certain screens allowing save only (NPC or so).

Edit2: I decided to take monsterbits in action, and make a new NPC monster for saving game - that way it works the best.
 
Last edited:

Retrofaija

Member
I wonder how you fix that you cannot load a save when you first fire up the game - it glitches up coz there's no save data in.

I'm having a simple screen for my game to either start a fresh game, or load previous save.

1676049708878.png
 

JamesNES

Well-known member
My solution was to write something specific to the first byte, then when you read the first byte, if it's not what is expected then it means nothing's been written yet, and you can cancel out of trying to load and start a new game instead.
 

Retrofaija

Member
My solution was to write something specific to the first byte, then when you read the first byte, if it's not what is expected then it means nothing's been written yet, and you can cancel out of trying to load and start a new game instead.
Sounds great, though I don't have skills to pull that off, so any help would be appreciated! :)
 

JamesNES

Well-known member
CallWriteByte just writes whatever is in the accumulator, so you make sure the first thing you write is something non-zero. Like

Code:
LDY #$00
LDA #$FF
CallWriteByte
INY
;;then the rest of your saved variables

And when you're loading, just check that the first byte is non-zero:

Code:
Flash_Load:
    
    LDY #$00
        

        LDA SaveSegmentStart,y
        BNE +keepLoading 

                  ;;abort your loading process and start a new game instead
                  RTS
        +keepLoading
        INY 
        LDA SaveSegmentStart,y 
        STA warpMap
        
       ;;and so forth
 

DocNES

Member
I've been stuck on this for about three weeks. I feel like it maybe something I'm just over looking. When I do test script for load and save bound to start and select the game crashes. I've attached gif of each. One the Player Object kinda just explodes, and locks up. Other just freezes completely. Any help would be greatly be appreciated. If I get it working I'll buy you a coffee :)
 

Attachments

  • LOAD.gif
    LOAD.gif
    68.9 KB · Views: 12
  • SAVE.gif
    SAVE.gif
    68.7 KB · Views: 10
  • 1.jpg
    1.jpg
    27.2 KB · Views: 11
  • 2.jpg
    2.jpg
    75.9 KB · Views: 10

JamesNES

Well-known member
If you've moved inputs out of the static bank then that bank switch will mess things up, that's one thing I can think of. It uses the sprite/OAM buffer so sprites ARE meant to glitch out for a frame, but they're also meant to go straight back to normal. If they're staying glitched, you could be stuck in a loop; I'd look in the debugger to see what it's stuck on.

Otherwise I'd be ripping it out and doing it again.
 

JamesNES

Well-known member
Would this be useful in saving a High score in arcade style games? If so how would one go about that?
You can write any bytes you want, as long as you know which variables you're storing score data in and you write them in the same order you read them it'll be the same thing.
 

baardbi

Well-known member
To anyone who followed James's tutorial for moving input scripts to bank $1A and wants to save / load from an input script:

I put this at the bottom of the FlashSave.asm file:

;;;; Use this when saving from input scripts
FlashSaveFromInput:

JSR SaveSubroutine
SwitchBank #$1A
RTS

;;;; Use this when loading from input scripts
FlashLoadFromInput:

ReturnBank ;Return from bank $1A
SwitchBank #$1E
jsr Flash_Load
ReturnBank
SwitchBank #$1A ;Go back to bank $1A to resume input script
RTS

Then use JSR FlashSaveFromInput or JSR FlashLoadFromInput in the input scripts.
 

Retrofaija

Member
To anyone who followed James's tutorial for moving input scripts to bank $1A and wants to save / load from an input script:

I put this at the bottom of the FlashSave.asm file:



Then use JSR FlashSaveFromInput or JSR FlashLoadFromInput in the input scripts.
This doesnt behave any different atleast on my end. I end up having crash on the save, after moving inputs to 1A.
 

baardbi

Well-known member
This doesnt behave any different atleast on my end. I end up having crash on the save, after moving inputs to 1A.
It's hard to say what the problem is since there's so much that can crash when using bank switching. But assuming that you followed James's tutorial without any modification, make sure that my code block is at the bottom of the FlashSave.asm file. Also make sure that Mesen is updated to the latest version. Then it depends how you are using it in the input scripts. You could do a simple test like this:

Save input script:
;;;; Save

JSR FlashSaveFromInput

RTS

Load input script:
;;; Load

JSR FlashLoadFromInput

WarpToScreen warpToMap, camScreen, #1

RTS
 
Top Bottom