Access SRAM with libnds?

NotImpLife

Active Member
OP
Newcomer
Joined
Mar 9, 2021
Messages
41
Trophies
0
Website
github.com
XP
487
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,362
Trophies
1
XP
3,297
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
41
Trophies
0
Website
github.com
XP
487
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
  • No one is chatting at the moment.
  • K3Nv2 @ K3Nv2:
    I'll reformat and have a 3tb raid0 m. 2 at least
    +1
  • K3Nv2 @ K3Nv2:
    Lmao that sold out fast
    +1
  • Veho @ Veho:
    Yeet the cat.
    +1
  • K3Nv2 @ K3Nv2:
    Good idea
    +1
  • The Real Jdbye @ The Real Jdbye:
    i thought everybody knew cocktails are like 75% ice
  • Veho @ Veho:
    Yeah but not like this.
  • Veho @ Veho:
    It's not like they're complaining that their Slurpee is 99% ice or something, but if the cocktail calls for "shot of vodka, shot of vermouth, shot of gin, shot of Campari, three shots of juice, squirt of lemon" and ends up being a thimbleful of booze, that's a problem.
  • The Real Jdbye @ The Real Jdbye:
    the funny thing is cocktails in norway are only allowed to have 1 20ml shot of booze
  • The Real Jdbye @ The Real Jdbye:
    so..... yeah
  • The Real Jdbye @ The Real Jdbye:
    we're used to only having a thimbleful of booze
  • Veho @ Veho:
    Booo.
  • The Real Jdbye @ The Real Jdbye:
    same thing if you want whisky on the rocks or something, you can't get a double
  • The Real Jdbye @ The Real Jdbye:
    but you could buy as many shots of whisky (or anything else) as you want and ask for a glass of ice and pour them in
  • The Real Jdbye @ The Real Jdbye:
    it's dumb
  • Veho @ Veho:
    Maybe.
  • Veho @ Veho:
    There was a comparison of the number of Ibuprofen poisonings before and after they limited the maximum dosage per box or per pill (i'll look that up). No limit on the number of boxes you can still buy as many as you want, so people argued it was pointless.
  • Veho @ Veho:
    But the number of (accidental) poisonings dropped because drinking an entire package of ibuprofen pills went from "I need a new liver" to "I need a new box of Ibuprofen".
  • Veho @ Veho:
    Here we have ketoprofen that used to be prescription-only because of the risk of toxic dosages, but then they halved the dose per pill and sell them in bottles of six pills apiece instead of twenty and it doesn't need a prescription any more. Yes you can buy more than one bottle but people simply don't.
  • Psionic Roshambo @ Psionic Roshambo:
    Usually accidentally overdose of ibuprofen here is from people taking like cold medicine then ibuprofen for a headache and the combination is over what they need
    Veho @ Veho: https://imgur.com/gallery/QQkYnQu