General Instructions
Codeword is a computerised version of the popular word puzzle (also known as Codebreak or Crosswise. It takes place on a crossword-like grid, but instead of clues the numbers in the white squares represent letters, and the same number is always the same letter.
You will first of all be asked which puzzle you would like to play. 10 puzzles are provided, and it's easy to add more of your own. There is a short delay while the computer 'shuffles' the numbers - it chooses which number to assign to which letter - meaning that if you play the same puzzle again, different numbers will represent different letters.
The display consists of the codeword grid, shown to the top left, with unused letters below, and on the right is a list of numbers 1-26 to which any letters are currently assigned. The computer will help you get started by assigning a few letters to this list. These letters will also be placed at the appropriate positions on the codeword grid.
Now, if you think that A=1, type in A01 at the prompt (or if you think B=14 then type B14 and so on) and press RETURN. The letter A will be printed in every square with the number 1 in it. If you change your mind, type A00 (or simply A) followed by RETURN to remove the letter A from the grid. You can't assign a letter to a number, or a number to a letter, already used; if you try to do this you'll be told off.
When you think you've solved the puzzle, press RETURN (without typing anything in) and wait while the computer checks your result against the answer. You'll receive a congratulatory message if your solution is correct. Have fun!
Technical Notes
Adding Your Own Puzzles
The puzzles are arranged in a text file like so:
GASKET PUMAS <--- 12 letters followed by carriage return L E R O A U INTEREST C N N P S EWERS TOSSES N R E O ENTRANT PROFUSE T * <--- note any character other than A-Z can be used to R T N GRIEVE separate words; here I have used * to make sure OTHER R N L the line is exactly 12 characters long. P S EXORCISE E A A I U G ROYAL DIRECT (carriage return) NEXT PUZZLE <--- Beginning of next puzzle
and so on for all 10 puzzles. The default set of puzzles was arranged in View.
Memory Allocation
Codeword uses its own set of Times-style fonts. These are user-defined graphics characters held in pages &9-C. The statement ?&367=15 sets bits 0-3 (i.e. 1+2+4+8) of the fonts flag at location &367 so that characters 224-255 (bit 0), 192-223 (bit 1), 160-191 (bit 2), and 128-159 (bit 3) can all be defined. The statement !&36B=&0C0B0A09 sets the values at &36B-E to &9-C, the PAGE number of where the character definitions are located. If the program finds itself running on a BBC Master, INKEY-256=253, then the characters are peeked out of memory and defined with VDU23.
The text file containing the puzzles is loaded in at &1100; the default set is called CWDATA1. BBC Master owners must therefore set PAGE to &1700 or higher to play Codeword.
Main Procedures
add | Adds the letter L% to the grid, prints a blank at the appropriate position in the letter list. Correct co- ordinate given by (L% MOD 13,13+L% DIV 13). E.g. for the letter N, L%=13 so (L% MOD 13,13+L% DIV 13) = (0,14). Then prints letter at right position in number list, see line 520. Sets byte in 'plyd%' to L%+1 (because 0 in the array means that no letter has been assigned to that number). |
init | Initialisation routine. Loads the fonts and text file (see text). |
mssg(A$) | Prints the string A$ in the special font at the centre of the screen. |
number(X%,Y%,A%) | Prints number A% at (X%,Y%) in small font. Note how correct graphics char given for each digit, e.g. for A%=12, 232+12 DIV 10 = 233; 232+12 MOD 10 = 234. CHR$232 is start of the 'small number' fonts. PLOT 0,-16,0 backspaces half a character back in VDU5 |
play | Prompts the player to a letter and number. String A$ should contain something like A01, in which case N%=1, and L%=0. Function FNokay will return FALSE if it's anything different. Adds (if N%>0) or takes away (N%=-1=TRUE, the result of doing ASCLEFT$(A$,1) when A$="") the letter from the grid. |
screen | Shuffles the letters, draws the grid lines, prints Codeword title, prints list of digits on the right hand side. Puts the numbers on the grid, and chooses some letters to start the player off. |
shuffle | Chooses the numbers to which the letters are assigned. First arrange numbers 1-26 in random order in 'playd%'. Then fill grid with numbers that correspond to the letters given in the puzzle in the text file, e.g. value in playd%?1 is the number assigned to the letter B. |
sub | Subtracts letter from grid, prints blank in number list and restores letter to right position in letter list (see notes on PROCadd). |
tile(X%,Y%,A%) | Prints letter A% in big font at (X%,Y%), where A%=1 for A, A%=2 for B etc. excepting special case where A%=0 and blank square printed. Correct group of 2x2 characters worked out from 124+A%*4. E.g. for letter B, 124+A%*4 = 124+2*4 = 32. |
Functions
lett(L%) | Finds the number assigned to letter L% by searching the 'playd%' array. If it's in there, function will return with 0-25; if it isn't, function will return with 26. |
okay | Checks string typed in by player. If A$="" then they pressed RETURN so end procedure with FNsolvd. If length of string is more than 3, or letter isn't A-Z then player mistyped. If the string is OK, then check to see that letter hasn't already been played. |
solvd | Checks player's solution against actual answer. C% set to TRUE to begin with, then if any letter in the player's grid doesn't match, function will end with C%=FALSE. |
Chris Dewhurst, EUG #55