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 > Adding binary data

#8934 - punchy - Thu Jul 24, 2003 10:00 am

Hi,

I'm working on a simple emulator for the GBA and I'm getting ready to release it. Currently I take the ROMs for the game I emulate, run them through objcopy to get labels the linker will pick up, and then link them in at compile time.

However, I can't release the emulator with copyrighted ROMS so I need a way of adding them to the already complied binary. How do I refer the ROM images in code if they aren't added yet?

Any help would be most appreciated.

#8936 - ampz - Thu Jul 24, 2003 10:27 am

Newbie or C/C++ section perhaps?
Your load the ROM image from file into RAM.

#8937 - Quirky - Thu Jul 24, 2003 10:27 am

After you compile, pad your binary to a particular size, then set an address in the code to this known padded size. You can access the data at that memory location.

For example, if your binary (.gba) file compiles to 31000 bytes... you could potentially pad it to 32000 bytes and add a pointer to 32000 in rom:

Code:

#define datapointer (( u8*)(0x8000000+32000))

int main (void) {
 load_rom(datapointer);
}


void load_rom(u8 * data) {
   // data points to the data...
}


then recompile it - it might recompile to 31020 bytes now (for example)... but you pad it to 32000 so it doesn't matter.

Append your roms with (in dos)

copy /b emulator.gba+<file>.rom emulatorandgame.gba

By having a "size" byte in the appended rom or knowing all games are a particular size, you can step from the base pointer to other games in rom.

What's the emulator of, by the way? :)

#8939 - punchy - Thu Jul 24, 2003 11:25 am

Thanks Quirky!

The emulator is Phoenix.

http://www.geocities.com/rgbPhoenix/index.html

#9001 - www-fmsoftware-info - Sat Jul 26, 2003 2:03 am

Very nice game.

Not sure about pressing select to fire though :\
_________________
[Images not permitted - Click here to view it]
www.fmsoftware.info

#9511 - Burre - Thu Aug 07, 2003 12:36 am

www-fmsoftware-info wrote:
Very nice game.

Not sure about pressing select to fire though :\


Since the screen is tilted i guess it is supposed to be played like that (making the select-button a more clever choice than the A-button). Though if you have an SP either one could be difficult to use.

Nice demo anyway...
_________________
"The best optimizer is between your ears..."