REM ---///Welcome to FxStudio///---
REM ---Made by Mikael Lagre 2001---

REM "My homepage: http://fly.to/lagre"
REM "MY email: mikael_lagre@hotmail.com"
REM "Latest version: this one"
REM "Nr of lines: 1577" 
REM "Parsing time: Around 15 seconds" 
REM "Other: ...I heard something about the analog sticks"
REM "...don't know what it means though... ;)"




REM ---Init Graphics---
open window 640,512
setrgb 0,0,0,0
clear window
setdispbuf 0
setdrawbuf 0



REM ---Effect Menu---
cursorX = 90
cursorY = 104
cursorSpeed = 3
selectedEffectNr = 1

label effectMenu
open window 640,512
setrgb 0,0,0,0
clear window
port1_menu = 0
window origin "lt"

while (port1_menu<>1)
 port1_menu = peek("port1")

 REM ---Up on controller1---
 if (and(port1_menu,16) > 0) then
  cursorY = cursorY-cursorSpeed
  if cursorY<100 cursorY=100
 endif

 REM ---Down on controller1---
 if (and(port1_menu,64) > 0) then
  cursorY = cursorY+cursorSpeed
  if cursorY>308 cursorY=308
 endif

 if port1_menu = 6 goto qwerty

 REM ---Calculates current selected effect
 selectedEffectNr = int((cursorY-92)/20)+1

 REM ---X on controller1---
 if (and(port1_menu,16384) > 0) then
  REM ---check which effect we should start---
  if selectedEffectNr = 1 goto lblStarfield
  if selectedEffectNr = 2 goto lblGouradShow
  if selectedEffectNr = 3 goto lblFire
  if selectedEffectNr = 4 goto lblFountain
  if selectedEffectNr = 5 goto lblFlower
  if selectedEffectNr = 6 goto lblFireworks
  if selectedEffectNr = 7 goto lblFadeblocks
  if selectedEffectNr = 8 goto lblColorshow
  if selectedEffectNr = 9 goto lblLandscape
  if selectedEffectNr = 10 goto lblps2logo
 endif


 
 REM ---Draw menu and cursor
 setrgb 1,255,255,255
 text 10,30, "Welcome to FxStudio! (c)2001 mikael lagre"
 setrgb 1,0,100,200
 text 100,400, "Controlls:"
 setrgb 1,50,200,200
 text 220,400, "-Up/Down - select Fx"
 setrgb 1,100,200,200
 text 220,420, "-X - Start effect"
 setrgb 1,150,250,200
 text 220,440, "-Triangle - end effect"
 setrgb 1,200,250,200
 text 220,460, "-Select - end program (must be in menu!)"
 
 setrgb 1,150,150,150
 text 100,108, "3DStarfield..."
 text 100,128, "Gourad show..."
 text 100,148, "Fire..."
 text 100,168, "Fountain..."
 text 100,188, "Flower..."
 text 100,208, "Fireworks..."
 text 100,228, "Fade out blocks..."
 text 100,248, "Color show..."
 text 100,268, "Landscape..."
 text 100,288, "PS2 logo..."
 text 100,308, "About..."

 REM ---highlights effect text and displays information---
 setrgb 1,0,0,100
 setrgb 2,0,0,0
 setrgb 3,0,0,100
 gtriangle 300,100 to 300,350 to 610,350
 gtriangle 610,350 to 610,100 to 300,100


 if selectedEffectNr = 1 then 
  setrgb 1,150,150,100
  text 100,108, "3DStarfield..."
  setrgb 1,255,255,255
  text 300,110, "3dStarfield is a simple demo"
  text 300,130, "that uses rects with different"
  text 300,150, "velocity, depth and shade"
  text 300,170, "to create the effect of 'stars'"
  text 300,190, "that moves."
  text 300,210, "Notice how the stars with"
  text 300,230, "highest Z also has the"
  text 300,250, "lowest brightness."
  text 300,270, "That makes them look farther"
  text 300,290, "away from the user..."
 endif

 if selectedEffectNr = 2 then 
  setrgb 1,150,150,100
  text 100,128, "Gourad show..."
  setrgb 1,255,255,255
  text 300,110, "Gourad show is suppose to"
  text 300,130, "display the gtriangle effect"
  text 300,150, "used in Yabasic."
  text 300,170, "What you may notice is that"
  text 300,190, "the routine is very fast and"
  text 300,210, "gtriangle is therefore very"
  text 300,230, "good to use in games and"
  text 300,250, "other graphical programs!"
 endif

 if selectedEffectNr = 3 then 
  setrgb 1,150,150,100
  text 100,148, "Fire..."
  setrgb 1,255,255,255
  text 300,110, "This is the basics of a fire"
  text 300,130, "routine and gives a lot to"
  text 300,150, "the user for improvement!"
  text 300,170, "The fire particles are scaled"
  text 300,190, "and therefore looks very"
  text 300,210, "'blocky'"
 endif

 if selectedEffectNr = 4 then 
  setrgb 1,150,150,100
  text 100,168, "Fountain..."
  setrgb 1,255,255,255
  text 300,110, "This is an interesting effect"
  text 300,130, "and can only be described"
  text 300,150, "as a simulation program!"
  text 300,170, "Particles flying up and being"
  text 300,190, "pulled down by different"
  text 300,210, "values in gravity. Notice"
  text 300,230, "the sudden drop in framerate"
  text 300,250, "when we have to many"
  text 300,270, "particles!"
 endif

 if selectedEffectNr = 5 then 
  setrgb 1,150,150,100
  text 100,188, "Flower..."
  setrgb 1,255,255,255
  text 300,110, "An example of real-time"
  text 300,130, "drawing without clearing"
  text 300,150, "the screen or use of double-"
  text 300,170, "buffering!"
  text 300,190, "17 different randomized"
  text 300,210, "values ensure you that every"
  text 300,230, "flower is unique!"
 endif

 if selectedEffectNr = 6 then 
  setrgb 1,150,150,100
  text 100,208, "Fireworks..."
  setrgb 1,255,255,255
  text 300,110, "This is a graphical demo"
  text 300,130, "that looks like fireworks!"
  text 300,150, "The small particles are"
  text 300,170, "drawn using the fill circle"
  text 300,190, "method."
 endif

 if selectedEffectNr = 7 then 
  setrgb 1,150,150,100
  text 100,228, "Fade out blocks..."
  setrgb 1,255,255,255
  text 300,110, "If you want to switch between"
  text 300,130, "different parts in your"
  text 300,150, "game/program then this is a"
  text 300,170, "effect you might like!!"
 endif

 if selectedEffectNr = 8 then 
  setrgb 1,150,150,100
  text 100,248, "Color show..."
  setrgb 1,255,255,255
  text 300,110, "The color show is just"
  text 300,130, "a demo showing off YaBasic's"
  text 300,150, "power in using a lot of"
  text 300,170, "object and calculations at"
  text 300,190, "the same time!"
  text 300,210, "30 different values are used!"
  text 300,230, "YaBasic IS powerful!!!! :)"
 endif

 if selectedEffectNr = 9 then 
  setrgb 1,150,150,100
  text 100,268, "Landscape..."
  setrgb 1,255,255,255
  text 300,110, "Landcape generator v1.4!"
  text 300,130, "Using a very easy algoritm"
  text 300,150, "we can create a 'pseudo3d'"
  text 300,170, "decent looking landscape."
  text 300,190, "The only problem is the"
  text 300,210, "loading time..."
 endif

 if selectedEffectNr = 10 then 
  setrgb 1,150,150,100
  text 100,288, "PS2 logo..."
  setrgb 1,255,255,255
  text 300,110, "Draws the ps2 logo for you!"
  text 300,130, "This logo is not an EXACT"
  text 300,150, "copy of the original and"
  text 300,170, "the color representation"
  text 300,190, "are that one on your machine!"
  text 300,210, "(Notice the color difference"
  text 300,230, "between the logo on your"
  text 300,250, "machine and the one on the"
  text 300,270, "demo disk case!!!)"
 endif

 if selectedEffectNr = 11 then 
  setrgb 1,150,150,100
  text 100,308, "About..."
  setrgb 1,255,255,255
  text 300,110, "FxStudio made by Mikael Lagre"
  text 300,130, "Feel free to use any of this"
  text 300,150, "effects and manipulate with"
  text 300,170, "the code as much you like"
  text 300,190, "as long credits is given."
  text 300,210, "Please support:"
  text 300,230, "--www.yabasic.co.uk--"
  text 300,250, "Do not smoke, eat right, and"
  text 300,270, "remember that even Hideo"
  text 300,290, "Kojima started with the"
  text 300,310, "basics!!"
  text 450,350, "/Master Tonberry"
 endif



 REM --Draws cursor---
 setrgb 1,255,0,0
 setrgb 2,255,0,0
 setrgb 3,20,0,0
 gtriangle cursorX,cursorY to cursorX-10,cursorY-10 to cursorX-10,cursorY+10
 setdrawbuf 1 - draw
 setdispbuf draw
 draw = 1 - draw
 clear window

