News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

PlayBASICFX / PBFX Vm2 Translation (WIP)

Started by kevin, September 08, 2008, 12:13:35 PM

Previous topic - Next topic

kevin

  Xenon 2000 Comparison

   These pictures are of the standard Xenon 2000 map load/viewer code running in both PB1.64 and the current PBFX1.74 beta.  Drawing tiles is GPU bound, but even so  the smarter render engine & runtime give us an extra 80->100 free fps to play with.   Even more in full screen exclusive.


kevin


Sign Function in Vm2



// Sign function (returns -1 for neg values 0 for 0 and 1 if positive)
print "Sign"
For lp=-10 to 10
print Sgn(lp)
next

// Get Sign Bit (returns sign bit)
print "GetSign"
For lp=-10 to 10
print GetSign(lp)
next

Sync
waitkey



kevin

#47
  Kyruss Comparison

   These pictures are of Kyruss (Virtual Machine) running in PlayBasic V1.64 AND PlayBasicFX1.74 rc10.   Without change, the Vm2 (in PBFX) gives us another 60fps odd (and more) when Kyruss is running 4 synchronous tasks.


  What is Kyruss VM ? - See this demo.   Old Kyruss Demo


kevin

  Z Rotator With Alpha

  This is the Z rotator example running in PBFX1.74 (form the example pack  See -> Projects/Demos) with alpha applied to the foreground playfield.

kevin


  Shape Collision

    The combined shape method was missing for the sprite compare function.  Added in PBFX V174rc11.

    Demo Projects\Sprites\_Collision\SpriteCollisionMode3_shape


   

kevin

#50
  PlayBasic FX -  Basic 3D Demo

  This demo is the old Dragon demo running in PlayBasicFX V1.74 rc12..  

  While PlayBasicFX is primarily a 2D language (with 3d hardware acceleration), you can use the entity sprites and the perspective sprite rendering to create custom 3D scenes, among other things.


Controls:

      Mouse       = View
      Arrow Keys     = move
      ESC      = Exit demo   



Download

 PlayBasicFX Basic 3D Demo (login required) (1.2 meg)



kevin

 PBFX V1.75 Beta #2 - Parser Updates

  This beta introduces most (if not all) of the recent parser changes from PlayBasic compiler (V1.64i & j) into PlayBasicFX compiler.   

  Namely,

   - optional INC/DEC amount parsing
   - optional conditional expression for DO statement
   - optional conditional expression for LOOP statement
   - added extra byte code buffer overflow protection
   - added compiler confirmation when building from a 'beta' compiler




kevin

#52
 PBFX V1.76 Beta #1 - Compiler/Parser Updates

 This series of beta will be to bring PBFX inline with recent language changes found to PlayBasic V1.64K2..  


 First port of call is adding the Math Shorts cuts.. So far only ++, -- are working..  But the rest should fall like a deck of cards..


A=A+1
print A
A++
print A

A=A-1
print A
A--
print A

sync
waitkey




and a few hours later we have... ++,--, +=, -=, *=, /= , &=,|= and  ~= support for variables...


print "++ Add"
A++
print A

print "-- Sub"
A--
print A


print "Add & Subtract"

A+=10
print a

A-=5
print a

print "Mult & Divide"
A*=10
print a

A/=10
print a

print "And"
a=255
print a
A&=15
print a



print "Or"
A|=$f0
print a


print "XOr"
A~=$ff
print a

sync
waitkey




Math Shorts In Integer/Float & String Array Assignments





Dim Table(100)

print "integer Array Test-----------------------------------------"

Table(20)=5
print Table(20)


print "++ Add"
Table(50)++
print Table(50)

print "-- Sub"
Table(50)--
print Table(50)

print "Add & Subtract"

Table(50)+=10
print Table(50)

Table(50)-=5
print Table(50)

print "Mult & Divide"
Table(50)*=10
print Table(50)

Table(50)/=10
print Table(50)

print "And"
Table(50)=255
print Table(50)
Table(50)&=15
print Table(50)



print "Or"
Table(50)|=$f0
print Table(50)


print "XOr"
Table(50)~=$ff
print Table(50)


sync
waitkey
waitnokey


Cls 0

Dim FltTable#(1000)

print "Float Array Test-----------------------------------------"

FltTable#(20)=5
print FltTable#(20)


print "++ Add"
FltTable#(100)++
print FltTable#(100)

print "-- Sub"
FltTable#(100)--
print FltTable#(100)

print "Add & Subtract"

FltTable#(100)+=10
print FltTable#(100)

FltTable#(100)-=5
print FltTable#(100)

print "Mult & Divide"
FltTable#(100)*=10
print FltTable#(100)

FltTable#(100)/=10
print FltTable#(100)

print "And"
FltTable#(100)=255
print FltTable#(100)
FltTable#(100)&=15
print FltTable#(100)



print "Or"
FltTable#(100)|=$f0
print FltTable#(100)


