' open file & get screen address
OPEN "o",#1,"oval.dat"
screen=XBIOS(3)
' set up sprite dimensions
LET xlen=32
LET ylen=32
' set up max and min values allowed for x and y
LET xmin=0
LET ymin=0
LET xmax=320-xlen
LET ymax=200-ylen
' set up centre co-ords
centrex=xmax/2
centrey=ymax/2
'
' now set up centre points & amount of increase
LET increase=0.05
LET a=150
LET b=0
' set up variable to keep track of start
start=0
' do loop to calculate points
REPEAT
  LET x=a*COS(ang)
  LET y=b*SIN(ang)
  LET x=x+centrex
  LET y=y+centrey
  GOSUB check_vals
  GOSUB plot_em
  IF start=0
    sx=INT(x)
    sy=INT(y)
    start=1
  ENDIF
  LET a=a+increase
  LET b=b+increase
  ang=ang+0.05
UNTIL INKEY$<>""
x=INT(x)
y=INT(y)
REPEAT
  IF x<sx
    x=x+1
  ENDIF
  IF x>sx
    x=x-1
  ENDIF
  IF y<sy
    y=y+1
  ENDIF
  IF y>sy
    y=y-1
  ENDIF
  GOSUB plot_em
UNTIL x=sx AND y=sy
CLOSE #1
END
'
'
'
PROCEDURE check_vals
  ' check x and y values to see if they exceed max/min
  LET back$="n"
  IF x<xmin
    LET x=xmin
    LET back$="y"
  ENDIF
  IF x>xmax
    LET x=xmax
    LET back$="y"
  ENDIF
  IF y<ymin
    LET y=ymin
    LET back$="y"
  ENDIF
  IF y>ymax
    LET y=ymax
    LET back$="y"
  ENDIF
  ' if we need to go backwards, alter the increase here!
  IF back$="y"
    increase=-increase
  ENDIF
RETURN
'
'
'
PROCEDURE plot_em
  ' save co-ords to disk...
  LET x_hi=INT(x/256)
  LET x_lo=INT(x)-(x_hi*256)
  POKE screen,x_hi
  BPUT #1,screen,1
  POKE screen,x_lo
  BPUT #1,screen,1
  POKE screen,y
  BPUT #1,screen,1
  PLOT x,y
RETURN
