' Circles, by TrickyKeyboard:
' trickykeyboard@moscowmail.com!

  open window 640, 512

  color1 = 0
  color2 = 255

  repeat
    gosub double_buffer
    gosub circles
    gosub check_controls
  until (quit = 1)

  end

  label double_buffer
    setdrawbuf dw
    dw = 1 - dw
    setdispbuf dw
    clear window
  return

  label circles
    setrgb 1, 0, 255, 0
    text 32, 32, "Hello, welcome to my demo called Circles!"
    text 32, 48, "When do you want to quit, hold x button!"

    if color1 = 0 then
      color1_direction = 1
    elseif color1 = 255 then
      color1_direction = 0
    endif

    if color2 = 0 then
      color2_direction = 1
    elseif color2 = 255 then
      color2_direction = 0
    endif

    if color1_direction = 0 then
      color1 = color1 - 1
    elseif color1_direction = 1 then
      color1 = color1 + 1
    endif

    if color2_direction = 0 then
      color2 = color2 - 1
    elseif color2_direction = 1 then
      color2 = color2 + 1
    endif

    setrgb 1, color1, 0, color2

    for size = 0 to 7
      for what_circle = 0 to 15
        circle 319, 255, what_circle * size
      next
    next
  return

  label check_controls
    command = peek("port1")

    if (command = 16384) then
      quit = 1
    endif
  return


