Dacta

De Centre de Ressources Numériques - Labomedia
Aller à : navigation, rechercher

Page de projet pour exploiter l'interface A de Lego Dacta.

A suivre …

10 CLS
20 GOSUB 1000
30 CX = 0
31 CY = 0
32 CXP = 0
33 CYP = 0
40 FX = (PEEK(&HE7F2) AND &H40) / 64
50 FY = (PEEK(&HE7F2) AND &H80) / 128
60 X1 = 0
65 Y1 = 0
70 X2 = 200
75 Y2 = 100
76 DX = X2 - X1
77 DY = Y2 - Y1
80 GOSUB 2000
90 E = DX
91 DX = 2 * E
92 DY = DY * 2
100 ' PROGRAMME
130 A = PEEK(&HE7F2)
140 IF ((A AND 64) = 64) AND FX = 0 THEN GOSUB 4000
150 IF ((A AND 64) = 0) AND FX = 1 THEN GOSUB 4100
160 IF ((A AND 128) = 128) AND FY = 0 THEN GOSUB 4200
170 IF ((A AND 128) = 0) AND FY = 0 THEN GOSUB 4300
200 IF (X1 + CX) > X2 THEN GOSUB 3000
210 IF CX <> CXP THEN CXP = CX:E = E -DY: IF (E <=0 ) THEN E = E+DX : GOSUB 2200
200 IF CYP <> CY THEN CYP = CY:GOSUB 2700
900 GOTO 100
990 END
1000 ' INITIALISATION
1010 POKE &HE7F3, 0
1020 POKE &HE7F2, 63
1030 POKE &HE7F3, 4
1040 POKE &HE7F2, 0
1200 ' BRANCHEMENT FLECHE
1210 GOSUB 3000
1230 ON KEY = 8 GOSUB 2100
1240 ON KEY = 9 GOSUB 2000
1250 ON KEY = 10 GOSUB 2200
1260 ON KEY = 11 GOSUB 2300
1270 ON KEY = "A" GOSUB 2400
1280 ON KEY = "Z" GOSUB 2500
1290 ON KEY = " " GOSUB 3000
1300 RETURN
2000 ' DIRECTION X POSITIF
2005 MM = (PEEK(&HE7F2) AND NOT 2) OR 1
2010 POKE &HE7F2, MM
2020 RETURN
2100 ' DIRECTION X NEGATIF
2105 MM = (PEEK(&HE7F2) AND NOT 1) OR 2
2110 POKE &HE7F2, MM
2120 RETURN
2200 ' DIRECTION Y POSITIF
2205 MM = (PEEK(&HE7F2) AND NOT 8) OR 4
2210 POKE &HE7F2, MM
2220 RETURN
2300 ' DIRECTION Y NEGATIF
2305 MM = (PEEK(&HE7F2) AND NOT 4) OR 8
2310 POKE &HE7F2, MM
2320 RETURN
2400 ' Z POSITIF
2410 POKE &HE7F2, 16
2420 RETURN
2500 ' Z NEGATIF
2510 POKE &HE7F2, 32
2520 RETURN
2600 ' ARRET DE L'AXE X
2605 MM = (PEEK(&HE7F2) AND NOT 3)
2610 POKE &HE7F2, MM
2620 RETURN
2700 ' ARRET DE L'AXE Y
2705 MM = (PEEK(&HE7F2) AND NOT 12)
2710 POKE &HE7F2, MM
2720 RETURN
3000 ' MISE A ZERO DES SORTIES
3010 POKE &HE7F2, 0
3015 PRINT CX; CY
3020 RETURN
4000 ' COMPTAGE BLANC AXE X
4010 CX = CX + 1
4020 FX = 1
4040 RETURN
4100 ' COMPTAGE NOIR AXE X
4110 CX = CX + 1
4120 FX = 0
4140 RETURN
4200 ' COMPTAGE BLANC AXE Y
4210 CY = CY + 1
4220 FY = 1
4240 RETURN
4300 ' COMPTAGE NOIR AXE Y
4310 CY = CY + 1
4320 FY = 0
4340 RETURN