Compucolor.org – Virtual Media

Listing of file='MSTMND.BAS;01' on disk='vmedia/chip_106-sector.ccvf'

10 REM   * * * MASTERMIND / C.BELL, DEC 1979
20 CLEAR 5000
30 DIM  BRD(10,6):REM  CODE, BLACK, WHITE
35 DIM  MSG$(15)
40 DIM SCR(2),ROL(2):REM  SCORES AND CMPTR ROLE SWTCH
50 DEF FN R(X)= INT (RND (1)* X+ .999999)
60 SC(1)= 0:SC(2)= 0
70 GOSUB  1200:REM  INTRO + SET ROLE(1) AND (2),1=MACHINE
75 SET= 1
80 MAKE= 1:BREAK= 2
100 POKE  33283,13:POKE  33284,240
110 REM  BEGIN GAME HERE
120 PLOT  12
140 GOSUB  1350
150 POKE  61452,1:PO= CALL (1):REM  INITIALIZE POSSIBILITY ARRAY
155 GOSUB  1440:MSG$(0)= "CODEMAKER, "+ PL$(MAKER)
160 IF  ROLE(MAKE)= 0 THEN GOTO 170
161 MSG$(1)= "HAS SET HIS HIDDEN CODE BELOW...."
162 IF  ROLE(BREAK)= 1 THEN  GOTO  166
163 MSG$(3)= "IT IS MASKED OFF UNTIL END OF TURN--"
164 MSG$(4)= "  YOU WILL HAVE TO EARN THAT SIGHT!"
165 PLOT  3,28,28:PRINT  "? ? ? ? ? ?":GOSUB  1450:GOSUB  210:FOR  ZI= 1 TO  1500:NEXT  ZI:GOTO  250
166 MSG$(3)= "IT IS DISPLAYED BELOW FOR OUR VIEWERS."
167 GOSUB  1450:GOSUB  210:SX= 28:SY= 28:SI= 0:GOSUB  1600
169 GOTO  250
170 MSG$(1)= "SHOULD NOW SET THE HIDDEN CODE...."
171 IF  ROLE(BREAK)= 0 THEN  GOTO  181
172 MSG$(3)= "YOU MAY REGISTER YOUR CODE EXTERNALLY"
173 MSG$(4)= "(ON A PIECE OF PAPER, ETC) OR FOR"
174 MSG$(5)= "CONVENIENCE, I WILL DISPLAY IT BELOW"
175 MSG$(6)= "(I PROMISE NOT TO PEEK!)"
176 MSG$(7)= "WOULD YOU CARE FOR YOUR CODE TO BE"
177 MSG$(8)= "DISPLAYED BELOW?":GOSUB  1450
178 GOSUB  1700:IF  ANS$< > "Y" AND  ANS$< > "N" THEN  PLOT  3,0,31,11:PRINT  "  Y OR N":GOTO  178
179 PLOT  3,0,31,11:IF  ANS$< > "Y" THEN  SVD(0)= 0:PLOT  3,28,28:PRINT  "? ? ? ? ? ?":GOTO  250
180 MSG$(4)= "":MSG$(5)= "":MSG$(6)= "":GOSUB  183:GOTO  189
181 MSG$(3)= "THE CODEBREAKER SHOULD TURN HIS HEAD"
182 MSG$(4)= "(CLOSE HIS EYES, 'WHAT-EVER'!); THEN":GOSUB  183:GOTO  189
183 MSG$(6)= "PRESS ANY COLORED KEY (NOT BLACK OR"
184 MSG$(7)= "WHITE) TO ENTER EACH PEG.  TO ERASE"
185 MSG$(8)= "THE LAST PEG DRAWN, ENTER THE <- KEY."
186 MSG$(9)= "WHEN YOUR FOUR PEGS ARE IN PLACE,"
187 MSG$(10)= "   PRESS THE RETURN/ENTER KEY."
188 MSG$(12)= "ENTER YOUR CODE NOW...":RETURN
189 GOSUB  1450:SI= 0:OX= 28:OY= 28:GOSUB  190:GOSUB  196:GOTO  200
190 SJ= 0
191 GOSUB  1700:GOSUB  1800:IF  NV= 13 AND  SJ> = 4 THEN  RETURN
192 IF  NV= 13 THEN  PLOT  3,0,31,11:PRINT  " ENTER 4 COLORED PEGS THEN RETURN.":GOTO  191
193 IF  NV= 26 THEN  BRD(SI,SJ)= 0:GOSUB  1610:GOSUB  246:GOTO  191
194 IF  SJ< 5 THEN  SX= OX+ ((SJ- 1)* 3):SY= OY:GOSUB  1610
195 GOTO  191
196 SVD(0)= 1:FOR  SL= 1 TO  4:SVD(SL)= BRD(0,SL):NEXT  SL:RETURN
200 IF  ROLE(BREAK)= 1 THEN  GOTO  250
201 PLOT  3,28,28:PRINT  "? ? ? ? ? ?"
209 GOTO  250
210 FOR  ZI= 1 TO  4
220 BRD(0,ZI)= FN R(6)
230 POKE  61439+ ZI,BRD(0,ZI)
240 NEXT  ZI
245 RETURN
246 IF  SJ< 1 THEN  RETURN
247 IF  SJ> 1 THEN  SX= SX- 3
248 SJ= SJ- 1
249 RETURN
250 PLOT  3,0,31,11:PRINT  "THE CODE IS NOW SET...."
260 FOR  II= 1 TO  10:I= II
262 PLOT  3,42,1+ ((I- 1)* 3):PRINT  "(";I;")"
264 GOSUB  1440
266 MSG$(1)= "CODEBREAKER, "+ PL$(BREAK)
280 IF  ROLE(BREAK)= 1 THEN GOTO 350
281 MSG$(2)= "SHOULD ATTEMPT TO GUESS THE HIDDEN"
282 MSG$(3)= "CODE.  TO DO THIS:"
283 GOSUB  183
284 OX= 47:OY= 1+ ((I- 1)* 3):SI= I
285 GOSUB  1450
286 GOSUB  190
300 FOR  J= 1 TO  4
320 POKE  61443+ J,BRD(I,J)
330 NEXT  J
340 GOTO 480
350 REM  COMPUTER GUESS
351 MSG$(2)= "OFFERS THE FOLLOWING GUESS....."
352 GOSUB  1450
360 IF  I> 1 THEN FOR  J= 1 TO  4:BRD(I,J)= PEEK (61443+ J):NEXT  J:GOTO 470
370 BRD(1,1)= FN R(6)
380 BRD(1,2)= BRD(1,1)
390 BRD(1,3)= FN R(6):IF  BRD(1,3)= BRD(1,2) THEN GOTO 390
400 BRD(1,4)= FN R(6):IF  BRD(1,4)= BRD(1,1) OR  BRD(1,4)= BRD(1,3) THEN GOTO 400
410 FOR  J= 1 TO  4
420 A1= FN R(4):A2= FN R(4):SV= BRD(I,A1):BRD(I,A1)= BRD(I,A2):BRD(I,A2)= SV
430 NEXT  J
440 FOR  J= 1 TO  4
450 POKE  61443+ J,BRD(I,J)
460 NEXT  J
470 SX= 47:SY= 1+ ((I- 1)* 3):SI= I:GOSUB  1600
480 REM  GRADE GUESS
481 GOSUB  1440:MSG$(1)= "CODEMAKER, "+ PL$(MAKE)
482 MSG$(2)= "MUST GRADE THE GUESS BY AWARDING ONE"
483 MSG$(3)= "BLACK PEG FOR EACH COLORED PEG WHICH"
484 MSG$(4)= "IS CORRECT IN BOTH COLOR AND POSITION"
485 MSG$(5)= "--AND--ONE WHITE PEG FOR ANY REMAINING"
486 MSG$(6)= "PEG WHICH IS CORRECT IN COLOR BUT NOT"
487 MSG$(7)= "POSITION (MAX OF 4 PEGS TOTAL)."
490 IF  ROLE(MAKE)= 0 THEN GOTO 580
500 POKE  61452,0
502 FOR  ZI= 1 TO  4
504 POKE  61439+ ZI,BRD(0,ZI)
506 NEXT  ZI
510 PO= CALL (0):BRD(I,5)= PEEK (61448):BRD(I,6)= PEEK (61449)
511 MSG$(9)= "YOUR GUESS IS GRADED AT RIGHT"
512 GOSUB  1450:GOSUB  2400:REM  PRINT AND GRADE
520 IF  BRD(I,5)= 4 THEN  GOSUB  1440:GOTO 770
530 IF  ROLE(BREAK)= 1 THEN  GOTO  621
570 GOTO 630
580 MSG$(8)= "GRADE THE GUESS WITH BLACK OR WHITE"
581 MSG$(9)= "PEGS BY PRESSING THE BLACK(P) OR"
582 MSG$(10)= "WHITE(W) KEYS.  THE <- WILL ERASE THE"
583 MSG$(11)= "GRADE RESPONSE TO ALLOW REGRADING THIS"
584 MSG$(12)= "GUESS.  PRESS RETURN/ENTER KEY WHEN"
585 MSG$(13)= "YOU HAVE COMPLETED GRADING THIS GUESS."
586 GOSUB  1450
587 BRD(I,5)= 0:BRD(I,6)= 0:TPEG= 0
588 GOSUB  1700:TPEG= TPEG+ 1:REM  GET ONE BYTE
589 IF  NV= 13 THEN  GOTO  595:RETURN  KEY HIT
590 IF  TPEG< 5 AND  ANS$= "W" THEN  BRD(I,6)= BRD(I,6)+ 1:BW= 1:GOSUB  2600:GOTO  588
591 IF  TPEG< 5 AND  ANS$= "P" THEN  BRD(I,5)= BRD(I,5)+ 1:BW= 0:GOSUB  2600:GOTO  588
592 IF  NV= 26 THEN  GOSUB  2700:GOTO  587
593 PLOT  3,0,31,11:PRINT  "ONLY BLACK, WHITE, <-, OR RETURN"
594 TPEG= TPEG- 1:GOTO  588
595 IF  ROLE(1)= 1 OR  ROLE(2)= 1 THEN  GOTO  600
596 POKE  61452,0:FOR  ZI= 1 TO  4:POKE  61439+ ZI,BRD(0,ZI):NEXT  ZI
597 PX= CALL (0)
598 IF  BRD(I,5)< > PEEK (61448) OR  BRD(I,6)< >  PEEK (61449) THEN  GOTO  690
600 PLOT  3,0,31,11:PRINT  "GRADING COMPLETED."
610 POKE  61448,BRD(I,5):POKE  61449,BRD(I,6)
620 IF  BRD(I,5)= 4 THEN  GOSUB  1440:GOTO 770
621 POKE  61452,4:REM  GRADE AGAINST POSSIBILITIES
622 PO= CALL (4)
623 POKE  61452,2:REM  SELECT ANSWER RTN
624 XX= CALL (FN R(PO))
630 SV= I:FOR  I= 1 TO  SV
631 SX= 47:SY= 1+ ((I- 1)* 3):SI= I
632 GOSUB  1600:GOSUB  2400:REM  DRAW PEGS AND MARKERS
633 NEXT  I:I= SV
670 IF  ROLE(MAKE)= 1 THEN GOTO 740
680 IF  PO> 0 THEN GOTO 730
690 FOUL= 0:PLOT  3,0,31,11:PRINT  "A FOUL IS DECLARED....":GOSUB 830
700 IF  FOUL= 0 THEN GOTO 760
710 SCR(BREAK)= SCR(BREAK)+ 3
720 GOTO 110
730 PLOT  3,0,31,11:PRINT  PO;" POSSIBILITIES REMAIN."
740 NEXT  II
750 REM  FALL OUT OF 10 ITERATION LOOP HERE
751 GOSUB  1440
752 MSG$(1)= "THAT COMPLETES 10 ATTEMPTS.."
753 MSG$(3)= "   THATS ALL FOLKS."
760 I= 10
761 GOTO  775
770 MSG$(1)= "CODEBREAKER, "+ PL$(BREAK)
771 MSG$(2)= "HAS SUCCESSFULLY GUESSED THE CODE."
775 SCR(MAKE)= SCR(MAKE)+ I
780 MSG$(6)= PL$(MAKE)+ "'S SCORE INCREASED BY"
781 MSG$(7)= STR$ (I)+ " POINTS."
785 GOSUB  1400:SX= 28:SY= 28:SI= 0:GOSUB  1600:GOSUB  1450
800 SA= MAKE:MAKE= BREAK:BREAK= SA:REM  REVERSE ROLES
805 IF  MAKE< > 1 THEN  FOR  K= 1 TO  2500:NEXT  K:GOTO  110
806 SET= SET+ 1:IF  ROLE(1)= 1 AND  ROLE(2)= 1 THEN  FOR  K= 1 TO  2500:NEXT  K:GOTO  110
807 PLOT  3,0,31,11:INPUT  "  WANT TO PLAY ANOTHER SET? ";ANS$
808 IF  LEFT$ (ANS$,1)< > "Y" THEN  PLOT  12,27,11:END
809 GOTO  110
830 REM  ROUTINE TO VERIFY MISGRADED GAME
831 GOSUB  1440
832 MSG$(1)= "A FOUL IS CALLED........."
840 MSG$(3)= "I BELEIVE YOU GRADED INCORRECTLY."
845 MSG$(4)= "IF I CAN DEMONSTRATE THAT, I WILL BE"
850 MSG$(5)= "AWARDED THREE POINTS AND THIS GAME"
853 MSG$(6)= "IS REPLAYED."
856 MSG$(8)= "IF YOU GRADED CORRECTLY, YOU WILL BE"
859 MSG$(9)= "AWARDED THE FULL TEN POINTS!"
860 IF  SVD(0)= 0 THEN  GOTO  864
861 FOR  LZ= 1 TO  4:BRD(0,LZ)= SVD(LZ):NEXT  LZ
862 GOSUB  1450
863 FOR  YZ= 1 TO  1500:NEXT  YZ:GOTO  900
864 MSG$(12)= "ENTER YOUR CODE NOW..."
865 GOSUB  1450:SI= 0:OX= 28:OY= 28:GOSUB  190
900 FOR  L= 1 TO  4
920 POKE  61439+ L,BRD(0,L)
930 NEXT  L
940 FOR  L= 1 TO  I
950 FOR  L2= 1 TO  4
960 POKE  61443+ L2,BRD(L,L2)
970 NEXT  L2
980 POKE  61452,0:XX= CALL (0)
990 IF  PEEK (61448)< > BRD(L,5) OR  PEEK (61449)< > BRD(L,6) THEN GOTO 1040
1000 NEXT  L
1010 GOSUB  1440
1011 MSG$(2)= "BOY! IS MY FACE R E D !!!"
1012 MSG$(4)= "I RUE THE DAY I EVER THOUGHT TO"
1013 MSG$(5)= "QUESTION YOU--YOU'VE EARNED 10 POINTS."
1014 GOSUB  1450:FOR  K= 1 TO  1500:NEXT  K
1020 FOUL= 0
1030 RETURN
1040 GOSUB  1440
1041 MSG$(1)= "SORRY,"+ PL$(MAKE)
1042 MSG$(3)= "YOU GRADED TURN "+ STR$ (L)+ " TO BE"
1043 MSG$(4)= STR$ (BRD(L,5))+ " BLACK AND "+ STR$ (BRD(L,6))+ " WHITE."
1044 MSG$(6)= "TO BE GRADED CORRECTLY IT SHOULD HAVE"
1045 MSG$(7)= STR$ (PEEK (61448))+ " BLACK AND "+ STR$ (PEEK (61449))+ " WHITE."
1050 GOSUB  1450
1052 PLOT  3,42,1+ ((L- 1)* 3):PRINT  ">>->"
1054 PLOT  3,42,2+ ((L- 1)* 3):PRINT  ">>->"
1060 FOUL= 1
1070 PLOT  3,0,31,11:INPUT  "PRESS ENTER TO CONTINUE GAME/SET.";ANS$
1080 RETURN
1200 GOSUB  33000
1201 ZQ= PEEK (33209)+ (PEEK (33210)* 10)
1202 ZQ= RND (- ZQ)
1205 PL$(1)= "COMPUCOLOR II":PL$(2)= "COMPUCOLOR II"
1210 PLOT 27,4:PRINT "LOAD GRADE":PLOT 27,27
1220 PLOT  6,4,3,8,5
1260 INPUT  "HOW MANY WILL PLAY (0,1,OR 2):";PLAY
1270 IF  PLAY< 0 OR  PLAY> 2 THEN  GOTO  1220
1280 IF  PLAY= 0 THEN  ROLE(1)= 1:ROLE(2)= 1:RETURN
1290 IF  PLAY= 2 THEN  ROLE(1)= 0:ROLE(2)= 0:GOSUB  1330:GOSUB  1340:RETURN
1300 PLOT  3,8,6:INPUT "WOULD YOU CARE TO GO FIRST: ";ANS$
1310 IF  LEFT$ (ANS$,1)= "Y" THEN  ROLE(1)= 1:ROLE(2)= 0:GOSUB  1340:RETURN
1320 ROLE(1)= 0:ROLE(2)= 1:GOSUB  1330:RETURN
1330 PLOT  3,8,7:INPUT  "NAME PLAYER1: ";PL$(1)
1331 IF  LEN (PL$(1))< 2 OR  LEN (PL$(1))> 25 THEN  GOTO  1330
1332 PL$(1)= ""+ PL$(1)+ ""
1333 RETURN
1340 PLOT  3,8,8:INPUT  "NAME PLAYER2: ";PL$(2)
1341 IF  LEN (PL$(2))< 2 OR  LEN (PL$(2))> 25 THEN  GOTO  1340
1342 PL$(2)= ""+ PL$(2)+ "":RETURN
1350 REM  ROUTINE TO ERASE AND REDRAW BOARD
1355 PLOT  27,24:REM  PAGE MODE
1360 PLOT  6,5,12,2,0,5,242,127,5,127,127,0,127,0,5
1370 PLOT  253,83,5,242,83,127,119,127,119,5
1375 PLOT  253,0,17,242,83,17
1380 PLOT  253,0,90,242,83,90,83,110,0,110,255
1390 PLOT  3,8,2,14:PRINT  "* * M A S T E R M I N D * *"
1400 PLOT  3,2,5:PRINT  "* PLAYER NAME *     / SET # ";SET;" / SCORE"
1410 PLOT  3,2,6:PRINT  PL$(1):PLOT  3,36,6:PRINT  SC(1)
1420 PLOT  3,2,8:PRINT  PL$(2):PLOT  3,36,8:PRINT  SC(2)
1425 PLOT  3,2,28:PRINT  "CODEMAKERS HIDDEN CODE ="
1430 RETURN
1440 FOR  IM= 0 TO  15:MSG$(IM)= "":NEXT  IM:RETURN
1450 FOR  IM= 0 TO  15
1460 PLOT  3,2,11+ IM
1470 PRINT "                                      "
1475 PLOT  3,2,11+ IM
1476 IF  LEN (MSG$(IM))> 38 THEN  MSG$(IM)= LEFT$ (MSG$(IM),38)
1480 PRINT  MSG$(IM)
1490 NEXT  IM
1500 RETURN
1600 FOR  SJ= 1 TO  4:GOSUB  1610:SX= SX+ 3:NEXT  SJ:RETURN
1610 PLOT  6,BRD(SI,SJ):REM  SET COLOR OF PEG
1620 PLOT  3,SX,SY:PRINT  "tu":PLOT  3,SX,SY+ 1:PRINT  "vw":RETURN
1700 PLOT  3,0,31
1705 POKE  61452,3:NV= CALL (3):ANS$= CHR$ (NV)
1710 PLOT  3,0,31:RETURN
1800 IF  NV= 13 OR  NV= 26 THEN  GOTO  1820
1805 IF  (NV> = 81 AND  NV< = 86) THEN  GOTO  1820
1808 PLOT  3,0,31,11:PRINT  "PRESS ONE OF THE COLORED KEYS."
1810 GOSUB  1700
1815 GOTO  1800
1820 IF  SJ< 0 THEN  SJ= 0
1825 IF  NV= 13 OR  NV= 26 THEN  RETURN
1826 IF  SJ< = 4 THEN  SJ= SJ+ 1
1827 IF  SJ= 5 THEN  PLOT  3,0,31,11:PRINT  "PRESS RETURN TO ENTER MOVE.":RETURN
1830 BRD(SI,SJ)= NV- 80
1835 RETURN
2400 TPEG= 0:IF  BRD(I,5)= 0 THEN  GOTO  2500
2402 BW= 0
2405 FOR  IX= 1 TO  BRD(I,5):TPEG= TPEG+ 1:GOSUB  2600:NEXT  IX
2500 IF  BRD(I,6)= 0 THEN  RETURN
2505 BW= 1
2510 FOR  IX= 1 TO  BRD(I,6):TPEG= TPEG+ 1:GOSUB  2600:NEXT  IX
2515 RETURN
2600 IF  BW= 0 THEN  PLOT  6,56
2605 IF  BW= 1 THEN  PLOT  6,7
2610 IF  TPEG= 1 THEN  PLOT  3,60,1+ ((I- 1)* 3)
2615 IF  TPEG= 2 THEN  PLOT  3,62,1+ ((I- 1)* 3)
2620 IF  TPEG= 3 THEN  PLOT  3,60,2+ ((I- 1)* 3)
2625 IF  TPEG= 4 THEN  PLOT  3,62,2+ ((I- 1)* 3)
2630 PRINT  "d";:PLOT  6,6
2635 RETURN
2700 PLOT  6,6,3,60,1+ ((I- 1)* 3):PRINT  "   "
2710 PLOT  3,60,2+ ((I- 1)* 3):PRINT  "   "
2720 RETURN
33000 PLOT  30,22,12:REM  SET CYAN BACKGROUND
33010 PLOT  29,21,2,10,10,242,10,117,117,117,117,10,10,10,255:REM  BOARDER
33020 PLOT  3,8,5:PRINT  "SCORE: 5 TO 6"
33030 PLOT  3,20,12:PRINT  "M A S T E R   M I N D"
33040 PLOT  3,10,18:PRINT  "AN INTERACTIVE GAME OF SKILL FOR 0, 1, OR"
33050 PLOT  3,13,20:PRINT  "TWO PLAYERS......."
33060 PLOT  3,9,23:PRINT  "tu tu tu tu  dd   <==<<  YOU WIN ....."
33070 PLOT  3,9,24:PRINT  "vw vw vw vw  dd"
33080 PLOT  3,9,26:PRINT  "tu tu tu tu  dd"
33090 PLOT  3,9,27:PRINT  "vw vw vw vw  d"
33100 RETURN