Magazine    : Personal Computing Today
Issue       : April 1984
Location    : Pages 86 and 87
Author      : D J Fazackerley

COMBINATIONS
---------------------------------------------------------------------
I've started, so I'll finish..... says D J Fazackerley who has
concocted this game to run on your 16K or 48K Spectrum.
---------------------------------------------------------------------

The game is based on the popular brain teaser "Mastermind". The
Sinclair Spectrum chooses an eight character string, and you have to
find out what it is. You are allowed nine guesses! As you enter each
guess it is printed on the screen. Underneath the Spectrum prints
eight 'clues', one for each of the characters in your guess.
These clues are; a green square for the right character in the right
place; a red square for the right character in the wrong place; a 
blank if the character is not in the Spectrum's chosen string. The
Spectrum can only award one coloured square for each of the
characters in its string.
There are two levels of play, 'numbers' and 'letters'. In 'numbers'
the Spectrum chooses from the digits 0 to 9 to form its string. In
the more difficult 'letters', characters A to T are used. Other than
these restrictions, selection is random and a particular character
may be chosen more than once.
You may be wondering why such a simple theme requires this long
program. The answer is that it doesn't! A large portion of the
program is dedicated to presentation. It is a sad fact that some
programmers tend to ignore the presentation which is silly because
there is nothing worse than a game with no sound and boring, dull
graphics. If, as in this case, a game has no graphics, then add some.
They really do make all the difference.
The program is relatively straight forward. One point of particular
interest is a statement in line 97, RANDOMIZE USR 4317. This
activates a routine in ROM that changes character mode. The program
'plays' in upper case mode. When you play 'letters' it is a nuisance
to have to use the shift key, so this line will automatically set
upper case mode (if you are not already in it).

HOW IT RUNS

Lines	 8- 30	Poke USR characters. Use data in lines 600 to 606.
Lines	46- 80	Draw the basic screen layout. Use the subroutine at
		line 1000 which draws rectangles. The dimensions of
		the rectangles are held in the data statements 1020
		to 1040.
Line	88	Sets variables ready for the game.
		(The program returns to this point when you play the
		game again.)
Lines 	90-120	Ask whether you want to play numbers or letters.
		Characters from 0 to 9 or from A to T according to
		your choice are selected at random and stored in a
		character array.
Lines  134-156	FOR NEXT loop.
		Inputs your guess, one character at a time using
		INKEY$. Each character is checked, printed on the
		screen, and stored into an array.
Lines  170-192	This section checks your guess against the computers
		string and prints the 'clues'. If you have guessed
		the string the program jumps to line 400. If you have
		not guessed all eight and have not had nine attempts
		then the program jumps back to let you guess again.
Lines  202-204	You have lost. An appropriate message is printed!
Lines  300-320	Print the answer. Ask if you want another go. If the
		answer is yes, part of the screen is cleared and the
		program returns to line 88.
Lines  400-406	If you win a game then the program jumps to here. The
		program selects an 'appropriate' message (based on,
		whether you are playing numbers or letters, and how
		many goes you took), prints it and returns to line 300.

HINTS ON CONVERSION

Conversion of the program is quite simple. But unless your screen
configuration is very similar to the Spectrum's the graphic
instructions are unlikely to produce the right results. My advice is
to try the program and then adjust the graphics to your satisfaction.
If necessary invent your own graphics! Line 97 of the program must be
either replaced with the equivalent instruction for your computer, or
left out of the program.

Variables Used

S1	: Your score.
S2	: Spectrum's score.
b$	: Character array that contains your guess.
X$	: Character array that contains the Spectrum's string.
W$	: A copy of X$.
g	: Vertical print position.
K	: Horizontal print position.
q	: Set to zero if you are playing 'numbers'. One, if playing
	  'letters'.
e	: A count of how many characters in the computer's string you got
	  right.
J	: Variables used for
M	: 'general purpose'
N	: applications ie FOR NEXT loops.

---------------------------------------------------------------------
Alterations made by person typing in this program

336 IF INKEY$ ="n" OR INKEY$ ="N" THEN GO SUB 2000: PRINT AT 20,12;"***OK***": STOP

Added the

OR INKEY$ ="N"

to the line above