wend


REM -----Quit-----
end











REM ---//{(..EFFECTS..)}//---


REM ---1: Starfield3D---
REM ################################
label lblStarfield


REM This is the 3dStarfield program
REM -------------------------------

setrgb 0,0,0,0
clear window
setdrawbuf 0
setdispbuf 0

dim x(1000)     REM The x Value
dim y(1000)     REM The y Value
dim z(1000)     REM The z Value


REM __Starfield values__
nrStars = ran(150)+30
starfieldSpeed = ran(13)+5
worldDepth = 1300
halfWorldDepth = worldDepth/2
maxSize = 3


REM __Init__
for i=1 to nrStars
 x(i) = ran(260)-130
 y(i) = ran(260)-130
 z(i) = ran(worldDepth)
next i

brightnessDivider = 255/halfWorldDepth
sizeDivider = maxSize/worldDepth


draw = 0

REM ---Loop---
port1_starfield = 0
while (port1_starfield<>4096)
 port1_starfield=peek("port1")


setdrawbuf 1 - draw
setdispbuf draw
draw = 1 - draw
setrgb 1,0,0,0
fill rect 0,0,640,512


for i=1 to nrStars
 z(i) = z(i) - starfieldSpeed
 if (z(i) < 0) then
  x(i) = ran(260)-130
  y(i) = ran(260)-130
  z(i) = worldDepth
 endif

 if (z < halfWorldDepth) then
  sX = 640*(x(i)/z(i)) + 320
  sY = 512*(y(i)/z(i)) + 256
  brightness = 255-(brightnessDivider*z(i))
  size = maxSize-(sizeDivider*z(i))

  if (size <= maxSize) then
   setrgb 1,brightness,brightness,brightness
   halfSize = size*0.5
   fill rect sX-halfSize,sY-halfSize,sX+halfSize,sY+halfSize

  endif
 endif
next i

wend

goto effectMenu
REM ################################






REM ---2: Gourad Show---
REM ################################
label lblGouradShow

REM ---Data for color values: r=red, g=green, b=blue---
dim r(3), g(3), b(3)
dim dr(3), dg(3), db(3)

for i = 1 to 3
 r(i) = ran(255)
 g(i) = ran(255)
 b(i) = ran(255)
 dr(i) = ran(2)-1
 dg(i) = ran(2)-1
 db(i) = ran(2)-1
next i

setdispbuf 0
setdrawbuf 0
clear window

port1_gourad = 0

