Converting Files to Object Modules

User projects written in or related to FreeBASIC.
jevans4949
Posts: 1151
Joined: May 08, 2006 21:58
Location: Crewe, England

Converting Files to Object Modules

Postby jevans4949 » Mar 30, 2007 14:40

At last it's here!

http://members.aol.com/jevans4949/File2Obj.zip

At various points people have raised the question of how to link bitmaps, etc. into their programs. Now you can!

Eventually I found the documentation for the Common Object File Format, which FreeBasic / GNU uses, and figured out how to write 'em.

This program allows you to incorporate any files (text, graphics, audio, whatever) into an object module which can be statically linked into your .exe. All you need is an extern statement in your program.

The zip file above contains documentation (the RTF file), source, executables and test files.

Thus far I have only tested it with simple text files. Let me know how you get on with other stuff.

Enjoy!

P.S.: This program has been developed using 0.17 30Jul2006 version. Please let me know of any incompatibilities with current CVS.
ytwinky
Posts: 217
Joined: Dec 03, 2005 12:44
Location: MD, Germany

Postby ytwinky » Mar 31, 2007 14:41

Hi jevans4949,
I did not yet try your program, but I translated your description to german for the needs of our german-forum-users..
So if you should ever need a german description, hal@:
http://ytwinky.freebasic.de/tuts/file2obj_d.htm
Plz note, that it is the first version, which won't change in contents but maybe in style..
Thx for your efforts ;)
Regards
ytwinky
jevans4949
Posts: 1151
Joined: May 08, 2006 21:58
Location: Crewe, England

Postby jevans4949 » Mar 31, 2007 22:26

Thanks, ytwinky.

I read through your translation, and it looks good to me. (I can read it, although I would struggle to write it!)

P.S.: Could you also post a reference on the German web site for the download file? This is not included in the documentation itself.
ytwinky
Posts: 217
Joined: Dec 03, 2005 12:44
Location: MD, Germany

Postby ytwinky » Apr 01, 2007 11:18

Hi jevans4949,
I'm glad you don't dislike my translation :D
a guy from the german forum wanted to link a bitmap to his program and didn't know how, so I suggested to use file2obj:
http://forum.qbasic.at/viewtopic.php?t=4160
(..and therefore I had to finish the translation quickly so that he could use it)
Alas, he got another solution..
btw:
This is not a joke ;)
[Edit]
..added a download link to the german description..
Regards
ytwinky
D.J.Peters
Posts: 8024
Joined: May 28, 2005 3:28
Contact:

Postby D.J.Peters » Apr 05, 2007 4:36

You can use .INCBIN for any files too.

Code: Select all

goto binary_end ' dont execute your binary datas jump over it
binary_start:
asm .incbin "anyfile.ext"
binary_end:
dim as any ptr lpData=@binary_start

now you can use lpData or lpData[index] as array.

that's all simple or not?

Joshy

NOTE: sorry not tested i will do it if i'm at home.
jevans4949
Posts: 1151
Joined: May 08, 2006 21:58
Location: Crewe, England

Postby jevans4949 » Apr 05, 2007 9:15

@D.J.Peters : That looks a neat solution. I hadn't seen it suggested anywhere before as an answer to the problem.

A person on the German website was apparently trying to use it to link in a .BMP as a direct substitute for BLOAD, which doesn't work as the format is different. I'm thinking about an alternative program to build graphic image buffers to be linked as EXTERNs.
I3I2UI/I0
Posts: 90
Joined: Jun 03, 2005 10:39
Location: Germany

Postby I3I2UI/I0 » Apr 05, 2007 20:35

Yeah, Joshy
But not so simple.

Code: Select all

Dim As Any Ptr lpData
Asm 
  jmp binary_end
  .balign 16
  binary_start:
  .incbin """poke_.bin"""
  .balign 16
  binary_end:
  lea eax, binary_start
  mov [lpData], eax
End Asm
(FB016b)

Code: Select all

...
  .incbin "poke_.bin"
...
(FB017CVS)
Alexa
Posts: 56
Joined: May 01, 2007 20:22

Postby Alexa » Jun 26, 2007 2:32

i can't understand how can i use it with my Bload

Bload @mybmp , abc

?!!!
jevans4949
Posts: 1151
Joined: May 08, 2006 21:58
Location: Crewe, England

Postby jevans4949 » Jun 26, 2007 12:19

No, BLOAD doesn't work with it at the moment.

As mentioned, I was planning to develop an alternative version that (effectively) did a BLOAD and built a buffer image (which is a totally different format).

Sorry, if there is an interest I will try to do it this evening.
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Dec 17, 2008 16:10

You can download his utility here.. File2Obj.zip

-Vince
Mysoft
Posts: 777
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Postby Mysoft » Dec 17, 2008 18:39

i can make some "library" to load resources in a way that can be usable by freebasic... (for windows only)

if any interest into that...
Lachie Dazdarian
Posts: 2338
Joined: May 31, 2005 9:59
Location: Croatia
Contact:

Postby Lachie Dazdarian » Dec 17, 2008 23:24

Yeah, I'm interested Mysoft.

Anyway, I wasn't aware of this routine. Gonna test it later to see how functional it's today.
jcfuller
Posts: 324
Joined: Sep 03, 2007 18:40

Postby jcfuller » Dec 18, 2008 10:04

Doesn't resource file RCDATA perform the same task??

James
marcov
Posts: 2963
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Postby marcov » Dec 18, 2008 13:18

Mysoft wrote:i can make some "library" to load resources in a way that can be usable by freebasic... (for windows only)

if any interest into that...


There are ways for other platforms too. FPC does something like that, but only in 2.3.x (trunk).

However IIRC that means you will have to customize the linker file, and can't use the built-in one.

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 6 guests