
' add payout, and spread the new total over the chip values
' a() = array with current and new numbers of chips
' ds  = payout to be added to the total value
' function returns the new total value
'
def chips(a(),ds)
if not v(0) then
  v(0)=1 ! v(1)=5 ! v(2)=10 ! v(3)=25 ! v(4)=100
  end if
s=ds ! for i=0 to 4 ! s+=a(i)*v(i) ! next i ! sum=s
for i=0 to 4
  nc=min(5,floor(s/v(i))) ! a(i)=nc ! s-=nc*v(i) ! next i
for i=4 to 0 step -1
  nc=floor(s/v(i)) ! a(i)+=nc ! s-=nc*v(i)
  next i
return sum
end def

' fill a ring between an inner and outer radius
' xc,yc = pixel coordinates of the centre
' ri = inner radius,  ru = outer radius
' da = stepsize in degrees
'
def fill_ring(xc,yc,ri,ru,da)
for a=0 to 360-da step da
  x1=xc+ri*cos(a) ! y1=yc+ri*sin(a)
  x2=xc+ru*cos(a) ! y2=yc+ru*sin(a)
  x4=xc+ri*cos(a+da) ! y4=yc+ri*sin(a+da)
  x3=xc+ru*cos(a+da) ! y3=yc+ru*sin(a+da)
'fill color 1,0,0
  fill tri x1,y1,x2,y2,x4,y4
'fill color 0,0,1
  fill tri x2,y2,x3,y3,x4,y4
  next a
end def

def col(r)
if r=0 then fill color 1,1,1
if r=1 then fill color 1,0,0
if r=2 then fill color 0,1,0
if r=3 then fill color 0,0,1
if r=4 then fill color 1,1,0
if r=5 then fill color 0,1,1
fill color 0,0,0
return


