#163392 - gauauu - Wed Oct 01, 2008 4:52 pm
I'm trying to figure out sort of the "standard" places that the community uses to save game data, so my game can play nicely and act like everything else. Although it seems like there all sorts of different ways that games are using, from this thread, it sounds like the generally accepted places are:
1. In /data/my_game_name
or
2. Check and see if argv[0] is provided, and write the save data in the same directory as the .nds file.
Is that correct? And if so, assuming argv[0] is provided (which may be a crazy assumption), which of the two is preferable, in everyone's opinion?
(note that this is only for saving player's game state -- the resource data for the game is all contained in the .nds file itself)
#163404 - sgeos - Wed Oct 01, 2008 7:51 pm
Is it possible to just masquerade as a program that expects some sort of on card backup and let the card figure out what to do with the save file? I suppose you could save to the current directory if argv[0] is provided or to the root directory (or /data/my_game_name) if it is not.
#163408 - zzo38computer - Wed Oct 01, 2008 9:07 pm
Possibly make it so that if argv[0] isn't provided, the directory name can be a offset in the .NDS file that you could patch before copying it to the CF card or SD card or whatever. The offset could be provided together in the .ZIP that comes with it, described in a "offset patch" data file, would could be for example, like this, for example: Code: |
[00020FE9 WORKING_DIR ASCIIZ 1E]
[0024FFCA EXTRA_DATA ENUM INT32BE]
1 ONE
2 TWO
3 THREE
5 FIVE
[00000001 SOMETHING_ELSE RANGE 1 1B5 INT16LE]
[0000102D CHECKSUM CHECKSUM 00000000 0000102C INT16LE]
|
_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.
#163413 - gauauu - Wed Oct 01, 2008 10:15 pm
zzo38computer wrote: |
Possibly make it so that if argv[0] isn't provided, the directory name can be a offset in the .NDS file that you could patch before copying it to the CF card or SD card or whatever. |
Sneaky, and a cool idea. Do you think that people would actually care enough to use it?
sgeos wrote: |
Is it possible to just masquerade as a program that expects some sort of on card backup and let the card figure out what to do with the save file? |
Not sure I follow (probably my own ignorance) -- are there programs that do this? (And does it work with most cards?)
#163415 - mml - Wed Oct 01, 2008 10:40 pm
Have you looked at EFS Lib, NitroFS, etc? See other threads on this board. Executive summary: they embed a file system in your .nds file so you can keep your game and all your data in a single file, rather than cluttering up people's devices with lots of data files. If you-preallocate the save files you'll need at build time, you can save game progress data in there too later.
#163417 - Sweater Fish Deluxe - Wed Oct 01, 2008 11:35 pm
Yeah, if you know how much data will be in your save file (and I don't know why you wouldn't), using EFS seems like by far the best option even if you wouldn't be using EFS otherwise. That way there's no extra files for the user to worry about at all. Just remember to provide an option in game for re-initializing the save data.
Last time I checked, NitroFS didn't support writing.
...word is bondage...
#163423 - gauauu - Thu Oct 02, 2008 2:12 am
Aaah, very cool. The game data (other than saves) is already bundled into the .nds file, so that would be perfect. I glanced at EFS while researching this, but didn't look at it closely enough to realize that it could handle writing back to the .nds file at run time.
#163546 - gauauu - Sat Oct 04, 2008 6:41 pm
Well, just realized that the problem with something like EFS is that, if I release a bug-fix version of my game, it's much more difficult for players to upgrade the game but keep their existing save files. I think maybe I'll just use libfat and save to the card like normal.
#163562 - zazery - Sun Oct 05, 2008 12:52 am
Whenever I start up a homebrew game on my R4 it asks if I want to create a .sav file. Is there some reason why homebrew can't let the flash card handle the saving?
#163564 - tepples - Sun Oct 05, 2008 1:49 am
I imagine that the "create a save file" is designed for <yarr>copies of Game Cards built with Nintendo's SDK,</yarr> so that their EEPROM or flash save chip gets mapped to the card. I don't know how well the R4 would patch programs that use libnds functions (not NitroSDK functions) to write to the flash save chip this way. Besides, I've read on some other forum that the file system implementation of the R4 firmware menu has defects that caused at least one member's microSD card's master boot record to get overwritten.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#163587 - josath - Sun Oct 05, 2008 10:34 pm
tepples wrote: |
I don't know how well the R4 would patch programs that use libnds functions (not NitroSDK functions) to write to the flash save chip this way. |
In my experience (writing a eeprom tool), no flashcarts will patch libnds eeprom functions. It may work on a couple flashcarts I haven't tried, but you wouldn't want to restrict your game to only work on a few carts. Libnds is the way to go.
As far as save file, I'd say check argv[0] if it's set to find the current dir, otherwise save to a single file called 'gamename.sav' in the root of the card.