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.

Coding > Getting data into a ROM

#1879 - Sweex - Fri Jan 24, 2003 11:08 pm

I'm looking for a fast way to get data into my binary. Currently I'm converting my data to source file containing a const array of u32. Problem is that these files get really big and take up time to compile.

So I'm looking for some fast way to get a datafile included without having to convert it to "source code". Is there a way to output in the format of an obj (.o) file?

(Background info: I'm writing some data system to get files into my ROM. Probably similar to GBFS, but I'm storing contents of a directory (tree) so you don't need to add it to some kind of archive.)

Tnx in advance!:)

#1883 - Touchstone - Fri Jan 24, 2003 11:48 pm

I'm converting my data to assembly source, which is way faster to assemble than compiling a huge C file.
Code:

      .DATA      @ Put in data segment

      .ALIGN      4
      .GLOBAL      gfx_tiles   @ Export label
gfx_tiles:
      .word      0x00000040   @ array size
      .byte      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @ Array content
      .byte      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
      .byte      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
      .byte      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
      .byte      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
      .byte      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
      .byte      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
      .byte      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

      .END      @ End of data segment

_________________
You can't beat our meat

#1886 - Sweex - Sat Jan 25, 2003 12:27 am

I thought about that already but dunno alot about asm, so tnx for the sample! However, it still has to be parsed.

I'm currently figuring out the ELF file format, and with a little luck I can write my own .elf containing binary data. That would rock!:-)

#1887 - Paul Shirley - Sat Jan 25, 2003 1:17 am

removed

Last edited by Paul Shirley on Sun Mar 28, 2004 9:36 pm; edited 1 time in total

#1888 - Sweex - Sat Jan 25, 2003 2:27 am

DOH! I was looking for just that, but I didn't think that would work in gcc. I did that trick back in my turbo Pascal days...! (Why is the most obvious way always the last one to think of?;)

Going to try that!!:)

#1890 - tepples - Sat Jan 25, 2003 2:38 am

You can store a GBFS file inside a GBFS file and do "directories" that way. Or you can store GBFS files one after the other because GBFS has a function to return a pointer to the end of a GBFS file.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#1906 - ampz - Sat Jan 25, 2003 11:05 am

Another way is to convert to source, but set up the dependencies so that the compiler doesn't have to recompile all the data every time.

#1909 - Sweex - Sat Jan 25, 2003 2:31 pm

YES!! Got objcopy working just the way I want it! It takes about 5 seconds to convert my 6.5mb test file into an ELF! Thanks for the tips all (especially Paul S.!)

@Tepples: I just don't want to use GBFS. Not that I think it isn't any good (In fact, I'm going to do something similar), but I want to code it myself and want to have a directory on my harddisk where I can directly copy files to. That directory (tree) will then be packed into one file and converted to an ELF using objcopy. I think this is just a bit more flexible, and I have can check which files are changed and need to get "repacked".