Search the web
Sign In
New User? Sign Up
gbadev
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
How to add binary data files to projects?   Message List  
Reply | Forward Message #9715 of 15019 |
RE: [gbadev] How to add binary data files to projects?

Use INCBIN statement in an assembly file.
That way you can pad it yourself.

Aelius.

>-----Original Message-----
>From: Jason Emery [mailto:felixd@...]
>Sent: Thursday, January 31, 2002 23:18
>To: gbadev@yahoogroups.com
>Subject: Re: [gbadev] How to add binary data files to projects?
>
>
>
> Here is my problem: I would like to convert a (large) binary data file into
an object file so I can insert it into my
>project, thr problem is that I can't find a proper way to do it. Here is the
alternatives I found so far: (note that I'm
>using Visual C++ 6.0 and ARM Developer Suite 1.1)
>
> 1/ Convert the file to an array and let the compiler create the object.
> Pros: easy to do, even you dont have a converter, you can write one
in less than 15 minutes.
> Cons: the size of the output .c file increases exponentially compared
to the input binary file. At some point
>compiling the file can take up to 1/2 hour and eat more than 1g swap memory.
(the input data files are 8megabytes+ in size)
>
> 2/ Convert the file using bin2o by Darkfader.
> Pros: easy to use and fast.
> Cons: the output object file is byte array-based so it won't be
padded by the compiler, and you can have
>unaligned reads if you read more than one byte at a time. Also, the output file
cannot be used with MS's compiler.
>
> 3/ Convert the file using objcopy.
> Pros: err, i can't find any, except that it outputs an (unusable)
object file.
> Cons: data is moved to .data section (iwram) so i can't really use
it, plus it's unaligned as Darkfader's bin2o.
>Same remark regarding Visual Studio.
>
> Please note that i'm using Visual with the embedded compiler, not GCC. (not
using gcc at all for compiling)
>
> If someone have an idea on how to do that, i'll be grateful.
>
>What I plan on doing is creating raw files and importing via assembly .s files,
then assigning them global variables
>through extern statements in my C code. This is done using the INCBIN command
as mentioned in the assembly program, then
>writing an extern to the symbol you use.
>
>An example of this assembly file is:
>
>.code 16
>.align 4
>.text
>.global VariableName
>.type VariableName,"object"
>VariableName:
>.incbin "filename.raw"
>
>And in C, you'd type:
>
>extern const char const VariableName[];
>
>Or some similar array type, depending on what you need, though I have yet to
test this thoroughly.
>
>Also, I've just written a program to convert a .c/.h file array to a .raw file
for this purpose, so I can use whatever
>data or program I want (many don't convert to .raw). If anyone wants it, feel
free to ask.
>
>(My sprite file was 8 megs uncompiled, which was taking about a minute or two
to compile.)
>
>Jason Emery
>World Tree Games
>
>
>[Non-text portions of this message have been removed]
>
>
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>





Thu Jan 31, 2002 11:15 pm

pdafantast
Offline Offline
Send Email Send Email

Forward
Message #9715 of 15019 |
Expand Messages Author Sort by Date

Hello, Here is my problem: I would like to convert a (large) binary data file into an object file so I can insert it into my project, thr problem is that I...
Alex GANEA
alex_toresh
Offline Send Email
Jan 31, 2002
4:35 pm

... (not using gcc at all for compiling) As you're using the ARM SDT why not just INCBIN the data from an assembler file? . . . label: INCBIN file.bin . . ....
James Boulton
jim@...
Send Email
Jan 31, 2002
5:38 pm

Hi, I used the ARM SDT evaluation version when I started GBA stuff, and the way I did things was to have a .s (assembly) file where I put ALL my data using the...
Francis Lillie
francis_lillie@...
Send Email
Jan 31, 2002
5:38 pm

Here is my problem: I would like to convert a (large) binary data file into an object file so I can insert it into my project, thr problem is that I can't find...
Jason Emery
felix_draconis
Offline Send Email
Jan 31, 2002
10:59 pm

Use INCBIN statement in an assembly file. That way you can pad it yourself. Aelius....
George Andre
pdafantast
Offline Send Email
Feb 1, 2002
8:42 am

I'd like to chime in again about adding in binary data files, simply to be helpful, though this depends on what compiler you're using. The version of GAS that...
Jason Emery
felix_draconis
Offline Send Email
Feb 1, 2002
8:44 am

Thank you guys for your answers, I completely forgot about .incbin! It would also be cool that everyone who answers in this group, reads what ppl answered...
Alex GANEA
alex_toresh
Offline Send Email
Feb 1, 2002
3:31 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help