Access SRAM with libnds?

NotImpLife

Active Member
OP
Newcomer
Joined
Mar 9, 2021
Messages
42
Trophies
0
Website
github.com
XP
491
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,402
Trophies
2
XP
3,427
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
491
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
  • NinStar @ NinStar:
    on tiramisu you can access it by opening mii maker
  • crafthp434 @ crafthp434:
    okay
  • NinStar @ NinStar:
    I don't have a wii u anymore to test it myself, but if homebrews are not visible on the wii u menu I think you can press L + R + minus to open the plugin menu, there should be an option called "homebrews on wii u menu" or something similar
  • crafthp434 @ crafthp434:
    nope
  • crafthp434 @ crafthp434:
    it is L+dpad down+ select
  • crafthp434 @ crafthp434:
    but homebrew is appearing in the home menu btw
  • NinStar @ NinStar:
    yes, now I remember it
  • NinStar @ NinStar:
    then it is working, I also don't like that they did this but it is the only option you have if you are using aroma
  • crafthp434 @ crafthp434:
    i just didint know the homebrew launcher didint exist in aroma
  • crafthp434 @ crafthp434:
    thanks btw
  • Xdqwerty @ Xdqwerty:
    Im downloading fallout 3 goty edition
    +1
  • BigOnYa @ BigOnYa:
    I'm downloading more ram for my hamster pc
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    New hamster PC, with anal operation and BT connectivity!
    +1
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, How do I make enemies respawn on gdevelop after
    the player dies?
  • Psionic Roshambo @ Psionic Roshambo:
    Carrying a PC or phone is so old school!
  • Psionic Roshambo @ Psionic Roshambo:
    Squeeze your cheeks twice to answer calls!
  • BigOnYa @ BigOnYa:
    @Xdqwerty you can use a "spawner" function on any object.
    +1
  • BigOnYa @ BigOnYa:
    Or when your player dies, you can say in code, if enemy exists, do nothing, but if enemy does not exist, then create enemy at certain spot. (This would be a pain tho for lots of emeies)
    +1
  • BigOnYa @ BigOnYa:
    Easiest, simple way would be just restart scene, but player would restart from beginning.
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, thx in advance
    +1
  • Spider2190 @ Spider2190:
    Heya
  • Spider2190 @ Spider2190:
    How are you doing, @Xdqwerty
    ?
  • Psionic Roshambo @ Psionic Roshambo:
    Dolphin porn??? This man has my vote!!! Lol
    Psionic Roshambo @ Psionic Roshambo: Dolphin porn??? This man has my vote!!! Lol