DLDI is a framework to allow DS Homebrew programs to support newly discovered SLOT-1 and SLOT-2 flash cards.
History of libfat
For many DS applications to be useful, it is necessary for the application to read and write data to and from the storage medium (SD card, microSD, CF, etc) used by the homebrew device. This lets you save your login for IRC, save your TODO list, delete files, read MP3 files, etc.
To do this, a coder named Chishm came up with a pair of libraries called gba_nds_fat and libfat, some reusable programming code that allowed for read/write access to the CF and SD cards of a few popular devices of the time, like the Supercard and M3. Since coders typically don't like to reinvent the wheel, pretty much every homebrew application out there used one of these libraries.
However, herein lied the problem. What if you weren't using a supported device? New devices started coming out more rapidly, faster than Chishm could successfully add stable, usable code to libfat. Some cards, like the DS-X and G6, didn't even release drivers at all, so they remained incompatible with many DS homebrew applications. In addition, after each new device was added to libfat, each and every homebrew program would have to recompile with the new libfat to add support for the device. Needless to say, this became a problem for older homebrew that was abandoned by its authors. In December of 2006, Chishm decided that a change was necessary. He proposed a new system called DLDI that would replace the current system, bringing with it great benefits. Most of the GBAdev community seemed acceptable to the idea, and thus Chishm gave the community a great Christmas present, releasing the first version of the DLDI interface.
What is DLDI?
DLDI is a Dynamically Linked Device Interface for libfat. What does that mean? Basically, instead of including static drivers for each device in every homebrew program, a 32 KB placeholder is inserted into the code instead. This placeholder is then replaced by the user, who patches the homebrew program with a specific DLDI patch for his or her specific homebrew device.
Benefits of DLDI
- Chishm no longer has to maintain all the drivers for all the cards. As soon as a driver is written by anyone, it is usable by everyone.
- Cards that aren't even released yet are supported by programs that have already been compiled. No more having to recompile to add support for a card.
- Manufacturers don't have to release source code to release an easily usable driver. No more having to recompile using other libraries. They don't need to make publicly available their trade secrets. Of course, this means we have to disassemble whatever they do release to understand the hardware, but we already have to do this (M3, G6, GBAMP).
Downsides of DLDI
In 2007, after new homebrew apps began to work with DLDI, makers of DS flash adapters began to incorporate automatic DLDI patching in the firmware. Notable exceptions were Datel (Games n' Music) and the maker of the GBA Movie Player v2. For users of cards without automatic patching, DLDI introduces an extra step
- Developers need to add a step to a project's makefile to run
dlditool, a command line tool to patch a program. This is fairly straightforward.
- Users need to patch any apps that use libfat for their particular card. This is okay, as they already do it for commercial roms. Alternatively, builds for the most popular cards can be released on a website, but this reduces the utility of such a scheme.
Because users must patch each piece of homebrew they wish to add to their flash cart, users of devices already supported by libfat might view it as nothing but an inconvenience. However, the benefits outweigh the downsides. With the recent onslaught of new slot-1 devices being released, the DLDI interface allows for each device to be instantly compatible with many homebrew applications as soon as a DLDI patch file is made for the device.
But there is a further drawback even with automatic patching: Some drivers do not fully conform to the DLDI specification. Such defective drivers may interfere with DMA or interrupts, or they may read or write incorrect data when handling odd numbers of bytes.
To begin using the DLDI system, first ensure that the homebrew program you wish to try has indeed been compiled with DLDI support. Anything last updated before December 2006 will not have DLDI support at all. Once you've found a suitable homebrew program, download it and extract it to a folder.
Now you need to get a patching utility. There are several different utilities out there, all of which are available at http://dldi.drunkencoders.com/index.php?title=Category:Tools
In the Windows operating system, the recommended tool for ease of use is "DLDIrc" aka "DLDI right-click". Upon installing, simply right-click the *.nds file (or *.bin or *.gba if you specified those options in the installer) and select the new patching option that appears.
Alternatively, you could use the folloing command-line instructions: once you've obtained dlditool.exe, the DLDI file your device, and the DS binary you wish to patch, put all of them into the same folder. Open a command shell and type "dlditool.exe" to receive the simple syntax instructions. As an example, typing
dlditool.exe scsd.dldi WordWrap.nds
will patch the WordWrap.nds file with the Supercard SD DLDI file.
Some newer Supercards have different internal workings that do not work with the default DLDI file. Supercard Lites were the first to exhibit this behavior, but issues with regular Supercard SD units have also been reported. They show few signs of being modified, and it is not a change that was ever announced by the Supercard team. However, due to differences in the internal workings of the devices, normal libfat code does not work. Moonlight, the creator of Moonshell, has created an alternate SCSD_moon.dldi patch file that has been reported to work on these Supercards when the standard SCDS.dldi and SCLT.dldi patches have failed.
This modified DLDI patch is reportedly made up of Supercard SD fat code taken from older versions of Moonshell, which were different than that of libfat. 
The main location to download this file is the official DLDI Wiki page, although the following mirrors are provided as a convenience:
- Moonlight's blog - this file was previously reported to have only reading capability, not writing. However, it has the same CRC as the reportedly fully working ones.
- Cryptosystem mirror
- Tepples' temp server