Author Topic: Crap plasma using tinypct (ez)  (Read 422 times)

0 Members and 1 Guest are viewing this topic.

Offline Roly

  • Amiga 1200
  • ****
  • Posts: 390
  • Karma: 7
    • View Profile
Crap plasma using tinypct (ez)
« on: May 17, 2006 »


Original post from Shockwave, taken from the ezboard forum


Use it if you want, though it's a bit shit.

Code: [Select]

'
' Simple Plasma Test By Shockwave / DBF 2006.
'
' THIS PROGRAM WAS JUST A TEST TO SEE IF A 640 X 480 SCREEN CAN BE RENDERED
' IN PIXELS QUICK ENOUGH TO DO STUFF.
'
' A SLOW PLASMA ROUTINE WAS ADDED IN TO SIMULATE SOME OF THE CALCULATIONS THAT
' WOULD BE NEEDED TO MAKE TEXTURED VECTORS OR PARTICLE EFFECTS ETC.
' SEEMS TO RUN QUITE QUICK AND THE SINE TABLES / COLOUR TABLES ARE NOT EVEN
' PRECALCULATED WHICH IS A GOOD OMEN.
'
' WILL WORK ON SOME FAST PLASMA ROUTINES IN THE NEXT FEW DAYS.
' IT IS A LOT FASTER THAN BLITZ THOUGH EVEN AS IT STANDS.
'
'--------------------------------------------------------------------------


'-------------------------------------
' Includes.
'-------------------------------------
#Include Once "tinyptc.bi"

'--------------------------------------------------------------------------
' Open 640 X 480
'--------------------------------------------------------------------------
If( ptc_open( "DBF SIMPLE PLASMA", 640, 480 ) = 0 ) Then
End -1
End If


'--------------------------------------------------------------------------
' Define Storage;
'--------------------------------------------------------------------------
Dim Shared As Integer Buffer( 640 * 480 )
DIM SHARED  R,G,B AS INTEGER
DIM SHARED L1,L2 AS INTEGER
DIM SHARED COMBINED AS INTEGER
DIM SHARED F1,F2,F3 AS INTEGER
DIM SHARED PM AS DOUBLE
PM=3.14/180
'--------------------------------------------------------------------------
' Declare sub-routines
'--------------------------------------------------------------------------
Declare Sub ClearScreen ()

DO
    F1=F1+4
    F2=F2+2
    F3=F3+3
        CLEARSCREEN()
        FOR L1=1 TO 479
            AV2=30+20*SIN(F3 / 20)
            AV=50+AV2*COS((L1-F3)*PM  )
            G=100+AV*COS((F1+L1) * PM )
            B=100+AV*SIN((L1+F3)*PM)
            FOR L2=1 TO 639           
                R=100+AV*SIN((L2+L1+F2) * PM )                     
                COMBINED= RGB (R,G,B)
                Buffer(L2 + (L1 * 640)) = COMBINED
            NEXT
        NEXT


ScreenLock()
'Update PTC screen with temp buffer
Ptc_Update @Buffer(0)
ScreenUnlock()
       
LOOP UNTIL INKEY$<>""
END

'--------------------------------------------------------------------------
' Subs;
'--------------------------------------------------------------------------

Sub ClearScreen()

Dim i as integer
for i = 0 to 640*480
Buffer(i) = 0
next

End Sub

All part of the learning process I guess.
I'll get there.

¤´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´ (¸.·`¤... SHOCKWAVE / DBF...¤

Quote
rbraz

Nice plasma :)

I'll recode one BB version to FB and post it here later :D

Quote
5H0CKW4VE

Thanks Rbraz, looking forward to seeing your plasma too.

Here's a little re-hash with nicer colours.
 
Code: [Select]
'
' Simple Plasma Test By Shockwave / DBF 2006.
'
' THIS PROGRAM WAS JUST A TEST TO SEE IF A 640 X 480 SCREEN CAN BE RENDERED
' IN PIXELS QUICK ENOUGH TO DO STUFF.
'
' Same again but with prettier colours.
'
'
'--------------------------------------------------------------------------


'-------------------------------------
' Includes.
'-------------------------------------
'#define PTC_WIN
#Include Once "tinyptc.bi"

'--------------------------------------------------------------------------
' Open 640 X 480
'--------------------------------------------------------------------------
If( ptc_open( "DBF SIMPLE PLASMA", 640, 480 ) = 0 ) Then
End -1
End If


'--------------------------------------------------------------------------
' Define Storage;
'--------------------------------------------------------------------------
Dim Shared As Integer Buffer( 640 * 480 )
DIM SHARED  R,G,B AS INTEGER
DIM SHARED L1,L2 AS INTEGER
DIM SHARED COMBINED AS INTEGER
DIM SHARED F1,F2,F3 AS INTEGER
DIM SHARED PM AS DOUBLE
PM=3.14/180
'--------------------------------------------------------------------------
' Declare sub-routines
'--------------------------------------------------------------------------
Declare Sub ClearScreen ()

DO
    F1=F1+1
    F2=F2-7
    F3=F3+3
        CLEARSCREEN()
        FOR L1=1 TO 479
            av=50*sin((l1+f1)*PM)
            av2=60+av*cos((f2+l1)*pm)
            av3=100+10*sin((f1+l1)/10)
            bl=100+70*(cos(av2+l1 )) shr 2
            FOR L2=1 TO 639           
                R=140+AV2*SIN((L2+av2+l1) /av3 )                     
                COMBINED= RGB (r,av2,bl)
                Buffer(L2 + (L1 * 640)) = COMBINED
            NEXT
        NEXT



'Update PTC screen with temp buffer
Ptc_Update @Buffer(0)

       
LOOP UNTIL INKEY$<>""
END

'--------------------------------------------------------------------------
' Subs;
'--------------------------------------------------------------------------

Sub ClearScreen()

Dim i as integer
for i = 0 to 640*480
Buffer(i) = 0
next

End Sub

Quote
Clyde Radcliffe

Nice mate, it totally rocks with commenting out the bl calculation.
One thing that might be of use to you is that FB uses radians and not degrees. sin( a * PI/180.00 ) is a little converter example. But you probably knew that allready. :D

I really like the type of movement of the plasma. Cool mate :)

Cheers and all the best,
Clyde :)
« Last Edit: May 31, 2006 by Clyde »