MASTERMIND
250 IF q$(1)=a$(1) THEN FOR i=1 TO number: LET r$(i)=a$(i): LET q$(i)=b$(i): NEXT i: LET line=21: LET p$="All changed: Press C": GO SUB print: RETURN
260 FOR i=1 TO number: LET q$(i)=a$(i): LET r$(i)=b$(i): NEXT i: LET line=21: LET p$="All changed: Press C": GO SUB print: RETURN : REM END OF SWAP

Lines 250260 The 'Swap' subroutine. 
280 IF t$=u$ THEN LET total=total+1: LET line=20: LET p$=" That's right!": GO SUB print: RETURN
290 IF flag=99 AND t$<>u$ THEN LET g(i)=1: GO SUB wrong: RETURN : REM SCORE ENDS
300 IF t$<>u$ THEN LET e(i)=1: GO SUB wrong: RETURN : REM SCORE ENDS

Lines 280300 The 'Score' subroutine works out your score. 
320 POKE 23607,249: FOR p=1 TO LEN p$: PRINT AT line,1;p$( TO p): BEEP .005,12: NEXT p: POKE 23607,60: RETURN

Line 320 The 'Print' subroutine. 
340 RANDOMIZE : DIM f(number): DIM a(number): FOR i=1 TO number: LET a(i)=i: NEXT i
350 LET c=number: FOR j=1 TO number: LET x=INT (RND*c+1): LET f(j)=a(x): LET a(x)=a(c): LET c=c1
360 NEXT j: RETURN : REM Array f holds random order of numbers.RAND ENDS

Lines 340360 The 'Rand' (randomise) subroutine. 
380 POKE 23658,8: LET flag=0: LET total=0: DIM e(number): CLS : POKE 23607,249: PRINT INK 1; PAPER 7;v$: POKE 23607,60: GO SUB rand: FOR i=1 TO number: LET current=f(i)
390 LET line=5: LET p$="Question "+STR$ i+" of "+STR$ number: GO SUB print
400 PRINT AT 7,0;q$(current)
410 LET line=10: LET p$="Type in your answer": GO SUB print: LET line=11: LET p$="then press ENTER": GO SUB print: INPUT t$
420 LET t$=t$+" ": LET u$=r$(current, TO LEN t$): GO SUB score
430 CLS : POKE 23607,249: PRINT INK 1; PAPER 7;v$: POKE 23607,60: NEXT i
440 IF total<number THEN LET line=5: LET p$="You scored "+STR$ total: GO SUB print: LET line=7: LET p$="You had "+STR$ (numbertotal)+" wrong": GO SUB print: LET line=9: LET p$="If you wish to try the wrong ones again press ""X"" or press any letter": GO SUB print
450 IF total=number THEN LET line=5: LET p$="You scored "+STR$ total: GO SUB print: LET line=7: LET p$="Very well done": GO SUB print: LET line=9: LET p$="Press any letter to continue": GO SUB print: PAUSE 0: RETURN
460 IF INKEY$<>"" THEN GO TO 460
470 LET i$=INKEY$: IF i$="" THEN GO TO 470
480 IF i$="x" OR i$="X" THEN GO TO replay
490 RETURN : REM PRESENT ENDS


510 PRINT AT 10,0;f$: LET line=10: LET p$="Sorry that's wrong": GO SUB print: LET line=11: LET p$="Correct reply =": GO SUB print: PRINT AT 13,0;r$(current): LET line=20: LET p$="Press any letter to continue": GO SUB print: PAUSE 0: RETURN : REM WRONG ENDS

Line 510 The 'Wrong' subroutine that tells you when you've answered a question incorrectly. 
530 LET h=0: LET flag=99: LET total=0: DIM g(number): CLS : POKE 23607,249: PRINT INK 1; PAPER 7;v$: POKE 23607,60: FOR i=1 TO number: LET current=f(i)
540 IF e(i)=0 THEN NEXT i
550 LET h=h+1: LET line=5: LET p$="REPLAY": GO SUB print
560 PRINT AT 7,0;q$(current)
570 LET line=10: LET p$="Type in your answer": GO SUB print: LET line=11: LET p$="then press ENTER": GO SUB print: INPUT t$
580 LET t$=t$+" ": LET u$=r$(current, TO LEN t$): GO SUB score
590 CLS : POKE 23607,249: PRINT INK 1; PAPER 7;v$: POKE 23607,60: NEXT i
600 LET line=5: LET p$="YOU SCORED "+STR$ total: GO SUB print: LET line=7: LET p$="You had "+STR$ (htotal)+" wrong": GO SUB print: LET line=9: LET p$="Press any letter to continue": GO SUB print
610 PAUSE 0
620 RETURN : REM REPLAY ENDS

