Access SRAM with libnds?

NotImpLife

Active Member
OP
Newcomer
Joined
Mar 9, 2021
Messages
42
Trophies
0
Website
github.com
XP
489
Country
Romania
I was writing some homebrew game and once had the need to save the game progress and I wonder how can I do that in the way commercial games do. I mean, in order to make my game run fine on both hardware and emulators, I want to save 'directly to the card' instead of using the SD card. (this translates to having a "*.sav" file created by the emulator)

I learned that libnds has a predefined SRAM address and tried to follow the steps from the double.nz tutorial to access it, but I didn't manage to make it work. Then I tried the indications in this post which suggest using fatInitDefault(), but as excpected I received the "Failed to initialize FAT driver" error.

Last but not least, I tried the examples\nds\card\eeprom demo which gave me the following result: EEPROM: Type: -1 Size: 0.

I came to the conclusion that (correct me if I'm wrong) the NDS header (or any part of the file) must be configured in order to support SRAM, but I have no idea what or how could I achieve that. Can ndstool do the job or I need to find/write another tool that enables SRAM for my DS game?
 

ghjfdtg

Well-Known Member
Member
Joined
Jul 13, 2014
Messages
1,367
Trophies
1
XP
3,309
Country
You probably have no choice other than creating a file on the flashcart microSD. How it usually works is the flashcart kernel patches the game according to a database of save types or it tries to guess the save type based on code. The patch makes the game write the savegame directly to pre-allocated microSD sectors through the flashcart's DLDI. Or in other words DS flashcarts don't even support real EEPROM/flash savegames.
 

NotImpLife

Active Member
OP
Newcomer
Joined
Mar 9, 2021
Messages
42
Trophies
0
Website
github.com
XP
489
Country
Romania
Is this also available for emulators? Also, couldn't we 'trick' the kernel into recognizing the homebrew as a well-known ROM (e.g Zelda Spirit Tracks) and make use of its saving system?
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • SylverReZ @ SylverReZ:
    Remember when RiiShop was a thing?
  • BakerMan @ BakerMan:
    not really
  • SylverReZ @ SylverReZ:
    It got shutdown because somebody "accidentally" leaked the database for the amount of people using the beta.
  • SylverReZ @ SylverReZ:
    RiiShop is the laziest way of downloading Wii games. Did somebody not think of this through?
  • BakerMan @ BakerMan:
    although i ended up accidentally changing my nand with no way of going back bc i didn't know you needed a gamecube controller to restore it (i have a wii minus/1.1, which doesn't have gamecube controller support)
  • SylverReZ @ SylverReZ:
    @BakerMan, I think you're talking about the recovery mode that the SaveMii used, and also was to restore softbricked systems.
  • SylverReZ @ SylverReZ:
    If your NAND was hardbricked, then just buy another Wii. Or go with the dirty NAND flasher method.
  • BakerMan @ BakerMan:
    and if i find the sd card i have my NAND backed up on, i can not only restore the NAND if i solder the right part in, but i can also put my NAND on dolphin, then i can play dolphin online, like PMEX Remix or MKWii Riibalanced
  • Xdqwerty @ Xdqwerty:
    Brb
  • SylverReZ @ SylverReZ:
    @BakerMan, Oh yeah, that was a thing too. Dolphin does support Wiimmfi.
  • BakerMan @ BakerMan:
    yeah you just need to put your NAND backup with wiimmfi on it
  • BakerMan @ BakerMan:
    ngl i feel like if a bunch of my friends have wiis and know how to get wiimmfi and back up their NAND, then we could do a PMEX Remix tournament
  • BakerMan @ BakerMan:
    maybe even add UMVC3/DBFZ and make it a biathlon/triathlon
  • Psionic Roshambo @ Psionic Roshambo:
    Too bad Excite Truck wasn't multi player :(
  • Psionic Roshambo @ Psionic Roshambo:
    Loved that game lol
  • Xdqwerty @ Xdqwerty:
    @SylverReZ, sorry for the stupid suggestion I had in that thread
  • SylverReZ @ SylverReZ:
    Its fine
  • BakerMan @ BakerMan:
    what thread?
  • Sonic Angel Knight @ Sonic Angel Knight:
    BakerMan won't bake cakes for chat. :ninja:
    +3
  • Xdqwerty @ Xdqwerty:
    @Sonic Angel Knight, but we can have uremum's cake
    K3Nv2 @ K3Nv2: 🌱🟫