#127476 - snowsquirrel - Wed May 02, 2007 8:04 pm
Simple question:
I want to add some data to my ds project. I am assuming libfat is the way to do this. So I link in libfat, and try to open a file as "fat0:/test.txt", and it fails.
Most likely it is missing from .nds. So my question is, what do I have to do, to get test.txt into my .nds file so it is found?
Thanks,
~S
#127486 - josath - Wed May 02, 2007 11:01 pm
You don't have to specify fat0:
Just do fopen("/test.txt", "r");. Of course, make sure 'test.txt' actually exists on your SD or CF card in the root directory.
Basically, you don't embed the files in your .nds if you want to use libfat. You put them on the card along with the .nds
#127488 - snowsquirrel - Wed May 02, 2007 11:24 pm
Thanks for the reply. That clears a lot up. Now, what if I wanted to embed in the .nds? Should I be looking at gbafs for that?
Thanks,
~S
#127489 - Lick - Wed May 02, 2007 11:49 pm
Instead of GBFS you could simply rename your file *.bin, and put it in the data folder. Just like your graphics.
_________________
http://licklick.wordpress.com
#127490 - snowsquirrel - Wed May 02, 2007 11:53 pm
I use my own makefile.
(For images I use PAGfx.exe which converts them to static arrays, for now. I was going to change this though.)
My makefile doesn't do anything to the data directory. But I'll look at the makefile templates and see what they do with .bin files in the data directory.
Then how do I load/read those files, at runtime?
#127492 - Lick - Thu May 03, 2007 12:12 am
How do you load your graphics? (If you have any)
The libnds template Makefile takes all the *.bin from the data folder and automatically includes it in your binary. It also generates header files that you include (don't even need to write them yourself) in your project.
Code: |
#include "webcam_bin.h" // "data/webcam.bin"
memcpy(dst, webcam_bin, webcam_bin_size); |
That's all there is to it.
_________________
http://licklick.wordpress.com
#127501 - tepples - Thu May 03, 2007 12:45 am
But then how do you get the makefile to regenerate the .bin files every time the corresponding .bmp files change?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#127506 - Lick - Thu May 03, 2007 12:48 am
Not sure, but it seems to auto-detect it in my projects. If I change the file it will be told in the build output messages. If I haven't changed it, it won't be in those messages.
_________________
http://licklick.wordpress.com
#127517 - snowsquirrel - Thu May 03, 2007 1:31 am
If it is putting it in a .h, then it must be as static data. My understanding is that if it is static data, then on most systems, it must be taking up RAM? Whereas if it is in a file, it is not taking up memory until you load it.
Quote: |
memcpy(dst, webcam_bin, webcam_bin_size); |
dst must be the same size as webcam_bin, so now you have it memory twice.
This is what I currently do with images. This is what I am trying to get away from.
~S
#127524 - Lick - Thu May 03, 2007 2:09 am
Well as far as I know, GBFS data has to be loaded into memory as well (because it's in your NDS file and that whole file gets loaded).
Only libfat will keep the files away from RAM until needed.
_________________
http://licklick.wordpress.com
#127525 - snowsquirrel - Thu May 03, 2007 2:11 am
hmmm, ok. sounds like libfat is what I want. Thanks,
~S
#127527 - Lick - Thu May 03, 2007 2:20 am
No problem,
~L
_________________
http://licklick.wordpress.com
#127536 - snowsquirrel - Thu May 03, 2007 3:33 am
OK, I put a test.txt right beside my .nds file. Then I run desmume.exe on the .nds, but I am unable to open the file:
fatInit( 8, true);
const char* mesg = 0;
FILE* test = fopen( "/delme.txt", "r" );
if( test )
{
mesg = "opened file";
}
else
{
mesg = "could not open file";
}
fclose( test );
SCRN_PRINT( mesg );
#127537 - tepples - Thu May 03, 2007 3:45 am
snowsquirrel wrote: |
OK, I put a test.txt right beside my .nds file. Then I run desmume.exe |
Have you tried checking the fatInit() return value? Have you tried running the file on a Nintendo DS video game system instead of on desmume.exe?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#127539 - snowsquirrel - Thu May 03, 2007 4:00 am
Yeah, you got it. The init is failing... probably to do with emulator I am guessing.
I still don't have a flash cart yet. It is in the works. Are there any emulators that work with libfat?
~S
#127548 - GPFerror - Thu May 03, 2007 5:13 am
snowsquirrel wrote: |
Yeah, you got it. The init is failing... probably to do with emulator I am guessing.
I still don't have a flash cart yet. It is in the works. Are there any emulators that work with libfat?
~S |
search forums for FCSR.
desumem, no$gba and ideas all work with libfat with specially appended FAT12 images and patched with a fcsr.dldi patcher
#127603 - snowsquirrel - Thu May 03, 2007 2:34 pm
Ok, following these steps from GPFerror:
http://forum.gbadev.org/viewtopic.php?t=12654%3C/blockquote%3E%3C/div%3E
I got the filesystem to init using no$gba. desmume just crashes though.
~S