Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessing to the save/load game data
#8
Code:
__ASM("SAVEOFFSET    EQU    0x1e0000");

The SAVEOFFSET is where the save data will begin.  

You might want to look at a couple PDF documents named SysCall.pdf and FlashMem.pdf  
https://www.google.com/search?q=syscall....ashMem.zip

In FlashMem.pdf, you can see the block layout of the different chip/cart sizes.  Look at the table called "16Mbit Flash Memory Card."

Now, actually, in the code pasted, it's using the block that starts at 0x1e0000 for savegame.  This would not be typical.  You would usually use blocks numbered 31, 32, and 33 for savegame stuff.  That's not necessary, but it's more typical.  

Keep in mind that flash memory is a bit weird to work with.  For the sake of simplicity, let's just talk about the chips on NGPC carts.  You can do 2 things with them.  You can turn all the bits in a block to 1 or you can turn a single bit from 1 to 0.  This means that you can write anything you want to a block, but you have to erase it first.  This can be tricky.  

Any time you want to write your savegame data, you COULD erase the whole block and write your data.  That's slow and it can actually wear out the flash chip faster.  So, people come up with novel approaches to that will write multiple versions of the savegame data at different places and then have some sort of method to determine which is the latest version.  Then, if you ever fill it up, you erase the entire block and start over.

BUT, notice that Thor's code erases the block and writes the data.  This will work.  It's probably the easiest way, but it's not the "best" way to do it.

I hope that makes a little sense.  

If I were you, I would probably pick block 32 and then change to

Code:
__ASM("SAVEOFFSET    EQU    0x1f8000");
__ASM("BLOCK_NB        EQU    32");

These 2 items much match up based on the table I mentioned.  If you used block 32, then SAVEOFFSET must be between 0x1f8000 and 0x1f9fff (from the table).

Also look at SysCall.pdf.  In particular, look at VECT_FLASHWRITE and VECT_FLASHERS.  These are what Thor's code is calling.  The ASM is just setting up the parameters to call those SysCall functions.

Also, notice that Loïc's ASM code is setting up writing to block "0x21" which is block 33. Then he uses 0x1fa000 as his SAVEOFFSET.
Card Fighters' Clash 2 English Translation ( http://cfc2english.blogspot.com/ )
Neo Geo Pocket Flash Cart and Linker Project ( http://www.flashmasta.com/ )
Avatar art thanks to Trev-Mun ( http://trevmun.deviantart.com/ )
Reply


Messages In This Thread
Accessing to the save/load game data - by KeiDash - 11-14-2018, 11:38 PM
RE: Accessing to the save/load game data - by Flavor - 11-17-2018, 02:07 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)