Converting Files to Object Modules
-
- Posts: 1186
- Joined: May 08, 2006 21:58
- Location: Crewe, England
Converting Files to Object Modules
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.
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.
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
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
-
- Posts: 1186
- Joined: May 08, 2006 21:58
- Location: Crewe, England
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
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
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
You can use .INCBIN for any files too.
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.
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
that's all simple or not?
Joshy
NOTE: sorry not tested i will do it if i'm at home.
-
- Posts: 1186
- Joined: May 08, 2006 21:58
- Location: Crewe, England
@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.
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.
Yeah, Joshy
But not so simple.(FB016b)
(FB017CVS)
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
Code: Select all
...
.incbin "poke_.bin"
...
-
- Posts: 1186
- Joined: May 08, 2006 21:58
- Location: Crewe, England
-
- Posts: 2338
- Joined: May 31, 2005 9:59
- Location: Croatia
- Contact:
There are ways for other platforms too. FPC does something like that, but only in 2.3.x (trunk).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...
However IIRC that means you will have to customize the linker file, and can't use the built-in one.