Author Topic: TinyPTC Ext  (Read 43350 times)

0 Members and 1 Guest are viewing this topic.

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2750
  • Karma: 492
    • View Profile
    • http://www.rbraz.com/
TinyPTC Ext
« on: February 16, 2007 »
Here's a new tinyptc version that I made for Shockwave some time ago, in this new version you will capable to switch to fullscreen or windowed mode when the app start, it uses directdraw and mmx routines, like the original tpc.
Here's the function list:

Standard ptc functions:
ptc_open
ptc_update
ptc_close

Tinyptc extension
ptc_setflip
ptc_getmousex
ptc_getmousey
ptc_getleftbutton
ptc_getrightbutton
ptc_setdialog
ptc_allowclose
ptc_getwindow
ptc_setmousewheel *new
ptc_getmousewheel *new

To install:
From "tinyptc_ext.rar" extract and copy the new tinyptc library ( libtinyptc_ext.a and libmmx.a) to this folder:
C:\FreeBasic\lib\win32
And "tinyptc_ext.bi" to the folder C:\FreeBasic\inc

If you need some example code, I'll post it later...

Have fun!
« Last Edit: January 19, 2020 by Rbz »
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17394
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC Ext
« Reply #1 on: February 16, 2007 »
Thank you for releasing this for everyone Rbraz. +10 Karma! It's a fabulous extension.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline bbear

  • C= 64
  • **
  • Posts: 87
  • Karma: 4
    • View Profile
    • Legacy
Re: TinyPTC Ext
« Reply #2 on: February 16, 2007 »
thank you very much  :goodpost:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2750
  • Karma: 492
    • View Profile
    • http://www.rbraz.com/
Re: TinyPTC Ext
« Reply #3 on: February 16, 2007 »
No problem  :cheers:
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17394
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC Ext
« Reply #4 on: February 16, 2007 »
I just want to say that this extension has made *everything* I have done in FB possible. It is just perfect and very kind of you to release it so that people can use it. You've made a great thing there mate and it's the one thing I could not do without... Of course there are other things you have made that I need too, those are bin2bas and bmp2raw. You made my life so much easier with those things, I'll never be able to thank you enough.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: TinyPTC Ext
« Reply #5 on: February 16, 2007 »
Very cool indeed.

Offline .:] Druid [:.

  • freebasic n00b
  • Pentium
  • *****
  • Posts: 563
  • Karma: 47
    • View Profile
    • Intro-Inferno
Re: TinyPTC Ext
« Reply #6 on: February 17, 2007 »
 :clap: :clap: :clap:

Nice one Rbraz!  Thanks a lot!

 :clap: :clap: :clap:
[sheep]: im sure he wants to goto prison.. they didnt get him last time.. he was promised a big cock up his arse.. and no doubt looking forward to it.. lets hope he gets his wish this year.

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: TinyPTC Ext
« Reply #7 on: February 17, 2007 »
Cool of you to release it, karma coming your way. Unfortunately I have decided to stick with Bmax due to the limited time I spend on code these days, but otherwise I would just right on the bandwagon as this makes everything so much easier.

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2750
  • Karma: 492
    • View Profile
    • http://www.rbraz.com/
Re: TinyPTC Ext
« Reply #8 on: February 19, 2007 »
No problem dudes, it's my pleasure :)

Here's a little code using mouse functions:

Code: [Select]
option explicit
option static

'-------------------------------------
' Includes.---------------------------
'-------------------------------------
#include "tinyptc_ext.bi"
#include "windows.bi"

'Screen width x height
Const XRES = 640
Const YRES = 480

dim shared buffer(XRES*YRES) as integer

dim shared as integer x,y1,y2
dim shared as double angle
dim c as integer

c = &hff0000ff

If( ptc_open( "Mouse Test", XRES, YRES ) = 0 ) Then
    End -1
End if


    while(GetAsyncKeyState(VK_ESCAPE)<>-32767)
       
            y1 = 80 + sin(angle)*20
            angle += 0.05
           
            for x=0 to 639
                buffer(x+(y1*XRES)) = c
            next

            y2 = 400 + cos(angle)*20
           
            for x=0 to 639
                buffer(x+(y2*XRES)) = c
            next
                     
            cls
            locate 1,1
            print "Mouse Xpos: ";ptc_getmousex()
           
            locate 2,1
            print "Mouse Ypos: ";ptc_getmousey()
           
            locate 4,1
            print "Left Mouse Button: ";ptc_getleftbutton()

            locate 5,1
            print "Right Mouse Button: ";ptc_getrightbutton()


            ptc_update(@buffer(0))
           
            erase buffer
           
    wend
Challenge Trophies Won:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: TinyPTC Ext
« Reply #9 on: February 20, 2007 »
If you are using this on .17 then you'll need to change the $inclib to #inclib in the bi file, since .17 doesn't use the older format.

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: TinyPTC Ext
« Reply #10 on: February 20, 2007 »
rbraz,
thanks matey - i agree with shockwave - you are one of the most helpful people on here!  :clap:
karma up +++

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2750
  • Karma: 492
    • View Profile
    • http://www.rbraz.com/
Re: TinyPTC Ext
« Reply #11 on: March 03, 2007 »
Thanks DrewPee  :)


I know that some people hates that window asking for fullscreen mode  ;) , so I've added a new function capable to enable/disable message box,  and if you enable it you can choose your own text for it.

ptc_setdialog(1,"Do you really want FullScreen ?",0)