while (port1_gourad<>4096)

 port1_gourad=peek("port1")

 for i = 1 to 3
  r(i) = r(i) + dr(i)
  if (r(i) > 255 or r(i) < 0) dr(i) = -dr(i)
  g(i) = g(i) + dg(i)
  if (g(i) > 255 or g(i) < 0) dg(i) = -dg(i)
  b(i) = b(i) + db(i)
  if (b(i) > 255 or b(i) < 0) db(i) = -db(i)
 next i
 setrgb 1,r(1),g(1),b(1)
 setrgb 2,r(2),g(2),b(2)
 setrgb 3,r(3),g(3),b(3)

 gtriangle 50,50 to 50,462 to 590,462
 gtriangle 50,50 to 590,50 to 590,462

 setrgb 1,r(1),g(1),b(1)
 fill rectangle 0,50 to 50,462
 setrgb 1,r(2),g(2),b(2)
 fill rectangle 590,50 to 640,462
 setrgb 1,r(3),g(3),b(3)
 fill rectangle 0,0 to 640,50
 fill rectangle 0,462 to 640,512
wend
goto effectMenu
REM ################################







REM ---3: Fire---
REM ################################
label lblFire

xSize = 60
ySize = 15
dim fire(xSize,ySize)

REM ---init the red line---
for i=1 to xSize step 1
   fire(i,ySize)=255
next i

sX=5
sY=5

startDrawX = 320-((xSize*sX)/2)
startDrawY = 256-((ySize*sY)/2)
colorDec = 50
port1_fire = 0

setdrawbuf 0
setdispbuf 0
clear window

while (port1_fire<>4096)
 port1_fire = peek("port1")
 for y=1 to ySize-1 step 1
  for x=1 to xSize-1 step 1
   fire(x,y)=fire(x,y+1)-ran(colorDec)
    x1 = x*sX+startDrawX
    y1 = y*sY+startDrawY
    setrgb 1,fire(x,y),0,0
    fill rect x1,y1 to x1+sX,y1+sY
  next x
 next y 
wend

goto effectMenu
REM ################################




REM ---4: Fountain---
REM ################################
label lblFountain
window origin "lb"

maxdrops = ran(290)+10
gravity = -(ran()/10)

xcenter  = 320
ycenter = 150

dim x(maxdrops)
dim y(maxdrops)
dim vx(maxdrops)
dim vy(maxdrops)
dim t(maxdrops)
dim col(maxdrops)

REM ---Init drops
for i=1 to maxdrops
 x(i) = xcenter+ran(10)-5
 y(i) = ycenter+ran(10)-5
 vx(i) = ran(6)-3
 vy(i) = ran(8)
 t(i) = -ran(100)
 col(i) = ran(255)
next i

setdispbuf 0
setdrawbuf 0
clear window

port1_fountain = 0
while (port1_fountain<>4096)

 port1_fountain = peek("port1")

 for i=1 to maxdrops
  t(i) = t(i) + 1
  if t(i) > 10000 t(i)=0
  if (t(i) > 0) then
   x(i) = x(i) + vx(i)
   y(i) = y(i) + vy(i) + (gravity*t(i)*t(i))/2
   if y(i) < 0 then 
    x(i) = xcenter+ran(10)-5
    y(i) = ycenter+ran(10)-5
    vx(i) = ran(6)-3
    vy(i) = ran(8)
    t(i) = 0
   end if
   setrgb 1,200+(ycenter-y(i)),col(i),200-(xcenter-x(i))
   dot x(i),y(i)
  endif
 next i

 setdrawbuf 1 - draw
 setdispbuf draw
 draw = 1 - draw
 clear window

wend
goto effectMenu
REM ################################






REM ---5: Flower---
REM ################################
label lblFlower

REM ---Init lines---
dim line_x(3), line_y(3)
dim line_lenght(3), line_rot(3), line_rotspeed(3)
dim line_red(3),line_green(3),line_blue(3)
dim line_redfrom(3), line_redto(3), line_redinc(3)
dim line_greenfrom(3), line_greento(3), line_greeninc(3)
dim line_bluefrom(3), line_blueto(3), line_blueinc(3)


line_lenght(1) = ran(50)+90
line_lenght(2) = ran(70)+50
line_lenght(3) = ran(40)+20
line_rotspeed(1) = ran(1.5) - 0.75
line_rotspeed(2) = ran(0.05)-0.0025
line_rotspeed(3) = ran(0.1) - 0.05
for i=1 to 3
 line_redfrom(i) = ran(255)
 line_red(i) = line_redfrom(i)
 line_redto(i) = ran(255-line_redfrom(i))+line_redfrom(i)
 line_redinc(i) = ran(1)

 line_greenfrom(i) = ran(255)
 line_green(i) = line_greenfrom(i)
 line_greento(i) = ran(255-line_greenfrom(i))+line_greenfrom(i)
 line_greeninc(i) = ran(1)

 line_bluefrom(i) = ran(255)
 line_blue(i) = line_bluefrom(i)
 line_blueto(i) = ran(255-line_bluefrom(i))+line_bluefrom(i)
 line_blueinc(i) = ran(1)
next i


xCenter = 320 : yCenter = 256

setdispbuf 0
setdrawbuf 0
clear window

setrgb 1,255,255,255
text 10,504, "Press X for new flower"
port1_flower = 0

