Commits

Pierre Surply committed 11b752e

Added standard library

  • Participants
  • Parent commits d6ba13a

Comments (0)

Files changed (5)

+REM BASIC-RoBots
+REM Standard Library
+REM * Pierre Surply
+
+REM com
+
+GOTO end_com
+
+   LABEL send_position
+      PUSH C
+      LET C A
+      CALL sendmsg
+      LET A (C << 4) | (X >> 4)
+      CALL sendmsg
+      LET A (C << 4) | (X & 0xF)
+      CALL sendmsg
+      LET A (C << 4) | (Y >> 4)
+      CALL sendmsg
+      LET A (C << 4) | (Y & 0xF)
+      CALL sendmsg
+      POP C
+   RETURN
+
+   LABEL listen_channel
+      PUSH B
+      CALL recvmsg B
+      WHILE B >> 4 != A
+         CALL recvmsg B
+      ENDWHILE
+      LET A B & 0xF
+      POP B
+   RETURN
+
+   LABEL recv_position
+      LET B A
+      PUSH B
+      PUSH C
+      PUSH D
+
+      GOTOSUB listen_channel
+      LET C A << 4
+      
+      LET A B
+      GOTOSUB listen_channel
+      LET C C | A
+
+      LET A B
+      GOTOSUB listen_channel
+      LET D A << 4
+      
+      LET A B
+      GOTOSUB listen_channel
+      LET D C | A
+
+      LET A C
+      LET B D
+
+      POP D
+      POP C
+      POP B
+   RETURN
+
+LABEL end_com

File res/lib/keyboard

+REM BASIC-RoBots
+REM Standard Library
+REM * Pierre Surply
+
+REM keyboard
+
+GOTO end_keyboard
+
+LABEL :KeyPressed
+   IF (K & 1)      THEN b1
+   IF (K >> 1 & 1) THEN b2
+   IF (K >> 2 & 1) THEN b3
+   IF (K >> 3 & 1) THEN b4
+   IF (K >> 4 & 1) THEN b5
+   IF (K >> 5 & 1) THEN b6
+   IF (K >> 6 & 1) THEN b7
+   IF (K >> 7 & 1) THEN b8
+
+LABEL end_keyboard

File res/lib/move

+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_left
+        IF C == 2 THEN set_orient_back
+        IF C == 3 THEN set_orient_right
+     LABEL end_set_orient
+        POP C
+   RETURN
+
+   LABEL move_to
+      GOTO start_move_to
+         LABEL error_move_to
+            PRINT Cannot find path to ( $A , $B )
+	    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
 ##    along with BASIC-RoBots.  If not, see <http://www.gnu.org/licenses/>.
 ## 
 ## Started on  Wed May  9 17:39:28 2012 Pierre Surply
-## Last update Sat Aug 11 20:41:18 2012 Pierre Surply
+## Last update Sun Aug 19 14:31:50 2012 Pierre Surply
 ##
 
 import os
+import shutil
 
 import display
 import events
         os.makedirs("saves/" + path)
         os.mkdir("saves/" + path + "/env")
         os.mkdir("saves/" + path + "/robots")
+        shutil.copytree("res/lib", "saves/" + path + "/lib", \
+                             ignore=shutil.ignore_patterns("*~"))
         wm = worldmap.WorldMap(path)
         wm.save()
         return wm

File src/robot/robot.py

 ##    along with BASIC-RoBots.  If not, see <http://www.gnu.org/licenses/>.
 ## 
 ## Started on  Sun Jul  1 15:34:10 2012 Pierre Surply
-## Last update Sat Aug 18 10:39:29 2012 Pierre Surply
+## Last update Sat Aug 18 13:58:11 2012 Pierre Surply
 ##
 
 import os