open window 640,512
curbuf=0
x=320:y=256
setrgb 1,255,255,255
setrgb 2,255,255,255
setrgb 3,0,0,0

repeat
 setdrawbuf curbuf
 curbuf=1-curbuf
 setdispbuf curbuf
 clear window

 gtriangle 0,0 to 0,512 to x,y
 gtriangle 0,0 to 640,0 to x,y
 gtriangle 640,0 to 640,512 to x,y
 gtriangle 0,512 to 640,512 to x,y

 joypad=peek("port1")
 if and(joypad,32)>0 then x=x+1 fi
 if and(joypad,128)>0 then x=x-1 fi
 if and(joypad,16)>0 then y=y-1 fi
 if and(joypad,64)>0 then y=y+1 fi
until (joypad=16384)