while (port1_flower<>4096)
 port1_flower = peek("port1")
 if (port1_flower = 16384) goto lblFlower
 for i=1 to 3
  line_rot(i) = line_rot(i) + line_rotspeed(i)
  if line_rot(1) > 12*PI line_rot=line_rotspeed(i)-line_rot(i)
  line_x(i) = (line_lenght(i)*cos(line_rot(i)))
  line_y(i) = (line_lenght(i)*-sin(line_rot(i)))
 next i

 x1 = xCenter+line_x(1) 
 y1 = yCenter+line_y(1)
 x2 = x1+line_x(2)  
 y2 = y1+line_y(2)
 x3 = x2+line_x(3)
 y3 = y2+line_y(3)

 for i=1 to 3
  line_red(i) = line_red(i) + line_redinc(i)
  if (line_red(i) > line_redto(i) or line_red(i) < line_redfrom(i)) line_redinc(i)=-line_redinc(i)
  line_green(i) = line_green(i) + line_greeninc(i)
  if (line_green(i) > line_greento(i) or line_green(i) < line_greenfrom(i)) line_greeninc(i)=-line_greeninc(i)
  line_blue(i) = line_blue(i) + line_blueinc(i)
  if (line_blue(i) > line_blueto(i) or line_blue(i) < line_bluefrom(i)) line_blueinc(i)=-line_blueinc(i)
 next i

 setrgb 1,line_red(1),line_green(1),line_blue(1)
 line xCenter,yCenter to x1,y1
 setrgb 1,line_red(2),line_green(2),line_blue(2)
 line x1,y1 to x2,y2
 setrgb 1,line_red(3),line_green(3),line_blue(3)
 line x2,y2 to x3,y3
wend
goto effectMenu
REM ################################







REM ---6: Fireworks---
REM ################################
label lblFireworks

nrMaxParticles = 100
dim px(nrMaxParticles),py(nrMaxParticles)
dim dpx(nrMaxParticles),dpy(nrMaxParticles)

setdispbuf 0
setdrawbuf 0
clear window

label lblNewExplosion
nrParticles = ran(25)+5

REM ---Init Particles---
xCenter = ran(590)+50 : yCenter = ran(462)+50
for i = 1 to nrParticles
 degree = (i*2*PI)/(nrParticles)
 px(i) = xCenter+(15*cos(degree))
 py(i) = yCenter+(15*sin(degree))
 dpx(i) = ((px(i)-xCenter)/5)+ran(1)-0.5
 dpy(i) = ((py(i)-yCenter)/5)+ran(1)-0.5
next i

fadecol = 255
fadespeed = ran(7)+3
setrgb 1,255,255,255
fill circle xCenter,yCenter,10
bell
usecol = int(ran(5)+1)

port1_fireworks = 0
while (port1_fireworks<>4096)
 port1_fireworks = peek("port1")
 setrgb 1,0,0,0
 setrgb 2,0,0,30
 setrgb 3,0,0,30
 gtriangle 0,0 to 0,512 to 640,512
 setrgb 2,0,0,0
 gtriangle 0,0 to 640,0 to 640,512
 fadecol = fadecol-fadespeed
 if fadecol < 0 goto lblNewExplosion
 if (usecol = 1) setrgb 1,fadecol,0,0
 if (usecol = 2) setrgb 1,0,fadecol,0
 if (usecol = 3) setrgb 1,0,0,fadecol
 if (usecol = 4) setrgb 1,fadecol,fadecol,0
 if (usecol = 5) setrgb 1,fadecol,0,fadecol
 for i=1 to nrParticles
  px(i) = px(i) + dpx(i)
  py(i) = py(i) + dpy(i)  
  dpx(i) = dpx(i)*0.97
  dpy(i) = dpy(i)*0.97
  fill circle px(i),py(i),5
 next i
 for i=1 to nrParticles
 setrgb 1,fadecol+20,fadecol+20,fadecol+20
  fill circle px(i),py(i),3
 next i
 setdrawbuf 1 - draw
 setdispbuf draw
 draw = 1 - draw
wend

goto effectMenu
REM ################################






REM ---7: Fade out/in (Blocks)---
REM ################################
label lblFadeblocks

setdispbuf 0
setdrawbuf 0
clear window
 
rndRes = int(ran(260))+40
xRes = rndRes : yRes = rndRes
draw_xRes = 640/xRes
draw_yRes = 512/yRes
nrBlocks = xRes*yRes

dim b_drawOrder(nrBlocks)
for i=0 to nrBlocks
 b_drawOrder(i) = i
next i

setrgb 1,ran(255),ran(255),ran(255)
setrgb 2,ran(255),ran(255),ran(255)
setrgb 3,ran(255),ran(255),ran(255)
gtriangle 0,0 to 640,0 to 640,512
setrgb 2,ran(255),ran(255),ran(255)
gtriangle 0,0 to 0,512 to 640,512

for i=0 to nrBlocks
 rndPlace = ran(nrBlocks)
 temp = b_drawOrder(i)
 b_drawOrder(i) = b_drawOrder(rndPlace)
 b_drawOrder(rndPlace) = temp
next i  

rndBlue = ran(255)
for i = 0 to nrBlocks

 block = b_drawOrder(i)
 by = int(block/xRes)+1
 bx = block-(by*xRes)+xRes
 draw_y = (by-1)*draw_yRes
 draw_x = bx*draw_xRes
 setrgb 1,0,0,0
 fill rect draw_x,draw_y to draw_x+draw_xRes+1,draw_y+draw_yRes+1
next i

wait 1

goto effectMenu
REM ################################




REM ---8: Color show---
REM ################################
label lblColorshow

max_pix = 1000
dim pix_x(max_pix),pix_y(max_pix)
dim pix_dx(max_pix), pix_dy(max_pix)
dim pix_red(max_pix),pix_green(max_pix),pix_blue(max_pix)
dim pix_reddx(max_pix),pix_greendx(max_pix),pix_bluedx(max_pix)


viewz=200
viewzspeed = 10
restore objX
read nrVertex
read nrPolys
dim cosD(360), sinD(360)
dim px(nrVertex),py(nrVertex),pz(nrVertex)
dim screenX(nrVertex), screenY(nrVertex)
dim poly(nrPolys,4)
dim polyRed(nrPolys), polyGreen(nrPolys), polyBlue(nrPolys)
dim vertexZ(nrVertex)
dim visible(nrPolys)
dim sortz(nrPolys)
dim renderOrder(nrPolys)

for i=0 to 360
  cosD(i)=cos(i*pi/180)
  sinD(i)=sin(i*pi/180)