print "XOr"
FltTable#(100)~=$ff
print FltTable#(100)


sync
waitkey
waitnokey



Cls 0

Dim StrTable$(10)

print "String Array Test-----------------------------------------"

StrTable$(1)="hello"
print StrTable$(1)


StrTable$(1)+="A"
print StrTable$(1)



sync
waitkey
waitnokey


kevin


PBFX V1.76 Beta #2 - Short Cut Support For User Defined types

   Slowly slotting the new part of the PBV1.64 parser into PBFX.    This revision adds Math short cut support to typed variables and arrays.




  Type Test1
  x,y,z
  endtype
 
  Type Test2
  i,f#,s$
  Endtype


  Dim a  as Test2

  Dim b(10)  as Test2


   b(5).i=45
b(5).i-=10
   print b(5).i
   b(5).f=100
   print b(5).f

   b(5).s="Hello"
   b(5).s+="World"
   print b(5).s


b(6) = new test1



   a.i=45
a.i-=10
   print a.i
a.f=123.456
a.f++
   print a.f

   a.s="Hello"
a.s+="World"
   print a.s


 
  Sync
  Waitkey
 

kevin

#54
 Auto Casting of Mismatched Assignments

 These changes allows pointers to be used more like 'integers'....  Which brings FX more inline with the changes made to  PB V1.64 (Seen Here)




; declare pointer (generic)
Dim a as pointer

;  assign the Integer variable PTR the integer value of 5
ptr=5


// move integer to pointer
a = ptr

// move pointer to integer
i=a
print i


// Add  pointer to integer
i+=a
print i

sync
waitkey





more Tests

Mismatched Integer/Float to Float/Integer assignments in types


  Type tTest
  i
  f#
  EndType
 
  dim a as tTest pointer
 
a= new tTest
 
  a.i=5
  print A.i
 
  a.i=22.33
  print A.i


  a.f=5
  print A.f
 
  a.f=22.33
  print A.f

  Sync
  waitkey





another test with arrays and pointer assignments



// declare pointer (generic)
Dim a as pointer

   a=5

Dim Stuff(100)
Dim Stuff#(100)


print "Integer Array Assignments"

Stuff(1) =a
Stuff(1) +=a
print Stuff(1)

print "Float Array Assignments"
Stuff#(1) +=a
print Stuff#(1)


Type SomeData
x,y,z
f#
endtype

print "Typed Array Assignments"
Dim W(10) as somedata



w(1).x =a
w(1).f =a

print "typed array"
print w(1).x
print w(1).f

w(1).x *=a
w(1).f *=a

print "typed array"
print w(1).x
print w(1).f




print "Typed Variable Assignments"
Dim Y as SomeData

y.x =a
y.f =a
print "typed variable"
print y.x
print y.f


y.x *=a
y.f *=a

print "typed variable"
print y.x
print y.f

sync
waitkey






kevin

#55
 PBFX V1.76 Beta #3 - SizeOF + Byte / Word Fields in Types

 So far I've added the SizeOF() function as well as adding parsing support for  BYTE and WORD fields in type declarations.    Can't access them though, but that shouldn't take too long..
 



Type Test
i as integer
f as float
b as byte
w as word
EndType


Dim A as Test
a= new test

print sizeof(test)

constant s =sizeof(test)
print s

Sync
waitkey



 ahh finally  it's working.  Been fumbling around with this most of the night, getting to write the Byte/Word fields was easy enough, but getting it read them turned into one of those witch hunts.  Long story short, turned out to be some broken table(s) and and hey presto, it works...  Annoyingly, I had pretty much the same drama adding it V1.64k..  completely forget about that :),  oh well.





Type Test
i as integer
f as float
b as byte
w as word
IArray(10)
fArray#(10)
sArray$(10)
EndType


Dim A as Test
a= new test

print sizeof(test)
constant s =sizeof(test)

print s




a.b=$aabbccdd
a.w=$aabbccdd
print a.b
print hex$(a.b)
print "Byte:"+hex$(a.b )
print "Word:"+hex$(a.w)


a.i=$11223344
a.f=123.456
print " Int:"+hex$(a.i)
print " Flt:"+Str$(a.f)


a.IArray(5)=455
print a.IArray(5)

a.fArray(5)=123.456
print a.fArray(5)

a.sArray(5)="Hello world"
print a.sArray(5)


Sync
waitkey





   PBFX V1.76 Beta #3 - Sort Array Supports String Arrays
 
    Dropped this one into PBFX also..





Size=10
Dim name$(Size)
for lp=0 to size
name$(lp)=ReadData$()
next


SortArray name$(),0,size

for lp=0 to size
print name$(lp)
next
Sync
waitkey

Data "zack","wolf","kev","andy","michelle","dogs","tess","c64","zynaps","dudes","Alpha"




 



kevin

