Converting Files to Object Modules

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
Post Reply
jevans4949
Posts: 1186
Joined: May 08, 2006 21:58
Location: Crewe, England

Converting Files to Object Modules

Post by jevans4949 »

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

Post by ytwinky »

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: 1186
Joined: May 08, 2006 21:58
Location: Crewe, England

Post by jevans4949 »

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

Post by ytwinky »

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: 8586
Joined: May 28, 2005 3:28
Contact:

Post by D.J.Peters »

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: 1186
Joined: May 08, 2006 21:58
Location: Crewe, England

Post by jevans4949 »

@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

Post by I3I2UI/I0 »

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

Post by Alexa »

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

Bload @mybmp , abc

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

Post by jevans4949 »

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: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Post by vdecampo »

You can download his utility here.. File2Obj.zip

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

Post by Mysoft »

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:

Post by Lachie Dazdarian »

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: 325
Joined: Sep 03, 2007 18:40

Post by jcfuller »

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

James
marcov
Posts: 3462
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Post by marcov »

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.
Post Reply