8-Bit Software Online Conversion

Knights Tour - Listing

10DEFFNS="Knights" 20ONERROR:MODE0:OSCLI"FX 4":REPORT:PR INTERL:END 30DIM G%(65):REM Grid 40DIM M%(65):REM Memory 50C%=255 60Z%=0 70P%=1 80X%=1 90Y%=1 100H%=88 110A%=X% 120B%=Y% 130M%=0 140PROCfill 150MODE7 160VDU23;8202;0;0;0; 170PROCscreen 180PROCdisp 190REPEAT 200VDU31,X%-1,Y%-1 210REPEAT 220REPEAT 230VDUH%,8 240FORD%=1TO250:NEXT 250VDUG%(P%),8 260FORD%=1TO250:NEXT 270K%=INKEY(0) 280UNTIL K%<>-1 290IF K%=82:RUN 300UNTIL K%=136 OR K%=137 OR K%=138 OR K%=139 OR K%=66 OR K%=68 OR K%=83 OR K% =76 OR K%=13 310*FX21 320IF M%=1:IF H%=88:VDUH%,8 330IF M%=1:IF A%=X% AND B%=Y% VDU88 340IF K%=136:IF X%>1:X%=X%-1:P%=P%-1:I F M%=1:H%=120 350IF K%=137:IF X%<8:X%=X%+1:P%=P%+1:I F M%=1:H%=120 360IF K%=138:IF Y%<8:Y%=Y%+1:P%=P%+8:I F M%=1:H%=120 370IF K%=139:IF Y%>1:Y%=Y%-1:P%=P%-8:I F M%=1:H%=120 380IF K%=66:IF M%<>0:PROCBack 390IF K%=83:PROCchoose("Save"):PROCSav e 400IF K%=76:PROCchoose("Load"):PROCLoa d 410IF K%=13:PROCConfirm 420IF K%=68:IFM%=1:PROCdemo 430IF M%(64)<>0 IF Z%=0:PROCwon:Z%=1 440UNTILFALSE 450END 460DEFPROCscreen 470T$="   490PRINTTAB((39/2-LENT$/2)-2);" ";T$ 500PRINT'TAB(3);" Programmed By C.J. Richardson " 510PRINT TAB(0,19);" Land on all of th e positions in the" 520PRINT" grid by moving in an 'L' sha pe using" 530PRINT" the Arrow Keys. Press 'RETUR N' to" 540PRINT" commit to the square you are on." 550PRINT" (B)ack a move. (S)ave game s tate." 560PRINT" (L)oad game state. (R)estart (D)emo."; 570PRINTTAB(15,7)" 12345678" 580PRINTTAB(14)" 1" 590PRINTTAB(14)" 2" 600PRINTTAB(14)" 3" 610PRINTTAB(14)" 4" 620PRINTTAB(14)" 5" 630PRINTTAB(14)" 6" 640PRINTTAB(14)" 7" 650PRINTTAB(14)" 8" 660VDU28,16,16,23,8 670*FX4,1 680ENDPROC 690DEFPROCConfirm 700IF M%(64)<>0:ENDPROC 710F%=0 720IF M%=0:M%=1:PROCok:ENDPROC 730IF P%-E%=6 OR P%-E%=10 OR P%-E%=15 OR P%-E%=17:IF G%(P%)<>32:F%=1 740IF E%-P%=6 OR E%-P%=10 OR E%-P%=15 OR E%-P%=17:IF G%(P%)<>32:F%=1 750IF F%=0 ENDPROC 760PROCok 770ENDPROC 780DEFPROCok 790A%=X% 800B%=Y% 810H%=88 820G%(P%)=32 830L%=0 840REPEAT 850L%=L%+1 860UNTILM%(L%)=0 870M%(L%)=P% 880E%=P% 890PROCdisp 900ENDPROC 910DEFPROCdisp 920VDU30 930FORL%=1 TO 64 940VDUG%(L%) 950NEXT 960VDU31,A%-1,B%-1,88 970VDU31,X%,Y% 980ENDPROC 990DEFPROCBack 1000Z%=0 1010L%=65 1020REPEAT 1030L%=L%-1 1040UNTILM%(L%)<>0 OR L%=1 1050IF L%=1:ENDPROC 1060G%(E%)=255 1070P%=M%(L%-1) 1080X%=(P% MOD 8) 1090Y%=(P% DIV 8)+1 1100IF X%=0 X%=8:Y%=Y%-1 1110M%(L%)=0 1120E%=M%(L%-1) 1130A%=X% 1140B%=Y% 1150H%=88 1160PROCdisp 1170ENDPROC 1180DEFPROCLoad 1190I%=OPENIN F$ 1200FORL%=1 TO 64 1210INPUT#I%,G%(L%),M%(L%) 1220NEXT 1230INPUT#I%,X%,Y%,A%,B%,P%,M%,H%,E% 1240CLOSE#I% 1250PROCdisp 1260ENDPROC 1270DEFPROCSave 1280I%=OPENOUT F$ 1290FORL%=1 TO 64 1300PRINT#I%,G%(L%),M%(L%) 1310NEXT 1320PRINT#I%,X%,Y%,A%,B%,P%,M%,H%,E% 1330CLOSE#I% 1340ENDPROC 1350DEFPROCchoose(G$) 1360VDU26 1370CLS 1380PRINT'" Type Filename to "+G$+" R ETURN=KniDat "' 1390*. 1400INPUT " Filename :"F$ 1410IF F$="" F$="KniDat" 1420CLS 1430PROCscreen 1440PROCdisp 1450ENDPROC 1460DEFPROCfill 1470FORL%=1 TO 64 1480G%(L%)=C% 1490NEXT 1500ENDPROC 1510DEFPROCdemo 1520VDU30 1530FORL%=1 TO 64 1540VDU255 1550NEXT 1560L%=0 1570REPEAT 1580L%=L%+1 1590A%=M%(L%) MOD 8 1600B%=(M%(L%) DIV 8)+1 1610IF A%=0 A%=8:B%=B%-1 1620VDU31,A%-1,B%-1,32,8 1630FOR IL%=1 TO 200 1640VDU120,8,88,8 1650NEXT 1660VDU32,8 1670UNTIL L%=64 OR M%(L%+1)=0 1680VDU31,A%-1,B%-1,88,8 1690ENDPROC 1700DEFPROCwon 1710RESTORE:S%=0 1720ENVELOPE1,1,0,0,0,1,1,1,60,-4,-1,-1 ,120,90:B$="C D EF G A Bc d ef":C$="5555 1111555511555566661154321155":E$="888877 77888877888899997A88357A88":D$="123475.A .86...9":T%=9:O%=6:READA$,N%:D%=TIME:Q%= 0:U%=FALSE:R%=O%+4*INSTR(D$,LEFT$(C$,1)) 1730REPEAT:IFINKEY(0)=32THENG%=32:UNTIL TRUE:ENDPROC 1740IFQ%<=0Q%=Q%+3:IFLENC$SOUND&11,1,R% -(S%-R%)*U%,-1:SOUND&12,1ANDU%,S%+12,-1: U%=NOTU%:R%=O%+4*INSTR(D$,LEFT$(C$,1)):S %=O%+4*INSTR(D$,LEFT$(E$,1)):C$=RIGHT$(C $,LENC$+U%):E$=RIGHT$(E$,LENE$+U%) 1750Q%=Q%-N%:SOUND&13,1,O%+4*(INSTR(B$, LEFT$(A$,1))-(INSTR(A$,"#")>0)+12),-1:D% =D%+N%*T%:REPEATUNTILTIME>D%:READ A$,N%: UNTILA$="dne":ENDPROC 1760DATAC,2,f,1,e,2,d,1,c,2,A#,1,A,2,G, 1,F,3,A,3,F,6,dne,0