Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: Rbz on December 20, 2008

Title: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Rbz on December 20, 2008
Freebasic tinyptc extended++
----------------------------

Standard ptc functions:
-----------------------
ptc_open
ptc_update
ptc_close

Tinyptc extension functions:
----------------------------
ptc_setflip
ptc_getmousex
ptc_getmousey
ptc_getleftbutton
ptc_getrightbutton
ptc_setdialog
ptc_allowclose
ptc_getwindow
ptc_setmousewheel
ptc_getmousewheel

Including ufmod ver.1.25.2a:
----------------------------
uFMOD_PlaySong
uFMOD_StopSong
uFMOD_Pause
uFMOD_Resume
uFMOD_GetStats
uFMOD_GetTime
uFMOD_GetTitle
uFMOD_SetVolume
uFMOD_Jump2Pattern
uFMOD_Rewind()

Sound FX player:
----------------
sndfx_init()
sndfx_load(byval as any ptr, byval samplesize as integer, byval samplenum as integer) as integer
sndfx_play(byval samplenum as integer, byval smploop as integer) as integer
sndfx_stop(byval samplenum as integer) as integer
sndfx_setvolume(byval samplenum as integer, byval volume as integer) as integer
sndfx_release()


To install:
-----------
From "tinyptc_ext++.zip" file extract and copy the new tinyptc_ext++ library
( libtinyptc_ext++.a and libmmx.a) to the freebasic install folder:
Ex.:   C:\FreeBasic\lib\win32
And "tinyptc_ext++.bi" to the folder C:\FreeBasic\inc

Check out examples test folder




This version was designed for people who had troubles adding .xm song to their intros using ufmod, which I admit is a bit annoying to compile, this new library includes the latest ufmod library (1.25.2a) + tinyptc_ext in one file, making newbies life a bit easy.

In the examples folder you will find one example to load song from memory and from file and plus an image loader routine.

Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: bikerboy on December 20, 2008
thanx man :cheers:

i'll go test it right now  :stirrer:

EDIT: okies i've installed as instructed and i get these results:

result 1 with this command #Include Once "tinyptc.bi"

the code

Code: [Select]
Screenres 640,480,16,2

#Include Once "tinyptc.bi"
#include "windows.bi"
#include "ufmod.bi"
#include "tune.bas"
#include "crt.bi"

       Dim hWave As HWAVEOUT
       hWave = uFMOD_PlaySong(@Music(0),31009,XM_MEMORY)

the tune.bas

