Wordsearch: A Comparison between the ZX80 and TS1000

Last year, during the return of the Comet Halley, my planetarium was planning to send a monthly newsletter to the local elementary schools. In order to provide a little diversion, a good word search puzzle was to be included in each newsletter. The program to generate such a puzzle was found in “THE BEST OF SYNC: VOL. I” ( (c)1983 Creative Computing Press, page 24).

A problem soon arose however, in that the program would work fine on the ZX80 for which it was written, but wouldn’t work on a TS1000. After reading many sources comparing and explaining the differences between the two computers, several modifications were made to the original program in an attempt to get it to work on the TS1000. All to no avail.

The author of the original program, Bill McCray, was located and consulted. Mr. McCray stated that he had never produced a TS1000 version of his WORDSEARCH program. Futhermore, while several other people had contacted him about the problem of ZX80/TS1000 incapatability, to date he was not aware of anyone sucessfully modifying his program to run on the TS1000. Mr. McCray did suggest that perhaps examining the sections of the program that depend on relational operators might shed some light on the incapatibility problem.

That was an area that had been overlooked during research of comparisons between the two computers. In fact, the differences as to how the two machines handle relational operators turned out to be the key to making the WORDSEARCH program operate successfully on the TS1000. In the process of translating from ZX80 Basic to TS1000 Basic, a number of “tricks” were discovered that allow successful conversion of programs between the two computers. Please follow along with the listing of the modified and now working program. Also note that in all references given below, ZX81 is equivalent to TS1000. Program lines have also been renumbered so they no longer match those given in “THE BEST OF SYNC” for the ZX80.

Before we delve into relational operators, a few other differences in ZX80 Basic vs. TS1000 Basic need to be explained. In lines 20 and 30 of the listing, two arrays are DIMensioned. The first holds the 165 characters of the 11 X 15 puzzle. The second holds the character codes for each letter of the 11 letter words that will be entered into the puzzle. On the two machnes the lines would be entered differently:

ZX80: 20 DIM A(164)      ZX81: 20 DIM A(165)
      30 DIM B(10)             30 DIM B(11)

The differences arise because because a ZX80 array allows a 0th element. The arrary is therefore dimensioned 0 to 164.

Because a 0th element is possible, some of the FOR…NEXT loops in the program start and end with different varible values. The varible C, for instance, takes on the values 0 to 10 in the ZX80 version while it ranges from 1 to 11 in the ZX81 version.

ZX80: 170 FOR C=0 to 10
ZX81: 170 FOR C=1 to 11

It is also necessary to change lines 500 and 600 since the variable K takes on the values of C.

Line 200 contains a command to slice the first character of A$ from the string after that character code has been stored in the B array. There is a satisfactory substitution for the ZX80 command TL$:

ZX80: 200 LET A$=TL$(A$)
ZX81: 200 LET A$=A$(2 TO)

The random number generators of the two computers also operate differently. The ZX80 automatically makes an integer out of random numbers in the range of 0 to N and includes N in the range. The ZX81 does not. Line 300 shows how you must take the INT of the RND number on the ZX81 and add +1 to the result.

ZX80: 300 FOR I=1 to RND*8
ZX81: 300 FOR I=1 TO INT (RND*8)+1

The same consideration must be applied to lines 400 and 410.

Now back to the relational operators. When the ZX80 uses the relational operators =, >, and < to determine the equality or inequality, a result of false is evaluated as 0, and true is evaluated as -1. When the ZX81/TS1000 performs the same comparisons, false is still 0, but true is +1. Because of the differences in assigning a value for true, when converting from ZX80 Basic to ZX81 basic it’s necessary to multiply some expressions containing relational operators by -1. Line 360 shows how this is accomplished. Note that the ZX81 version also has (C-1); that’s because C is 1 greater in the ZX81 version than the ZX80 version.

ZX80: 360 LET D=-C*(U<0)
ZX81: 360 LET D=(C-1)*(U<0)

Once again, in the ZX81 line above, 1 has been subtracted from C since its value is one less than the lenght of the word to be embedded into the puzzle. C has also been multiplied by -1 to account for the differences in relational operators.

The same operations also hold true for lines 370, 380, and 390. They are not necessary for lines 910 and 920 since they involve the multiplication of two possibly negative numbers. The result will always be 0 or positive in these lines so no changes are necessary.

At this point the program functioned properly. One final communication from Bill McCray eliminated the annoying problem of words starting in the last column of the puzzle and wrapping around to the first. This change is related to the fact that the ZX80 array contained elements 0 to 164 instead of 1 to 165.

The variables M and P (lines 490 and 590, respectively) become subscripts of the A array (in lines 510 and 670). They should therefore take on values 1 to 165 in the ZX81 version of the program. To have them do so requires the adition of 1 to the lines in which the values of M and P were calculated.

ZX80: 490 LET M=X+15*Y
      590 LET P=X+15*Y

ZX81: 490 LET M=X+15*Y+1
      590 LET P=X+15*Y+1

Now the program works like a charm. You can keep entering words for as long as you like. Lenghty words should be entered first to give them a better chance of being properly embedded into the puzzle. If you’re not happy with the way the program arranged the puzzle, reRUN the program.

