gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > libfat help

#117065 - Balkman - Thu Feb 01, 2007 12:52 am

I need the ability to store game assets that arn't compiled into the ARM binarys to save memory. Libfat is the answer to this aparently, but I am having a pretty difficult time finding any tutorials/documentation on how to use the library.

First off, I have no clue what a DLDI is, so I have downloaded the source for the corresponding card I own (in my case it's the R4).

There isn't many functions within the source making not overwhelming at least, but I have some questions on what exactly I should be putting into the parameters of these methods.

My other question is how/where do I store these external resources such as graphics and sounds. Placing them in the "data" folder located in the project directory will result in them being compiled into header files (which I want to avoid) due to wintermute's makefile. I just need to know how to get them onto the R4 along with my executable.

(P.S. I haven't actually recieved my R4 card yet in the mail)

#117067 - tepples - Thu Feb 01, 2007 12:58 am

You place the asset files in a folder on your microSD card, and then you give the pathnames to fopen().
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#117105 - GrizzlyAdams - Thu Feb 01, 2007 10:35 am

You don't need to touch the DLDI source unless you are writing a new driver.

Add libfat to your arm9 LIBS= line in your makefile (before -lnds9)

In the file with your main() add this line to the includes:
Code:
#include <fat.h>


In your main() where you do all your initialization, add this:
Code:
fatInitDefault();


now you can use both stdio (fopen, fread, etc...) and fileio (open, read, lseek, etc...) like you would on any other platform.

Grab the .DLDI for your card, and patch your .nds with dlditool.

#117115 - Diddl - Thu Feb 01, 2007 11:44 am

if you dont want to do it with DLDI, I have a io-driver for actual fatlib. it works fine in DSdoom on R4 and M3simply.