next i

for i=1 to nrVertex
  read px(i),py(i),pz(i)
next i

for i=1 to nrPolys
 for v=1 to 4
  read poly(i,v)
 next v
 read polyRed(i),polyGreen(i),polyBlue(i)
 visible(i)=0
next i



dim star_x(2000)
dim star_y(2000)
dim speed(2000)
dim shade(2000)
maxstars = 50
maxspeed = 10

REM ---Init stars---
for i=1 to maxstars step 1
 star_x(i) = ran(640)
 star_y(i) = ran(512)
 speed(i) = ran(maxspeed)-maxspeed/2
 shade(i) = ((speed(i)/maxspeed)*255)+100
 if shade(i) > 255 shade(i)=255
next i

rect_width = ran(100)+50
rect_height = ran(100)+50
rect_x = ran(640-rect_width)
rect_y = ran(512-rect_height)
rect_dx = 5
rect_dy = 5

dim rect_red(4),rect_green(4),rect_blue(4)
dim rect_reddx(4),rect_greendx(4),rect_bluedx(4)

REM ---Init rect color data---
for i= 1 to 4
 rect_red(i) = ran(255)
 rect_green(i) = ran(255)
 rect_blue(i) = ran(255)
 rect_reddx(i) = ran(6)-3
 rect_greendx(i) = ran(6)-3
 rect_bluedx(i) = ran(6)-3
next i


nr_pix = ran(10)+10
pix_rad = 6


REM --Init pix(els)---
for i=1 to nr_pix
 pix_x(i) = ran(rect_width-(pix_rad*2))+pix_rad
 pix_y(i) = ran(rect_height-(pix_rad*2))+pix_rad
 pix_dx(i) = ran(10)-5
 pix_dy(i) = ran(10)-5
 pix_red(i) = ran(100)+150
 pix_green(i) = ran(100)+150
 pix_blue(i) = ran(100)+150
 pix_reddx(i) = ran(6)-3
 pix_greendx(i) = ran(6)-3
 pix_bluedx(i) = ran(6)-3
next i



setdispbuf 0
setdrawbuf 0
clear window

port1_colorshow = 0
while (port1_colorshow<>4096)
 port1_colorshow = peek("port1")


bet = bet + 3
if bet > 360 bet=bet-360

gam = gam + 3
if gam > 360 gam=gam-360

alp = alp + 3
if alp > 360 alp=alp-360


viewz = viewz - viewzspeed
if viewz < 150 viewzspeed = -viewzspeed
if viewz > 500 viewzspeed = -viewzspeed


mx1 = sinD(gam)*sinD(bet)*sinD(alp)+cosD(gam)*cosD(alp)
my1 = cosD(bet)*sinD(alp)
mz1 = sinD(gam)*cosD(alp)-cosD(gam)*sinD(bet)*sinD(alp)

mx2 = sinD(gam)*sinD(bet)*cosD(alp)-cosD(gam)*sinD(alp)
my2 = cosD(bet)*cosD(alp)
mz2 = -cosD(gam)*sinD(bet)*cosD(alp)-sinD(gam)*sinD(alp)

mx3 = -sinD(gam)*cosD(bet)
my3 = sinD(bet)
mz3 = cosD(gam)*cosD(bet)



'Calculate 2d
for i=1 to nrVertex
 newx = px(i)*mx1 + py(i)*my1 + pz(i)*mz1
 newy = px(i)*mx2 + py(i)*my2 + pz(i)*mz2
 newz = px(i)*mx3 + py(i)*my3 + pz(i)*mz3

 newz = newz + viewz
 vertexZ(i)=newz
 screenX(i) = (320*newx/(newz-50))/(16/9)+320
 screenY(i) = (256*newy/(newz-50))+256
next i


'Backface Culling and CalcZ
nrVisible=0
for i=1 to nrPolys
 x1 = screenX(poly(i,1))
 y1 = screenY(poly(i,1))
 x2 = screenX(poly(i,2))
 y2 = screenY(poly(i,2))
 x3 = screenX(poly(i,3))
 y3 = screenY(poly(i,3))
 x4 = screenX(poly(i,4))
 y4 = screenY(poly(i,4))
 if (((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)) <= 0) then
  z1 = vertexZ(poly(i,1))
  z2 = vertexZ(poly(i,2))
  z3 = vertexZ(poly(i,3))
  z4 = vertexZ(poly(i,4))
  nrVisible=nrVisible+1
  REM Find Lowest z on polygon
  if (z1 <= z2 and z1 <= z3 and z1<=z4) zmin = z1
  if (z2 <= z1 and z2 <= z3 and z2<=z4) zmin = z2
  if (z3 <= z1 and z3 <= z2 and z3<=z4) zmin = z3
  if (z4 <= z1 and z4 <= z2 and z4<=z3) zmin = z4
  sortz(nrVisible) = zmin
  renderOrder(nrVisible)=i
 endif
next i

'Bubble sort to determine RenderOrder for polygons
done = 0
while (done=0)
 done=1    REM Will turn to 0 if swapped Z
 for p=1 to nrVisible-1
  if (sortz(p) < sortz(p+1)) then
   temp = sortz(p)
   sortz(p) = sortz(p+1)
   sortz(p+1) = temp
   REM Changing RenderOrder also
   tempr = renderOrder(p)
   renderOrder(p) = renderOrder(p+1)
   renderOrder(p+1) = tempr
   done = 0
  endif
 next p
wend



