100 '==================================
120 '= Robotica com MSX - I           =
130 '==================================
140 '= Marco A. Marques de Souza      =
141 '= Maio de 1990                   =
142 '==================================
143 '= Alterado por Marcio Soares     =
144 '= Agosto de 1991                 =
145 '==================================
160 CLEAR500,&HBFFF:KEYOFF: CLS
170 FORX=0TO7:POKE&HC000+X,10:NEXTX
180 POKE &HC008,0 : POKE &HC009,0
190 G=0:G1=0:G2=0
200 'Identifica‡±o dos movimentos
210 ID$(1)="Direita"
220 ID$(2)="Esquerda"
230 ID$(3)="Baixo"
240 ID$(4)="Cima"
250 ID$(5)="Sobe Bra‡o"
260 ID$(6)="Desce Bra‡o"
270 ID$(7)="Vago"
280 ID$(8)="Vago"
290 PRINTSPC(5);"==================="
300 PRINTSPC(5);"= R O B O T I C A ="
310 PRINTSPC(5);"= com M S X - I   ="
320 PRINTSPC(5);"==================="
330 PRINT:PRINT
340 PRINT " P = Ajusta passos"
350 PRINT " M = Inicia memorizacao"
360 PRINT " F = Finaliza memoriza‡±o"
370 PRINT " R = Repete memoriza‡±o"
380 PRINT " L = Limpa memoriza‡±o"
390 PRINT " N = Mov p/ Nro de passos"
400 PRINT " E = Encerra"
410 LOCATE 3,20
420 PRINT "Setas/Joystick   Movimentos"
430 PRINT "   ESC  Cancela movimentos"
440 F=0
450 IF STRIG(0) THEN F=4
460 IF STICK(0)=3 THEN M=0+F:GOSUB590:GOTO440
470 IF STICK(0)=7 THEN M=1+F:GOSUB590:GOTO440
480 IF STICK(0)=5 THEN M=2+F:GOSUB590:GOTO440
490 IF STICK(0)=1 THEN M=3+F:GOSUB590:GOTO440
500 A$=INKEY$:IFA$=""THEN440
510 IF A$="P" OR A$="p" THEN GOSUB750:GOTO440
520 IF A$="M" OR A$="m" THEN GOSUB1120:GOTO440
530 IF A$="F" OR A$="f" THEN GOSUB1190:GOTO440
540 IF A$="R" OR A$="r" THEN GOSUB880:GOTO440
550 IF A$="L" OR A$="l" THEN GOSUB1260:GOTO440
560 IF A$="N" OR A$="n" THEN GOSUB1380:GOTO440
570 IF A$="E" OR A$="e" THEN CLS:STOP
580 GOTO 440
590 '================
600 '= Aciona motor =
610 '================
620 IF G=0 THEN 680
630 POKE (&HC010+G2),M
640 G2=G2+1
650 IF G2=2048 THEN G2=0: BEEP:BEEP
660 POKE &HC008,INT(G2/256)
670 POKE &HC009,G2-(INT(G2/256)*256)
680 P=PEEK(&HC000+M):N=2^M
690 GOSUB 1330
700 PRINT "Nro=";G2;"Mov=";ID$(M+1);
710 PRINT " Passo=";P;
720 OUT &H91,N
730 FORX=0TOP:NEXTX:OUT&H91,0
740 RETURN
750 '=================
760 '= Altera passos =
770 '=================
780 FOR X = 0 TO 7
790 P1=PEEK(&HC000+X)
800 GOSUB 1330
810 PRINT"Passo ";ID$(X+1);" = ";P1;
820 LOCATE 30,15: INPUT P1
830 IF P1>255 THEN 800
840 POKE &HC000+X,P1
850 NEXT X
860 GOSUB 1330
870 RETURN
880 '====================
890 '= Repete movimento =
900 '====================
910 GOSUB 1330
920 PRINT"Pausa ente passos <";W;">";
930 INPUT W
940 G1=PEEK(&HC009)+(PEEK(&HC008)*256)
950 GOSUB 1330
960 PRINT"Repeti‡±o iniciada"
970 FOR G2=0 TO (G1-1)
980 M=PEEK(&HC010+G2)
990 GOSUB590:FORX=0TOW:NEXTX
1000 A$=INKEY$:IF A$="" THEN 1080
1010 IF ASC(A$)=&H1B THEN G2=G1-1: GOTO 1080
1020 GOSUB 1330
1030 PRINT "Repeti‡±o paralisada"
1040 A$=INKEY$:IFA$=""THEN1040
1050 IF ASC(A$)=&H1B THEN G2=G1-1: GOTO 1080
1060 GOSUB 1330
1070 PRINT"Repeti‡±o reiniciada"
1080 NEXTG2:G2=0
1090 GOSUB 1330
1100 PRINT"Repeti‡±o Encerrada"
1110 RETURN
1120 '===============
1130 '= Memoriza‡±o =
1140 '===============
1150 GOSUB 1330
1160 PRINT"Memoriza‡±o iniciada"
1170 G=1:G2=0
1180 RETURN
1190 '======================
1200 '= Fim de memoriza‡±o =
1210 '======================
1220 GOSUB 1330
1230 PRINT"Memoriza‡±o encerrada"
1240 G=0
1250 RETURN
1260 '=====================
1270 '= Limpa memoriza‡±o =
1280 '=====================
1290 GOSUB 1330
1300 PRINT"Memoriza‡±o reinicializada"
1310 POKE &HC008,0:POKE &HC009,0
1320 RETURN
1330 '========================
1340 '= Limpa area mensagens =
1350 '========================
1360 LOCATE 1,15:PRINT SPC(40)
1370 LOCATE 1,15: RETURN
1380 '=========================
1390 '= Mov por nro de passos =
1400 '=========================
1410 GOSUB 1330
1420 PRINT "Digite movimento"
1430 F=0
1440 IF STRIG(0) THEN F=4
1450 IF STICK(0)=3 THEN M=0+F:GOTO1520
1460 IF STICK(0)=7 THEN M=1+F:GOTO1520
1470 IF STICK(0)=5 THEN M=2+F:GOTO1520
1480 IF STICK(0)=1 THEN M=3+F:GOTO1520
1490 A$=INKEY$: IF A$="" THEN 1430
1500 IF ASC(A$)=&H1B THEN 1710
1510 GOTO 1430
1520 GOSUB 1330
1530 PRINT "Mov = ";ID$(M+1);
1540 PRINT "Confirma ? (Return)"
1550 A$=INKEY$: IF A$="" THEN 1550
1560 IF ASC(A$)=&H1B THEN 1380
1570 IF ASC(A$)=&HD THEN 1590
1580 GOTO 1550
1590 GOSUB 1330
1600 PRINT"Digite numero de passos";
1610 INPUT NP
1620 GOSUB 1330
1630 PRINT"Pausa entre passos <";W;">";
1640 INPUT W
1650 FOR Y= 1 TO NP
1660 GOSUB 590:FOR X=0 TO W: NEXT X
1670 A$=INKEY$: IF A$="" THEN 1690
1680 IF ASC(A$)=&H1B THEN Y=NP
1690 NEXT Y
1700 GOTO 1380
1710 GOSUB 1330: G2=0
1720 RETURN