#135659 - jonnyhilly - Wed Jul 25, 2007 9:44 am
Hi, I'm using the file system and added a big database file, about 4mb
and the compiler game me an error about pointers not working...
I though I could have more than 4MB of data if I use the file system. How does this work, and what are the real limits ?
thanks
Jon
#135663 - Sektor - Wed Jul 25, 2007 11:29 am
What file system are you using? Libfat can access files stored on your card of any size.
The arm9 binary can't be larger than 4MB since it is loaded into RAM. That would only happen if you were embedding the data. If you attach it to the .nds after compiling then it won't be loaded into RAM and you could access it with libfat if you knew where on the card the .nds file was stored or you could just have it as an external file.
_________________
GTAMP.com/DS
#135665 - OOPMan - Wed Jul 25, 2007 12:13 pm
Even if you are using libfat, attempting to load the entire file into memory won't really work...
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI
You can find my NDS homebrew projects here...
#135683 - jonnyhilly - Wed Jul 25, 2007 4:42 pm
I'm using the file system which comes with devkitpro,
"embedded_gbfs" so that must be the problem
I'm only loading a line of text at a time, but I guess that doesn't matter
as its just down to the file being too big to include.
I'll go searching for LibFat
thanks
#135688 - kusma - Wed Jul 25, 2007 4:51 pm
libfat also comes with devkitPro.
#135710 - M3d10n - Wed Jul 25, 2007 6:33 pm
GBFS only works for slot-2 flashcarts, since the GBA cart space is memory mapped. If you use it on slot-1 devices, you'll be limited to the 4MB main memory. Use libfat for that.
#135772 - jonnyhilly - Thu Jul 26, 2007 7:35 am
kusma wrote: |
libfat also comes with devkitPro. |
It does? cool, thanks
I found fat.h and libfat.a in the lib and include folders.
I don't see any examples that uses libfat though
I see, sound, graphics, input, realTimeClock, debugging and filesystem example folders, and the filesystem folder only has embedded_gbfs examples. no, libFat examples though
Where can I get some example code or some docs on libfat ?
or for that matter, docs on the whole libnds ?
Do I need a special makefile ?
thanks for the tip
#135775 - calcprogrammer1 - Thu Jul 26, 2007 7:56 am
Libfat is pretty awesome...I'm using it for my file browser, and it's pretty good. You can read the directory list and open files. The command for reading a file is simple:
fread();
though I forget the syntax, you can search online for "fread() c" (libfat replicates all the C file functions on the DS). I think it was www.cplusplus.com that had some good references.
EDIT: Here's the page I was referring to:
http://www.cplusplus.com/reference/clibrary/cstdio/fread.html
You can read files in text or binary mode, though for a database you'd probably want text, read a line of text in, store it to an array, etc, but remember that what's loaded in RAM at any given time has to be <4MB, so cycle the data in and out from the file.
You'll also need the includes
#include <fat.h>
#include <sys/dir.h> //for directory support
You also have to change the LIBS section of the makefile, find the line
LIBS := -lnds9
and change to
LIBS := -lfat -lnds9
and last you have to use the command
fatInitDefault();
to set up the FAT system...look on Chishm's libfat page for info.
_________________
DS Firmware 1, Datel Games n' Music card / Chism's FW hacked GBA MP v2 CF
There's no place like 127.0.0.1.
#135777 - jonnyhilly - Thu Jul 26, 2007 8:05 am
thanks very much
I have to say the help on these forums is great
I hope to contribute in future :)
#135780 - calcprogrammer1 - Thu Jul 26, 2007 8:10 am
That's exactly why I visit these forums every day :)
Now that I've had some experience in programming libfat (though I'm still awful at it), I post what I've learned, and if you're in need of source code, I'll post some examples if I know any, that's something that people on these forums have done for me.
...I guess that's a good thing, because I haven't found much 'official' documentation (other than references to other c sites) for these libraries.
Another thing I'd recommend to new DS programmers: PAlib (www.palib.info), it takes the figuring of allocating vram and stuff just to display a background or an image out, but it's still compatible with libfat, I'm using it (along with libfat) to create my file browser.
_________________
DS Firmware 1, Datel Games n' Music card / Chism's FW hacked GBA MP v2 CF
There's no place like 127.0.0.1.