'Draw
for y=1 to nrVisible
 i=renderOrder(y)
 x1 = screenX(poly(i,1))
 y1 = screenY(poly(i,1))
 x2 = screenX(poly(i,2))
 y2 = screenY(poly(i,2))
 x3 = screenX(poly(i,3))
 y3 = screenY(poly(i,3))
 x4 = screenX(poly(i,4))
 y4 = screenY(poly(i,4))  
 REM setrgb 1,polyRed(i),polyGreen(i),polyBlue(i)
 REM setrgb 2,polyRed(i),polyGreen(i),polyBlue(i)
 setrgb 3,polyRed(i),polyGreen(i),polyBlue(i)
 setrgb 1,rect_red(1),rect_green(1),rect_blue(1)
 setrgb 2,rect_red(2),rect_green(2),rect_blue(2)
 REM setrgb 3,rect_red(3),rect_green(3),rect_blue(3)
 gtriangle x1,y1 to x2,y2 to x3,y3
 gtriangle x1,y1 to x4,y4 to x3,y3
next y





 for i = 1 to maxstars step 1
  star_x(i) = star_x(i) + speed(i)
  if star_x(i)>640 speed(i) = -speed(i)
  if star_x(i)<0 speed(i) = -speed(i)
  setrgb 1,ran(255),ran(255),ran(255)
  fill rect star_x(i)-2,star_y(i)-2,star_x(i)+2,star_y(i)+2
 next i

 rect_x = rect_x + rect_dx
 rect_y = rect_y + rect_dy
 if (rect_x < 0 or rect_x+rect_width > 640) rect_dx=-rect_dx
 if (rect_y < 0 or rect_y+rect_height > 512) rect_dy=-rect_dy


 for ri = 1 to 4
  rect_red(ri) = rect_red(ri)+rect_reddx(ri)
  rect_green(ri) = rect_green(ri)+rect_greendx(ri)
  rect_blue(ri) = rect_blue(ri)+rect_bluedx(ri)
  if (rect_red(ri) < 0 or rect_red(ri) > 255) rect_reddx(ri)=-rect_reddx(ri)
  if (rect_green(ri) < 0 or rect_green(ri) > 255) rect_greendx(ri)=-rect_greendx(ri)
  if (rect_blue(ri) < 0 or rect_blue(ri) > 255) rect_bluedx(ri)=-rect_bluedx(ri)
 next ri

 setrgb 1,rect_red(1),rect_green(1),rect_blue(1)
 setrgb 2,rect_red(2),rect_green(2),rect_blue(2)
 setrgb 3,rect_red(3),rect_green(3),rect_blue(3)
 gtriangle rect_x,rect_y to rect_x+rect_width,rect_y to rect_x+rect_width,rect_y+rect_height
 setrgb 2,rect_red(4),rect_green(4),rect_blue(4)
 gtriangle rect_x,rect_y to rect_x,rect_y+rect_height to rect_x+rect_width,rect_y+rect_height

 for i=1 to nr_pix
  pix_x(i)=pix_x(i) + pix_dx(i)
  pix_y(i)=pix_y(i) + pix_dy(i)
  if ((pix_x(i)-pix_rad) < 0 or (pix_x(i)+pix_rad) > rect_width) pix_dx(i)=-pix_dx(i)
  if ((pix_y(i)-pix_rad) < 0 or (pix_y(i)+pix_rad) > rect_height) pix_dy(i)=-pix_dy(i)
  
  setrgb 1,pix_red(i),pix_green(i),pix_blue(i)

  pix_red(i) = pix_red(i)+pix_reddx(i)
  pix_green(i) = pix_green(i)+pix_greendx(i)
  pix_blue(i) = pix_blue(i)+pix_bluedx(i)

  if (pix_red(i) < 0 or pix_red(i) > 255) pix_reddx(i)=-pix_reddx(i)
  if (pix_green(i) < 0 or pix_green(i) > 255) pix_greendx(i)=-pix_greendx(i)
  if (pix_blue(i) < 0 or pix_blue(i) > 255) pix_bluedx(i)=-pix_bluedx(i)


  fill circle rect_x+pix_x(i),rect_y+pix_y(i),pix_rad
  setrgb 1,255,255,255
  fill circle rect_x+pix_x(i),rect_y+pix_y(i),pix_rad*.5
 next i
 setdrawbuf 1 - draw
 setdispbuf draw
 draw = 1 - draw
 clear window
wend

goto effectMenu
REM ################################






REM ---9: Landscape Generator---
REM ################################
label lblLandscape

setdispbuf 0
setdrawbuf 0
draw = 0
setrgb 1,0,0,0
setrgb 0,0,0,0
clear window


REM ---Data for the program---
lWidth = ran(50)+60
lHeight = ran(50)+60
scaleX = ran(5)+2
scaleY = ran(3)+2
nrHotspots = ran(450)+100
originalHeight = ran(200)+100
XAngle = ran(110)-55
smoothing = ran(13)+5

dim l(lWidth,lHeight)
REM ---Prints landscape information---
setrgb 1,255,255,200
text 10,10, "Landscape data"
text 10,20, "-----------------------"
text 10,40, "Width: " + str$(lWidth)
text 10,60, "Height: " + str$(lHeight)
text 10,80, "ScaleX: " + str$(scaleX)
text 10,100, "ScaleY: " + str$(scaleY)
text 10,120, "Hotspots: " + str$(nrHotspots)
text 10,140, "Hotspot height: " + str$(originalHeight)
text 10,160, "XAngle: " + str$(XAngle)
text 10,180, "Smoothing: " + str$(smoothing)

setrgb 1,255,255,255
text 10,250, "Generating hotspots......."
REM ---Generate Hotspots---

for i=1 to nrHotspots
  x = ran(lWidth-8)+4
  y = ran(lHeight-8)+4
  l(x,y) = originalHeight
  procentDone = (i/nrHotspots)*100
next i 
setrgb 1,0,0,0
fill rect 10,230 to 500,270
setrgb 1,255,255,255
text 10,250, "Generating hotspots.......100% completed"



startDrawX = 320-((lWidth*scaleX)/2)-(XAngle*1.5)
startDrawY = 256-((lHeight*scaleY)/2)

procentDone = 0

