8-Bit Software Online Conversion
Countdown - Listing
10REM" Countdown
20REM" John Davis -'97.
30*K.10
40MODE7
50PROCting
60DIMA%(6):DIMB%(6):DIMC%(6):DIMD%(6)
70DIMP$(5):DIMQ$(5):DIMS$(6)
80S$(1)="+":S$(2)="-":S$(3)="*":S$(4)
="p":S$(5)="m":S$(6)="t"
90F%=5
100L$=" "+CHR$157+" * C O U N T
D O W N *"
110VDU23,1,0;0;0;0;
120PRINTL$
130PRINT'TAB(12)" "CHR$157" Options "
CHR$156
140PRINT'" Press: I for Info."
150PRINTTAB(7)" E to Enter numbers."
160PRINTTAB(7)" R for Random numbers."
170PRINTTAB(7)" ESC to quit."
180PRINT'CHR$145;STRING$(39,",");
190ONERRORVDU23,1,1;0;0;0;:PRINT:END
200G$=GET$
210IFG$="I"ELSE240
220*K.10CH."C/DOWN"|M
230*RUN CD/INFO
240ONERRORVDU26:CLS:GOTO110
250IFG$="E"PROCinput:CLS:GOTO310
260IFG$="R"CLS:GOTO280
270GOTO190
280IFRND(1)<.1A%(1)=10ELSEA%(1)=25*RND
(4)
290FORN%=2TO6:A%(N%)=RND(10):NEXT
300T%=99+RND(900)
310FORN%=1TO6:B%(N%)=A%(N%):NEXT
320PROCscreen
330TIME=0:Z%=0:V%=500
340REM" **
350REPEAT
360FORY%=1TOF%
370Z%=Z%+1
380IFRND(1)<.2R%=4ELSER%=4+RND(2)
390FORN%=1TOR%-(1ANDR%=6)
400W%=7-N%:X%=RND(W%)
410C%(N%)=B%(X%)
420B%(X%)=B%(W%)
430B%(W%)=C%(N%)
440NEXT
450IFR%=6C%(6)=B%(1)
460IFC%(1)MODC%(2)=0ANDC%(2)>1P$(1)="d
"ELSEP$(1)=S$(RND(6))
470FORN%=2TOR%-1
480P$(N%)=S$(RND(6))
490NEXT
500K%=1:D%(1)=C%(1)
510FORN%=1TOR%-1
520IFASC(P$(N%))<97GOTO580
530 IFP$(N%)="p"D%(K%)=D%(K%)+C%(N%+1)
540 IFP$(N%)="m"D%(K%)=D%(K%)-C%(N%+1)
550 IFP$(N%)="t"D%(K%)=D%(K%)*C%(N%+1)
560 IFP$(N%)="d"D%(K%)=D%(K%)/C%(N%+1)
570 GOTO610
580D%(K%+1)=C%(N%+1)
590Q$(K%)=P$(N%)
600K%=K%+1
610NEXT
620J%=D%(1)
630IFK%>1ELSE690
640 FORN%=1TOK%-1
650 IFQ$(N%)="+"J%=J%+D%(N%+1)
660 IFQ$(N%)="-"J%=J%-D%(N%+1)
670 IFQ$(N%)="*"J%=J%*D%(N%+1)
680 NEXT
690PROCclosest
700NEXT
710PROCdisp
720IFINKEY$(0)="P"PROCpause
730UNTIL0
740" **
750DEFPROCnumstr
760E$=""
770FORN%=1TOR%-1
780E$=E$+STR$(C%(N%))+P$(N%)
790NEXT
800E$=E$+STR$(C%(R%))
810ENDPROC
820" **
830DEFPROCdisp
840PROCnumstr
850PRINT" "E$
860PRINTCHR$(131-2*SGN(J%));ABS(J%);"
";TAB(7)" No.";Z%'
870VDU26
880TM%=TIME/100
890PRINTTAB(20,21);TM%DIV60;"min ";TM%
MOD60;"sec "
900VDU28,0,23,16,2
910PRINTTAB(0,21);
920ENDPROC
930" **
940DEFPROCinput
950CLS:PRINTL$:PRINT
960PRINTTAB(10)" "CHR$(157)" Enter Num
bers "CHR$(156)
970PRINT'" First enter the six numbe
rs, in any order, and then the target
number."
980VDU23,1,1;0;0;0;
990PRINT
1000FORN%=1TO6
1010PRINT'" Number ";N%;"?"
1020NEXT
1030PRINT'" Target?"
1040PRINTTAB(0,22)CHR$(145);STRING$(39,
",");
1050PRINT'" Press ESC to cancel.";
1060FORN%=1TO6
1070PRINTTAB(11,N%*2+6);
1080INPUT" "A%(N%)
1090NEXT
1100PRINTTAB(9,N%*2+6);
1110INPUT" "T%
1120PRINTTAB(0,24)" Are these all corre
ct? (Y/N)";
1130G$=GET$
1140IF G$="N" THEN950
1150IF G$<>"Y" THEN1130
1160VDU23,1,0;0;0;0;
1170ENDPROC
1180" **
1190DEFPROCscreen
1200PRINTL$
1210PRINTTAB(17,2)" "CHR$157
1220FORN%=3TO21
1230PRINTTAB(17,N%)CHR$148CHR$255
1240PRINTTAB(38,N%)CHR$148CHR$255;
1250NEXT
1260PRINTTAB(17,22)" "CHR$157
1270PRINTTAB(0,24)" "CHR$157" ESC for O
ptions P/P:Pause/Go";
1280PRINTTAB(19,3)" Numbers:"
1290PRINTTAB(19,4)" ";
1300FORN%=1TO6:PRINT;A%(N%);" ";:NEXT
1310PRINTTAB(19,5)" Target:"
1320PRINTTAB(19,6)" ";T%
1330PRINTTAB(20,7)",,,,,,,,,,,,,,,,,,"
1340PRINTTAB(19,8)" Closest so far:"
1350PRINTTAB(19,10)" Value:"
1360PRINTTAB(19,12)" Attempt:"
1370PRINTTAB(19,14)" Time:"
1380PRINTTAB(20,16)",,,,,,,,,,,,,,,,,,"
1390PRINTTAB(19,17)" Display Frequency:
"
1400PRINTTAB(19,18)" Every: ";F%
1410PRINTTAB(20,19)",,,,,,,,,,,,,,,,,,"
1420PRINTTAB(19,20)" Running time:"
1430PRINTTAB(19,21)" "
1440VDU28,0,23,16,2
1450PRINTTAB(0,21);
1460ENDPROC
1470" **
1480DEFPROCclosest
1490U%=ABS(T%-ABS(J%))
1500IFU%<=V%ELSEENDPROC
1510PROCnumstr
1520V%=U%:TM%=TIME/100
1530IFV%<11VDU7
1540VDU26
1550PRINTTAB(19,9)SPC17
1560PRINTTAB(19,9)" "E$
1570PRINTTAB(19,11)CHR$(131-2*SGN(J%));
ABS(J%);" "
1580IFJ%<0PRINTTAB(26,10)" (negative)"E
LSEPRINTTAB(26,10)" "
1590PRINTTAB(19,13)" ";Z%
1600PRINTTAB(19,15)" ";TM%DIV60;"min ";
TM%MOD60;"sec "
1610IFABS(J%)=T%PROChowzat
1620VDU28,0,23,16,2
1630PRINTTAB(0,21);
1640ENDPROC
1650" **
1660DEFPROChowzat
1670VDU7:TT%=TIME
1680PRINTTAB(2,23)" C to Continue"SPC18
;
1690PRINTTAB(19,24)" ";
1700PRINTTAB(19,8)" Solution: "
1710FORN=1TO20
1720PRINTTAB(26,11)" Howzat!?"
1730FORD=1TO300:NEXT
1740PRINTTAB(26,11)" Howzat!?"
1750FORD=1TO400:NEXT
1760NEXT
1770G$=GET$
1780IFG$="C"ELSE1770
1790PRINTTAB(25,11)SPC11
1800PRINTTAB(0,23)SPC16;
1810IFF%>99PRINTTAB(17,23)" * Running
...";
1820PRINTTAB(19,24)" ";
1830TIME=TT%
1840ENDPROC
1850" **
1860DEFPROCting
1870ENVELOPE1,1,0,0,0,0,0,0,127,-4,-2,-
1,126,90
1880*FX212,0
1890*FX213,170
1900ENDPROC
1910" **
1920DEFPROCpause
1930TT%=TIME
1940VDU26
1950PRINTTAB(0,23)" ¶¶¶ Pause ¶¶¶"
1960PRINTTAB(17,23)" "CHR$157" F for ne
w frequency";
1970G$=GET$
1980IFG$="F"ELSE2060
1990 PRINTTAB(20,23)SPC19;
2000 VDU23,1,1;0;0;0;
2010 INPUTTAB(20,23)"Frequency? "F%
2020 PRINTTAB(17,23)SPC22;
2030 IFF%<1F%=5
2040 PRINTTAB(27,18);F%;" "
2050 GOTO2070
2060IFG$="P"ELSE1970
2070PRINTTAB(0,23)SPC39;
2080IFF%>99PRINTTAB(17,23)" * Running
...";
2090VDU28,0,23,16,2
2100VDU23,1,0;0;0;0;
2110PRINTTAB(0,21);
2120TIME=TT%
2130ENDPROC