20220901ProgBtn10.txt

13Sep - by Joe-90 - 0 - In 未分類

HOPE-2020およびHOPE-2022システムのプログラムです。
Maker Faire Tokyo 2022 で使用した完成版のプログラムになります。

    10 '---20220901ProgBtn10.txt
    20 OUT $E3,$8A
    30 OUT $E7,$83
    40 P%=0
    50 N%=0:PROG$=" "
    60 SUB%=0:ST%=0
    70 MUKI%=0:PMUKI%=0
    80 OUT $E0,0:A%=0
    90 IF SUB%=0 THEN OUT $E4,255 ELSE OUT $E4,241
   100 '
   110 PRINT "PROG?":PIN%=IN($E5):OUT $E4,$FF
   120 IF PIN%=IN($E5)GOTO 120
   130 PIN%=IN($E5)
   140 IF BIT(PIN%,0)=0 GOTO 1120
   150 IF BIT(PIN%,7)=0 THEN PROG$=PROG$+"0"
   160 IF BIT(PIN%,6)=0 THEN PROG$=PROG$+"4"
   170 IF BIT(PIN%,5)=0 THEN PROG$=PROG$+"2"
   180 IF BIT(PIN%,4)=0 THEN PROG$=PROG$+"3"
   190 IF BIT(PIN%,3)=0 THEN PROG$=PROG$+"1"
   200 IF BIT(PIN%,2)=0 GOTO 250
   210 IF N%=LEN(PROG$)GOTO 120 ELSE GOTO 220
   220 N%=LEN(PROG$)
   230 IF N%>=38 THEN PRINT "OVERFLOW!":GOSUB 890:GOTO 40
   240 PRINT "INPUT>>>",RIGHT$(PROG$,1),PROG$:GOTO 120
   250 '---TONE=F
   260 BEEP INT(50000/440)
   270 GOSUB 890
   280 '
   290 PRINT "RUN":PRINT " "
   300 OUT $E0,254
   310 HUA%=0:HUB%=0
   320 SHUT$="O"
   330 '
   340 FOR C%=2 TO N%
   350 P%=VAL(RIGHT$(LEFT$(PROG$,C%),1))
   360 IF C%<N% THEN PF%=VAL(RIGHT$(LEFT$(PROG$,C%+1),1))
   370 PRINT " ":PRINT " LOOP >>> ",C%-1
   380 PRINT P%,PF%
   390 '
   400 IF P%<PF% THEN PMUKI%=0
   410 IF P%>PF% THEN PMUKI%=1
   420 '
   430 '-----MAIN-----
   440 '
   450 H%=IN($E1)
   460 BT%=IN($E5)
   470 '
   480 IF (ST%=1)*(BIT(BT%,2)=0)THEN PRINT "RESTORE.":GOTO 40
   490 IF BIT(BT%,0)=0 GOTO 1120
   500 IF (BIT(BT%,1)=0)*(ST%=0)THEN P%=1:PF%=0:PRINT "STOP":ST%=1:GOTO 400
   510 '
   520 IF BIT(H%,7)=1 THEN MUKI%=0:'RIGHT
   530 '
   540 IF BIT(H%,3)=1 THEN MUKI%=0:SUB%=1
   550 IF (BIT(H%,3))*(ST%=1)THEN ST%=0:GOTO 1050
   560 '
   570 IF BIT(H%,5)=1 THEN HUA%=1:GOSUB 1010
   580 IF (BIT(H%,5))*(P%=2)THEN MUKI%=PMUKI%
   590 IF (BIT(H%,5))*(P%>2)THEN MUKI%=0
   600 IF (BIT(H%,5))*(P%=1)THEN MUKI%=1:SUB%=1
   610 IF (BIT(H%,5))*(P%=0)THEN MUKI%=1:SUB%=0
   620 '
   630 IF BIT(H%,4)=1 THEN HUB%=1
   640 IF (BIT(H%,4))*(P%=3)THEN MUKI%=PMUKI%
   650 IF (BIT(H%,4))*(P%>3)THEN MUKI%=0
   660 IF (BIT(H%,4))*(P%<3)THEN MUKI%=1
   670 '
   680 IF BIT(H%,6)=1 THEN MUKI%=1:'LEFT
   690 '
   700 IF HUA%+HUB%=0 THEN SHUT$="O"
   710 IF HUA%+HUB%=1 THEN SHUT$="C"
   720 IF HUA%+HUB%=2 THEN SHUT$="O":HUA%=0:HUB%=0:GOSUB 890
   730 '
   740 IF SHUT$="O"THEN OUT $E2,(4+3*MUKI%)
   750 IF SHUT$="C"THEN OUT $E2,(0+3*MUKI%)
   760 '
   770 PT%=255
   780 IF SUB%=0 THEN RES PT%,7
   790 IF SUB%=1 THEN FOR X%=4 TO 7:RES PT%,X%:NEXT X%
   800 OUT $E4,PT%
   810 '
   820 IF P%=0 THEN A%=7
   830 IF P%=1 THEN A%=3
   840 IF P%=2 THEN A%=5
   850 IF P%=3 THEN A%=4
   860 IF P%=4 THEN A%=6
   870 IF BIT(H%,A%)=1 GOTO 930 ELSE GOTO 430
   880 '
   890 FOR LOOP%=1 TO 300
   900 NEXT LOOP%
   910 RETURN 
   920 '
   930 PRINT "PASS POINT>>>",A%
   940 NEXT C%
   950 IF PF%=0 THEN OUT $E2,7:IF BIT(IN($E1),7)=0 THEN OUT $E0,0 ELSE GOTO 950
   960 FOR FIN%=1 TO 2
   970 BEEP INT(50000/440):GOSUB 890
   980 NEXT FIN%
   990 GOTO 50
  1000 '
  1010 IF PF%=2 THEN SUB%=1:MUKI%=1
  1020 IF PF%=1 THEN SUB%=0:MUKI%=1
  1030 RETURN 
  1040 ' 
  1050 OUT $E0,0:PRINT "RESET?"
  1060 FOR CON%=0 TO 2500
  1070 IF BIT(IN($E5),2)=0 THEN PROG$="10":N%=3:PRINT "RESTART.":GOTO 290
  1080 IF INT(CON%/250)=(CON%/250)THEN PRINT 10-(CON%/250)
  1090 NEXT CON%
  1100 GOTO 50
  1110 '
  1120 PRINT "Emergency brake activated!"
  1130 OUT $E0,0
  1140 IF SUB%=0 THEN OUT $E5,255 ELSE OUT $E5,241
  1150 FOR EM%=1 TO 3
  1160 GOSUB 890
  1170 '---TONE=F
  1180 BEEP INT(50000/440)
  1190 NEXT EM%
  1200 GOTO 50