Dark Bit Factory & Gravity

PROGRAMMING => Coding tutorials => Topic started by: Shockwave on August 13, 2006

Title: UFMOD >>Step By Step Guide<<
Post by: Shockwave on August 13, 2006
Here is a step by step guide to get a song to be included in a demo and compile it in freebasic.
First of all I want to thank Rbraz / Gvy because I am using one of his tools and some of his code here.
Also credit to Radix, I've used one of his tracks because it's small and good.

First of all download the attachment and unzip it to your desktop, you'll see that it contains
a folder called ufmod toolkit.
Inside the folder you will find;


Bin2Bas.exe
example no music.bas
ufmod.bi
ufmod.o
mustro.bas
music


The first thing I would like you to do is just to run example no music from Fbide.
You'll see a pretty 3D starfield, nothing else. Don't change anything in the listing for now.

First we'll convert the music.

The file Music in the folder used to be called "filename.xm" I just renamed it to "Music"
for your purposes, whatever XM file you use, just rename the file to "Music" this makes things easier.

We are now going to convert this with Bin2Bas so that it can be included as part of your exe.


go to the start menu on your computer
click on run
type cmd and then press enter
type cd desktop
then cd ufmod toolkit
now type Bin2Bas Music Music.bas
now type exit


In the folder ufmod toolkit you will see that another file has appeared called Music.bas
It's much bigger than the original but don't worry about that as it will shrink when compiled!

Now we need to go to wherever you have freebasic stored on your pc.

On my computer it is in;
C:\FreeBasic


So click on My computer
Then Local Disk (C:)
Then open the Freebasic folder.


We need to copy the following files from ufmod toolkit into the freebasic folder.


ufmod.bi
Music.bas
mustro.bas
ufmod.o


Now we are ready to make our 1 file exe with music :-)


Back to the start menu
run
cmd
cd\
cd freebasic
fbc -s gui ufmod.o mustro.bas


and that's it.

Your freebasic folder now contains a file called mustro.exe which if you pack it with UPX will shrink to about 30kb.
The file you compiled "mustro.bas" is identical to "example no music.bas" except that mustro has 6 comments removed.
If you can't figure out how to include ufmod after reading this tut you probably shouldn't be
coding, but if you need more help, ask.

[ edit ~ It packs down to 19.5 kb with upx -9 !!! ]
Title: Re: UFMOD >>Step By Step Guide<<
Post by: thrawn89 on August 13, 2006
Quote
[ edit ~ It packs down to 19.5 kb with upx -9 !!! ]

Huzzah!  :||

Thrawn
Title: Re: UFMOD >>Step By Step Guide<<
Post by: Rbz on August 13, 2006
There's a little error in your code (mustro.bas), in fact it's my fault, check out this line:
Code: [Select]
hWave = uFMOD_PlaySong(@Music(0),50600,XM_MEMORY)
I forgot to mention what this number is (50600), it's the length of your music (in bytes), which in my example it should be 50601 ( just a little typo  ::) ).
And that music you have used it should be 10171 (look at music.bas --> dim shared music(0 to 10170) = 10171

 :cheers:
Title: Re: UFMOD >>Step By Step Guide<<
Post by: Shockwave on August 13, 2006
Ooops! I wasted 40k!
Thanks Rbraz.
Title: Re: UFMOD >>Step By Step Guide<<
Post by: DrewPee on August 13, 2006
Once again - thanks guys - excuse for me being a bit thick!

DrewPee
Title: Re: UFMOD >>Step By Step Guide<<
Post by: Shockwave on August 13, 2006
You're not thick Drew, now go and make something nice with it :)
Title: Re: UFMOD >>Step By Step Guide<<
Post by: Dad1916 on August 14, 2006
Thanks for the step by step guide Shockwave. O0 O0
Title: Re: UFMOD >>Step By Step Guide<<
Post by: Shockwave on August 14, 2006
You're welcome Rootuid :)

Sorry for my little 40kb oversight guys.
You can get the size that the line;

hWave = uFMOD_PlaySong(@Music(0),50600,XM_MEMORY)

Should contain by loading in the file Music.bas and seeing how much space it allocates for the array.
Title: Re: UFMOD >>Step By Step Guide<<
Post by: Clyde on August 21, 2006
Top tutorial dude, and really helped me understand how to use Bin2Bas ( I was dragging the files over the exe )

Hip Hip Hurray to Shockwave And Rbraz.

Cheers,
Clyde.
Title: Re: UFMOD >>Step By Step Guide<<
Post by: Shockwave on August 21, 2006
Bin2bas is essential afaic, I couldn't manage without a program like that now.
Title: Re: UFMOD >>Step By Step Guide<<
Post by: bikerboy on December 21, 2008
very useful tut man thanx :cheers:

what is the difference between those two?

fbc -s gui ufmod.o mustro.bas
fbc -s console ufmod.o Your_Intro_Name_Here.bas
Title: Re: UFMOD >>Step By Step Guide<<
Post by: Shockwave on December 21, 2008
The difference is that one of them compiles a program that doesnt create a console window and the other compiles a program that does.