#56
 PBFX V1.76 Beta #4 - POst Fix Support For User Functions
 
  This additions bring user functions into line with the internally bound & native VM operations.   In other words you can declare a user function name and use the # and $ symbols at the end.    The parser doesn't use this are the return prototype though,  the return type still comes from the what exported after the EndFunction statement.  

PlayBASIC Code: [Select]
   Print Yeah$(45)
print SomeOtherFunction#(11.22)

Sync
waitkey

Function Yeah$(A)
This$="Yeah Function="+str$(a)
EndFunction This$

Function SomeOtherFunction#(ThisFloat#)
Print Thisfloat#
This#=Thisfloat#*10
EndFunction This#





  DLL bindings now support the # and $ chr;s also.  


PlayBASIC Code: [Select]
   Print Yeah$(45)
print SomeOtherFunction#(11.22)


Function Yeah$(A)
This$="Yeah Function="+str$(a)
EndFunction This$

Function SomeOtherFunction#(ThisFloat#)
Print Thisfloat#
This#=Thisfloat#*10
EndFunction This#


linkDll "Some.Dll"

TestFunction(Param) alias "Something" as integer
TestFunction$(Param) alias "Something2" as string
TestFunction#(Param) alias "Something3" as float

EndlinkDll


TestFunction(Param)
TestFunction#(Param)
TestFunction$(Param)


Sync
waitkey






PBFX V1.76 Beta #4 - Optional Parameter Support For Internal Commands & Functions


 
PlayBASIC Code: [Select]
   Do   

Cls 0

print "Optional Parameters in Commands"

box 100,100,200,200

circle 400,400,50


print "Optional Parameters in Functions"
a$="Hello"

for lp=1 to len(a$)
print mid$(a$,lp) ; notice the length is missing, it defaults to one now
next

Sync
loop




More info can be found here in the V1.64k WIP thread


kevin


Debugger Prototype in PBFX V1.76 Beta #4

   This is the recent debugger parser prototype running in today's edition of PBFX.      The demo loads a 20,000 line source code, then pre-parsers (syntax highlights) the entire document.    This as you can imagine is brute force operation.   Pb V1.64k is able to run this test around 1450->1500 milliseconds,   while PBFX runs it in 1100->1150 milliseconds.   Approximately a 300->350 milliseconds gain on a 20,000 line document.

See Debugger Prototype Thread


kevin


PBFX V1.76 Beta #5 - Function Declarations

   Starting Updating the pre-parser to being it inline with the version in V1.64k.  Slow progress currently,  due to the number of changes that need to be made.   But it'll get there...




Function TestReturns_None()
EndFunction

Function TestReturns_1i()
EndFunction a

Function TestReturns_1f()
EndFunction a#

Function TestReturns_1s()
EndFunction a$




Function TestAsDatatypeReturns_1i()
EndFunction a as integer

Function TestAsDatatypeReturns_1f()
EndFunction a as float

Function TestAsDatatypeReturnsb_1f()
EndFunction a# as float,b


Function TestAsDatatypeReturns_1s()
EndFunction a as string

Function TestAsDatatypeReturnsb_1s()
EndFunction a$ as string


Sync
waitkey


 
   

kevin

#59
 PBFX V1.76 Beta #6/7 - Function Declarations Continued

  Still running through the pre-parsing changes, cleaning up the parsing code while I go...  really exciting stuff ;)

PlayBASIC Code: [Select]
Function Test_Void()
EndFunction

Function TestInputs_2i(a,b)
EndFunction



Function TestInputs_1i(a as integer)
EndFunction


Function TestInputs_1f(a as float)
EndFunction

Function TestInputs_1fb(a# as float)
EndFunction

Function TestInputs_1s(a as string)
EndFunction

Function TestInputs_1sb(a$ as string)
EndFunction


Function TestPointerInputs_1(a as pointer)
EndFunction

Function TestPointerInputs_2(a as byte pointer)
EndFunction

Function TestPointerInputs_3(a as word pointer)
EndFunction

Function TestPointerInputs_4(a as integer pointer)
EndFunction

Function TestPointerInputs_5(a as float pointer)
EndFunction

Function TestPointerInputs_6(a as stringref pointer)
EndFunction

Type Vector2D
x#,t#
EndType


Function TestPointerInputs_7(a as vector2d pointer,b as vector2d pointer)
EndFunction


; integer array container
Function TestArrays_1(Me())
EndFunction

Function TestArrays_1b(Me() as integer)
EndFunction


; float array container
Function TestArrays_2(Me#())
EndFunction

Function TestArrays_2b(Me() as float)
EndFunction



; string array container
Function TestArrays_3(Me$())
EndFunction

Function TestArrays_3b(Me() as string)
EndFunction


; Pass typed variable container
Function TestArray_4(Me.Vector2d)
EndFunction



; Pass typed array container
Function TestArray_5(Me().Vector2d)
EndFunction

Function TestArray_5b(Me() as Vector2d)
EndFunction


; Pass typed array container
Function TestArray_6(Me as Vector2d list)
EndFunction


sync
Waitkey