' Entry300
' Coded by TrickyKeyboard,
' trickykeyboard@moscowmail.com!

' Some basic stuff..

  open window 640, 512

  dim block(9, 7)

  message$ = "                                Hey, where's my coke? Thanks. Oh, welcome to Entry300, my entry for YaBasic 300 line demo competion! I (TrickyKeyboard) have done this, in case you didn't know it already.. I hope you like it! Well, greetings to Doctor, Xalthorn, ShockWave and all other m8s from internet! And greetings to family too! Hit x button to quit! Bye!                                "

  length = len(message$)

' Somekind of intro..

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

    setrgb 0, 31, 31, 31

    for what = 0 to 31
      setrgb 1, 0, what * 8, 0
      text 320, what + 128, "TrickyKeyboard presents", "cc"
    next

    setrgb 1, 255, 255, 255
    text 320, 160, "TrickyKeyboard presents", "cc"

    setrgb 1, 255, 0, 255
    text 320, 192, "Entry300", "cc"

    setrgb 1, 0, 255, 0
    text 320, 320, "But, do you want to see it?", "cc"
    text 320, 384, "Select = no - Start = yes", "cc"

    command = peek("port1")

    if (command = 1) then
      end
    elseif (command = 8) then
      start = 1
    endif
  until (start = 1)

' Starting this loop and setting double buffer things..

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

' Graphics!

    for what = 0 to 31
      x_slower = x_slower - 1

      if (x_slower < 0) then
        if (the_x = -1536) then
          the_x_direction = 1
        elseif (the_x = 1536) then
          the_x_direction = 0
        endif

        if (the_x_direction = 0) then
          the_x = the_x - 1
        elseif (the_x_direction = 1) then
          the_x = the_x + 1
        endif

        if (the_x = 0) then
          x_slower = 3072
        endif
      endif

      mm = mm + 2
      x = the_x + 639 * sin(mm) + 319
      y = 511 * cos(mm) + 255

      if (the_x = 0) then
        setrgb 0, 0, 0, 64
        setrgb 1, 0, 0, 255
      else
        setrgb 0, 63, 0, 0
        setrgb 1, 255, 0, 0
      endif

      line 319, 255 to x, y
    next

    block_slower = block_slower - 1

    for y = 0 to 7
      for x = 0 to 9
        if (block_slower < 0) then
          block(x, y) = int(ran(2))
        endif

        if (block(x, y) = 1) then
          if (the_x = 0) then
            setrgb 1, 0, 0, 255
          else
            setrgb 1, 255, 0, 0
          endif

          rectangle x * 64, y * 64 to x * 64 + 64, y * 64 + 64
        endif
      next
    next

    if (block_slower < 0) then
      block_slower = 16
    endif

' Text stuff.. I'm very proud about that scrolling text..
' Also big thanks to Rafryer for that fps code!

    text_x = text_x + 0.2

    if (text_x > length - 32) then
      text_x = 0
    endif

    text_to_show$ = mid$(message$, text_x, 32)

    setrgb 1, 255, 255, 255
    text 320, 32, text_to_show$, "cc"

    setrgb 1, 0, 0, 0
    text 318, 256, "T   R   I   C   K   Y   K   E   Y   B   O   A   R  D", "cc"
    setrgb 1, 127, 127, 127
    text 322, 256, "T   R   I   C   K   Y   K   E   Y   B   O   A   R  D", "cc"

    lsec$ = sec$
    sec$ = right$(time$, 1)

    if (lsec$ <> sec$) then
      rate$ = str$(rate)
    endif

    if (lsec$ <> sec$) then
      rate = 0
    endif

    rate = rate + 1

    setrgb 1, 255, 255, 255
    text 320, 480, "Hmmm.. " + rate$ + " frame(s) per second!", "cc"

' And then controller reading..

    command = peek("port1")

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

  end

' And that's the end of that demo! :)