If you try to enter a word longer than 11 characters or a word containing a non-alpha character, then you’ll be asked to re-enter a different word. If there is no room left in the puzzle for a word you try to enter, try a shorter word. Program options allow you to display either the puzzle or its solution. The screen can be copied to your printer.

   0 REM WRITTEN FOR THE ZX80 BY
BILL MCCRAY
10 REM MODIFIED FOR TS/1000 BY
DUNCAN R. TEAGUE
20 DIM A(165)
30 DIM B(11)
40 CLS
50 RAND
60 PRINT " CREATE A WORDSEARCH PUZZLE "
70 PRINT
80 PRINT "WORDS MAXIMUM OF 11 LETTERS EACH"
90 LET A$="FIRST"
100 PRINT
110 PRINT A$;" WORD?";TAB 15;"NULL ENTRY TO END"
120 INPUT A$
130 CLS
140 IF A$="" THEN GOTO 720
150 PRINT A$
160 IF LEN A$>11 THEN GOTO 230
170 FOR C=1 TO 11
180 LET B(C)=CODE A$
190 IF B(C)<38 THEN GOTO 260
200 LET A$=A$(2 TO )
210 IF A$="" THEN GOTO 280
220 NEXT C
230 PRINT "TOO MANY LETTERS"
240 PRINT "RE-ENTER"
250 GOTO 120
260 PRINT "INVALID CHARACTER"
270 GOTO 240
280 LET U=1
290 LET V=0
300 FOR I=1 TO INT (RND*8)+1
310 GOSUB 910
320 NEXT I
330 LET A=-1
340 FOR I=1 TO 8
350 GOSUB 910
360 LET D=(C-1)*(U<0)
370 LET E=15-(C-1)*(U>0)
380 LET F=(C-1)*(V<0)
390 LET G=11-(C-1)*(V>0)
400 LET X=INT (RND*(E-D))+D
410 LET Y=INT (RND*(G-F))+F
420 FOR J=1 TO (E-D)*(G-F)
430 LET X=X+1
440 IF X<E THEN GOTO 480
450 LET X=D
460 LET Y=Y+1
470 IF Y=G THEN LET Y=F
480 LET B=0
490 LET M=X+15*Y+1
500 FOR K=1 TO C
510 LET L=A(M)
520 LET M=M+W
530 IF L=0 THEN GOTO 560
540 IF NOT L=B(K) THEN GOTO 610
550 LET B=B+1
560 NEXT K
570 IF NOT B>A THEN GOTO 610
580 LET A=B
590 LET P=X+15*Y+1
600 LET Q=W
610 NEXT J
620 IF A>-1 THEN GOTO 660
630 NEXT I
640 PRINT "WORD DOES NOT FIT"
650 GOTO 700
660 FOR K=1 TO C
670 LET A(P)=B(K)
680 LET P=P+Q
690 NEXT K
700 LET A$="NEXT"
710 GOTO 110
720 PRINT AT 21,0;"SOLUTION PUZZLE COPY END"
730 INPUT A$
740 IF A$="E" THEN STOP
750 IF A$="C" THEN GOTO 960
760 CLS
770 LET I=1
780 FOR K=0 TO 10
790 FOR J=0 TO 14
800 LET L=A(I)
810 IF L THEN GOTO 840
820 LET L=27
830 IF NOT A$="S" THEN LET L=INT (RND*26)+38
840 PRINT CHR$ (L);" ";
850 LET I=I+1
860 NEXT J
870 PRINT
880 PRINT
890 NEXT K
900 GOTO 720
910 LET W=(U>-1)*(V>-1)-(U<1)*(V<1)
920 LET V=15*((U<1)*(V>-1)-(U>-1)*(V<1))
930 LET U=W
940 LET W=U+V
950 RETURN
960 PRINT AT 21,0;" "
970 COPY
980 GOTO 720
990 SAVE "WORDSEARC▒"
1000 RUN

This is a bare bones program. Remember that the original program had to fit into the small memory of the ZX80. The user can easily add more programing lines to the ZX81 version to allow editing and printing out of the word list. Simple changes to the range of character codes will produce a TS2068 version of the WORDSEARCH program. Be sure to run the TS1000 version in FAST mode.

Included is a sample WORDSEARCH puzzle related to SyncWare News and its staff. Hidden in the puzzle are the following words: SYNCWARE, NEWS, TIMEX, COMPUTERS, SOFTWARE, HARDWARE, NACHBAUR, WOODS, BENT, and MOORE. See if you can solve the puzzle without peeking at the solution found elsewhere in this issue. GOOD LUCK!

Fun Corner

W H N Q I R T R C E N P L W E
F Y A T Z S Y N C W A R E B K
J Y M R E B P C E X C Z Q Z N
O L Q R D V U P C B H G U Z G
Q S O F T W A R E A B H J W U
A O D N H N A X V U A J Y R Y
M T I M E X S R E T U P M O C
F Q H K Y W J D E R R W I V Y
I Q I E E A S V O Y S Q W U X
T R L B G Y O P I O R G W E S
K S Q K R D P B B Q W T H Q N
Puzzle Solution
Puzzle Solution

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.