%%HP: T(3)A(D)F(.);
@ RETOTA, by Jeremy Smith
\<< 1 \-> x
  \<< LCD\-> PICT STO {# 0h # 0h } PVIEW 4 SF 1 SF
    WHILE x
    REPEAT 3
      IF FS?
      THEN 2
        IF FS?
        THEN "up" DROP PICT { # 0h # 0h } { # 82h # 0h } SUB
        PICT { # 0h # 1h } { # 82h # 3Fh } SUB
        PICT { # 0h # 0h } ROT REPL
        PICT { # 0h # 3Fh } ROT REPL
        ELSE "down" DROP
        PICT { # 0h # 3Fh } { # 82h # 3Fh } SUB
        PICT { # 0h # 0h } { # 82h # 3Eh } SUB
        PICT { # 0h # 1h } ROT REPL
        PICT { # 0h # 0h } ROT REPL
        END
      END 4
      IF FS?
      THEN 1
        IF FS?
        THEN "right" DROP
        PICT { # 82h # 0h } { # 82h # 3Fh } SUB
        PICT { # 0h # 0h } { # 81h # 3Fh } SUB
        PICT { # 1h # 0h } ROT REPL
        PICT { # 0h # 0h } ROT REPL
        ELSE "left" DROP
        PICT { # 0h # 0h } { # 0h # 3Fh } SUB
        PICT { # 1h # 0h } { # 82h # 3Fh } SUB
        PICT { # 0h # 0h } ROT REPL
        PICT { # 82h # 0h } ROT REPL
        END
      END
      IF KEY
      THEN
        CASE DUP 25 ==
          THEN DROP 3
            IF FS?
            THEN 2
              IF FS?
              THEN
              ELSE 3 CF
              END
            ELSE 3 SF 2 SF
            END
          END DUP 35 ==
          THEN DROP
            IF 3 FS?
            THEN
              IF 2 FS?
              THEN 3 CF
              END
            ELSE 3 SF 2 CF
            END
          END DUP 36 ==
          THEN DROP 4
            IF FS?
            THEN 1
              IF FS?
              THEN
              ELSE 4 CF
              END
            ELSE 4 SF 1 SF
            END
          END DUP 34 ==
          THEN DROP 4
            IF FS?
            THEN 1
              IF FS?
              THEN 4 CF
              END
            ELSE 4 SF 1 CF
            END
          END 'x' DECR DROP DROP
        END
      END
    END 1 2 3 4 CF CF CF CF
  \>>
\>>
