' TrickyKeyboard's DATA example
' Comments to:
' trickykeyboard@moscowmail.com!

  open window 640, 512

  dim block(2, 2)

  data_field = 2

  get_block = 1

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

    if (get_block = 1) then
      if (data_field = 1) then
        restore data1
      elseif (data_field = 2) then
        restore data2
      endif

      for y = 0 to 2
        for x = 0 to 2
          read block(x, y)
        next
      next

      get_block = 0
    endif

    for y = 0 to 2
      for x = 0 to 2
        if (block(x, y) = 1) then
          setrgb 1, 0, 0, 255
          fill rectangle x * 32, y * 32 to x * 32 + 32, y * 32 + 32
        endif
      next
    next

    setrgb 1, 0, 255, 0
    text 128, 32, "Hello, I hope you can learn DATA with this! Bye! :)"
    text 128, 64, "Hit x button to quit.."

    command = peek("port1")

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

  end

  label data1
  data 1, 1, 1
  data 1, 0, 1
  data 1, 1, 1

  label data2
  data 1, 0, 1
  data 1, 0, 1
  data 1, 0, 1
 