First option will disable messagebox, the 2nd option you will choose your text, the 3rd option will let you start direct in fullscreen or windowed mode when first option disables messagebox.

ptc_setdialog(0,"bla",1) 'Disable messagebox, and start in windowed mode

ptc_setdialog(0,"bla",0) 'Disable messagebox, and start in fullscreen mode

Add it before you open your ptc window

Code: [Select]
ptc_setdialog(1,"Do you really want Full Screen ?",0)
if ( ptc_open ( "TEST....", 640, 480) = 0 ) then
end -1
end if

have fun  ;D



« Last Edit: March 03, 2007 by rbraz »
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17394
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC Ext
« Reply #12 on: March 03, 2007 »
That's just the ticket Rbraz. Very useful and I'll be using it in th intro I am making for S!P.

Thank you kindly.

Have some Karma.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2750
  • Karma: 492
    • View Profile
    • http://www.rbraz.com/
Re: TinyPTC Ext
« Reply #13 on: March 04, 2007 »
No problem Shockie

Here's a little example using ptc_setdialog

Code: [Select]
'
'
'  "ptc_setdialog" command test
'        by rbraz 2007
'
'
'-------------------------------------
' Includes.
'-------------------------------------
#include once "tinyptc_ext.bi"
#include "windows.bi"

dim shared buffer(640*480) as integer
dim text as string

text = " ¤´¨) " & chr$(13)
text += " ¸.·´¸.·*´¨) ¸.·*¨)" & chr$(13)
text += "(¸.·´ (¸.·`¤... SHOCKWAVE ^ DBF ^ S!P ...¤" & chr$(13) & chr$(13) & chr$(13)
text += "FullScreen Mode ?"

ptc_setdialog(1,text,0)

'Open TinyPTC window
If( ptc_open( "ptc_setdialog command test", 640, 480 ) = 0 ) Then
    End -1
End if

'Main Loop
while(GetAsyncKeyState(VK_ESCAPE)<>-32767)
    ptc_update @buffer(0)
wend

I guess that you can see the possibilities for this  ;)
Challenge Trophies Won:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: TinyPTC Ext
« Reply #14 on: March 04, 2007 »
Excellent lib here. Works well with the CVS version of FB too once you make the changes to the inclib statement. The original tinyptc doesn't seem to work with the CVS version.

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2750
  • Karma: 492
    • View Profile
    • http://www.rbraz.com/
Re: TinyPTC Ext
« Reply #15 on: March 04, 2007 »
Sorry about the inclib statement, I'm still using the old 0.15 because it works fine for me, I tried to use the new one but it give me a lot troubles.
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17394
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC Ext
« Reply #16 on: March 04, 2007 »
Thanks for the example Rbraz. I also use fb 1.5, it works fine and does what I like so I don't upgrade mine either.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: TinyPTC Ext
« Reply #17 on: March 05, 2007 »
Here is a little update to the bi file; this may enable it to work with any version, if you feel so inclined. You should probably verify that this actually works with .15, since I don't have that installed and I am not sure what changes to the preprocessor were made in the different versions.

Code: [Select]
'
' TinyPTC by Gaffer
' www.gaffer.org/tinyptc
'
 
'
' TinyPTC Extension by rbraz 2007
'

#if __FB_VERSION__ < "0.17"
    '$inclib: "opengl32"
    '$inclib: "user32"
    '$inclib: "gdi32"
    '$inclib: "glu32"

    '$inclib: "mmx"
    '$inclib: "tinyptc_ext"
#else
    #inclib "opengl32"
    #inclib "user32"
    #inclib "gdi32"
    #inclib "glu32"

    #inclib "mmx"
    #inclib "tinyptc_ext"
#endif


#inclib "opengl32"
#inclib "user32"
#inclib "gdi32"
#inclib "glu32"

#inclib "mmx"
#inclib "tinyptc_ext"

'tinyptc api
declare function ptc_open cdecl alias "ptc_open" (byval title as zstring ptr, byval width as integer, byval height as integer ) as integer
declare function ptc_update cdecl alias "ptc_update" (byval buffer as integer ptr) as integer
declare function ptc_close cdecl alias "ptc_close" () as integer

'tinyptc extension
declare function ptc_setflip cdecl alias "ptc_setflip" (byval interval as integer) as integer
declare function ptc_getmousex cdecl alias "ptc_getmousex" () as integer
declare function ptc_getmousey cdecl alias "ptc_getmousey" () as integer
declare function ptc_getleftbutton cdecl alias "ptc_getleftbutton" () as integer
declare function ptc_getrightbutton cdecl alias "ptc_getrightbutton" () as integer
declare function ptc_setdialog cdecl alias "ptc_setdialog" (byval enable as integer, byval text as zstring ptr, byval mode as integer ) as integer


I also added the As Integer function return type on the setdialog since it didn't have an explicit return type. Implicit types causes an error unless -lang QB is set. Since the others had an explicit return type, I assumed it was probably just an oversight.

Anyway, thanks for the good work on this.



Offline Voltage

  • Professor
  • Pentium
  • *****
  • Posts: 857
  • Karma: 53
    • View Profile
Re: TinyPTC Ext
« Reply #18 on: March 05, 2007 »
Great lib rbraz!

What does ptc_setflip do?
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17394
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC Ext
« Reply #19 on: March 05, 2007 »
ptc_setlip() Allows you to switch vsync on or off.
ptc_setflip(1)
ptc_setfilp(0)

Will try that updated .bi Rick, Have some Karma.
Shockwave ^ Codigos
Challenge Trophies Won: