ROM Hack How to add DLDI?

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,348
Country
United Kingdom
DLDI is the feature added to recent builds of libfat and gba_NDS_fat, gba_nds_fat is the old version so unless you are adding to an app that already uses GBA_NDS_FAT might I suggest using libfat.

It comes as part of devkitpro/devkitarm but you can get it as a seperate download here, there is also a short tutorial there:
http://chishm.drunkencoders.com/libfat/index.html

If you are adding to an already existing app you did not make really you need source code, also check it has not already been done:
http://forum.gbadev.org/viewtopic.php?t=12146
 

chuckstudios

Putting the pro in procrastination
Member
Joined
Jul 19, 2006
Messages
890
Trophies
0
Age
124
Location
North Carolina, USA
Website
www.schlarp.com
XP
275
Country
United States
In your Makefile, you need to add the flag -lfat to the LIBS line, it has to go before -lnds9.

In your program, you first have to call fatInitDefault(); to start the FAT access. Then you use standard stdio functions like fopen, fread, fwrite, and fclose to do file input and output.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,348
Country
United Kingdom
Edit, far far too slow hitting reply and seemingly wrong. Oh well.

Sorry if I sound insulting, I assure you it is not my intent. DLDI is a feature of the libfat library (which acts as a go between for the DS and a flashcart, as I mentioned already GBA_NDS_FAT was the previous library most used to pull this off but it has since been dropped) that allows you to read contents on the FAT, as new carts appear and each seperate cart has different (often mutually incompatible) methods of accessing the FAT DLDI was born/adapted from a similar concept used in moonshell. It works by adding a small section of blank space (32KiB if I recall), adding a specially crafted read (and hopefully write) patch and then "calling" it every time FAT access is required.
As such you include it like any other library and call the functions it provides (you have to mount it before reading if memory serves and it is generally considered wise to unmount afterwards), the tutorial explains it far better than I can.

I am not so familiar with C? languages and makefile stuff in general but the makefile is really only needed for DLDI if you want it prepatched for a given cart and do not want to do it yourself (as I understand it you can add command line actions to them).

As for how you would want to add it if you are writing an app I can not say how you would want to do it: that is your call. In my opinion it depends on whether you are making an emulator/media player type app or a "game" type where only the textures/levels/sounds/monkey pictures are read into memory.
If it is the former then I suggest tying it into a file browser or if that is not desirable a hardcoded directory (I warn you though a fair few other apps do this and the root of my memory cards (even though I only use a few choice bits of homebrew) is very cluttered). Picodrive DS is considered a good example of a file browser: http://www.cryptosystem.org/projects/nds/picodriveds-0.1.7/ (tarball there although there is a bountysource site I seem to remember).

If it is a game where only the textures/level data..... is loaded with you only really altering the business side of the code then you can stand to hardcode the directories and even file names either in the app or get them read from a user editable "ini" file.

As for actually adding it to the code once again the tutorials on the sites I linked are your best bet, if you plan on doing a lot of of FAT access add it into the main section of the code, if it is for something like saves (kind of a waste in my opinion but that is just me) then you can probably add it to whatever section of code handles saves (although I would work it into the main section if possible).
 

chuckstudios

Putting the pro in procrastination
Member
Joined
Jul 19, 2006
Messages
890
Trophies
0
Age
124
Location
North Carolina, USA
Website
www.schlarp.com
XP
275
Country
United States
Also, I forgot to mention you need to #include "fat.h". To add onto what FAST6191 said about user-defined directories, I have found the iniParser library to be very adept at handling INI files, and it compiles without modification on the DS. It is also under the MIT license, so you don't have to make your projects which use it open source if you don't want to.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • BakerMan
    I rather enjoy a life of taking it easy. I haven't reached that life yet though.
  • BigOnYa @ BigOnYa:
    I don't trust the free ones, but ipvanish I've used for couple years now, n like
  • Psionic Roshambo @ Psionic Roshambo:
    I wonder if they could get CPUs to run that hot then use the heat to power a steam turbine to power the CPUs....
  • BigOnYa @ BigOnYa:
    Good idea, or at least power the GPU
  • Psionic Roshambo @ Psionic Roshambo:
    It's not the movies or games downloads that I would worry about, like breaking into networks, downloading encrypted things, spying on network traffic. I have seen so many "Top Secret" seals on files when I was a kid
  • Psionic Roshambo @ Psionic Roshambo:
    I was obsessed with finding UFOs, a surprising amount of US files where stashed on computers in other countries, China back in the early 90s omg sooo much
  • BigOnYa @ BigOnYa:
    Yea that crazy, I've never tried hack into anything, I just pirate, and my ISP have send me 3-4 letters, so had to VPN it
  • Psionic Roshambo @ Psionic Roshambo:
    Ship to ship communication software for the Navy although without access to the encrypting chips it was mostly useless
  • Psionic Roshambo @ Psionic Roshambo:
    I bet now a 4090 could probably crack it? Hmmm maybe not even back then I'm pretty sure they where using like 1024 bit encryption
  • Psionic Roshambo @ Psionic Roshambo:
    Yayyy the one set finished 324GBs lol
  • Psionic Roshambo @ Psionic Roshambo:
    Compressed....
  • Psionic Roshambo @ Psionic Roshambo:
    I wonder how many years that would have taken on a 56K modem lol
  • Psionic Roshambo @ Psionic Roshambo:
    18000 hours lol
  • Psionic Roshambo @ Psionic Roshambo:
    750 days lol
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    So Internet is very much faster now lol
  • BigOnYa @ BigOnYa:
    "Time Remaining- 2 years, 9 girlfriends, 6 hairstyles, please standby..."
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    I remember one time I downloaded like a 500MB ISO file on 56K and that literally took like 2 days
  • Psionic Roshambo @ Psionic Roshambo:
    I had some sort of resume thing, I remember the software had chains
  • Psionic Roshambo @ Psionic Roshambo:
    Damned if I can't remember.the name though
  • Psionic Roshambo @ Psionic Roshambo:
    Some sort of download management app
  • BigOnYa @ BigOnYa:
    Ok good chatting, I'm off to the bar, to shoot some pool, nighty night.
    +1
  • BakerMan @ BakerMan:
    hey psi
  • BakerMan @ BakerMan:
    i call your girl lyndon the way she b on my johnson
    BakerMan @ BakerMan: i call your girl lyndon the way she b on my johnson