#138661 - FOcaL - Mon Aug 27, 2007 2:30 pm
Hi,
I would to save data with my Nintendo DS, but I don?t know how ? I have seen the programm ?sram_demo1? but the compilation fail (and all my path are correctly install) and I don't arrive to modify my programm to include the VRAM part.
Thanks for your help.
#138663 - Diddl - Mon Aug 27, 2007 2:41 pm
look for source code of rein17 and eepinator. within you will find functions to access all kinds of savegame memory currently exists.
#138678 - tepples - Mon Aug 27, 2007 7:30 pm
Do you just want to save data, or do you specifically want to save data to a DS Game Card for some reason? If you just want to save data, then you can use libfat to make a folder /data/name_of_your_app/ and then make files inside that.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#138727 - FOcaL - Tue Aug 28, 2007 10:29 am
Ok thanks for your response.
I try to use libfat. If I have another problem I will repost^^
edit : ok It's good ^^ just think to add LIBS := -lfat in makefile to compil :p
#138748 - FOcaL - Tue Aug 28, 2007 3:13 pm
OK I have a little problem :p
I create my file, enter a text and the read this text.
But when my file is already create ( we turn off the NDS and turn on) I fail to read the file...
If I don't write the text on the same "session", I can't read the file...
I don't know if I'm clear ^^ but thanks for your help^^
edit :
this is my code :
void SaveToCard(char* data)
{
int size;
char *ptr = data;
size=sizeof(data);
if(!fatInitDefault())
{
printtop("Error to create save file");
}
else
{
FILE* Write = fopen ("DS.save", "wb");
fwrite(ptr, 1, size*4, Write);
fclose(Write);
}
}
void ReadToCard()
{
char result[9999];
int i=0;
char *ptr = &result;
FILE* Read = fopen ("DS.save", "rb");
if(Read != -1)
{
int size=0;
size=sizeof(ptr);
printtop("Read");
fread(ptr, 1, 4*size, Read);
printtop("Close");
fclose(Read);
}
else printtop("Error to read File");
printtop(ptr);
}
#138757 - tepples - Tue Aug 28, 2007 7:30 pm
FOcaL wrote: |
this is my code :
void SaveToCard(char* data)
{
int size;
char *ptr = data;
size=sizeof(data); |
sizeof(data) will always be 4 on ARM.
Quote: |
void ReadToCard()
{
char result[9999];
int i=0;
char *ptr = &result;
FILE* Read = fopen ("DS.save", "rb");
if(Read != -1)
{
int size=0;
size=sizeof(ptr); |
sizeof(ptr) will always be 4 on ARM.
Does your code work on a PC?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#138763 - Quirky - Tue Aug 28, 2007 9:26 pm
Could be that you don't call fatInit in the Read code. Ideally you should call it once at the start of main(), rather than in the "low-level" save/load stuff.
#138807 - FOcaL - Wed Aug 29, 2007 9:03 am
Yes Quirky you have right. It's a stupid error.... I'm so sorry.
And this code is an extract from a big code, and it work on the DS.