Lines 530620 The 'Replay' subroutine that gives you another crack at a question when you've got it wrong. 
640 DATA "LONDON", "UNITED KINGDOM", "PARIS", "FRANCE", "LISBON", "PORTUGAL", "CAIRO", "EGYPT", "BUENOS AIRES", "ARGENTINA", "STOCKHOLM", "SWEDEN", "AMSTERDAM", "HOLLAND", "COPENHAGEN", "DENMARK", "MADRID", "SPAIN", "WARSAW", "POLAND"
650 CLS : POKE 23607,249: PRINT v$: POKE 23607,60: LET line=5: LET p$="DEMONSTRATION": GO SUB print: LET line=7: LET p$="You will be shown the names of": GO SUB print: LET line=9: LET p$="ten capital cities": GO SUB print: LET line=11: LET p$="Try to name their countries": GO SUB print: LET line=20: LET p$="Press any letter when ready": GO SUB print
660 PAUSE 0
670 RESTORE 640: LET number=10: DIM a$(10,32): DIM b$(10,32): DIM q$(10,32): DIM r$(10,32): FOR i=1 TO 10: READ o$,n$: LET a$(i)=o$: LET b$(i)=n$: LET q$(i)=a$(i): LET r$(i)=b$(i): NEXT i
680 POKE 23658,8: GO SUB present: RETURN : REM DEMO ENDS

Lines 640680 The 'Demo' subroutine. 
900 FOR i=1 TO number: CLS : POKE 23607,249: PRINT v$: POKE 23607,60: LET line=5: LET p$="Question "+STR$ i: GO SUB print: PRINT : PRINT q$(i)
910 LET line=10: LET p$=" Answer "+STR$ i: GO SUB print
920 PRINT : PRINT r$(i)
930 LET line=20: LET p$="Press any letter for next": GO SUB print: PAUSE 0: NEXT i: RETURN : REM DISPLAY ENDS

Lines 900930 The 'Display' subroutine. 
950 CLS : LET line=5: LET p$="Copyright": GO SUB print: LET line=6: LET p$="1985 Chris Somerville": GO SUB print: LET line=7: LET p$="Presented in ""Your Spectrum""": GO SUB print


960 LET line=12: LET p$="Press any letter to clear": GO SUB print: LET line=13: LET p$="Press X to restart": GO SUB print: LET line=14: LET p$="Press C to copy on tape": GO SUB print
970 IF INKEY$<>"" THEN GO TO 970
980 LET i$=INKEY$: IF i$="" THEN GO TO 980
990 IF i$="X" THEN GO TO menu
1000 IF i$="C" THEN GO TO 1020
1010 STOP
1020 CLS : PRINT '" You can make a copy of this tape complete with any questions that you have entered. However, you will need to type ""CLEAR 63999"" before you load the new tape you have made."
1030 PRINT '" Press any letter when you are ready to record": PAUSE 0: CLS : PRINT AT 10,0;" Type in a name for your tape then press ENTER": INPUT "NOT MORE THAN 9 LETTERS";i$
1040 PRINT #1;AT 0,0;" Is Interface 1 attached? Press Y(yes) or N(no)"
1050 IF INKEY$<>"" THEN GO TO 1050
1060 LET j$=INKEY$: IF j$="" THEN GO TO 1060
1070 LET auto=23736: IF j$="y" OR j$="Y" THEN LET auto=23794
1090 SAVE i$ LINE 1100: POKE auto,181: SAVE "c"CODE 64000,746: GO TO menu
1100 LOAD "c"CODE 64000: GO TO menu
1110 STOP

Lines 9501110 The 'endthegame' routine. 
1130 POKE 23658,8: PAPER 6: INK 0: BORDER 4: CLS : POKE 23609,35: LET v$=" HOME TUTOR PROGRAM ": POKE 23607,249: PRINT v$: POKE 23607,60
1140 PRINT '
1150 PRINT '" To enter questions Press B"
1160 PRINT '" To test yourself Press C"
1170 PRINT '" To swap over Press D (ie:Questions become Answers)"
1180 PRINT '" For demonstration Press E"
1190 PRINT '" To list the questions Press F (to learn them)"
1200 PRINT '" To finish Press G"
1210 IF INKEY$<>"" THEN GO TO 1210
1220 LET i$=INKEY$: IF i$="" THEN GO TO 1220
1230 IF CODE i$<66 OR CODE i$>71 THEN GO TO 1210
1240 IF i$="G" THEN GO TO 940
1250 GO SUB (display AND i$="F")+(demo AND i$="E")+(entry AND i$="B")+(present AND i$="C")+(swap AND i$="D")
1260 IF i$="D" THEN GO TO 1220
1270 GO TO 1120
1280 STOP
1290 SAVE "h" LINE 1320: POKE 23736,181
1300 SAVE "c"CODE 64000,746
1310 STOP
1320 PRINT AT 20,0;
1330 LOAD "c"CODE 64000
1340 PAPER 2: INK 7: CLS : FOR i=0 TO 21: PRINT AT i,7;"STOP THE TAPE": BEEP .1,30: NEXT i
1350 GO TO menu

Lines 11301350 The main menu subroutine menu. 
