gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > saving homebrew data

#83886 - knight0fdragon - Fri May 19, 2006 9:08 am

Is there some convienient package out there that will let my apps save to any type of cart, or will i have to add all sorts of code to make this as compatible as possible
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#83977 - tepples - Sat May 20, 2006 12:11 am

Do you mean a library that will allow writing to all CF cards, all SD cards, all flash carts' SRAM, all flash carts' NOR area, and NOR/NAND hybrid carts' NAND area? Nope. Chishm's library supports CF and possibly a few other types, but not everything. Which makes and models were you talking about?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#83999 - knight0fdragon - Sat May 20, 2006 3:16 am

Basically what i want is a convienient way, yes a library, that pretty much auto detects for me,

so for example I have 3 users

User A has supercard

User B has XGLite

User C maybe has wifi download with MPFH to use for a save (this one is optional of course)

What I am looking for is something in the lines of

SaveToCard(data);

then when i need to read

data = LoadFromCard();

and in the black box realm, it detects the flash carts and what not.

Surely i doubt something THIS convienent exists, but perhaps there is something out there easier

I believe Chishm's library only writes to MP1/2 and a few flash carts

but not things like supercard.

If this doesnt exist I will perhaps work on some class to do this
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#84011 - tepples - Sat May 20, 2006 4:43 am

I assume that the XG has GBA SRAM; otherwise, the player couldn't have used it to install FlashMe using PassMe2 or a clone thereof. Reading and writing GBA SRAM is easy: it's just a byte array starting at 0x0A000000.

Support GBA SRAM and Chishm's library, and you've supported users A and B. Pseudocode follows:
Code:
/* returns nonzero for success and 0 for failure */
int save() {
  if (cfAvailable) {
    int wasWritten = 0;
    FILE *fp = fopen("/mygame/save.dat", "w");
    if(fp) {
      written = fwrite(loadSaveBuf, sizeof(loadSaveBuf), 1, fp);
      fclose(fp);
    }
    return wasWritten;
  } else if (sramAvailable) {
    /* First copy over the savegame. */
    bytecpy((char *)0x0A000000, loadSaveBuf, sizeof(loadSaveBuf));
    /* If the copy was successful, bytecmp() will return 0. */
    return !bytecmp((char *)0x0A000000, loadSaveBuf, sizeof(loadSaveBuf));
  } else {
    return 0;
  }
}

Do you claim that user C uses FlashMe+WMB exclusively? If so, how did user C install FlashMe?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#84014 - HyperHacker - Sat May 20, 2006 5:00 am

A borrowed flash cart?

BTW, you have to ensure that the CPU that's going to write to SRAM has access to the bus. Use sysSetBusOwners() in NDSLib.

#84018 - knight0fdragon - Sat May 20, 2006 5:12 am

well see the reason why i am asking this is because I want to make it easilt accessible to all kinds of different carts

I myself only have 2 kinds. and chishms driver doesnt write to SC I thought

its not a matter of the code, that i can do, thanks though for that

just looking for something that handles a lot of cases that have been tested, that i myself cannot. This is ok though, I will just write my own class since i doubt anything like this really exists

does the MP player have some virtual sram like the SC does????

perhaps i could just add a case where if its a non flash cart, then save the virtual sram to CF
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#84022 - tepples - Sat May 20, 2006 5:20 am

knight0fdragon wrote:
well see the reason why i am asking this is because I want to make it easilt accessible to all kinds of different carts

I myself only have 2 kinds. and chishms driver doesnt write to SC I thought

Chishm's driver has no problem writing to GBAMP CF, SuperCard CF, or M3 CF. But currently, you have to use the SRAM method to write to SD adapters or NOR cards.

Quote:
does the MP player have some virtual sram like the SC does????

M3 (GBAMP v3) does, but GBAMP v2 does not.

Quote:
perhaps i could just add a case where if its a non flash cart, then save the virtual sram to CF

That's pretty much what the pseudocode I posted does.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#84062 - knight0fdragon - Sat May 20, 2006 11:55 am

ok and i was refering to this when refering to chishms driver

Partially supported devices (read only, disabled by default)
SuperCard SD
M3 Adapter SD
EFA 2
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#84094 - zzo38computer - Sat May 20, 2006 3:32 pm

Another thing I would recomend for compatibility is to check if the DS game card has the same title as your game, and if it does it will save on the DS game card.
_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.

#84095 - thoduv - Sat May 20, 2006 3:32 pm

A modified version of chishms FAT libary can write on M3SD and SCSD (even it's slow). It's the version using ASM drivers. For instance, SaTa uses it in his Rein tool.

#84849 - knight0fdragon - Thu May 25, 2006 12:19 am

Ok now my next problem is actually detecting if its a supercard or not. I tried checking the header, supercard gives me ""

is there another way to detect what cart i have?
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#84892 - MaHe - Thu May 25, 2006 12:40 pm

Offtopic: SuperCard doesn't have 'virtual SRAM' but a real one, though it's not battery powered (it is on miniSD version).

Ontopic: A library like this would be very convenient, so I hope somebody manages to make it work :)
_________________
[ Crimson and Black Nintendo DS Lite | CycloDS Evolution | EZ-Flash 3-in-1 | 1 GB Transcend microSD ]