Mixed Game Bag 2 is a collection of three separate BASIC games: a memory-matching board game, a sequence-memorization quiz called Memory Magic, and a code-breaking game called Supermind (similar to Mastermind). The matching game draws a grid using block graphics, populates cells with random characters (ASCII codes 38–63) and bomb tokens, and uses PEEK of the print position address (16398/16399) to detect whether a cell is already revealed. Memory Magic generates random sequences of letters, numbers, or both at configurable difficulty levels, flashing each character briefly on screen before prompting recall. Supermind implements the classic code-breaking logic with configurable code length, tracking correct characters in correct positions (B) versus correct characters in wrong positions (D) using parallel flag arrays N and P.
Program Analysis
Program Structure
The listing contains three independent programs concatenated together, each beginning at line 1. They share no variables or control flow between them.
- Game 1 – Grid Matching Game (lines 1–540): A two-player tile-reveal game played on a printed grid.
- Game 2 – Memory Magic (lines 1–560): A sequence-memorization quiz with selectable character sets and difficulty levels.
- Game 3 – Supermind (lines 1–315): A Mastermind-style code-breaking game with adjustable code length and character set.
Game 1: Grid Matching Game
The board is a 8×8 logical grid displayed between columns 2–18 and rows 2–16 using block graphics printed with PRINT AT. Lines 10–90 draw the grid lines using filled-block characters. Lines 130–180 label columns with characters from ASCII 37 upward and rows with numerals.
The cell contents are stored in R$(64,1) — a 64-element, 1-character-wide string array. Lines 10–40 fill each slot with a random character in the range CHR$(INT(RND*26+38)), giving characters from ASCII 38 to 63. Lines 41–43 then overwrite 8 random cells with a bomb token ([▒], displayed as the inverse-video block graphic character).
Player input is validated at lines 230–240 and 441–442: a two-character string is required where the first character is a column letter (ASCII 38–45, i.e., &'()*+,-) and the second character is a digit 1–8. The cell index is computed at lines 420–430 and 460–470 as N = VM*8 + CM - 9.
Notable Technique: PEEK-Based Cell State Detection
Lines 432 and 485 use an interesting idiom to detect whether a cell has already been revealed:
IF PEEK (PEEK 16398+256*PEEK 16399)<>0 THEN GOTO 220
System variables 16398 and 16399 hold the low and high bytes of the current print position in the display file. After issuing a PRINT AT with no output, the program PEEKs the character code at that screen location. If it is non-zero, the cell already contains a character and the move is rejected. This avoids maintaining a separate “revealed” flag array and directly queries the display file state.
Bug: Copy-Paste Error in Game 1 Validation
Line 442 validates the second player’s input P$ but mistakenly tests VAL M$(B) (the first player’s input) instead of VAL P$(B). This means the row-range check for player 2’s move always uses player 1’s last row value rather than the newly entered one, which could allow invalid inputs to pass or valid inputs to be rejected.
Game 2: Memory Magic
This game challenges the player to memorize a sequence of characters flashed one at a time on screen. Difficulty level S (1–5) controls both the number of characters (S*2) and the display duration (inner loop 12/S iterations at line 350 — higher levels show each character for fewer iterations).
The character set is selected at lines 170–190 using INKEY$ after a PAUSE 40000:
- Letters only:
X=38, Y=26→ ASCII 38–63 (punctuation/uppercase range on this system) - Numbers only:
X=28, Y=10→ ASCII 28–37 - Both:
X=28, Y=36→ ASCII 28–63
All characters in the sequence are stored as individual characters in N$(1,1 TO 100) — a single-row, 100-column string. The answer check at line 420 compares the input C$ against the slice N$(1,1 TO K). Scores accumulate across rounds as D = D + (J-1)*S.
Line 550 contains a SAVE "MEMOR[Y]" statement embedded in the program but unreachable from normal execution flow; it serves as an in-listing note of the save filename.
Game 3: Supermind
This is a fully functional Mastermind clone. The secret code A$ is a string of M = L+2 characters drawn from block-graphic characters starting at ASCII 128. The player inputs guesses as G$ and receives two scores per guess:
- B – characters correct in the correct position
- D – characters correct but in the wrong position
The scoring algorithm uses two parallel integer arrays, N(7) and P(7), as match flags. Array N marks positions where G$(X) = A$(X) (exact matches), preventing those positions from contributing to the D count. Array P prevents double-counting of secret code characters already matched. The outer loop iterates over guess positions; the inner loop scans all code positions for a character match, skipping any already flagged in either array.
Results are printed using SCROLL (lines 260–261, called twice) to make room at the bottom of the screen, with columns for guess number, total matched characters, and exact position matches displayed via TAB.
The configurable level display at line 70 shows the applicable block graphic characters by slicing C$ as C$(F TO H*M), where F=1 and H=2, so each graphic in the string is separated by a space and two characters are selected per code position.
Key Variables Summary
| Game | Variable | Role |
|---|---|---|
| 1 | R$(64,1) | Board cell contents (1 char each) |
| 1 | N, L | Cell indices for players M and P |
| 2 | N$(1,100) | Sequence storage |
| 2 | S | Difficulty level (1–5) |
| 2 | D | Cumulative score |
| 3 | A$(M) | Secret code |
| 3 | B, D | Position-correct and char-correct counts |
| 3 | N(7), P(7) | Match-flag arrays for scoring |
Content
Image Gallery
Source Code
1 RAND
2 FAST
3 LET A=1
4 LET B=2
5 DIM R$(64,A)
10 FOR X=A TO 64
20 LET R$(X)=CHR$ (INT (RND*26+38))
40 NEXT X
41 FOR X=A TO 8
42 LET R$(INT (RND*64+A))="[▒]"
43 NEXT X
50 FOR X=A TO 15 STEP B
60 PRINT AT X,B;"█████████████████"
70 PRINT " █ █ █ █ █ █ █ █ █"
80 NEXT X
90 PRINT AT 17,B;"█████████████████"
130 FOR X=3 TO 17 STEP B
140 PRINT AT 0,X;CHR$ ((X-A)/B+37)
150 NEXT X
160 FOR X=B TO 16 STEP B
170 PRINT AT X,0;X/B
180 NEXT X
200 SLOW
220 INPUT M$
230 IF LEN M$<>B THEN GOTO 220
240 IF CODE M$(A)<38 OR CODE M$(A)>45 OR VAL M$(B)<A OR VAL M$(B)>8 THEN GOTO 220
400 LET VM=VAL M$(B)
410 LET CM=CODE M$(A)-36
420 LET N=VM*8+CM-9
430 PRINT AT B*VM,B*CM-A;
432 IF PEEK (PEEK 16398+256*PEEK 16399)<>0 THEN GOTO 220
435 PRINT AT B*VM,B*CM-A;R$(N)
440 INPUT P$
441 IF LEN P$<>B THEN GOTO 440
442 IF CODE P$(A)<38 OR CODE P$(A)>45 OR VAL M$(B)<A OR VAL M$(B)>8 THEN GOTO 440
450 LET VP=VAL P$(B)
460 LET CP=CODE P$(A)-36
470 LET L=VP*8+CP-9
480 PRINT AT B*VP,B*CP-A;
485 IF PEEK (PEEK 16398+256*PEEK 16399)<>0 THEN GOTO 440
490 PRINT AT B*VP,B*CP-A;R$(L)
500 IF R$(N)=R$(L) OR R$(N)="[▒]" OR R$(L)="[▒]" THEN GOTO 220
510 PAUSE 250
520 PRINT AT 2*VM,2*CM-1;" "
530 PRINT AT 2*VP,2*CP-1;" "
540 GOTO 220
1 RAND
10 DIM N$(1,100)
20 LET J=1
30 LET D=0
100 PRINT AT 0,8;"MEMORY MAGIC";AT 1,8;"▀▀▀▀▀▀▀▀▀▀▀▀"
110 PRINT AT 4,6;" INPUT LEVEL (1-5)?"
120 INPUT S
130 PRINT AT 8,3;"NUMBERS, LETTERS OR BOTH?"
140 LET X=28
150 LET Y=26
160 PAUSE 40000
170 IF INKEY$ ="L" THEN LET X=38
180 IF INKEY$ ="N" THEN LET Y=10
190 IF INKEY$ ="B" THEN LET Y=36
200 FOR I=J TO (J-1+S*2)
210 LET N$(1,I)=CHR$ (INT (RND*Y+X))
220 NEXT I
230 CLS
300 FOR J=1 TO I-1
310 LET A=INT (RND*22)
320 LET B=INT (RND*32)
330 PRINT AT A,B;N$(1,J)
340 FOR V=1 TO 12/S
350 NEXT V
360 PRINT AT A,B;" "
370 NEXT J
400 PRINT AT 11,4;" INPUT YOUR ANSWER?"
410 INPUT C$
415 LET K=J-1
420 IF C$=N$(1,1 TO K) THEN GOTO 500
430 PRINT AT 11,4;"WRONG, TRY AGAIN..."
440 PAUSE 250
445 CLS
450 GOTO 300
500 LET D=D+(J-1)*S
505 PRINT AT 11,4;"CORRECT, YOUR SCORE ";D
510 PRINT AT 17,8;"PLAY AGAIN?"
520 PAUSE 40000
530 IF INKEY$ ="Y" THEN GOTO 200
540 GOTO 600
550 SAVE "MEMOR[Y]"
560 PRINT AT 9,6;"TO START PRESS:";AT 11,4;"""RUN"" THEN""ENTER"""
1 LET F=1
2 LET H=2
5 LET C$="█ ▟ ▙ ▄ ▜ ▐ ▚ ▛"
10 PRINT AT F,9;"SUPERMIND"
20 PRINT AT H,9;"▀▀▀▀▀▀▀▀▀"
30 PRINT AT 6,H;" INPUT DESIRED LEVEL (1 TO 5)"
40 INPUT L
45 LET M=L+H
50 PRINT AT 6,H;" LEVEL ";L;" RULES: "
60 PRINT AT 9,3;"CODE LENGTH............ ";M
70 PRINT AT 11,3;"CHARACTERS: ";C$(F TO H*M)
75 PAUSE 200
80 DIM A$(M)
100 FOR X=F TO M
110 LET A$(X)=CHR$ (INT (RND*(L+2)+128))
120 NEXT X
130 CLS
140 PRINT " READY TO START"
141 PAUSE 200
142 PRINT AT 20,0;"NO. GUESS CHAR. POS."
145 LET K=0
150 INPUT G$
151 IF G$="X" THEN GOTO 320
152 DIM N(7)
153 LET T$=" "
155 IF LEN G$<>LEN A$ THEN GOTO 150
160 LET B=0
170 LET D=0
180 LET K=K+F
190 FOR X=F TO M
195 IF G$(X)<>A$(X) THEN GOTO 208
200 LET B=B+F
202 LET N(X)=F
204 GOTO 210
208 LET N(X)=0
210 NEXT X
214 DIM P(7)
215 FOR X=F TO M
220 IF N(X)=F THEN GOTO 245
225 FOR Y=F TO M
230 IF N(Y)=F THEN GOTO 242
231 IF P(Y)=1 THEN GOTO 242
232 IF G$(X)<>A$(Y) THEN GOTO 242
233 LET P(Y)=1
239 LET D=D+F
240 GOTO 245
242 NEXT Y
245 NEXT X
260 SCROLL
261 SCROLL
270 FOR X=F TO M
280 PRINT AT 20,8-L+2*X;G$(X)
290 NEXT X
300 PRINT AT 20,F;K;TAB 21;D+B;TAB 27;B
305 PRINT
310 IF G$<>A$ THEN GOTO 150
315 PRINT AT 20,20;"SUPERMIND"
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.