Saving game data
Saving game data
Just wondering if anyone knows anything about the DS native save format. Specifically I'd like to now how SAV files (that emulators and thr R4i use for instance) are written to by DS code.
Any help appreciated a lot, thanks
Any help appreciated a lot, thanks
Re: Saving game data
Include:
Init:
Declare the variables:
Set the to be saved variables to a certain value:
To write the to be saved variables to a file:
To read the variables:
Code: Select all
#include <fat.h>
Code: Select all
fatInitDefault();
Code: Select all
FILE* savefile;
struct VariablesToSave {
u8 var1;
int var2;
char var3[10];
} SaveFile;
Code: Select all
SaveFile.var1 = 100;
SaveFile.var2 = 1000;
strcpy(SaveFile.var3,"Hello");
Code: Select all
savefile = fopen("fat:/savefile.sav","wb");
fwrite(&SaveFile,1,sizeof(SaveFile),savefile);
fclose(savefile);
Code: Select all
savefile = fopen("fat:/savefile.sav","rb");
fread(&SaveFile,1,sizeof(SaveFile),savefile);
fclose(savefile);
Re: Saving game data
I don't think there is a general industry-defined standard to write game save data (unless Nintendo steps in and tell us what's theirs, if they ever had one, please, pretty please, with a cherry on top? ). Therefore, it is up to you to define a way to save / retrieve your own data for your application; the suggestion by JanMulder above to use the filesystem is actually a good one.
-
- Site Admin
- Posts: 2003
- Joined: Tue Aug 09, 2005 3:21 am
- Location: UK
- Contact:
Re: Saving game data
Save file formats are specific to the game they relate to, there's no real "standard"
-
- Posts: 23
- Joined: Thu Sep 09, 2010 1:28 pm
- Location: Australia
- Contact:
Re: Saving game data
I think the problem here is the mis-interpretation of the constant size of the save games (which depends on the kind of save it is, eg; EEEPROM) but yeah just to add another useless comment, the save formats are whatever you make them.WinterMute wrote:Save file formats are specific to the game they relate to, there's no real "standard"
Move over Mario... and cruise by Crash... Croc Rocks!
It's a serious adventure 3D platformer for all retro gamers to drool over =D
It's a serious adventure 3D platformer for all retro gamers to drool over =D
Re: Saving game data
Thanks a lot for help on this one. I've another problem though!
I've only just tried to get this to work and I'm getting a linker error saying
Everything seems to be in order. Maybe I have to modify my makefile to link an extra library?
Also, on the libnds online documentation there is no mention of fat.h in the file list, nor of any of its functions. Is it not a standard part of the library?
I've only just tried to get this to work and I'm getting a linker error saying
Code: Select all
game.cpp:(.text+0x2): undefined reference to `fatInitDefault'
Also, on the libnds online documentation there is no mention of fat.h in the file list, nor of any of its functions. Is it not a standard part of the library?
-
- Posts: 85
- Joined: Mon Sep 27, 2010 5:26 pm
Re: Saving game data
Yes, you have to add
to your Makefile.
Code: Select all
LIBS := -lfat -lnds9
Re: Saving game data
Hi,
Sorry to blatantly resurrect an old post but I am now experimenting with saving files and found this topic most useful.
One thing I have noticed is that this code only works on a real DS but on a PC, nothing happens.
I tried changing the code to "fopen("c:/savefile.sav","wb");" and nothing happened.
How does one go about saving files when you are running on a PC?
Sorry to blatantly resurrect an old post but I am now experimenting with saving files and found this topic most useful.
One thing I have noticed is that this code only works on a real DS but on a PC, nothing happens.
I tried changing the code to "fopen("c:/savefile.sav","wb");" and nothing happened.
How does one go about saving files when you are running on a PC?
Re: Saving game data
that code should work. you must be confused, or you must have no c: drive. unless, of course, by running on PC, you mean, running on an emulator. in which case you are very badly confused.
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests