'By Fryer - Please Upload.
'stesil demo - R.Fryer

gosub setup
label loop
gosub db
gosub control
gosub rotate
gosub draw
goto loop
label draw
for i=1 to mf
p1=p(i,1)
p2=p(i,2)
p3=p(i,3)
q1=p1
q2=p2
q3=p3
if (sx(p2)-sx(p1))*(sy(p3)-sy(p1))-(sx(p3)-sx(p1))*(sy(p2)-sy(p1))>0 goto nopoly
ix(1)=int(sx(p1)/8)
iy(1)=int(sy(p1)/8)
ix(2)=int(sx(p2)/8)
iy(2)=int(sy(p2)/8)
ix(3)=int(sx(p3)/8)
iy(3)=int(sy(p3)/8)
p1=1
if iy(2)<iy(1) p1=2
if iy(3)<iy(p1) p1=3
p3=1
if iy(2)>=iy(1) p3=2
if iy(3)>=iy(p3) p3=3
p2=6-p1-p3
y1=iy(p1)
y2=iy(p2)
y3=iy(p3)
dy1=y3-y1
dx1=(ix(p3)-ix(p1))/dy1
dy2=y2-y1
dx2=(ix(p2)-ix(p1))/dy2
tx1=ix(p1)
tx2=tx1
t=tex(i)
ox=ox(t)+550
oy=oy(t)+550
m=sig(dx2-dx1)
if m=0 goto nopoly2
for y=y1 to y2
xs=int(tx1):xe=int(tx2)
for x=xs to xe step m
tx=mod(x+ox,100)
ty=mod(y+oy,100)
setrgb 1,r(tx,ty,t),g(tx,ty,t),b(tx,ty,t)
fill rect x*8,y*8 to x*8+8,y*8+8
next x
tx1=tx1+dx1
tx2=tx2+dx2
next y
label nopoly2
dy2=y3-y2
dx2=(ix(p3)-ix(p2))/dy2
tx1=ix(p3)
tx2=tx1
m=sig(dx1-dx2)
if m=0 goto nopoly

for y=y3 to y2 step-1
xs=int(tx1):xe=int(tx2)
for x=xs to xe step m
tx=mod(x+ox,100)
ty=mod(y+oy,100)
setrgb 1,r(tx,ty,t),g(tx,ty,t),b(tx,ty,t)
fill rect x*8,y*8 to x*8+8,y*8+8
next x
tx1=tx1-dx1
tx2=tx2-dx2
next y
label nopoly
next i
return
label control
a=mod(a+3,360)
b=mod(b+2,360)
c=mod(c+1,360)
ox(1)=20*sn(mod(a*4,360))
oy(1)=0
ox(2)=20*sn(mod(b*4,360))
oy(2)=10*cs(mod(b*2,360))
ox(3)=0
oy(3)=a/2
ox(4)=10*cs(a)
oy(4)=10*sn(a)
ox(5)=b/2
oy(5)=b/2
return
label setup
open window 640,512
window origin "CC"
dim sn(360),cs(360)
for i=0 to 360
cs(i)=cos(i/180*pi)
sn(i)=sin(i/180*pi)
next i
read mp,mf
dim x(mp),y(mp),z(mp),p(mf,3),tex(mf)
dim sx(mp),sy(mp)
for i=1 to mp
read x(i),y(i),z(i)
next i
for i=1 to mf
read p(i,1),p(i,2),p(i,3),tex(i)
next i
dim r(100,100,6),g(100,100,6),b(100,100,6),ix(3),iy(3)
dim ox(6),oy(6)
rm=50+ran(150)
gm=50+ran(150)
bm=50+ran(150)
for y=0 to 100
for x=0 to 100
r(x,y,1)=rm+ran(100)-50
g(x,y,1)=gm+ran(100)-50
b(x,y,1)=bm+ran(100)-50

r(x,y,2)=100+100*sn(mod(y*18,360))*cs(mod(x*9,360))
g(x,y,2)=0
b(x,y,2)=150

g(x,y,3)=255

b(x,y,4)=255

r(x,y,5)=255

a=1+int(ran(20))
if a<7 then
r(x,y,a)=ran(255)
g(x,y,a)=ran(255)
b(x,y,a)=ran(255)
fi
next x
next y
a=0
b=0
c=0
return
label db
setdispbuf db
db=1-db
setdrawbuf db
clear window
return
label rotate
csa=cs(a):sna=sn(a)
csb=cs(b):snb=sn(b)
csc=cs(c):snc=sn(c)
for i=1 to mp
tz=z(i)*csa+x(i)*sna
tx=x(i)*csa-z(i)*sna
rx=tx*csb+y(i)*snb
ty=y(i)*csb-tx*snb
rz=800+tz*csc-ty*snc
ry=ty*csc+tz*snc
z=600/rz
sx(i)=rx*z
sy(i)=ry*z
next i
return
data 8,12
data -100,-100,-100
data -100,-100,100
data 100,-100,100
data 100,-100,-100
data -100,100,-100
data -100,100,100
data 100,100,100
data 100,100,-100

data 1,2,6,1,6,5,1,1
data 2,3,7,2,7,6,2,2
data 3,4,8,3,8,7,3,3
data 4,1,5,4,5,8,4,4
data 5,6,7,5,7,8,5,5
data 1,4,3,6,3,2,1,6






