0 Members and 1 Guest are viewing this topic.
'' Plasma Mk1.'#Include Once "TinyPtc_Ext.bi"Const XRES=640Const YRES=480Const ARES=XRES*YRESConst PI As Single = 3.14159'' Globals.'Dim Shared ScreenBuffer(ARES)Dim Shared Pal(256)Dim Shared x,y,incDim Shared ARGB Dim Shared Key As String'' Subroutines.'Declare Sub FeedPixels( Buffer(), ByVal x As Integer, ByVal y As Integer, ByVal col As Integer)Declare Sub GeneratePalette( ByVal Val1 As Integer,_ ByVal Val2 As Integer,_ ByVal Val3 As Integer )'' Setup.'PTC_SetDialog(0,"",0,0)PTC_Open("Plasma Mk1",XRES,YRES)GeneratePalette(16,128,0)'' Main Loop.'While Key<>chr(27) For x = 0 To XRES-1 For y = 0 To YRES-1 ARGB= int( 128.0 + (128.0 * sin(x / 16.0))_ + 128.0 + (128.0 * sin(y / 32.0))_ + 128.0 + (128.0 * sin(sqr(cdbl((x - XRES / 2.0)* (x - XRES / 2.0) + (y - YRES / 2.0) * (y - YRES / 2.0))) / 8.0))_ + 128.0 + (128.0 * sin(sqr(cdbl(x * x + y * y)) / 8.0))) / 4 FeedPixels(ScreenBuffer(),x, y, Pal(ARGB+inc and 255)) Next Next inc=inc+16 Ptc_Update @ScreenBuffer(0) Erase ScreenBuffer Key=Inkey() Wend'' Shutdown.'PTC_Close()Sub FeedPixels( Buffer(), ByVal x As Integer, ByVal y As Integer, ByVal col As Integer) If X>0 And X<XRES-1 And Y>0 And Y<YRES-1 Then Buffer(Y * XRES + X) = col End IfEnd SubSub GeneratePalette( ByVal Val1 As Integer,_ ByVal Val2 As Integer,_ ByVal Val3 As Integer ) ' ' Local variables. ' Dim A,R,G,B As Integer For A=0 To 255 R = int(128.0 + 128 * sin(PI * A / Val1)) G = int(128.0 + 128 * sin(PI * A / Val2)) B = int(128.0 + 128 * sin(PI * A / Val3)) Pal( A ) = ( R Shl 16 ) Or ( G Shl 8 ) Or ( B Shl 0 ) NextEnd Sub
'' Plasma Mk1.'#Include Once "TinyPtc_Ext.bi"Const XRES=640Const YRES=480Const ARES=XRES*YRESConst PI As Single = 3.14159'' Globals.'Dim Shared ScreenBuffer(ARES) as integerDim Shared Pal(256) as integerDim Shared as integer x,y,incDim Shared ARGB as integerDim Shared Key As String'' Subroutines.'Declare Sub FeedPixels( Buffer() as integer, ByVal x As Integer, ByVal y As Integer, ByVal col As Integer)Declare Sub GeneratePalette( ByVal Val1 As Integer,_ ByVal Val2 As Integer,_ ByVal Val3 As Integer )'' Setup.'PTC_SetDialog(0,"",0,0)PTC_Open("Plasma Mk1",XRES,YRES)GeneratePalette(16,128,0)'' Main Loop.'While Key<>chr(27) For x = 0 To XRES-1 For y = 0 To YRES-1 ARGB= int( 128.0 + (128.0 * sin(x / 16.0))_ + 128.0 + (128.0 * sin(y / 32.0))_ + 128.0 + (128.0 * sin(sqr(cdbl((x - XRES / 2.0)* (x - XRES / 2.0) + (y - YRES / 2.0) * (y - YRES / 2.0))) / 8.0))_ + 128.0 + (128.0 * sin(sqr(cdbl(x * x + y * y)) / 8.0))) / 4 FeedPixels(ScreenBuffer(),x, y, Pal(ARGB+inc and 255)) Next Next inc=inc+16 Ptc_Update @ScreenBuffer(0) Erase ScreenBuffer Key=Inkey() Wend'' Shutdown.'PTC_Close()Sub FeedPixels( Buffer() as integer, ByVal x As Integer, ByVal y As Integer, ByVal col As Integer) If X>0 And X<XRES-1 And Y>0 And Y<YRES-1 Then Buffer(Y * XRES + X) = col End IfEnd SubSub GeneratePalette( ByVal Val1 As Integer,_ ByVal Val2 As Integer,_ ByVal Val3 As Integer ) ' ' Local variables. ' Dim as integer A,R,G,B For A=0 To 255 R = int(128.0 + 128 * sin(PI * A / Val1)) G = int(128.0 + 128 * sin(PI * A / Val2)) B = int(128.0 + 128 * sin(PI * A / Val3)) Pal( A ) = ( R Shl 16 ) Or ( G Shl 8 ) Or ( B Shl 0 ) NextEnd Sub