Source

BASIC-RoBots / res / lib / move

Full commit
REM BASIC-RoBots
REM Standard Library
REM * Pierre Surply

REM move

GOTO end_move

   LABEL set_orient
     GOTO start_set_orient
       LABEL set_orient_left
         CALL rotleft
       GOTO end_set_orient
       LABEL set_orient_back
         CALL rotleft
         CALL rotleft
       GOTO end_set_orient
       LABEL set_orient_right
         CALL rotright
       GOTO end_set_orient
     LABEL start_set_orient
        PUSH C
        LET C (OR-A) % 4
        IF C == 1 THEN set_orient_right
        IF C == 2 THEN set_orient_back
        IF C == 3 THEN set_orient_left
     LABEL end_set_orient
        POP C
   RETURN

   LABEL move_to
      GOTO start_move_to
         LABEL error_move_to
            PRINT Cannot find path
      GOTO end_move_to
      LABEL start_move_to
      PUSH C
      CALL findpath C
      IF C == 0 THEN error_move_to
      POP A
      WHILE A != 5
         GOTOSUB set_orient
         CALL forward
         POP A
      ENDWHILE
      LABEL end_move_to
      POP C
   RETURN

LABEL end_move