Code: [Select]
'// Created with Bin2Bas V0.22 - by Rbraz (c) 2006
dim shared music(0 to 31009) as ubyte = { _
&H45,&H78,&H74,&H65,&H6E,&H64,&

and the error

Code: [Select]
Compiler output:
C:\Program Files\FreeBASIC\FBIDETEMP.o:fake:(.text+0x51): undefined reference to `uFMOD_PlaySong@12'

result 2 using #Include Once "tinyptc_ext++.bi" , same code and tune.bas file as above

Code: [Select]
Compiler output:
C:/Program Files/FreeBASIC/ufmod.bi(45) error 4: Duplicated definition
declare function uFMOD_PlaySong stdcall alias "uFMOD_PlaySong" (byval as LPVOID , byval as DWORD, byval as DWORD) as HWAVEOUT
                                                                                                                     ^
C:/Program Files/FreeBASIC/ufmod.bi(51) error 4: Duplicated definition
declare sub uFMOD_Pause stdcall alias "uFMOD_Pause" ()
                                                     ^
C:/Program Files/FreeBASIC/ufmod.bi(54) error 4: Duplicated definition
declare sub uFMOD_Resume stdcall alias "uFMOD_Resume" ()
                                                       ^
C:/Program Files/FreeBASIC/ufmod.bi(63) error 4: Duplicated definition
declare function uFMOD_GetStats stdcall alias "uFMOD_GetStats" () as UINTEGER
                                                                     ^
C:/Program Files/FreeBASIC/ufmod.bi(71) error 4: Duplicated definition
declare function uFMOD_GetTime stdcall alias "uFMOD_GetTime" () as UINTEGER
                                                                   ^
C:/Program Files/FreeBASIC/ufmod.bi(78) error 4: Duplicated definition
declare function uFMOD_GetTitle stdcall alias "uFMOD_GetTitle" () as ZSTRING ptr
                                                                             ^
C:/Program Files/FreeBASIC/ufmod.bi(87) error 4: Duplicated definition
declare sub uFMOD_SetVolume stdcall alias "uFMOD_SetVolume" (byval as DWORD)
                                                                           ^

Results:
Compilation failed
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Hotshot on December 20, 2008
work GREAT  ;D Excellent Library  8) 8) 8)
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Rbz on December 20, 2008
@bikerboy: Use the source code example from the examples folder, your old source code won't work anymore.

Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: bikerboy on December 20, 2008
Code: [Select]
Screenres 640,480,16,2

#Include Once "tinyptc_ext++.bi"
'#Include Once "tinyptc.bi"
#include "windows.bi"
#include "ufmod.bi"
#include "tune.bas"
#include "crt.bi"

       'Play our music
    Dim hWave As HWAVEOUT
    hWave = uFMOD_PlaySong(@Music(0),31009,XM_MEMORY)

    'Main loop
    while(GetAsyncKeyState(VK_ESCAPE)<>-32767)
       
        for x = 0 to 320
            for y = 0 to 240
                    buffer(x+(y*XRES)) = image(x+(y*320))
            next
        next
       
        ptc_update(@buffer(0))
           
        erase buffer
           
    wend

    'Stop playing
    uFMOD_StopSong()

Code: [Select]
'// Created with Bin2Bas V0.22 - by Rbraz (c) 2006
dim shared Music(0 to 31009) as ubyte = { _
&H45,&H78,&H74,&H65,

Code: [Select]
Compiler output:
C:/Program Files/FreeBASIC/ufmod.bi(45) error 4: Duplicated definition
declare function uFMOD_PlaySong stdcall alias "uFMOD_PlaySong" (byval as LPVOID , byval as DWORD, byval as DWORD) as HWAVEOUT
                                                                                                                     ^
C:/Program Files/FreeBASIC/ufmod.bi(51) error 4: Duplicated definition
declare sub uFMOD_Pause stdcall alias "uFMOD_Pause" ()
                                                     ^
C:/Program Files/FreeBASIC/ufmod.bi(54) error 4: Duplicated definition
declare sub uFMOD_Resume stdcall alias "uFMOD_Resume" ()
                                                       ^
C:/Program Files/FreeBASIC/ufmod.bi(63) error 4: Duplicated definition
declare function uFMOD_GetStats stdcall alias "uFMOD_GetStats" () as UINTEGER
                                                                     ^
C:/Program Files/FreeBASIC/ufmod.bi(71) error 4: Duplicated definition
declare function uFMOD_GetTime stdcall alias "uFMOD_GetTime" () as UINTEGER
                                                                   ^
C:/Program Files/FreeBASIC/ufmod.bi(78) error 4: Duplicated definition
declare function uFMOD_GetTitle stdcall alias "uFMOD_GetTitle" () as ZSTRING ptr
                                                                             ^
C:/Program Files/FreeBASIC/ufmod.bi(87) error 4: Duplicated definition
declare sub uFMOD_SetVolume stdcall alias "uFMOD_SetVolume" (byval as DWORD)
                                                                           ^
C:/Program Files/FreeBASIC/FBIDETEMP.bas(19) error 67: Array not dimensioned, before '('
                    buffer(x+(y*XRES)) = image(x+(y*320))
                           ^
C:/Program Files/FreeBASIC/FBIDETEMP.bas(19) warning 12(0): Implicit variable allocation, image
C:/Program Files/FreeBASIC/FBIDETEMP.bas(23) error 67: Array not dimensioned, before '('
        ptc_update(@buffer(0))
                           ^
C:/Program Files/FreeBASIC/FBIDETEMP.bas(25) error 59: Expected array
        erase buffer
              ^
C:/Program Files/FreeBASIC/FBIDETEMP.bas(25) error 123: Too many errors, exiting

Results:
Compilation failed

 :skint:

Ps.i have every file in the same folder

EDIT: just commented '#include "ufmod.bi" and it compiles just fine but no sound :skint:

EDIT3: lol my n00bness is unlimited :P

i had '#include "ufmod.bi" that's why there was no bling bling :P

works perfect now ;D

thanx again man :cheers:

question, is this method still valid for putting the bas file into the exe one? -> fbc -s console ufmod.o your_intro_name.bas

EDIT4: :o lol

yup it was a dump question it works perfectly :D
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Shockwave on December 20, 2008
Hey Rbz, you rock :)
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: bikerboy on December 20, 2008
hey guys i think i have a problem (as usual  ::))

the music plays just fine and it compiles and everything , but ...

the song plays only once and then pure silence, is there a command to add or something to make it start again once it's finished?
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Clyde on May 17, 2009
Had no idea there were 2 different versions available of TinyPTC_Ext.
I have been using the download from the other post without UFmod included, as I only need for now PTC_Ext.

o_O
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Rbz on May 17, 2009
And did you find it useful ?
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Clyde on May 19, 2009
I've used the other tinyptc_ext topic download link for ages, and its extremely usefull.
With this one tinyptc_ext++, I am not sure if this is exactly the same as the one im currently using plus the added bonus of ufmod, or if the tinyptc parts are totally different.

I do know one thing mind, if you use this one ( ext++.bi ) it clashes with Bass.
So I am presuming that the other sticky has an identical ptc_ext. just the ++ means its got UFMOD thrown in with it.

I may of answered my own question above, lack of sleep :)

Cheers,
Clyde.
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Shockwave on May 20, 2009
If you need to be analysing sound channel data etc I find that minifmod works really well with this version of tinyptc.
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Clyde on May 26, 2009
So is this an entirely new version update of tinyptc_ext?
or is it that it's the same version but with the added support of UFmod?

Thanks.
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Jim on May 26, 2009
Yes.

Jim.

The latter.
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Rbz on May 27, 2009
...
or is it that it's the same version but with the added support of UFmod?
...
Yes, the idea is to make it easy for newcomers to use ufmod library on their projects.
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Clyde on May 27, 2009
Ok cool, thanks for clarifying.

Just remember anyone using this version which is #include "tinyptc_ext++.bi" that if you want to use bass.bi for a change, you'll need to download and use the standalone tinyptc_ext.bi in the other sticky, as it will clash with ufmod.
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Rbz on July 18, 2009
Clyde, it does work with bass, just need some changes in the bass.bi,  I've attached one example here that uses ufmod and bass.
The dude who have converted bass.bi used some mmsystem.bi defines on it's file which clash with another library using mmsytem.bi like tinyptc++.

Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Clyde on July 22, 2009
Thanks kindly rbz.

Cheers your ex partner is crime,
Clyde.
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Mountiho on October 06, 2009
Great work!
Thank a lot1!
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Shockwave on October 06, 2009
Welcome to the forum Mountiho :)
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: nzo on November 22, 2009
Thanks for this! It has enabled me to get up and running very quickly and is absolutely ideal for retro remaking :)

cheers
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: nzo on February 25, 2010
It would be really good to be able to play one of the samples from the mod "ad hoc".
There's a lot of remakes that require a single SFX. I guess the playing of any SFX would be required to be added here, as the mixing of the sound buffer is done here.
Also, any games using music + SFX will need this.
I might be tempted to start looking at a game with TinyPTC with this feature :)

Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Rbz on February 26, 2010
Hi Nzo, do you mean a .wav sample or .mp3 ?

I tried to find this module "ad hoc" without any success, I'm an amiga noobzor :P
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: nzo on February 26, 2010

I mean, play any of the samples in the module (sample 1, sample 2 etc.) as a sound fx.
Ad hoc in this case would be better described at wikipedia :)

Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Rbz on February 26, 2010
Oh, hehe, it's Latin phrase ;D

Ok, I'll take a look at it :)
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Rbz on March 01, 2010
@Nzo: Check this out, I've added some sound fx functions.

Not really playing samples from xm file, as I've noticed that in some musics those samples are almost useless because note/pitch.

Instead I've made it play any ".wav" file simultaneously, you can load from memory or open a file.

There's an example included to show how to load from memory or file, press F1 or F2 to play samples while playing a music.

Enjoy :)


{Edited - tinyptc_ext++ now have sound fx replayer}
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: nzo on March 02, 2010
That appears to be spot on!
Thanks a lot - will be very useful :)
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Rbz on June 12, 2011
Updated:
+ Added sound fx to tinyptc_ext++
- Removed an "unwanted feature" (bug :)) on windowed mode.
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Shockwave on June 12, 2011
I really like the sound capabilities of this lib!

Playing samples is childs play with this now.  It's really kickass.
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Clyde on June 14, 2011
Any chance of an update to the original tinyptc_ext for the window mode bug? As I often use minifmod and others for music playback out of personal choice.

Cheers!
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: padman on June 14, 2011
Already done:  ;)

http://www.dbfinteractive.com/forum/index.php?topic=1382.0 (http://www.dbfinteractive.com/forum/index.php?topic=1382.0)
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Valazare on October 09, 2011
Hi, just registered here....
Title: Re: Tinyptc Ext++ (tinyptc_ext + uFmod)
Post by: Rbz on October 09, 2011
Welcome.