#117217 - Risine - Fri Feb 02, 2007 1:38 pm
I'd like to put my data as files on the rom, and no more as .H included in the code ( limited to 4Mo ).
Let's suppose I have 10Mo of pcx files ( I'm using EZ-Flash2 ), what are the possibilities?
1/ The one I'd rather use is with fopen/fread/.... Is it possible this way?
If possible, how do I add data files to the ROM?
2/ GBFS Is it possible this way too?
Are the steps below ok?
gbfs toto.gbfs img1.pcx img2.pcx hop.bin story/diag ...
padbin 16 hop.ds.gba
copy /b hop.ds.gba+toto.gbfs hop.ds.gba
#117218 - scknight - Fri Feb 02, 2007 1:49 pm
You can use ndstool to put files in the filesystem of the rom. Just use
ndstool -x mygame.nds -9 arm9.bin -7 arm7.bin -d myfolder
where your folder contains your data. However as far as I know there are no library options for reading the filesystem and youll have to write your own code to read the files from the rom
#117220 - silent_code - Fri Feb 02, 2007 2:40 pm
go with gbfs. on the nds you need to align the rom to 256, afaik. i attach the filesystem to the nds file, not the ds.gba, then dsbuild it. don't know of any problems when attaching to the.gba, but some cards need .nds files, some need .gba files. that way you have them both.
there are some good tutorials on this topic, like http://www.double.co.nz/nintendo_ds/nds_develop6.html.
happy coding!
#117229 - Risine - Fri Feb 02, 2007 4:03 pm
Guys, just wondering if I'm not saying wrong things :
Do data compiled as .H files using bin2o affect available RAM in the executable?
I mean, can I add 10Mo of .H data in the program without affecting the available RAM while running?
#117233 - wintermute - Fri Feb 02, 2007 5:51 pm
scknight wrote: |
You can use ndstool to put files in the filesystem of the rom. Just use
ndstool -x mygame.nds -9 arm9.bin -7 arm7.bin -d myfolder
where your folder contains your data. However as far as I know there are no library options for reading the filesystem and youll have to write your own code to read the files from the rom |
so what was the point of mentioning this at all?
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#117242 - sumiguchi - Fri Feb 02, 2007 8:09 pm
why not use libfat? With DLDI I would anticipate that it will provide the best compatability in the long term and gives you read and write capabilities. Plus you don't even need to add the files to your Rom, just put them on the media.
#117256 - josath - Fri Feb 02, 2007 9:45 pm
I believe EZ-Flash2 is an old-style gba flashcart. Which means to use libfat, you'd need to build an FCSR image.
There are some scripts for doing this on Windows and Linux, see GPF's page: http://gpf.dcemu.co.uk/ download the 'fcsrimage.zip' on the left sidebar.
The advantage of this method, is that you could distribute both the datafiles, and the FCSR image, and your code would work on pretty much every device out there (anything that supports gbarom OR libfat. The only things it wouldn't work on might be a few obscure slot-1 devices).
Basically the flow is like this:
1. Put all your PCX files in some data/ directory (don't convert them with bin2o)
2. in your code, use something like: Code: |
fatInitDefault(); //initalize filesystem
struct stat fileStat; //struct to hold info about file
stat("/data/person.pcx", fileStat); // read file info
int fileSize = fileStat.st_size; // get filesize
FILE *personFile = fopen("/data/person.pcx", "rb"); // open file
u8 *buffer = (char *)malloc(fileSize); //allocate memory
fread(buffer, 1, fileSize, personFile); //read file into memory
fclose(personFile); //close file
sImage personImg; //image struct
loadPCX(buffer, &personImg); //load the PCX into the image struct
int imageSize = personImg.width * personImg.height; // calculate size of image data. assumes 8-bit image
dmaCopy(personImg.image.data8, SPRITE_GFX, imageSize); //copy image data into VRAM
|
3. Compile your app
For GBA Flashcart users:
4. Create your FCSR image containing the data/ directory
5. padbin the .ds.gba file
6. Append the FCSR image to the .ds.gba file
7. flash the .ds.gba file to your GBA cart
For Media cart users:
4. Copy the data/ directory to your SD/CF card
5. Copy the .nds file to your SD/CF card
#117257 - Risine - Fri Feb 02, 2007 10:07 pm
Thanks everybody, I'll give a try to these solutions if I don't find a way for data .H files.
I tried to insert a data file around 13Mo ( as a .H ), and the link failed :
"
region ewram is full
section .init [02000000 -> 0200023b] overlaps section .ARM.extab [02000000 -> 020001af]
section .ARM.exidx [020001b0 -> 0200061f] overlaps section .init [02000000 -> 0200023b]
.......
"
Is there a way to link that stuff and allow big data .H files?
#117258 - rodif - Fri Feb 02, 2007 10:23 pm
Your arrays need to be declared as
static const int something[] = {};
const keyword tells the linker to put the data on the cart not epram
#117259 - josath - Fri Feb 02, 2007 10:27 pm
rodif wrote: |
Your arrays need to be declared as
static const int something[] = {};
const keyword tells the linker to put the data on the cart not epram |
That doesn't work on DS, you must be thinking of GBA. You are still limited to 4MB (actually a bit less) for your arm9 binary. Anything that gets linked, gets put into the binary. If you want more than 4MB of data, you need it attached some other way: appended gbfs/romfs/fcsr, or libfat to read directly from SD/CF.
#117269 - rodif - Fri Feb 02, 2007 11:56 pm
shoot forgot what form i was replying on.
ignore me
#117412 - silent_code - Sun Feb 04, 2007 7:48 pm
to put it straigth: FORGET ABOUT .H FILES (containing your game data)! ;) they contain persistent data, but you want dynamic data. use one of the librarys mentioned above. hope that makes it clear. ;p