setrgb 1,255,255,255
text 10,270, "Smoothing.......loading"

for i=1 to smoothing
 for y = 1 to lHeight-1
  for x = 1 to lWidth-1
   l(x,y) = (l(x+1,y)+l(x+1,y+1)+l(x,y+1)+l(x-1,y+1)+l(x-1,y)+l(x-1,y-1)+l(x,y-1)+l(x+1,y+1))*0.125
  next x
 next y
 procentDone = (i/smoothing)*100
 setrgb 1,0,0,0
 fill rect 0,255 to 550,290
 setrgb 1,255,255,255
 text 10,270, "Smoothing......." + str$(procentDone) + "% completed"
next i

setrgb 1,0,0,0
fill rect 0,255 to 550,290
setrgb 1,255,255,255
text 10,270, "Smoothing.......100% completed"

REM Let's Draw the landscape
setrgb 1,0,0,110
fill rect 0,0 to 640,512
incXAngle = XAngle/lHeight

for y = 1 to lHeight-1
 for x = 1 to lWidth-1
   x1 = startDrawX+x*scaleX+XAngle
   y1 = startDrawY+y*scaleY
   x2 = x1+scaleX
   y2 = y1+scaleY-(l(x,y)*3)
   if (l(x,y) >= 50) then
    setrgb 1,l(x,y)+50,l(x,y)+50,l(x,y)+50
    fill rect x1,y1 to x2,y2
   endif
   if (l(x,y) < 50 and l(x,y) > 40) then
    setrgb 1,l(x,y),l(x,y),l(x,y)
    fill rect x1,y1 to x2,y2
   endif

   if (l(x,y) <= 40 and l(x,y) > 6) then 
    setrgb 1,0,l(x,y)+30,0
    fill rect x1,y1 to x2,y2
   endif
   if (l(x,y) <= 6) then 
    setrgb 1,0,(l(x,y)*10),110
    fill rect x1,y1 to x2,y2
   endif
 next x
 XAngle=XAngle+incXAngle
next y

setrgb 1,255,255,255
text 1,500, "Press Triangle to quit..."


port1_landscape = 0
while (port1_landscape<>4096)
 port1_landscape = peek("port1")
wend
goto effectMenu
REM ################################









REM ---10: The PS2 Logo!
REM ################################
label lblps2logo

REM --------------------------------------------
REM A program that draws the PS2 Logo!!
REM Made by Mikael "Master Tonberry" Lagre, 2001
REM --------------------------------------------

restore ps2data
read nrLines
dim from_x(nrLines), from_y(nrLines)
dim to_x(nrLines), to_y(nrLines)

max_y = 0
max_x = 0

for i = 1 to nrLines
 read from_x(i),from_y(i),to_x(i),to_y(i)
 if (from_y(i) > max_y) max_y=from_y(i)
 if (to_y(i) > max_y) max_y=to_y(i)
 if (from_x(i) > max_x) max_x=from_x(i)
 if (to_x(i) > max_x) max_x=to_x(i)
next i

REM ---Color Values---
from_red = 64
from_green = 20
from_blue = 100
to_red = 8
to_green = 255
to_blue = 255
red_inc = (to_red-from_red)/max_y
green_inc = (to_green-from_green)/max_y
blue_inc = (to_blue-from_blue)/max_y
red = 0
green = 0
blue = 0


REM ---Draw---
inc_x = 0
inc_y = 0
scale_x = 1
scale_y = 1
startdraw_x = 320-((max_x)/2)-scale_x/2
startdraw_y = 256-((max_y)/2)-scale_y/2
red = from_red
green = from_green
blue = from_blue


setdispbuf 0
setdrawbuf 0
draw = 0
setrgb 1,0,0,0
setrgb 0,0,0,0
clear window



for i=1 to nrLines

 inc_y = sig(to_y(i)-from_y(i))
 if inc_y = 0 inc_y = 1

 for y = from_y(i) to to_y(i) step inc_y 
  red = from_red + y*red_inc
  green = from_green + y*green_inc
  blue = from_blue + y*blue_inc  
  setrgb 1,red,green,blue
  inc_x = sig(to_x(i)-from_x(i))
  if inc_x = 0 inc_x = 1

  for x = from_x(i) to to_x(i) step inc_x
   x1 = startdraw_x + x
   y1 = startdraw_y + y
   x2 = x1 + scale_x
   y2 = y1 + scale_y
   fill rect x1,y1 to x2,y2  
  next x
 next y
next i
port1_ps2logo = 0
while (port1_ps2logo<>4096)
 port1_ps2logo = peek("port1")
wend
goto effectMenu
REM ################################



REM Data for 'PS2' logo
label ps2data
data 12
data   0,  0,    80,  0
data  80,  1,    80, 21
data  80, 21,     0, 21
data   0, 22,     0, 42
data  81, 42,   121, 42 
data 121, 41,   121,  0
data 122,  0,   162,  0
data 172,  0,   252,  0
data 252,  1,   252, 21
data 252, 21,   172, 21
data 172, 22,   172, 42
data 172, 42,   252, 42










REM ---END OF EFFECTS---




REM ---POnG cHeAt--- :)
label qwerty
setdispbuf 0
setdrawbuf 0
open window 640,512
setrgb 0,255,255,255
clear window


setrgb 1,0,0,0
text 10,100, "Welcome to the pong cheat!!!!"
text 10,120, "This is a 2 player game so grab a friend and connect"
text 10,140, "your 2:econd controller to port2 right now!!!"
text 10,160, "First to a 5 wins!!"
text 10,180, "Why are U still sitting there!!!!! Go!!!!"
text 10,220, "X = startGaMe !!!"
repeat
  data1 = peek("port1")
until (data1=16384)


label GAME

data1=0
data2=0

score1 = 0
score2 = 0

xsize = 10
ysize = 50

x1=20
y1=200
x2=630-xsize-10
y2=200

