Hi Kent,
I use the module from this post:
http://community.thinbasic.com/index...11816#msg11816
I think Oxygen is not yet in official release, but could start to be with next preview.
Petr
Hi Kent,
Yes this works with the latest asmosphere. There was an FPU operand coding bug in the first release. But I have a thorough testing system now, which I hope will make bugs a rarity.
With the plasma screen, the messagebox at the end of the program hides behind the FBGX window so you have to uncover it to close the prog.
Hi Kent,
I use the module from this post:
http://community.thinbasic.com/index...11816#msg11816
I think Oxygen is not yet in official release, but could start to be with next preview.
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Oh ok thanks guys for the news. I found out I will be out of town to visit my Sister for a couple of days. So probably when I get back a new preview version will be out by then, so I will wait for that and something to look forward too!
Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server
I've had sme fun with the plasma program: this one composes the color into ARGB for FBGFX, with Petrs Subroutines combined. It runs at a fair pace.
[code=thinbasic]
'Plasma-like effect with FBGFX
uses "FBGFX"
uses "OXYGEN"
Dim w,h As long
w=400-1
h=300-1
FBGFX_ScreenRes(w,h,32,2)
Dim x,y,page As single
Dim c,t As single
dim divisor, two, fifteen As single
divisor = 100
two = 2
fifteen = 15
dim ColorCalcSrc as string="
'-----
fld dword [#x] ' Sin((x+y+t)/100)
fadd dword [#y]
fadd dword [#t]
fdiv DWORD [#divisor]
fsin
fld dword [#x] ' Cos((x-t)/100)
fsub dword [#t]
fdiv DWORD [#divisor]
fcos
faddp st(1)
fld dword [#y] ' Cos((y-t)/100)
fsub dword [#t]
fdiv DWORD [#divisor]
fcos
faddp st(1)
fld dword [#x] ' Cos((x-y+t)/100)
fsub dword [#y]
fadd dword [#t]
fdiv DWORD [#divisor]
fcos
faddp st(1) ')
fmul DWORD [#two] '*2
fld dword [#t] ' Sin(t/100)*15
fdiv DWORD [#divisor]
fsin
fmul DWORD [#fifteen]
faddp st(1)
fstp dword [#c] ' -> store to c
'-----
fld dword [#c]
fcos
fmul DWORD [#v64]
fadd DWORD [#v128]
fistp dword [#Green] ' -> store to Green
'-----
fld dword [#c]
fsin
fmul DWORD [#v64]
fadd DWORD [#v128]
fistp dword [#Red] ' -> store to Red
'-----
fld dword [#c]
fchs ' change sign
fdiv DWORD [#two]
fcos
fmul DWORD [#v64]
fadd DWORD [#v128]
fistp dword [#Blue] ' -> store to Blue
'-----
xor eax,eax
add eax,[#red]
shl eax,8
add eax,[#green]
shl eax,8
add eax,[#blue]
'or eax,0xff000000
mov [#compo],eax ' composite ARGB color
ret
"
dim v64, v128 as single
dim Red, Green, Blue, Compo as long = 255
v64 = 64
v128 = 128
dim ColorCalc as string = O2_ASM(ColorCalcSrc)
if len(O2_ERROR) then
msgbox 0, O2_ERROR+$crlf+"Program will end now"
stop
end if
dim t1, t2 as double
while FBGFX_InKey() <> "q" 'Program runs until "q" is pressed
t1 = gettickcount
t=t+1
For x = 0 To w step 3
For y = 0 To h step 3
MC_EXEC ColorCalc
FBGFX_circle x, y, 3, compo
Next
Next
'pageflip
page=-page+1
FBGFX_Sync(1)
FBGFX_ScreenSet(page,-page+1)
t2 = gettickcount
wend
'msgbox 0, ":"+hex$(fbgfx_rgb(0,0,1))
'msgbox 0, "FrameTime:"+STR$(t2-t1)
[/code]
This runs faster yet by simplifying the inner loop. The Assembler script takes on the task of stepping x and y then breaking the loop at the end of each frame. x and y have also been changed to integers.
The x y stepper illustrates how to use an O2 control structure in Asmosphere. - No jump labels needed.
[code=thnbasic]
'Plasma-like effect with FBGFX
uses "FBGFX"
uses "OXYGEN"
Dim w,h,x,y,i,syn As long
w=400 ' x boundary
h=300 ' y boundary
i=3 ' step
syn=0 ' loop flag
FBGFX_ScreenRes(w,h,32,2)
Dim page As single
Dim c,t As single
dim divisor, two, fifteen As single
divisor = 100
two = 2
fifteen = 15
dim ColorCalcSrc as string="
'-----
fild dword [#x] ' Sin((x+y+t)/100)
fiadd dword [#y]
fadd dword [#t]
fdiv DWORD [#divisor]
fsin
fild dword [#x] ' Cos((x-t)/100)
fsub dword [#t]
fdiv DWORD [#divisor]
fcos
faddp st(1)
fild dword [#y] ' Cos((y-t)/100)
fsub dword [#t]
fdiv DWORD [#divisor]
fcos
faddp st(1)
fild dword [#x] ' Cos((x-y+t)/100)
fisub dword [#y]
fadd dword [#t]
fdiv DWORD [#divisor]
fcos
faddp st(1) ')
fmul DWORD [#two] '*2
fld dword [#t] ' Sin(t/100)*15
fdiv DWORD [#divisor]
fsin
fmul DWORD [#fifteen]
faddp st(1)
fstp dword [#c] ' -> store to c
'-----
fld dword [#c]
fcos
fmul DWORD [#v64]
fadd DWORD [#v128]
fistp dword [#Green] ' -> store to Green
'-----
fld dword [#c]
fsin
fmul DWORD [#v64]
fadd DWORD [#v128]
fistp dword [#Red] ' -> store to Red
'-----
fld dword [#c]
fchs ' change sign
fdiv DWORD [#two]
fcos
fmul DWORD [#v64]
fadd DWORD [#v128]
fistp dword [#Blue] ' -> store to Blue
'-----
'compose rgb color
xor eax,eax
add eax,255
shl eax,8 ' alpha byte optional
add eax,[#red]
shl eax,8
add eax,[#green]
shl eax,8
add eax,[#blue]
mov [#compo],eax ' composite ARGB color
'-----
' increment x y and clear syn flag afer each screen cycle
mov eax,[#x]
mov ecx,[#y]
(
add eax,[#i] ' increment x
cmp eax,[#w] '
jl exit '
xor eax,eax ' zero x
add ecx,[#i] ' increment y
cmp ecx,[#h] '
jl exit
xor ecx,ecx ' zero y
mov [#syn],ecx ' zero sync
)
mov [#x],eax
mov [#y],ecx
ret
"
dim v64, v128 as single
dim Red, Green, Blue, Compo as long = 255
v64 = 64
v128 = 128
dim ColorCalc as string = O2_ASM(ColorCalcSrc)
if len(O2_ERROR) then
msgbox 0, O2_ERROR+$crlf+"Program will end now"
stop
end if
'msgbox 0,o2_view(ColorCalcSrc) ' look at O2 translated source
'stop
dim t1, t2 as double
while FBGFX_InKey() <> "q" 'Program runs until "q" is pressed
t1 = gettickcount
t=t+1
syn=1
while syn
MC_EXEC ColorCalc
FBGFX_circle x, y, i, compo
wend
page=-page+1 ' page flip
FBGFX_Sync(1)
FBGFX_ScreenSet(page,-page+1)
't2 = gettickcount
wend
'msgbox 0, "FrameTime:"+STR$(t2-t1)
[/code]
Thanks Charles,
all-in-one version is nice
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Well this is an all-in-two version, where the assembly code is in a separate asm file:
This is probably the easier way to handle larger pieces of code - and there are no restrictions on using double quotes.
In the latest release of thinBasic_Oxygen, I have tweaked the interpretation of a #variable, so that they can be 'diverted' to a local def instead of being a pointer defined by the parent program.
The reason for doing this is to make Asmosphere easier to embed in other programs, which do not have a scripting interface. They will generate their own def header to add to the main asm source script. Assembly code developed with thinBasic, can then be used without any alteration apart from this header.
The example below also demonstrates how to set up local variables on the stack and then release them before returning
I have included this with the latest thinBasic_Oxygen:
PlasmaColor2.asm
[code=thinbasic]
' Plasma-like effect with FBGFX
' -----------------------------
' allocatate local workspace on stack
push ebp
mov ebp,esp
sub esp,40
' variables bound to parent
' #x row pos
' #y column pos
' #i step
' #w width of window client
' #h height of window client
' #syn parent loop flag
' #compo composite color
' local variable macros
def #v128 ebp-04
def #v64 ebp-08
def #fifteen ebp-12
def #two ebp-16
def #divisor ebp-20
' these do not require an initial value
def #red ebp-24
def #green ebp-28
def #blue ebp-32
' initialise local variables
' (constants for the FPU)
mov [#v128], 128
mov [#v64], 64
mov [#fifteen], 15
mov [#two], 2
mov [#divisor], 100
'-----
fild dword [#x] ' Sin((x+y+t)/100)
fiadd dword [#y]
fadd dword [#t]
fidiv dword [#divisor]
fsin
fild dword [#x] ' Cos((x-t)/100)
fsub dword [#t]
fidiv dword [#divisor]
fcos
faddp st(1)
fild dword [#y] ' Cos((y-t)/100)
fsub dword [#t]
fidiv dword [#divisor]
fcos
faddp st(1)
fild dword [#x] ' Cos((x-y+t)/100)
fisub dword [#y]
fadd dword [#t]
fidiv dword [#divisor]
fcos
faddp st(1) ')
fimul dword [#two] '*2
fld dword [#t] ' Sin(t/100)*15
fidiv dword [#divisor]
fsin
fimul dword [#fifteen]
faddp st(1)
fstp dword [#c] ' -> store to c
'-----
fld dword [#c]
fcos
fimul dword [#v64]
fiadd dword [#v128]
fistp dword [#Green] ' -> store to Green
'-----
fld dword [#c]
fsin
fimul dword [#v64]
fiadd dword [#v128]
fistp dword [#Red] ' -> store to Red
'-----
fld dword [#c]
fchs ' change sign
fidiv dword [#two]
fcos
fimul dword [#v64]
fiadd dword [#v128]
fistp dword [#Blue] ' -> store to Blue
'-----
'compose rgb color
xor eax,eax
add eax,255
shl eax,8 ' alpha byte optional
add eax,[#red]
shl eax,8
add eax,[#green]
shl eax,8
add eax,[#blue]
mov [#compo],eax ' composite ARGB color
'-----
' increment x y and clear syn flag afer each screen cycle
mov eax,[#x]
mov ecx,[#y]
(
add eax,[#i] ' increment x
cmp eax,[#w] '
jl exit '
xor eax,eax ' zero x
add ecx,[#i] ' increment y
cmp ecx,[#h] '
jl exit
xor ecx,ecx ' zero y
mov [#syn],ecx ' zero sync
)
mov [#x],eax
mov [#y],ecx
' deallocate local workspace from stack
add esp,40
pop ebp
ret
[/code]
Test_PF2.tbasic
[code=thinbasic]
'Plasma-like effect with FBGFX
uses "FBGFX"
uses "OXYGEN"
Dim w,h,x,y,i,syn,compo As long
w=400 ' x boundary
h=300 ' y boundary
i=3 ' step
syn=0 ' loop flag
Dim page As single
Dim c,t As single
dim ColorCalc as string = O2_ASM_FILE "PlasmaColor2.asm"
if len(O2_ERROR)>0 then
msgbox 0, O2_ERROR+$crlf+"Program will end now"
stop
end if
dim t1, t2 as double
FBGFX_ScreenRes(w,h,32,2)
while FBGFX_InKey() <> "q" 'Program runs until "q" is pressed
t1 = gettickcount
t=t+1
syn=1
while syn
MC_EXEC ColorCalc
FBGFX_circle x, y, i, compo
wend
page=-page+1 ' page flip
FBGFX_Sync(1)
FBGFX_ScreenSet(page,-page+1)
t2 = gettickcount
wend
'msgbox 0, "FrameTime:"+STR$(t2-t1)
[/code]
That is really a great idea to have the option of all in one or all in two option!!
Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server
Bookmarks