Dark Bit Factory &  Gravity

Dark Bit Factory & Gravity

  • July 30, 2010 *
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

Pages: [1] 2 3 4   Go Down

Author Topic: TinyPTC Ext  (Read 5468 times)

0 Members and 1 Guest are viewing this topic.

rbz

  • MOD
  • Senior Member
  • *******
  • Karma: 272
  • Offline Offline
  • Posts: 2133
    • View Profile
    • WWW
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: September 06, 2009 by rbz »
Logged
rbz ^ Codigos

Shockwave

  • good/evil
  • ADMIN
  • Senior Member
  • ********
  • Karma: 356
  • Offline Offline
  • Posts: 15085
  • evil/good
    • View Profile
    • WWW
Re: TinyPTC Ext
« Reply #1 on: February 16, 2007 »
Thank you for releasing this for everyone Rbraz. +10 Karma! It's a fabulous extension.
Logged
Shockwave ^ Codigos....  Error: Keyboard not attached.... Press F1 to continue.

bbear

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

rbz

  • MOD
  • Senior Member
  • *******
  • Karma: 272
  • Offline Offline
  • Posts: 2133
    • View Profile
    • WWW
Re: TinyPTC Ext
« Reply #3 on: February 16, 2007 »
No problem  :cheers:
Logged
rbz ^ Codigos

Shockwave

  • good/evil
  • ADMIN
  • Senior Member
  • ********
  • Karma: 356
  • Offline Offline
  • Posts: 15085
  • evil/good
    • View Profile
    • WWW
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.
Logged
Shockwave ^ Codigos....  Error: Keyboard not attached.... Press F1 to continue.

rdc

  • Sliderules Rule!
  • MOD
  • Pentium
  • *******
  • Karma: 131
  • Offline Offline
  • Posts: 1437
  • Clark Productions
    • View Profile
    • WWW
Re: TinyPTC Ext
« Reply #5 on: February 16, 2007 »
Very cool indeed.

.:] Druid [:.

  • freebasic n00b
  • Pentium
  • *****
  • Karma: 46
  • Offline Offline
  • Posts: 561
    • View Profile
    • WWW
Re: TinyPTC Ext
« Reply #6 on: February 17, 2007 »
 :clap: :clap: :clap:

Nice one Rbraz!  Thanks a lot!

 :clap: :clap: :clap:
Logged
[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.

zawran

  • Sponsor
  • Pentium
  • *******
  • Karma: 54
  • Offline Offline
  • Posts: 778
    • View Profile
    • WWW
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.
Logged

rbz

  • MOD
  • Senior Member
  • *******
  • Karma: 272
  • Offline Offline
  • Posts: 2133
    • View Profile
    • WWW
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
Logged
rbz ^ Codigos

rdc

  • Sliderules Rule!
  • MOD
  • Pentium
  • *******
  • Karma: 131
  • Offline Offline
  • Posts: 1437
  • Clark Productions
    • View Profile
    • WWW
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.

DrewPee

  • I Toast Therefore I am
  • Sponsor
  • Pentium
  • *******
  • Karma: 25
  • Offline Offline
  • Posts: 544
  • Eat Cheese - It's good for you!
    • View Profile
    • WWW
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
Logged
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

rbz

  • MOD
  • Senior Member
  • *******
  • Karma: 272
  • Offline Offline
  • Posts: 2133
    • View Profile
    • WWW
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 »
Logged
rbz ^ Codigos

Shockwave

  • good/evil
  • ADMIN
  • Senior Member
  • ********
  • Karma: 356
  • Offline Offline
  • Posts: 15085
  • evil/good
    • View Profile
    • WWW
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.
Logged
Shockwave ^ Codigos....  Error: Keyboard not attached.... Press F1 to continue.

rbz

  • MOD
  • Senior Member
  • *******
  • Karma: 272
  • Offline Offline
  • Posts: 2133
    • View Profile
    • WWW
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  ;)
Logged
rbz ^ Codigos

rdc

  • Sliderules Rule!
  • MOD
  • Pentium
  • *******
  • Karma: 131
  • Offline Offline
  • Posts: 1437
  • Clark Productions
    • View Profile
    • WWW
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.

rbz

  • MOD
  • Senior Member
  • *******
  • Karma: 272
  • Offline Offline
  • Posts: 2133
    • View Profile
    • WWW
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.
Logged
rbz ^ Codigos

Shockwave

  • good/evil
  • ADMIN
  • Senior Member
  • ********
  • Karma: 356
  • Offline Offline
  • Posts: 15085
  • evil/good
    • View Profile
    • WWW
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.
Logged
Shockwave ^ Codigos....  Error: Keyboard not attached.... Press F1 to continue.

rdc

  • Sliderules Rule!
  • MOD
  • Pentium
  • *******
  • Karma: 131
  • Offline Offline
  • Posts: 1437
  • Clark Productions
    • View Profile
    • WWW
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.


Voltage

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

What does ptc_setflip do?
Logged

Shockwave

  • good/evil
  • ADMIN
  • Senior Member
  • ********
  • Karma: 356
  • Offline Offline
  • Posts: 15085
  • evil/good
    • View Profile
    • WWW
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.
Logged
Shockwave ^ Codigos....  Error: Keyboard not attached.... Press F1 to continue.
Pages: [1] 2 3 4   Go Up
 

 

B l a c k R a i n V.2 by C r i p

Page created in 0.15 seconds with 18 queries.