'zerol bas' - ZX Spectrum --------------------------- Variables r0 used to pass routine number a1, a2, a3 used for input parameters o1, o2, o3 used for output parameters a8, b8, c8, k8, n8 used as scratch variables 9000 REM define subroutines 9002 RESTORE 9050 9004 READ init, border, ornge, call, move, fd, bk, lt, rt, lfd, rfd, lbk, rbk, continue, setscal, setspd, padj, setpen, pu, pd, pu1, pd1, setspp, setleds, sethorn, fuzz, setsens, sethole, setline, setbump 9006 READ peek, error, stepos, scale, spd, spp, leds, horn, sensor, sensp, hole, line, bump 9008 REM define variables 9010 READ usrcall, routine, argl, arg2, arg3, err, mask, inv, off, on 9022 REM define adjust 9024 READ adjust 9026 REM variables for adjust 9028 READ zdstart,disfac,rotfac 9050 DATA 9100, 9102, 9104, 9106, 9108, 9110, 9112, 9114, 9116, 9118, 9120, 9122, 9124, 9126, 9128, 9130, 9132, 9136, 9138, 9140, 9142, 9144, 9146, 9148, 9150, 9160, 9152, 9154, 9156, 9158 9052 DATA 9180, 9182, 9184, 9186, 9188, 9190, 9192, 9194, 9196, 9198, 9200, 9202, 9204 9054 DATA 64966, 64981, 64982, 64983, 64984, 64976, 7, 0, 0, 1 9056 DATA 9212, 64958, 64978, 64977 9070 REM go check for additional subroutines 9080 GO SUB 9300 9090 REM fall through to INIT 9099 REM commands 9100 LET mask=PEEK 64980: POKE routine,0: RANDOMIZE USR usrcall: RETURN 9102 IF al>7 THEN GO TO ornge 9103 POKE 23750,al: RETURN 9104 PRINT "OUT OF RANGE": STOP 9106 POKE routine,rO: POKE argl,al: RANDOMIZE USR usrcall: RETURN 9108 LET a2=INT (al/256): LET a1=a1-a2*256: POKE arg2,a2: GO TO call 9110 LET r0=l: GO TO move 9112 LET r0=2: GO TO move 9114 LET r0=3: GO TO move 9116 LET r0=4: GO TO move 9118 LET r0=5: GO TO move 9120 LET r0=6: GO TO move 9122 LET r0=7: GO TO move 9124 LET r0=8: GO TO move 9126 LET r0=22: LET al=0: GO TO call 9128 LET r0=18: GO TO call 9130 LET r0=16: GO TO call 9132 LET r0 = 9: LET al=0 9133 GO SUB call: PAUSE 10: IF INKEY$="" THEN GO TO 9133 9134 RETURN 9136 PRINT "PRESS ANY KEY WHEN PEN AT TOP": GO TO padj 9138 LET r0=12: LET al=0: GO TO call 9140 LET r0=13: LET al=0: GO TO call 9142 LET r0=10: LET al=0: GO TO call 9144 LET r0=ll: LET al=0: GO TO call 9146 LET r0=17: GO TO call 9148 LET r0=14: GO TO call 9150 LET r0=15: GO TO call 9152 POKE arg3,inv: POKE arg2,a2: LET rO=18: GO SUB call: GO SUB error: IF ol=3 THEN GO TO ornge 9153 RETURN 9154 LET a1=0: GO TO setsens 9156 LET al=1: IF a2<>off THEN LET a2=mask 9157 GO TO setsens 9158 LET al=2: GO TO setsens 9160 LET a8=al: LET al=l: GO SUB setleds: LET al=l: GO SUB sethorn: PAUSE 10: FOR i=1 TO a8: LET al=3: GO SUB setleds: LET al=3: GO SUB sethorn: PAUSE 25: NEXT i: LET al=0: GO SUB setleds: LET al=0: GO SUB sethorn: RETURN 9170 REM functions 9180 POKE routine,r0: RANDOMIZE USR usrcall: LET ol=PEEK (arg1): RETURN 9182 LET ol=PEEK (err): RETURN 9184 LET r0=42: GO SUB peek: LET ol=ol+256*PEEK (arg2): RETURN 9186 LET r0=48: GO TO peek 9188 LET r0=46: GO TO peek 9190 LET r0=47: GO TO peek 9192 LET r0=44: GO TO peek 9194 LET r0=45: GO TO peek 9196 POKE argl,al: LET r0=39: GO SUB peek: LET a8=o 1: GO SUB error: IF o1=3 THEN GO TO ornge 9197 LET O1=a8: RETURN 9198 GO SUB peek: LET o2=PEEK (arg2): RETURN 9200 LET r0=31: GO TO sensp 9202 LET r0=30: GO TO sensp 9204 LET r0=32: GO TO sensp 9210 REM adjust routine 9212 CLS: PRINT "Centre robot on A4 sheet of paper , then press ""s"" to start or ""Q"" to stop" 9214 LET a$=INKEY$: IF a$="Q" OR a$="q" THEN RETURN 9216 LET al=2: GO SUB fd: GO SUB pd: LET al=200: GO SUB fd: LET al=90: GO SUB rt: LET al=200: GO SUB fd: GO SUB pu: LET al=100: GO SUB fd 9218 CLS: PRINT "Enter the length in mm of each side and the distance between the two end points": PRINT 9220 INPUT "Side 1 :";b8: INPUT "Side 2 :";c8: INPUT "Ends :";a8 9222 LET k8=PEEK disfac: LET n8=(b8+c8)/2: LET k8=INT (200*k8/n8 + .5) 9224 POKE disfac,k8: PRINT "Distance factor is";k8 9226 LET k8=PEEK rotfac: LET n8=180-(ACS (b8*b8 + c8*c8 - a8*a8)/(2*b8*c8)): LET k8=INT (90*k8/n8 +.5) 9228 POKE rotfac,k8: PRINT "Rotation factor is";k8 9230 RETURN 9300 REM additional subroutines from file zero2 go here 9399 RETURN