REM ***       T.V. Tennis By Fryer       ***
REM *** Thanks to Shockwave for the .xpo ***
REM
REM sound removed because its too slow!!!
REM
REM move the bat as it hits the ball to change
REM the angle the ball is moving

dim n(18,5),s(130,2)
for i=1 to 100
    s(i,1)=ran(640)
    s(i,2)=ran(500)
next i
for n=0 to 16
    for i=1 to 5
        read n(n,i)
    next i
next n
open window 640,512
y1=210:y2=210:x=315:y=245:my=1:mx=2:ss=0:p1=0:p2=0:w=100
setrgb 1,180,180,180
setrgb 0,18,18,18
label loop
    setdrawbuf ss
    clear window
    setrgb 1,90,90,90
    for l=0 to 8
        for i=1 to 5
            for j=0 to 2
                if w=100 and l<7 then
                   xp=215+40*l-10*j
                   yp=200+10*i
                   t=l+10
                end if
                if l>6 then
                    yp=40+i*10
                    xp=300-10*j+70*(l-7)
                    if l=7 t=p1
                    if l=8 t=p2
                end if
                b=2^j
                if and(n(t,i),b)=b and t<18 then
                   fill rectangle xp-10,yp-10 to xp,yp
                end if
                t=18
            next j
        next i
    next l
    if w<90 fill rectangle 315,30 to 325,470
    fill rectangle 40,20 to 600,30
    fill rectangle 40,470 to 600,480
    setrgb 1,180,180,180
    fill rectangle 579,y2 to 589,(y2+80)
    fill rectangle 51,y1 to 61,(y1+80)
    if w>20 and w<51 fill rectangle x,y to x+10,y+10
    setdispbuf ss
    ss=1-ss
    oy1=y1:oy2=y2
    j=peek("port1")
    y1=y1-and(j,16)/4+and(j,64)/16
    j=peek("port2")
    y2=y2-and(j,16)/4+and(j,64)/16
    if y1<30 or y1>390 y1=oy1
    if y2<30 or y2>390 y2=oy2
    if w=50 then
        x=x+mx:y=y+my
    end if
    if w<50 w=w+1
    if y<30 then 
        my=-my
        y=30-(y-30)
    end if
    if y>460 then 
        my=-my
        y=460-(y-460)
    end if
    if x=61 and y>y1 and y<(y1+70) then
        mx=-mx
        my=my+(oy1-y1)
    end if
    if x=569 and y>y2 and y<(y2+70) then
        mx=-mx
        my=my+(oy2-y2)
    end if
    if x<-20 then
        p2=p2+1:x=315:y=245:my=-my/abs(my)
        if p2<9 w=1
    end if
    if x>640 then
        p1=p1+1:x=315:y=245:my=-my/abs(my)
        if p1<9 w=1        
    end if
    if (p1=9 or p2=9) and w<100 w=w+1
    if w=100 then
        j=peek("port1")
        if and(j,16384)=16384 then
            w=1:p1=0:p2=0:mx=2
        end if
        j=peek("port2")
        if and(j,16384)=16384 then
            w=1:p1=0:p2=0:mx=-2
        end if
    end if
goto loop
data 7,5,5,5,7,2,2,2,2,2,7,1,7,4,7,7,1,7,1,7
data 5,5,7,1,1,7,4,7,1,7,7,4,7,5,7,7,1,1,1,1
data 7,5,7,5,7,7,5,7,1,7,7,5,7,4,4,7,5,7,6,5
data 7,4,6,4,7,7,4,7,1,7,7,4,7,1,7,0,0,0,0,0,5,5,2,5,5