'pong brickornas fart
speed = 10   


ballx = 320
bally = ran(492)+10
repeat
   dx = ran(10)-5
until (dx <-2 or dx > 2)
repeat
   dy = ran(10)-5
until (dy <-2 or dy > 2)




'radien
bsize = 10




setrgb 1,255,255,100
curbuff = 0

while (data1<>1)

setdrawbuf curbuff
curbuff = 1 - curbuff
setdispbuf curbuff
clear window


data1=peek("port1")
data2=peek("port2")

'UP on controller 1
if (and(data1,16) > 0) then
   y1=y1-speed
   if (y1<10) y1=10
endif

'DOWN on controller 1
if (and(data1,64) > 0) then
   y1=y1+speed
   if (y1>(502-ysize)) y1=502-ysize
endif



'UP on controller 2
if (and(data2,16) > 0) then
   y2=y2-speed
   if (y2<10) y2=10
endif

'DOWN on controller 2
if (and(data2,64) > 0) then
   y2=y2+speed
   if (y2>(502-ysize)) y2=502-ysize
endif


ballx = ballx + dx
bally = bally + dy

if ((ballx-bsize <= x1+xsize) and (bally+bsize >= y1 and bally-bsize <= y1+ysize)) then
   dx = dx - .5
   dx = -dx
   ballx = x1+xsize+bsize
   bell
elsif ((ballx+bsize >= x2) and (bally+bsize >= y2 and bally-bsize <= y2+ysize)) then
   dx = dx + .5
   dx = -dx
   ballx = x2-bsize
   bell
endif

if (ballx + bsize > 630) then
   score1 = score1 + 1
   ballx = 320
   bally = ran(492)+10
   repeat
      dx = ran(10)-5
   until (dx <-2 or dx > 2)
   repeat
      dy = ran(10)-5
   until (dy <-2 or dy > 2)
   bell
endif
if (ballx - bsize < 10) then
   score2 = score2 + 1
   ballx = 320
   bally = ran(492)+10
   repeat
      dx = ran(10)-5
   until (dx <-2 or dx > 2)
   repeat
      dy = ran(10)-5
   until (dy <-2 or dy > 2)
   bell
endif

if (bally + bsize > 502) then
   bally = 502 - bsize
   dy = -dy
   bell
endif
if (bally - bsize < 0) then
   bally = 10 + bsize
   dy = -dy
   bell
endif


setrgb 1,0,50,0
fill rectangle 10,10 to 630,502

setrgb 1,0,0,255
setrgb 2,0,0,150
setrgb 3,0,0,255
gtriangle x1,y1 to x1,y1+ysize to x1+xsize,y1+ysize
setrgb 2,200,200,200
gtriangle x1,y1 to x1+xsize,y1 to x1+xsize,y1+ysize


setrgb 1,255,0,0
setrgb 2,150,0,0
setrgb 3,255,0,0
gtriangle x2+xsize,y2 to x2+xsize,y2+ysize to x2,y2+ysize
setrgb 2,200,200,200
gtriangle x2+xsize,y2 to x2,y2 to x2,y2+ysize



setrgb 1,200,55,0
fill rectangle 318,10 to 322,502

setrgb 1,0,255,0
fill circle ballx,bally,bsize*0.75
setrgb 1,255,255,255
circle ballx,bally,bsize


setrgb 1,255,255,255
text 300,30, str$(score1)
text 327,30, str$(score2)
if (score1=5 or score2=5) goto PLAYAGAIN
wend


label PLAYAGAIN
if (score1=5) then
setrgb 1,0,100,255
text 20,200,"Player 1 won !"
elsif (score2=5) then
setrgb 1,255,100,0
text 340,200,"Player 2 won !"
endif
if (score1=5 or score2=5) then
   setrgb 1,255,255,255
   text 100,220,"Would you like to play again? X=yes, SELECT=no"
endif

setdrawbuf curbuff
curbuff = 1 - curbuff
setdispbuf curbuff
clear window

repeat
   data1 = peek("port1")
   data2 = peek("port2")
   if (data1=16384 or data2=16384) goto GAME
   if (data1=1 or data2=1) goto QUIT
until (1>2)

label QUIT
setdispbuf 0
setdrawbuf 0
setrgb 0,0,0,0
clear window
setrgb 1,255,255,255
text 140,140, "Do not Underestimate the Power of Master Tonberry"
repeat
until (1>2)
end





'########################
label objX

data 24,18
data  20, 40,-20
data  60, 40,-20
data -20,-40,-20
data -60,-40,-20
data   0,-20,-20
data  20,  0,-20
data  60,-40,-20
data  20,-40,-20
data -60, 40,-20
data -20, 40,-20
data   0, 20,-20
data -20,  0,-20
data  20, 40, 20
data  60, 40, 20
data -20,-40, 20
data -60,-40, 20
data   0,-20, 20
data  20,  0, 20
data  60,-40, 20
data  20,-40, 20
data -60, 40, 20
data -20, 40, 20
data   0, 20, 20
data -20,  0, 20

'Connector
data  1, 2, 3, 4,   255,  0,  0
data  5, 6, 7, 8,   255,  0,  0
data  9,10,11,12,   255,  0,  0
data 16,15,14,13,   255,  0,  0
data 20,19,18,17,   255,  0,  0
data 24,23,22,21,   255,  0,  0
data  4, 3,15,16,     0,100,255
data  3, 5,17,15,     0,100,255
data  5, 8,20,17,     0,100,255
data  8, 7,19,20,     0,100,255
data  6,18,19, 7,     0, 55,  0
data  2,14,18, 6,     0, 55,  0
data  1,13,14, 2,     0,100,255
data 11,23,13, 1,     0,100,255
data 10,22,23,11,     0,100,255
data  9,21,22,10,     0,100,255
data  9,12,24,21,     0, 55,  0
data  24,12,4,16,     0, 55,  0
