x Volume 1, Number 3 $2.50 (USA) May/June 1981 u 2120 (UK)

Graphics: a Translating from Other Basics @ Automatic Display Changes a Graphics Tricks j w Keyclick Generator

e Hunt for Gold e Walls and Dikes

Adventures of Crash Cursor

Games: e Hammurabi e Black Hole e Gauntlet

e Forest Treasure e Mastermind

Inside the ZX80 Keyboard

Handling Character Strings

SYNTAX ZX80

A PUBLICATION OF THE HARVARD GROUP

SYNTAX ZX80 is a brand-new monthly newsletter created just for you. We bring you news, reviews and forecasts of hardware, software and applications for your ZX80 or MicroAce, as well as technical details for circuit-builders. SYNTAX also provides a forum for users to share advice and problems about pro- grams, vendors and topics of mutual interest. As more products become available, we’ll bring you the ads and releases that keep you informed.

At SYNTAX we emphasize practicality. You can apply our suggestions even if you aren’t sure at first why they work, because we give you complete instruc- tions. Text is clear and easy to understand. SYNTAX readers already know about:

An automatic phone-dialer they can put to- gether in a few hours

e Syntactic Sums™ to check input for errors

e Printing characters four times normal size e e

Programs to explore computer memory Cassette eavesdropping to locate files on tape and simplify loading e How to build their own external additional RAM e How to add an 8212 I/O chip to control ex- ternal devices from their computers And SYNTAX readers like what they get every month. Subscribers know they can depend on us. After receiving only three issues of SYNTAX ZX80, I find that I anxiously await the next issue... keep up the

ood work! . 8 Martin Irons

Goshen, NY Congratulations on the brass-tacks, down- to-earth approach of your newsletter. I'll be looking forward to future issues. Otis Imboden Washington, DC Many readers get their first issue and immediately order the back issues more proof that they like what they see.

Bolton Road, Harvard. Mass. 01451

exp. date

signature

[] My check for $25 is enclosed.

account number _

What’s special about our publication? Just look through one issue. We work hard to bring you a qual- ity newsletter. We strive to print useful programs of above-average accuracy. As any computer magazine editor can tell you, program listing accuracy is tough to achieve, but we boost our average with every issue. We test each program to make sure it works, it fits in the designated RAM, and it runs when you follow the directions. We print program listings in screen-image format to make it easier for you (it’s sure not easier for us!) to enter programs accurately. We invented Syntactic Sum™ as an additional aid for you in get- ting error-free programs. With your subscription you also get access to hundreds of other readers, and our staff experts are available by phone to answer your questions or help you solve problems with your machine.

SYNTAX readers get every month: e Latest news of Z80 hardware and software e Programs to organize information, calculate, entertain, or instruct e Do-it-yourself additions to the ZX80/Micro- Ace e Clear explanations for beginners

To share the benefits of SYNTAX ZX80, just com- plete the coupon below and return it with your choice of payment. You will receive a year’s subscription, 12 issues, for only $25 in US funds (plus $13 for foreign airmail if you live outside North America).

We are so sure you'll find SYNTAX useful that we promise to refund your entire subscription fee if you aren't satisfied. An unconditional guarantee you can’t lose. But if you’re still skeptical, write for a free sample issue and see for yourself how SYNTAX can help you use and enjoy your ZX80 or MicroAce more.

Join the others who stretch the ZX80s and Micro- Aces to their utmost. Act now as soon as we receive your coupon with payment, your first issue will be on its way. For faster service, phone your credit card order to 617/456-3661. Don’t miss SYNTAX!

e

YES! Please send me 12 issues of SYNTAX for $25.

[ J Please charge my [L] MasterCard (J Visa L] American Express [] Diner's Club account.

bank number (MC only)

lowna O Sinclair ZX80

O MicroAce computer. Name

Organization

Address___ _ l _ _

City Phone No. (

Title _ State Zip ` ` (oo) Home Phone No. ( )

S681

N Oo Ub G WN

The magazine for Sinclair 2X80 users

ESL om

May/June 1981

LOMO a5 ys. no 4064s anotada AGRO See rapid CESS Glitchoidz Report.....................................

First Aid for Your Keyboard.................... Bridges Dealing with key problems

ZX81 Announced in Great Britain......................

Unfriendly Skies................................ Lubar A software review

Handling of Character Strings in the ZX80....... Taube Using USR(47)

26 27 30 32

33 33

More Truthin Programming........ Lubar Using NOT 8 BuckHole.............. O sss Eckel | 34

Shoot out the stars to escape

1 0 The SYNC Challenge................................. 35 Winners announced; and winning program

1 2 Auto-Display-Changing......................... Logan 36 Second in a series on machine language

46 Looking Inside thezx8g0... J... a... shanko | 40 Memory listing program

18 Puzzles and Problems....................... Townsend 42

20 Mastermind................................... Fowkes 45 Nine chances to beat the ZX80

22 Graphics Surprises............................ Parsons 48

Randomizing graphics for “Walls and Dikes”

Staff

Publisher/Editor-in-Chief Editorial Director Managing Editor Associate Editor

David H. Ahl George Blank Paul Grosjean

David Lubar

Secretary Elizabeth Magin Production Manager Laura MacKenzie Typesetter Jean Ann Vokoun Financial Coordinator William L. Baumann Bookkeeper Patricia Kennelly

Patricia Brown Joan Swihart

Customer Service Order Processing

Circulation Suzanne Guppy Frances Miskovich MEMBER Dorothy Staples

May/June 1981

Index to Advertisers

Advertiser

Artic Computing

Basic Computer Games Bug-Byte

CAI Instruments

Computers in Mathematics Creative Computing

Creative Computing Back Issues Harvard Group

Hewson Consultants

Lamo-Lem

Linsac

LJH Enterprises

New England Software Outbound Engineering Peripherals Plus

SYNC

SYNC T-Shirt

Tales of the Marvelous Machine Tensor Technology

Zeta Software

Volume 1, Number 3

Variable Conversions in the ZX80....... From one variable to another

Loco... Sutton Graphics, Games, and Gold..................... Oakes Building program units

A Trick and a Graphic System................... Comer Draw your own pictures on the ZX80

o AA Berggren A dash between monsters and walls

SYNC Reader Survey.................................

A A A column for short programs

Forest Treasure...._............................ Frahm Overcome the dangers for the gold

Translating from Other Basics................... Lubar ON...GOTO and LEN

8K Basic ROM and 16K-Byte RAM.......... Specifications

Key Click Generator.......................... Johnson Making entries audible

ZX80 Keyboard.............................. Ornstein Locating key closures

Crash Cursor.................................. Truman The Glitchoidz strike

Resources......

Po... S Š$ $ é & . $ Q Q $ %*

Volume 1. Number 3

Page SYNC is published bi-monthly for $10.00 per year 4 by Creative Computing, 39 E. Hanover Ave., Mor- 19 ris Plains, NJ 07950. Second class postage paid at 8 Morris Plains, New Jersey 07950, and additional Cover 4 entry offices. 29 39 Postmaster: Send address changes to SYNC, P.O. 24, 25 Box 789-M. Morristown. NJ 07960. Cover 2 4 Subscriptions in USA: 6 issues $10; 12 issues $18; 5 18 issues $24. UK and foreign airmail subscrip- 7 tions: 6 issues £10; 12 issues £18; 18 issues £25. Call 7 (800) 631-8112 toll-free (in NJ, 201-540-0445) to 10 begin your subscription. 17 16 Copyright 1981 by Creative Computing. All rights Cover 3 reserved. Reproduction prohibited in any form. 12 41 10 Ly

Randomizing - Your Music

Dear Editor:

In Richard Forsen's program—“Making Music with the ZX80"— lines 0001 to 0999 can be replaced with a simple con- tinuous random music generator.

500 LET P=RND 17

510 LET X=RND(8)*10

520 GO SUB 970+P*30

530 GO TO 500

Forsen's pitch scale (lines 1000 to 1500) may be used intact. When this program is run, it produces a continuous series of tones of random pitch and duration. The limits within which pitch and duration vary may be changed by altering the quantities in lines 500 and 510. Reducing the pitch limits somewhat will increase the frequency with which the tones seem to have some melody.

Cecil Bridges 1248 N. Denver Tulsa. OK 74106

Crash Advice

Dear Editor:

David Tebbutt (SYNC Jan/Feb ‘81) has found one too many ways to crash the ZX80. As Hugo Davenport (ZX80 Manual. p. 114) states, pressing EDIT in response to INPUT “doesn’t actually crash the system.” However. Mr. Davenport offers no further help.

In this situation, a LIST will appear with part or all of the line to which the cursor is presently positioned shown in an apparent EDIT mode. RUBOUT the entire line. Enter the required response. providing quotation marks if INPUTing a string. Press NEWLINE and proceed.

I hope this will be of help.

Sincerely yours, SUNFLOWER SYSTEMS Karl Brendel

420 South Eighth

Salina, KS 67401

2

More Channel 2 Tips

Dear Editor:

I’m quite impressed with the first issue of SYNC. Its format. quality and contents echo the best of Creative Computing —the favorite of friends and acquaintances. I have. however, an important recommenda- tion for you, your staff. and writers which will be of help to other beginning micronauts such as myself: Please indicate in the introduction to program listings the minimum RAM requirements. Some of us aren't yet able to guess by looking at a listing if it will fit in 1K! It'll save a lot of unnecessary typing and disappointment.

For those ZX80 owners who are experi- encing interference problems with TV connections. I've listed several suggestions. In the Bay Area. VHF Channel 2 is used for regular broadcasting. This makes it very difficult to eliminate station signals.

l. If you monitor your LOADing with an earphone. unplugging it when not in use will eliminate the interference it causes the television receiver.

2. Some metal objects seem to create annoying distortions and ripples in the screen image when near the ZX80. Remov- ing card file boxes. paper hole-punchers and even stacks of cassette tapes has helped in my case.

3. Try touching the shielded TV cable (which plugs into the Z X80) to one of the VHF terminal screws now accepting a signal from the ZX80 adapter box. I have found this to produce enough of a ground to clear up unstable displays and ghosts. Just tape the cable in position.

Respectfully.

Colin Alexander 120-28th Street

San Francisco. CA 94131

Tic Tac Toe

Dear Editor:

In Jeffrey Hoffman's “Tic. Tac. Toe” (SYNC 1:32) a CLS statement must be added to keep the screen display from overflowing:

442 CLS

The program also has some algorithmic problems:

1) The final board is not displayed when there is a winner on move nine.

2) Moves to occupied spots forfeit the player’s turn (noted by Hoffman).

The first problem can be solved by adding three lines and changing nine others. The new lines are:

5 LET Z=0

175 IF Z=1 THEN GOTO 470

178 IF Q2=10 AND Z=0 THEN GOTO 490 to THEN LET Z=1 The lines to be changed are:

100 Change to FOR Q=1 TO 10

370-440 Change THEN GOTO 470 to THEN LET Z=1

This letter is not meant to be negative but an incentive to maintain high editing standards for SYNC—we the readers care.

SYNCly.

Peter Beck

54 Richwood Pl. Denville. NJ 07834

If A CA >=

SYNC Magazine

Glifehoidz

heport

The GLITCHOIDZ REPORT will pass on to our readers errors, problems, and other Glitchoid activities which have been discovered. We welcome your contribu- tions to this column.

Random Graphics (1:22)

Some readers reported difficulties in getting this program to run. It will run as printed. Note especially the last two para- graphs.

Castle Doors (1:30) As many readers have found, this is a 2K game. Correct: 48 IF D=2 THEN A=RND (30) 140 Insert a space after PRINT

Basic Accounting with Decimal Currencies (1:36) 2K Make the following line additions and corrections: 197 GOSUB 1000 350 LET X=G 360 LET Y=G2 365 GOSUB 8000 465 GOSUB 600 8010 GOSUB 2000 Omit 8100

Artillery (2:27)

The GLITCHOIDZ had their biggest triumph to date in SYNC in shooting down the Artillery game. We were almost in shell-shock when we discovered the mag- nitude of their success, thanks to many readers. Enter the following corrections in your program:

Note: in Line 500 ** means “power” and is correct. It must be entered on the “H” key.

May/June 1981

` e

s `

Memory Display (2:16) Note in using this program:

Lines 50 and 90: no spaces between “”.

The program displays addresses only below $8000. Correction: 200 LET X=PEEK(A +1)

Truth in Programming (2:18) Column 3:

30 IF CODE(G$)=52+(N/2=N-N2)* Three lines further:

...tO be evaluated as -1

Widget (2:23) 330 PRINT “LAST MONTH YOU SOLD 258,00”

Tic Tac Toe (2:32)

Lines 270 to 360: add LET after THEN

Lines 370 to 440: add GOTO after THEN O

First Aid for Your Keyboard

Cecil Bridges

You have a normal screen and nothing happens when you punch a key. or you punch a key and the wrong symbol pops up. Your problem may be caused by keyboard switches that are permanently closed. Look at the keyboard at an angle against a light. If some or all the keys seem to be quite dented in. they may be pressing down against the contacts on the printed circuit board without releasing.

The ZX80 keyboard is prone to this problem because of the way it works: a sheet of aluminum foil is dented in and pressed against contacts on the printed circuit board when a key is pressed. The vinyl-aluminum sandwich that is the key- board does not have enough sufficient elasticity to pop back, and the key acts as if it were permanently pressed down.

Short of replacing it, the following procedure may rejuvenate your little machine. Take the case apart enough to clear the edges of the keyboard, and gently peel the sticky aluminum foil and vinyl keyboard off the sticky surface. Do not lay the sticky foil keyboard on any surface on which it would pick up anything. Do not fold the keyboard. Do not smear the gooey stickum on the clear spaces on the foil under the keys. If you managed this successfully. lay the foil keyboard right back down in the same position from which you removed it. pressing gently to re- stick. Peeling up the keyboard may straighten out the dents somewhat. or release air trapped between the two sticky surfaces. so that the abnormally closed contacts are now again open. If yours is like my MicroAce. it will now work like gangbusters. O

Cecil Bridges. 1248 N. Denver. Tulsa. OK 74106.

3

ZX81 Announced in Great Britain

Sinclair Research is now advertising the new ZX81 computer in British computer magazines. An improved version of the ZX80 computer, the ZX81 has been redesigned to incorporate a number of new features. The ZX80 reduced the number of integrated circuits to 21, but the ZX81 further reduces the number of chips to four by using a new custom-built chip that replaces 18 others. The 8k Basic ROM chip (now also available for the ZX80 as a drop-in replacement) gives the user the capacity to use decimals with 8 place accuracy, to work with log and trig functions (with their inverses), to plot graphs, and to make animated displays. A new 40 key keyboard expands the number of key words that can be entered by one key stroke, e.g., PEEK, POKE, SCROLL. This eliminates typing out these words.

“ZX-80 BASIC” A complete disassembled, annotated listing of the Sinclair 4K Basic, with Cross reference table. Discover how and why Your ZX-80 works.

PROGRAMS supplied on Cassette.

E1.01 - LCM 4 HCF, Prime factors, Statistics, Bar-chart plotter 1K U1.01 - Line renumberer, Stopwatch, LEN( $) 1K

M1.01 - Day finder, Sequence guesser, Scetcher 1K

M2.02 - LIFE: 1/7 second per generation, with demo program 2K G1.01 - Hangman, Matchstick game, Battleships, Hi-low 1K

G3.03 - Zombies, Sink the sub, Nim 3K

G4.04 - STARTREK: All the features of most larger games 4K G4.04 - Sword of peace: Dungeons & Dragons type game 4K

(ALL PRICES INCLUDE POSTAGE & PACKING) For free catalogue send SAE or 1$ to:

ARTIC COMPUTING 396, James Reckitt Avenue, Hull, N.Humberside, HU8 OJA, England TO ORDER MAKE CHEQUES, P.O. Payable to ARTIC COMPUTING.

Twenty new graphics characters and 54 inverse video characters increase the graphics capabilities. Users have the choice

of two speed modes: “slow” and “fast” which is four times the “slow” mode and comparable to other personal computers.

The slow mode eliminates screen flicker. Although the 1K RAM is the same as for

the ZX80, it can be expanded by plugging in the new 16K memory unit. (So can the Z X80.)

The ZX81 will sell in Great Britain for £69.95, but it will not be available in the U.S. for the foreseeable future. Even if we colonials fly to Britain to buy it, the British version will not work with an American TV set. However, ZX80 users can have most of the capabilities (excluding the animated display) if they upgrade to the new 8K Basic ROM which is now available in the U.S. for $39.95 plus shipping from Sinclair Research (see Resources Column).

Sinclair has also announced that a 32 column printer will be available in the summer of 1981 for about £50. This will work with the 8K ROM machines.

HINTS & TIPS FOR THE ZX80

This super book on the ZX80/Micro- Ace includes chapters on Saving Space, Machine Code Subroutines (including PAUSE and ACTIVE DIS- PLAY). Learn how to protect variables and how to CLEAR them one by one. 48 close-printed pages packed with routines and programs - £4.25

BUMPER BUNDLE - 14 programs on cassette for the 1K ZX80/MicroAce including several with ACTIVE DIS- PLAYs. Normal price £12.25, SPE- CIAL OFFER £6.75 only for orders received by 31 May 1981.

All price include p&p

Send SAE for full catalogue

Hewson Consultants

7 Grahame Close Blewbury Oxon 0x11 9QE UK

Tel 0235 850075

Dealer enquiries welcome

SYNC Magazine

Software Review...

Unfriendly Skies

David Lubar

A cult has grown around the game of Space Invaders. Individuals with glazed eyes and pockets full of quarters have been known to haunt arcades for hours, sending countless rows of aliens to a laser death. Now, Sinclair owners can experience the same mania in their own homes. Using

an active display to produce true animation, Softsync has given us Super ZX80 Invasion for the Sinclair. The tape comes with both 1K and 2K versions of the game. Let’s start with the 1K program.

The player has a ship (or laser base, depending on your interpretation) at the bottom of the screen. The ship can be moved left or right using the arrow keys. The 0 or 9 key is used for shooting. Above the player, rows of aliens rain down missiles. The aliens move slowly across the screen, and the entire group moves closer to the player on each pass. If you shoot them all before being hit five times, you are rewarded with another screenful of aliens. That's basically it. The 1K version doesn’t keep score, so you have to remember how many frames of aliens you have destroyed. Your ship contains a number telling you how many ships are left. When the number reaches zero, the game starts over. There are three skill levels available in the 1K version.

The program is fast, which introduces a problem. You have no chance to get set. As soon as it starts, the aliens are shooting at you. You can lose two or three ships before even touching a key. When your last ship is destroyed, there is no pause. The game starts again. If you are down to one ship and one alien, it can be hard to tell who hit who.

The 2K version does keep track of the number of frames completed. It also allows for fifty different skill levels, more aliens, and extended play for each frame com- pleted. Unfortunately, there is no way to stop the game and change skill levels. Once it is running, you can only stop it by pulling the plug. To go to a different skill level, you have to reload the tape.

Despite these problems, the game is fun, assuming you aren’t easily frustrated. It is probably the best Sinclair game to hit the market so far. The programmers have to be congratulated for putting so much into 1K of space. O

AND MORE!

May/June 1981

JUST POP IN THE CASSETTE AND PLAY! (REQUIRES 4K BASIC & 1K MEMORY OR MORE).

ALSO: OLD *1

FAMILIAR OLD PROGRAMS LIKE DICE THROW, MULTIPLICATION TABLES, AND ALSO MANY NEW, LIKE AUTO-PLOT (GRAPHS YOUR EQUATIONS, COMPLETE WITH LABELED AXES). ELECTRIC NOTEPAD LETS YOU CREATE PHONE LISTS, ETC.. GAMES, PUZZLES, TEN PROGRAMS IN ALL. ALL ON ONE CASSETTE, YOUR CHANCE TO TRY OUR SOFTWARE. JUST $2.99!

AAA a

CHEST OF CLASSICS [Es

FOUR CLASSIC COMPUTER GAMES xo FOR THE ZX80 AND MICROACE.

LUNAR LANDER MINDMASTER

ALL FOUR GAMES ON ONE CASSETTE, WITH GAME MANUAL, CHARTS, COLOR KEYBOARD OVERLAYS, COMPLETE LISTING IN BASIC,

LAMO-LEM LABS

CODE 203, BOX 2382, LA JOLLA, CA 92038

SOTA Sf (( A PALA LIA RIES KIA

WON

SS Z SSS PL, AA

K-TREK LIFE

$ 0.9

FREE: WRITE FOR OUR FREE CATALOG & RECEIVE ZX80 & MICROACE CODING SHEETS.

Handling Character Strings

in the ZX80

Hasse Taube

From the first day I tried to operate my new ZX80. I have been looking for a way to simulate some of the character-string operations possible in other programming languages. but not in the ZX80 Basic. An idea mentioned by Michael Kirkland in Personal Computer World. February. 1981. on using USR(47) to obtain the address of the end of the variables provided me with the key to start my programming tricks in the ZX80.

Consider the following piece of code:

100 LET A$=“ABCDEFGHIJKLMNOPQ”

200 LET A=USR(47) Then A is the address of the byte after the last“. Consider also: 100 LET A$=“ABCDEFGHIJKLMNOPQ”

200 LET A=USR(47)-2

A will contain the address of the last byte of the previous character string; in this case. A will be the address of the letter Q.

In order to use this facility. you should not have any other statements between 100 and 200 in the examples mentioned above. To test this on your ZX80. enter the following short program:

100 LET A$="ABCDEFG”

200 LET A=USR(47)

300 PRINT CHR$ (PEEK(A))

This should give the letter G as output. i.e.. the last character in a character string AS.

You know. of course, that you can always get the first character in a character string by a piece of code like this:

100 LET AS="ABCDEFGHIJ"

200 LET BS=CHRS(CODE(AS))

Then the variable BS will get the value A. i.e.. the first character of the character string AS.

Hasse Taube, Ericavej 39, DK 2820 Gentofte. Danmark.

It is. however. not so easy to get the last—or in fact any other than the first character. This is now possible with the use of the technique just described.

Suppose you want the last character of a string variable after a value has been assigned to it by an INPUT:

100 INPUT A$

200 LET A=USR(47)-2

300 PRINT CHRS(PEEK(A))

If you run this program and input. say. QWERTY. the output should be Y.

In other words, if you use:

(line number) LET A=USR(47)-2 immediately after an assignment of a string variable by a LET-statement or by an INPUT -statement. the variable A will point to the last character in the string.

If you know the length of the string. it Is easy to take a substring from it. Suppose you know that the length of the string is 5 as in the following example:

100 LET AS="ABCDE” 200 LET A=USR(47)

300 LET BS="XX"

400 LET B=USR(47)

500 POKE B-2.PEEK(A-5) 600 POKE B-3.PEEK(A-6) 700 PRINT BS

Then the output will be AB. i.e.. the first two characters from the string A$.

By using the example above with other values in statements 500 and 600. you could. of course. get another substring from AS. Also, if you would like to take a larger substring than just two characters as in the example. you probably would set up for a FOR... NEXT loop to do the POKE's and PEEK’s.

Suppose you do not know the length of the string variable from which you want to take. say. the second and third characters. How can you find the length of a string variable? Several methods are available. The first uses the TL$ in a loop like this:

100 INPUT AS 200 LET BS=AS 300 FOR I = 1 TO 1000

400 LET A$ = TLS(AS)

500 IF AS = “`` THEN GO TO 1000 600 NEXT I

1000 LET AS=BS

1100 PRINT I

Then the output-value will be the length of the string which you input.

A much more interesting method for finding the length of a string also gives you the address of the beginning of the string. In this second method strings are internally stored in the ZX80 as follows:

One byte with a code for the name of the string;

The string itself from first character to last character;

The ending quote.

The first byte contains a value which is equal to decimal 96 plus the code for a letter and which names the string. For example, a string named A$ will have 96+ 38= 134 (decimal) in the first byte. A string named ZS will have 96+63=159 (decimal) in the first byte. To understand these examples. you must know that the ZX80 representation for A is 38 and Z is 63. (See your instruction manual for the Z X80.)

To find the address of the first byte of the string in a string variable. you must set up a loop to test for the value in the first byte. described above. Assuming you know the address of the byte after the ending quote from USR(47). this should be fairly simple:

100 INPUT AS

200 LET A=USR(47)

300 FOR I=0 TO 1000

400 LET J=A-2-]

500 IF PEEK(J)=134 THEN GO TO 1000

600 NEXT I

1000 PRINT I

The program above will print out the length of the string which you input. but more interestingly. after statement 1000. J will point to the first byte of AS. and J+1 will point to the first byte in the string itself. O

SYNC Magazine

More Truth in Programming

David Lubar

The other day. while blithely working on a program, I discovered that something was amiss. I had made an assumption about a certain Boolean operator, and passed on the information without checking my assumption. As Murphy’s law would have it, the assumption was wrong. Going back to the article in issue two of SYNC, there is a discussion of various tricks with logical operators. For example, to test whether a number is not zero. you could use the following program.

10 INPUT N

20 IF N THEN PRINT “NOT ZERO”

There is no problem here. The expres- sion will only be true if N has a value other than zero. I had assumed that the converse was also true. believing expres- sions such as

IF NOT N THEN PRINT “THE NUM- BER IS ZERO” would also work. To put it bluntly, they don't. The reason for this is that NOT can function in two different ways (actually. it always functions in the same way. but has two different applications). When working only with true and false (values of -1 and 0), NOT will always make a true expression false, and make a false expres-

sion true. So far. so good. As long as the universe is restricted to the values 0 and -1, there is no problem.

Before going on. try the following on your computer. Ask it to PRINT NOT (0). Then ask it to PRINT NOT (-1). As you can see, this works in the expected manner. Now try PRINT NOT (5). You might expect an answer of 0. since 5 (or any number other than zero) is considered to be true when evaluated logically. But life is not that simple. What NOT actually does is to take each bit in the byte and change it. Ones becomes zeroes, zeroes become ones. Now, if you've been trying all this. you'll have found that any positive number N. when used in PRINT NOT(N) will produce a negative number. This has to do with the way the Sinclair stores numbers. In positive numbers, the highest bit is set to zero. In negative numbers. this bit is set to one. Since NOT changes each bit, it will change the sign of most numbers.

You've probably also noticed that PRINT NOT (5) does not produce -5. This, also, is tied in with the way numbers are stored in the Sinclair, and will be discussed in a later issue.

By now, it should be obvious that you can't test for zero with IF NOT (N) THEN PRINT “THE NUMBER IS ZERO”. If N is 0. NOT (N) will produce a value of -1, making the expression true. In this case, that is what we want. When N is zero, the expression will be true. and the statement “THE NUMBER IS ZERO” will be printed. And if N is -1, there is still no problem, since NOT (-1) will produce 0. making the expression false. But if N is any other number, NOT (N). as we've seen. will return a value other than zero or minus one. And. when evaluating the IF... THEN statement, the Sinclair will consider any value other than zero to be true. So IF NOT (N) THEN PRINT “THE NUMBER IS ZERO”, will end up printing the message for any value of N other than minus one.

To sum it up, as long as an expression produces only logical values (0 or -1). you can safely use NOT. Expressions such as IF NOT (A=B) THEN GO TO 10. or IF NOT (X 5 AND Y 8) THEN GO TO 10 are fine. They only deal with logical operators. The value inside the parentheses will be either zero or minus one. But if other integers enter the expression, it’s not safe to use NOT. O

KNOW YOUR ZX80

With LINSAC products for the Sinclair ZX80

THE ZX80 COMPANION

postage.

(SECOND EDITION) Appl

LINSAC

The ZX80 Monitor A complete assembly language listing of the ZX80’s 4K Monitor,

with annotations. Available as a clear typeset booklet from 16th March, price £5.95.

Cassette Software

All LINSAC program packs are on single C12 cassettes with printed run instructions. All run on 1K ZX80's unless otherwise

stated. Price £7.95 per pack incl. UK postage.

GAMES PACK 1 - GAMES PACK 2 GAMES PACK 3 _ (2K+) Fruit Machine, Four-in-a-line, Zombies. GAMES PACK 4 - EDUCATION PACK 1 EDUCATION PACK 2 EDUCATION PACK 3 UTILITY PACK 1 -

THE ZX80 COMPANION (Second Edition)

Maunder, Logan and Trotter ISBN 0 907211 00 3. Price £7.95 incl. UK

This best-selling manual on the Sinclair ZX80

covers ZX80 BASIC, hardware and programs

and has a detailed explanation of the ZX80

Monitor, routines and entry points. A routine e

for generating moving displays is also included.

Ch.1 Operating the ZX80.

Ch.2 Theory of Computers

Ch.3 ZX80 BASIC

Ch.4 The ZX80 Monitor

Ch.5 Construction and Hardware

Ch.6 - 2X80 Programs En

Comparison of Z-80 Opcodes and = . ZX80 Characters. e y s

App.2 The 8K ROM.

For a cassette of ten programs from the Com- panion add £4.95.

Three Towers, Number Guessing, Mastermind, Sketcher, Hurkle, Nim, Symbol Simon. _ Nine Lives, The Maze Game, Plain Sailing, OXO, Chinese Puzzle, Tower of Hanoi, Battleships.

Destination Venus, 3D Noughts & Crosses, Anagrams, Interaction, Maths Drill, Dot Recognition, Musica! Notes, Spelling Quiz, Day Finder.

Graph Plotter, Prime Factors, Number Bases, Bar Charts, Statistics.

Memory Display, Hex Code Monitor, Renumber, Memory Search.

Plans for ke $10.00

(2K+) Computer-Assisted Learning Quiz Package with three sample data sets.

LINSAC 68 Barker Road, Linthorpe, Middlesbrough, Co.Cleveland TS5 5ES

May/June 1981

board con

NOW AVAILABLE

Sion

Standard Compute

ersion with reverse video

Keyboard with complete parts and plans $65.00 Wired keyboard, complete with plans $85.00

Mail for information:

L.J.H. Enterprises P.O. Box 6273, Orange, CA 92667

For information or Visa or MasterCard orders call

(714) 772-1595. Shipping charge for U.S.— $5.00.

JOFTWARE

Jil GdSSe BUMPAPAK-25

25 programs for the unexpanded ZX80 on 3 cassettes. These are made up from the

best of our cassettes 1 - 8, and include UK biorhythms , moon-landing, hangman,ZX80 art, Stopwatch,treasure hunt,battleships and £12 many others complete with instructions.

Purchased together in this way, US they represent incredible value, B29 and an enormous Saving.

EDUCATIONAL

FRENCH VOCAB This program requires 16K UK and contains 200 French words with their £8 ~ 50

translations. Reference & testing modes US in both directions(F-E & E-F) 419

MULTIPLE CHOICE Allows you to enter any

Set of up to 25 multiple choice cuestions UK and performs testing, marking & correct-

ing. By SAVEing the complete program, a Sf ( 59 large number of tests may be derived from US this program - very easy to use.16K 217

JUNIOR MATES 5-12 yrs. Tables, division, aadition & subtraction, or a mixture may UK be tested in this self-contained, easy to E? . 50 use program. Variety of question types, age-dependent timing, scoring etc. 6K US 217

Programming Course Second edition

The course consists of a book and a cassette of programs, and has been designed to supplement the Sinclair manual. It is assumed that this has already been studied, and that the reader is capable of constructing very elementary programs. In our book, the ZX80's BASIC is explained in more detail, with special attention being given to those aspects likely to cause difficulty, for example, the use of PEEK and POKE and the USR function.

An introduction to machine code is given, removing some of the mystery which Surrounds this subject, and there is also a section explaining the workings of the Z80 microprocessor.

The accompanying cassette contains ready to run programs, which are dealt with in the text, which also includes many other useful programming examples, The emphasis is on understanding, and the course should give you the confidence to construct your own involved programs, thereby getting the most out of your ZX80.

251 HENLEY ROAD COVENTRY CU2 IBM

ENGLAN

Black Hole Bil Eckel

Black Hole is a game based on a machine language program on my Elf If which uses the RCA 1802 Microprocessor. I understand it was originally called “Teaser.” The challenge of rewriting it in Basic for the small memory could not be resisted. The program takes a little over 1K of memory.

Black Hole You are in space looking at your computer screen which shows a star surrounded by black holes.

000 0 * 0 000

To escape you must get the pattern to be a black hole sur- rounded by stars. x kK k k O *

x“ xk x

You can only fire at stars. The stars explode. leaving a black hole. but they also produce new stars in other locations. What the galaxy will look like after you fire at a star is important.

l x x 2 x x3 «x x x x x xx & x 5 x 6 XX x x x x x 8 x x x x 9

The number is the star fired upon. The x's are the holes changed to stars or stars changed to holes (the reverse of what they used to be). The .’s are the star or holes that are unaffected.

For convenience sake the computer displays the star numbers in a block next to the galaxy pattern. Examples are:

000 1 2 3 0 * O L 2 3 kee Shoot Star 5 kgk 456

will result in 000 789 this O * 0 789

Do not end with all black holes or you will be lost in space forever!

000

000

000

The lowest possible number of turns to solve the problem is eleven. There are many ways to solve it; here are two: 5.2.8.1.7.3.5.9.2.8.5 3.2.1.3.6.7.5.2.9.8.5 You cannot read the program listing and figure out how to solve it. It is very challenging game which will give hours of fascinating fun.

Bill Eckel, 7336 South 71st Ave., Omaha, NB 68157.

SYNC Magazine

5 REM BLACK HOLE WRITTEN BY BILL ECKEL APRIL

2. 1981 10 DIM X(9) 14FORI=1TO9 16 LET X(I) = 0 18 NEXT I 20 LET X(5) = 1 25 CLS 30 PRINT. BLACK HOLE” 32 PRINT 34 PRINT 35 LETI=1 40 PRINT .: 42 FORA = 1 TO3 640 RETURN 980 IF X(B) = 0 THEN GOTO 986 44 IF X(I) = 1 THEN PRINT “‘*”: 700 LET B = 4 983 IF X(B) = 1 THEN X(B) = 0 46 IF X(I) = 0 THEN PRINT “O”: 710 GOSUB 980 984 RETURN 48LETI=1+ 1 720 LET B = 5 986 LET X(B) = 1 49 PRINT “>; 730 GOSUB 980 990 RETURN 50 NEXT A 740 LETB =8 1000 FORI=1TO9 52 PRINT 3 1-3; * "1-2," 1-1 750 GOSUB 980 1010 IF X(I) = 1 THEN GOTO 1050 53 PRINT 760 RETURN 1020 NEXT I 54 IF NOT I = 10 THEN GOTO 40 800 LET B =7 1025 PRINT “YOU BLEW IT” 56 PRINT 810 GOSUB 980 1030 PRINT “YOU ARE LOST IN SPACE FOREVER" 58 PRINT 820 LET B = 9 1040 STOP 60 GOSUB 1000 830 GOSUB 980 1050 IF X(5) = 1 THEN RETURN 65 PRINT “WHICH STAR?” 840 RETURN 1060 FORI=1TO4 70 INPUT S 900 LET B = 5 1070 IF X(I) = 0 THEN RETURN 75IFS 1ORS 9THEN GOTO 70 910 GOSUB 980 1080 NEXT I 78 IF X(S) = 0 THEN GOTO 70 920 LET B = 6 1090 FORI=6TO9 85 LET X(S) =0 930 GOSUB 980 1100 IF X(I) = 0 THEN RETURN 90 GOSUB S * 100 940 LET B = 8 1110 NEXT I 95 GOTO 25 950 GOSUB 980 1120 PRINT “CONGRATULATIONS” 100 LET B =2 960 RETURN 1130 PRINT “YOU FOUND THE BLACK HOLE” 110 GOSUB 980 1140 STOP 120 LET B = 4 130 GOSUB 980 eee —- .Oo —— 1. 140 LET B = 5 150 GOSUB 980 SAMPLE and 160 RETURN ———— ere 200 LET B = 1 210 GOSUB 980 220 LET B = 3 230 GOSUB 980 A EA 240 RETURN 000 12 3 300 LET B = 2 0* O 45 6 310 GOSUB 980 320 LET B = 5 uh a oe 330 GOSUB 980 WHICH STAR? 340 LET B = 6 5 350 GOSUB 980 360 RETURN OO u ua AAA 400 LET B = 1 410 GOSUB 980 BLACK HOLE 420 LET B = 7 0 * O 123 430 GOSUB 980 I 440 RETURN =O oa 500 LET B = 2 0x0 789 510 GOSUB 980 WHICH STAR? 520 LET B = 4 2 530 GOSUB 980 540 LET B = 6 —m o IsyT s rÁ, OO. 550 GOSUB 980 560 LET B = 8 BLACK HOLE 570 GOSUB 980 a 580 RETURN os 123 600 LET B = 3 * O x 45 6 610 GOSUB 980 ee te 620 LET B =9 WHICH STAR?

630 GOSUB 980

Seer

May/June 1981

NEW ENGLAND SOFTWARE

7 GAMES FOR THE zx80 AND MICROACE ONCASSETTE

MASTERMIND DOUBLEMIND

SLOT MACHINE CRAPS

TIC TAC TOE SUB RESCUE

WHITE HOT NUMBER ALL RUN IN1K RAM

New England Sofiware Bex 691 Hyannis, MA, 02601

$ 1 1.00 ORDERS MAILED

First Class (U.S.A.

£ 6.00 Air Mail (England)

OUR BEST VALUE IN QUALITY SOFTWARE

CAMES

* * * FOR THE 1K AND 2K ZX-80, MICROACE * * *

CASSETTE ¿ 11

e SLOT MACHINE - BRING PLENTY OF MONEY e ROBOT FIGHT - WHOs THE FASTEST LASER e CORPORATION - CAN YOU KEEP A COMPANY AFLOAT e TANK BATTLE - TANK AGAINST TANK ON A MINE FIELD

CASSETTE &

e LUCKY LINDY - MAKE IT ACROSS THE ATLANTIC e CROP DUSTER - SPRAY A FIELD FROM TWO FEET e NUKE em - BOMB ENEMY MISSILE SILOS e CARRIER LANDING - DON'T LAND IN THE DRINK

PHARAGHS TREASURE EXPLORE THE PHARAOHS PYRAMID FOR TREASURE

TRAVERSE THE INTRICATE MAZE SEARCHING 1K FOR ANCIENT TREASURE. BEWARE THE PHARAOHS CURSE THAT NO ONE SHALL COME OUT ALIVE !

EACH CASSETTE $10.00

Tensor (Technology ©

P.0. BOX 17868 IRVINE,CA 92713 (714) 770-8239

SEND FOR UUR FREE BROCHURE CALIF, RESIDENTS ADD 6% SALES TAX

FOREIGN ORDERS: - ADD $2.00 FOR SHIPPING - SEND U.S, FUNDS FOR PROMPT SERVICE

10

In our first issue we challenged our readers to fit the Ham- murabi game from Creative Computing’s Basic Computer Games into the 1K memory of the ZX80. A number of readers took us up on the challenge and submitted their entries. The results are as follows:

First place

(a one year subscription to SYNC and a

SYNC T shirt): Michael Hodgkins

46 Broadway

Duffield Nr. Derby DE6 4BU England Second place

(a one year subscription to SYNC): Un Jung Kang

1620 McElderry St. 12D-4 Baltimore, MD 21205

Third place

(a SYNC T shirt): Ken Berggren

104 Ridgeway Ave. Louisville, K Y 40207

Honorable mentions

Dennis A. Adcock 9516 - 76 Street Edmonton, Alberta T6C 2K9

Canada

Lester S. Cottrell. Jr. 108 River Heights Drive Cocoa. FL 32922

Bob Ferguson 19 Farrington Ave. Allston. MA 02134

John P. Filley 1501 Murfreesboro Rd. Nashville. TN 37217

Leonard Gaunt

44 Hartherop Road

Hampton Middlesex TW12 2RP England

Dennis A. Likens Box 1125 Tuskegee Institute. AL 36088

lan S. Logan

24, Nurses Lane Skellingthorpe Lincoln LN6 OTT England

Claude Ostyn Box 2035 Sitka, AK 99835

Robert M. Selz P.O. Box 24 Pleasant Plains. IL 62677

Harley Shanko 15025 Vanowen. #209 Van Nuys, CA 91405

Ken Stetina 3626 Eastway Drive Island Lake. IL 60042

Ephraim Vishniac 38 Gorham Street Arlington, MA 02174

SYNC Magazine

Hammurabi in ik Michael Hodgkins

g LET Gafa |

PRINT "WE HAVE "36" BUSHELS"

15 ERINT “POPULATION " A

E PRINT SUA TN OWNS "A" ACRES" |

SO TE Yell THEN SOTO 250

35 PRINT "LAND PRICE “pp BUSHELS/ACRE” 40 PRIM T "BUY HOW MUCH”

as INEUT E

SO IE Past THEN GOTO Fe

55 LET =+ O LET G=G-FX] 65 GOTO 9 O PRINT ELL HOW MUCH” S INPUT E Go LET Fs] es GOTO ss QO [UL 23 LET FusRMD CS LOO LET G=G- SS PRINT "PEED YOUR "ee! SUEJECTS—-pax "si

! LO TMPUT É

H i hac Je Fee THEN GOTO tin ' l

tee

210 PRINT RATS ATE

215 LET Yeved

-ge

220 GOTO Lo

PRINT “PLAGUE” SEQ PRINT E<FEZ2; 9 DIE" O35 LET Pap yo 240 GOTO 210 24% PRINT "MURDER Es 250 PRINT CEND

To run. press RUN and NEWLINE. Then enter your choices as called for by the computer.

When you reach “END OF REIGN” and want to start again. press any key and then press RUN and NEWLINE.

May/June 1981

The game begins by telling the player the state of the economy he is to manage. The lines of the game function as follows:

2-8 Set up variables, year, population, acreage. and grain.

10-20 PRINT information on the screen.

25 Sets random land price. 30 Year counter to check for end of reign.

35-45 PRINTs land price and asks how much the player wishes to buy.

50 If no land is bought. the program jumps to 70.

55-60 Adjusts acres and grain according to the transaction.

70-85 Asks how much land the player wants to sell; then goes to 55 to adjust variables as before.

95-100 Chooses a random number to be used for a variety of things. First it subtracts the amount of grain eaten by rats.

105-145 Tells the player to feed subjects; checks that he

| is not feeding them more gram than he has; works out how many people starved and the remaining grain. If the number starved is too large, it jumps to 245.

155-170 Instructions to sow grain, telling player how much grain may be sown, tended. etc.

175 Checks that he is not cheating.

185 Decides crop to be harvested.

190-210 Gives readout of year’s events.

215 Increments year number by 1.

220 Returns to beginning of new year.

225-240 Plague routine; approximately half the people die. 245 Prints MURDERER if more than 10 people have

starved. 250 Final statement; game over.

The program uses almost every byte of memory available. The same variable F is used for all INPUT's to save memory and also a single random number R is used for the number of people entering the city. the number of bushels devoured by rats. and the test for a plague. A plague occurs when R=1, thus avoiding the complications caused by “1 PEOPLE” entering the city. O

11

How Is It Done? Aseries of articles

Auto-Display-Changing

Introduction

The standard ZX80 is supplied with a 4K ROM and 1K of memory. There are 22 commands that can be used in the Basic provided in the 4K ROM. How- ever, there is no command that will cause the display to be shown for a specified length of time before a change is made to show the next display. The advertise- ments for the 8K ROM mention a com- mand called PAUSE which is expected to perform this function.

The following program constructs the machine code routine for such a PAUSE command. The actual program occupies about 1/4K, leaving the programmer a little under 3/4K in which he can store his different displays.

The actual displays are constructed using Basic PRINT commands in the ver- sion given here, but there is no reason why machine code constructed displays should not be used if greater speed or complexity is required. (See SYNC, vol. 1, no. 1)

A certain amount of ‘flicker’ is pro- duced between displays because the rou- tine ‘returns to Basic’ after the specified time period. This ‘flicker’ can be elimi- nated only by remaining in machine code and synchronizing the program perfectly.

The Theory

The Screen and Keyboard routine, decimal address 316-437, Hex. address 013C-01B5, in the 4K monitor program

Dr. I. S. Logan, 24 Nurses Lane, Skellingthorpe, Lincoln LN6 OTT England. This article is the second in a series.

12

Dr. I. S. Logan

can be considered the dominant routine in the operation of the ZX80.

It is this routine that both reads the Keyboard and produces the display on the TV screen. It therefore follows that this routine cannot be called unless a complete display file has already been constructed.

The routine can be divided into three parts:

Part 1. Update the frame counter.

Part 2. Test the Keyboard for new input.

Part 3. Produce the display of the cur- rent display file.

COMPLETE A DISPLAY FILE

SCREEN & KEYBOARD ROUTINE

PRODUCE DISPLAY

ISA KEY BEING

NO PRESSED?

INITIALISE

If there is no key being pressed, then the whole routine is executed over and over again. However, if a key is being pressed, then an exit is made from the routine to handle the ‘interruption.’ This may lead to the cursor being moved, characters being added to the current E- line, or the RUNning of a Basic program. As long as the programmer has not cre- ated a ‘never ending loop,’ the Screen and Keyboard routine will eventually be re-entered and a display will again appear on the TV screen.

The flow diagram below illustrates the normal operation of the ZX80.

n[ A.” —.—

ACT ON KEY

e.g.. Move cursor. | build up E-line.

| RUN BASIC. |

UPDATE FRAME COUNTER

SYNC Magazine

The AUTO-DISPLAY-CHANGING program copies most of the Screen and Keyboard routine from the 4K monitor program into the memory and adds a timing loop so that the display can be held for up to 256 frames, about 5 sec- onds. The programmer is then able to use this ‘new’ routine to produce a display on

The Program

The program, although fairly simple, is quite difficult to enter. Therefore do it slowly and carefully. SAVE the partly entered program often. Step 1 Enter the following lines and then SAVE:

2 REM 12345678901234567890123456789 01234567890 1234567890 12345678901 234 56789012345678901234567890 123456789 01234567890123456789012345678901234

4 GO TO 28

6 LET A=USR(16428)

8 CLS

Reserve 134 locations. Do not use all spaces!

A will return the Keyboard codes.

the TV screen.

It is important to emphasize again that a complete display file of 24 lines must be constructed before the routine is called. In the following program the display file is completed by calling the subroutine at line 16. However, this can also be done in machine code if required.

The following flow diagram shows how the ZX80 operates with the new” rou- tine:

From now on NEVER use LIST or HOME.

The magazine for Sinclair ZX80 users

Bi A $ ©

ACT ON KEY RUN BASIC Es SNA PROGRAM

RUN BASIC

INITIALIZE | TIMER —> |

CONSTRUCT DISPLA Y

| | IN BASIC |

NO COMPLETE DISPLA Y ds YES cm

ANOTHER DISPLAY?

‘NEW SCREEN

W; ë k

T-SHIRTS!

Proclaim the computer of your choice on your chest with our own Crash Cursor and Sync. Design is white on dark blue shirt for a striking effect. Available in adult S,M,L and XL. $6.00 postpaid in U.S.A.; 3.00 postpaid in U.K. Send U.S. orders to SYNC, 39 East Hanover Ave., Morris Plains, NJ 07950. Send U.K. orders to SYNC, 27 Andrew Close, Stoke Golding, Nuneaton CV13 6EL.

PRODUCE DISPLAY

DECREASE

& KEYBOARD ROUTINE TIMER

NO

ISA KEY BEING PRESSED?

IS TIMER AT ZERO?

YES

May/June 1981 13

Step 2

Make the following check:

Enter as a direct command:

PRINT PEEK(64*256+199) & NEW- LINE and the value 118 should appear. (This is the ‘end of line marker’ for line 6 and the correct address must be known.)

Now enter RUN 10 & NEWLINE. The screen will now display the machine code that has been entered into line 2 and held off the screen.

The correct CHECKSUM is 14421; cor- rect any errors before proceeding.

Step 4

Delete all the lines from 10 to 80 (inclu- sive) by entering the line number and NEWLINE over and over again.

SAVE the program. It should consist of lines 4-8 on the screen and line 2. off the screen.

Step 3

Enter the following lines and then SAVE. 10 LET A=16428

12 POKE A.205

14 POKE A+1.59

16 POKE A+2.64

18 POKE A+3.33

20 POKE A+4.199

22 POKE A+5.64

24 POKE A +6.34

26 POKE A+7.38

28 POKE A+8.64

30 POKE A+9.96

32 POKE A+10,105

34 POKE A+11.201

36 POKE A+12,205

38 POKE A+13.173

40 POKE A+14.1

42 POKE A+15.58

44 POKE A+ 16,43

46 POKE A+17,64

48 POKE A+18.61

50 POKE A+19.200

52 POKE A+20.50

54 POKE A+21.43

56 POKE A +22.64

58 FOR I=319 TO 427 60 POKE 16132+1.PEEK(I) 62 NEXT I

64 POKE A+24.4

66 POKE A+132,135

68 LET T=0

70 FOR I=A TO A+132 72 PRINT PEEK (I);

74 LET T=T+PEEK(1) 76 NEXT I

78 PRINT

80 PRINT “CHECKSUM = `;T SAVE.

Step 5

Eniter the rest of the Basic program: 10 POKE 16427,255

12 POKE 16421.24

14 RETURN

16 LET A=PEEK(16421)-1

18 IF A=0 THEN RETURN

20 FOR A=1 TOA

22 PRINT

24 NEXT A

26 RETURN

28 GO SUB 8

30 REM AUTO-DISPLA Y-CHANGING

The program is now complete. so SAVE this version carefully. Remember. never use LIST or HOME.

n | ZN MM cm Oe ee ——r- ——ə.. —N —. h = —— -— ——— —oS—Szss—-Fr

Call the routine at line 42

The address of the end of line 6

The return address needs to be stored in System Variable 16422 and 16423 Return Keyboard codes in HL register

pair.

Call screen production subroutine.

Fetch timer from 16427.

Decrement timer. Exit if timer Is zero.

Restore timer.

Copy most of Screen and Keyboard rou- tine from monitor to the memory.

Adjust timing slightly. Change a JR value.

Form a CHECKSUM

Initialize timer to 5 seconds.

Create a 24th line so as to give a

‘full display.’

This routine will complete the display file. It adds the appropriate number of PRINT’s to fill the 24 lines.

Initialize timer for Ist display.

Optional REM line.

SYNC Magazine

Using the program

It is not really the author's intention in this article to describe at any great length just how the program can be used. The following examples are given so that the reader can start to see for himself how different problems are tackled.

Simple display changing

Enter the lines; 100 PRINT “DISPLAY ONE” 196 GO SUB 16 198 GO SUB 6

200 PRINT “DISPLAY TWO” 296 GO SUB 16

298 GO SUB 6

300 GO TO 100

996 CLS

998 STOP

RUN

As long as the program is entered cor- rectly, the first display should appear on the screen for five seconds. Then the screen will ‘flicker’ and the second dis- play will appear. Because of the LOOP BACK the displays will alternate forever!

Note that all the keys are active. Press- ing any key. except BREAK. will cause a switch to the next display. The BREAK key is still active as it is tested at the end of each Basic line. This key can therefore be used to ‘exit’ from the LOOP.

The largest possible display

The following lines show that there are about 550 locations still available for the displays in the standard 1K ZX80.

100 FOR I=1 TO 550

102 PRINT “*”;

104 NEXT I

106 PRINT

196 GO SUB 16

198 GO SUB 6

200 GO TO 198

996 CLS

998 STOP

In the above program the LOOP BACK is used in a different way. By repeating line 198 over and over again. the current display file is used again with- Out any changes.

May/June 1981

—— ——

A very simple 1 line display. Complete display file. Produce the display.

Another simple display. Complete the 2nd display. Produce the display. LOOP BACK

Display is to have 550 *s,

Always go to the next line. Complete display. Produce display.

LOOP BACK.

Find the number

The following game shows how the A variable returns the keyboard code.

In the program a random number in the range 1-5 is the first generated. Then the keys that are pressed by the player are tested for the correct key value.

Each time a key is pressed the score is incremented. At the end of each 5 sec- ond period without a key stroke the score is also incremented.

100 REM FIND THE NUMBER

102 LET N=RND(5)

104 LET N=521*(N=1) OR 1033*(N=

2) OR 2057*(N=3) OR 4105*(N=4) 0

R 8201*(N=5)

106 LET T=]

198 GO TO 204

200 PRINT “SORRY. TRY AGAIN"

202 LET T=T+1

204 PRINT

206 PRINT “I KNOW THE KEY. DO YOU? (1-5)"

296 GO SUB 16

298 GO SUB 6

300 IF NOT A=N THEN GO TO 200

302 PRINT “WELL DONE”

304 PRINT “YOU TOOK"T:" GO”:

306 IF NOT T=1 THEN PRINT “ES”

308 PRINT

310 PRINT “PRESS NEWLINE TO RES TART”

312 INPUT A$

314 IF NOT A$="" THEN STOP

316 CLS

318 RUN

The Key values

The Screen and Keyboard routine scans the keyboard and returns in the BC register pair a KEY VALUE that is differ- ent for every stroke. As there are 78 key- strokes. there are 78 different key values.

In the ‘Build up an E-line’ routine these key values are changed to the range I to 78; then the look up table is used to find the correct ZX80 character codes.

However, in order to make the AUTO- DISPLAY-CHANGING program as short as possible. the conversion of key values to character codes has not been included.

The following program can be used to show the KEY VALUES:

100 REM KEY VALUES

102 LET A=0

104 PRINT A

196 GO SUB 16

198 GO SUB 6

200 GO TO 104

Conclusion

Many other kinds of programs can be written using the AUTO-DISPLAY- CHANGING routine. The author has a very nice digital clock. but the ‘flicker’ is a little annoying. Much of the back- ground work for this article is discussed in the authors The ZX80 Companion which contains a more elementary ver- sion of this particular program.

15

Looking inside the ZX80

by Harley Shanko

Since the materials supplied with the ZX80 had no machine language examples, I decided to write routines to let Basic show me the ROM contents. These routines resulted from that effort; later they were combined to permit switching from one mode to another.

The object code routine OBJ allowed me to generate a ‘hand-disassembled’ listing of the 4K ROM, and SYMB to see the ‘printables’ —this allows locating the Basic statement look-up table, single key codes expansion, and the ‘integral function’ expressions. CODE allows a look into the details of how the Basic lines are stored (note: constants are stored in decimal form as entered, unlike some Basic’s) and permits easy counting of the number of bytes consumed by each line.

Use of the program is straightforward. After RUN, the selection is displayed. The operation and keyboard activity are as follows:

Enter number (1 to 3) of desired listing (plus NEWLINE); the address is then requested enter decimal value of address beginning.

Hit NEWLINE.

To change selection, hit any other key (except SPACE or NEWLINE) plus NEWLINE to return to selection mode.

After listing and cursor returns, hit SPACE then NEWLINE twice.

Selection:

Continue: Change:

Exit:

The display is in standard format, with the address in hex at the left and data contents to the right. OBJ presents a cluttered display. Since the program uses

Harley Shanko, 15025 Vanowen, #209, Van Nuys, CA 91405.

16

about 1/2 K and the displayed information uses 336 bytes, formatting with spaces between bytes (hex-pairs) can only be done by either displaying fewer lines or using OBJ as a stand-alone program to increase readability. SYMB is better as it is textual. Look at ROM beginning at 006C (108

¿ç 2 SSS u A IA e, ers G Aa NENP Z CU Looking amgide tine š Ç:

ZREO (1%) MEMORY LISTER

10 PRINTO"1=0BJ @=SYMB 3=CODE" 15 REM BY H SHANEO-22FEBG1 20 INPUT 5

22 CLS

24 IF S>3 THEN GO TO 10

26 PRINT "ADDR="

28 INPUT N

BO LET F=Sx100

52 CLS

54 FOR A=1 TO 16

S6 IF S=3 THEN FOR A=1 TO ZO 60 LET X=N

62 GO SUB 80

64 PRINT " ";

66 GO SUB F

68 PRINT

70 NEXT A

72 INFUT N$

74 IF N$="" THEN GO TO 52 75 IF N$=" " THEN STOF

76 GO TO 10

80 PRINT CHR$(X/4096+28) 82 LET X=X- (X/4096) k4096 84 PRINT CHRS(X/256+28) ; LET X=X-(X/255) #256 88 PRINT CHRS(X/16+28)3 90 LET X=X-(X/16) #16

92 PRINT CHRS(X+28) ;

94 RETURN

75 LET X=PEEE (N)

97 GO TO 88

100 FOR L=1 TO 8 110 GO SUE 95

120 GO TO 250 200 FOR L=1 TO 210 LET X=PEEK (N)

220 IF X>127 THEN LET X=X-128 230 IF X<12 OR X63 THEN LET X=0 240 PRINT CHR (xX)

250 LET N=N+1

260 NEXT L

270 RETURN

200 GO SUB 25

210 PRINT, CHRS (PEER (CN) ) š ZO LET N=HN+2

330 RETURN

Ñ ns

z $26 e

W

decimal) for the keyboard matrix decoder, OOBD (189) for the single-key code expan- sion, OBCO (3008) for the integral function decoder, or at RAM at 4028 (16424) to see this program as stored by the ZX80. Use of CODE at 4028+ details exactly each byte of the program.

Selection

Test if selection Ok

Enter beginning address now Set selection GOSUR address

Set #lines to 164

Get address

and display it

Go to selection subroutine do "CRLF" for each line until done

Get keyboard entry

test if "continue! ae "step"

Otherwise is "nen selection"

4—-hex entry for decimal—-hex conv.

calculate next hex digit achex entry

ehes entry ilehex entry Get byte at address

Set for 3 bytes/line gek byte and loop until done

Set far 16 char/line Get byte remove if “diverted video! exclude nom-textiual char. Display char. Increment address

and loop until done

Get byte at address, display it do SFACE and display CODE t

Get next address

SYNC Magazine

A byte-search routine BYT was used before disassmebling the ROM to locate data, such as Z80 unconditional CALL, JumP, RETurn addresses, although it will search for any byte. Unfortunately, adding BYT, like most other routines to the program, will cause OBJ and SYMB selections to bomb-out with “4” type errors, not enough memory, before completing the display. However, CODE and BYT will still be usable. An alternate solution is to make a second file by deleting a selection and its routine and substituting BYT. To add BYT, follow printout labeled Figure 1.

Another routine generated was a ZX80 dot-matrix routine DOT to study the characters at an 8x scale; the characters are 7 x 6in an 8 x 8 box and DOT forms a SPACE or inverted one for each dot in the character. As a fifth selection, modify the program so that printout will appear as in Figure 2.

Line 520 displays a ‘period’ for the character dot location where the dot should be OFF; this provides a reference for the character location in the box. For a true

Figure 1. change 1G add ...4=BYT... to print statement 4 CHANGE ...S923... te ¿..SS%254... So change saa DTA., CW are BPMs ae acicl 26 IF 524 THEN GO TO 52

50 FRINT "EYTE="; 40 INFUT E 42 GO SUE 410

400 LET MaN 1 Iner. address

410 IF NOY PEEK iN) =B THEN GO TO 400 Loop until match

420 FE TUN

Figure 2. chance LO add ...5S°BYT... 24 change sa BEI (or 4 ta 525 ado WOO LET X=FEEK ON) Get byte

310 FOR Lei TO 8 Do 3 dots/iine

320 LET C227 "space"

3530 IF X41206 THEN 50 TO S60 Test ms bit

SAS LET C= 126 Lt ONE, invert

"apace"

60 LET X=x*x2 70 PRINT CHR® (CO) : NEXT L

LET N=N+1 RETURN

representation, change 520 to LET C=0.

If a 0,1 type (binary) display is desired,

change C=28 at 520 and C=29 at 540. The ZX80 dot matrix is located at 0E00

Remove mab, if

ONE Da left shift Display dat/no dot Locp until done Then incr. address

through OFFF; thus to see the characters enter decimal 3584 (=0E00). Because of their size, only two characters per display are possible.

Blank Cassettes

The quality of cassette tape used to save and load programs is an important factor in getting the programs to run. Tape quality for computers is measured differently from quality for audio tape. The tape must be capable of sending to the computer the electronic signals of the program without transmitting extra- neous noises that could interfere with the ability of the computer to load the tape.

Our blank cassettes are tested and recommended for computer use. C-10 cassette, 5 min. per side, blank label on each side in a Norelco hard plastic box. [0010] $1.25 each.

Head Cleaner

After hours of use, the read/write head in a cassette recorder will pick up minute particles of tape oxide. This dirt will hardly be noticable in dictation or music. But it is very noticable in computer use. One dropped “bit in 16,000, and the program won't load. Help keep your recorder in top shape with our non-abrasive head cleaner. It consists of 18 inches of stiff cleansing fabric:in a standard cassette sheii. One 10-second pass every 40 hours of use will keep your heads as good as new. [0011] $2.00. Send pay- ment plus $1.00 Shipping per order to:

Peripherals Plus

39 East Hanover Avenue Morris Plains, NJ 07950

May/June 1981

Find ZX-80 Owners

Advertise in SYNC, the magazine ex- clusively dedicated to the Sinclair ZX-80 and The MicroAce. Call or write for de- tails and a rate card. Let SYNC readers know who you are.

SYNC 39 E. Hanover Ave. Morris Plains, New Jersey 07950

R.F. SHIELD

(CUTS DOWN T.V. INTERFERENCE)

For the MICRO-ACE Easy to install kit with complete instruc- tions. ZX80 owners! if your shield is damaged, the kit will work for you. (Please specify MICRO-ACE or ZX80) Send $5.00 U.S.A. (£2.5) to:

OUTBOUND ENGINEERING P. O. Box 218 Chandler, Texas 75758 U. S. A.

Why wait 2 or 3 weeks for your check to clear? Send Cash or Money Order. Texas residents add 5% Sales Tax.

INVENTIVE PROGRAMS

FOR THE ZX80 4K ROM/1K RAM

Games, subroutines, and teaching aids in 4 K BASIC and MACHINE CODE. All listings include statement/ subroutine logic and 8K ROM/16K RAM appendix.

PRICE: $1.00 per program listing (minimum order 10, plus $2.50 S& H )

PARTIAL LIST * (4K/1K)

* FLIP-A-COIN * TEST PATTERN

* 1 KEY BANDIT * CASSINDEX * TURRET GUNNER * FOIL FENCING * 2X80. BASIC TEST * BANG! FOR 1 * BLACKJACK * EASTER DATE * FIBONACCI SEQUENCE * STATE CAPITALS TEST * COORD GRAPHICS * MACHINE CODE DISPLAY * BARRAGE * GUILLOTINE * ACEY-DUCEY II

* LINE RENUMBER

* KEYBOARD GRAPHICS * 81 BOXES

TO ORDER Specify programs wanted and enclose payment. ZETA SOFTWARE

P.O. BOX 3522 GREENVILLE, S.C. 29608

* Complete list sent with your order, or send SASE for FREE list and order blank.

17

puzzles % problems

A Building Problem

ur first problem today is an interesting test in construction. In the illustration at the right we see a triangle that has been constructed using three matchsticks and three balls of clay. In our puzzle you are given nine matchsticks and as much clay as you need to connect them together in such a manner as to form seven equilateral triangles. You are not allowed to cross or break the matchsticks. Merlin will be by shortly to inspect your construction.

The Lucky Number

any persons have what they consider a “lucky” number. Show such a person the row of figures subjoined 1, 2, 3, 4, 5, 6,7, 9 (consisting of the numerals from 1 to 9 inclusively, with the 8 only omitted) and inquire what is his lucky or favorite number. He names any number he pleases from 1 to 9, say 7. You reply that, as he is fond of sevens, he shall have plenty of them, and accordingly proceed to multiply the series given above by such a number that the resulting product consists of sevens only. Required, to find for each number that may be selected the multiplier which will produce the above result.

(From Merlin's Puzzler)

The Puffer-Belly Problem

Conrail passenger and freight train out of Hoboken, New Jersey, was heading west towards Morristown, home of Creative Computing, at a speed of 45 miles per hour. Along the way the train meets and is passed by a Dover local train heading east at 36 miles per hour. An alert passenger on the Conrail train, for some reason unknown to us, clocks the Dover train as it passes by him. He finds that it takes exactly 6 seconds for the Dover train to pass by his window. Using the information above, can you calculate the length of the Dover train?

A Seven-Letter Charade

Iright, Hermione, let's see what you learned this year at St. Trinian's. From the four following hints you should be able to deduce the word asked for by this charade. The numbers refer to positional letters within the word.”

“My 1, 2, 7 is an extreme point.”

“My 3, 4, 5, 7 is what the reader will be when he solves this puzzle.”

“My 5, 2, 3, 1, 4 is in heaven.”

“My 4, 5, 6, 7 is the earth.”

“My whole is a country in Europe.”

The Three Jealous Husbands

hree jealous husbands traveling with their wives find it necessary to cross a stream in a boat which holds only two persons. Each of the husbands has a great objection to his wife crossing with either of the other male members of the party unless he himself is also present.

How is the passage to be arranged?

The Four Jealous Husbands

rithmeticians have racked their brains to devise a means of transit for four husbands and four wives under the same conditions stated in the previous puzzle, but, with a boat holding two persons only, the problem is insoluble. If we suppose, however, that the boat contains three persons, it may be solved.

How is this passage to be arranged? (The two puzzles above are from Merlin's Puzzler 3)

If you have a favorite puzzle that you would like to share with our readers, thensend italong to Merlin. If he uses your puzzle, he will send you a copy of one of his famous puzzle and game books. If you can’t wait that long, then you can buy these books from Creative Computing. Each book, Merlin s Puzzler, Merlin s Puzzler 2, and Merlin's Puzzler 3, is 128 pages long and a big 8” x 11” in size. There's a world of “puz- zling” entertainment in these three volumes.

Until next time, Merlin says, “Have a happy 1” You fill in the blank.

>? Your editor, Charles Barry Townsend ES BTS Z SN

Answers on page 35.

18 | SYNC Magazine

The story behind the two best selling computer games books in the world.

Computer

Games

by David H. Ahi

Everybody likes games. Children like tic tac toe. Gamblers like blackjack. Trekkies like Star Trek. Almost everyone has a favor- ite game or two.

It Started in 1971

Ten years ago when | was at Digital Equipment Corp. (DEC), we wanted a pain- less way to show reluctant educators that computers weren't scary or difficult to use. Games and simulations seemed like a good method.

Contents of Basic Computer Games (right)

and More Basic Computer Games (below).

Artillery-3 Life Expectancy Baccarat Lissajous Bible Quiz Magic Square Big 6 Man-Eating Rabbit Binary Maneuvers Blackbox Mastermind Bobstones Masterbagels Bocce Matpuzzle Boga || Maze Bumbrun Millionaire Bridge-lt Minotaur Camel Motorcycle Jump Chase Nomad Chuck-A-Luck Not One Close Encounters Obstacle Column Octrix Concentration Pasart Condot Pasart 2 Convoy Pinball

Corral Rabbit Chase Countdown Roadrace Cup Rotate Dealer's Choice Safe Deepspace Scales Defuse Schmoo Dodgem Seabattle Doors Seawar

Drag Shoot

Dr. Z Smash

Eliza Strike 9 Father Tennis

Flip Tickertape Four In A Row TV Plot Geowar Twonky Grand Prix Two-to-Ten Guess-lt UFO

ICBM Under & Over Inkblot Van Gam Joust Warfish Jumping Balls Word Search Puzzle Keno Wumpus 1

L Game Wumpus 2

May/June 1981

So | put out a call to all our customers to send us their best computer games. The response was overwhelming. | got 21 ver- sions of blackjack, 15 of nim and 12 of battleship.

From this enormous outpouring | se- lected the 90 best games and added 11 that | had written myself for a total of 101. | edited these into a book called 101 Basic Computer Games which was published by DEC. It still is.

When | left DEC in 1974 | asked for the rights to print the book independently. They agreed as long as the name was

changed.

Introduction Hi-Lo The Basic Language High I-Q Conversion to Other Hockey

Basics Horserace Acey Ducey Hurkle Amazing Kinema Animal King Awari Letter Bagels Life Banner Life For Two Basketball Literature Quiz Batnum Love Battle Lunar LEM Rocket Blackjack Master Mind Bombardment Math Dice Bombs Away Mugwump Bounce Name Bowling Nicomachus Boxing Nim Bug Number Bullfight One Check Bullseye Orbit Bunny Pizza Buzzword Poetry Calendar Poker Change Queen Checkers Reverse Chemist Rock, Scissors, Paper Chief Roulette Chomp Russian Roulette Civil War Salvo Combat Sine Wave Craps Slalom Cube Slots Depth Charge Splat Diamond Stars Dice Stock Market Digits Super Star Trek Even Wins Synonym Flip Flop Target Football 3-D Plot Fur Trader 3-D Tic-Tac-Toe Golf Tic Tac toe Gomoko Tower Guess Train Gunner Trap Hammurabi 23 Matches Hangman War Hello Weekday Hexapawn Word

Converted to Microsoft Basic

The games in the original book were in many different dialects of Basic. So Steve North and | converted all the games to standard Microsoft Basic, expanded the descriptions and published the book under the new name Basic Computer Games.

Over the next three years, people sent in improved versions of many of the games along with scores of new ones. So in 1979, we totally revised and corrected Basic Computer Games and published a com- pletely new companion volume of 84 ad- ditional games called More Basic Com- puter Games. This edition is available in both Microsoft Basic and TRS-80 Basic for owners of the TRS-80 computer.

Today Basic Computer Games is in its fifth printing and More Basic Computer Games is in its second. Combined sales are over one half million copies making them the best selling pair of books in recrea- tional computing by a wide margin. There are many imitators, but all offer a fraction of the number of games and cost far more.

The games in these books include classic board games like checkers. They include challenging simulation games like Camel (get across the desert on your camel) and Super Star Trek. There are number games like Guess My Number, Stars and Battle of Numbers. You'll find gambling games like blackjack, keno, and poker. All told there are 185 different games in these two books.

Whether you're just getting started with computers or a proficient programmer, you ll find something of interest. You'll find 15-line games and 400-line games and everything in between.

The value offered by these books is out- standing. Every other publisher has raised the price of their books yet these sell for the same price as they did in 1974.

Moneyback Guarantee

Examine one or both of these books and key some games into your computer. If you're not completely satisfied we'll refund the full purchase price plus your return postage.

Basic Computer Games costs only $7.50 and More Basic Computer Games just $7.95 for either the Microsoft or TRS-80 edition (please specify your choice on your order). Both books together are $15. Send payment plus $2.00 shipping and handling to Creative Computing Press, Morris Plains, NJ 07950. Visa, MasterCard and American Express orders should include card number and expiration date. Charge card orders may also be cailed in toll-free to 800-631-8112 (in NJ 201-540-0445).

Order today to turn your computer into the best game player on the block.

creative Gorepatirg

Morris Plains, NJ 07950 Toll-free 800-631-8112 (In NJ 201-540-0445)

19

Mastermind x

Raymond Fowkes

This game is played much like the original board version. The computer selects a code of four colors from a possible six: red. orange, yellow, green, blue, and white (duplicates allowed). It is now up to you to find. in nine moves or less. the exact color and position of each element of the code by entering four colors of your choice. first letters only, one at a time. The computer then compares the guess with the pre-selected code, first for black pegs and then for white pegs. The pegs are displayed next to the corres- ponding guess. A black peg means a right color in the right position, a white peg means a right color in the wrong position.

For example. suppose the hidden code was R B W B, and the first guess was R G B O. You would be given one black peg and one white peg because ‘red’ is in the right position and ‘blue’ is correct but in the wrong position.

These features make this program Superior to many other versions of this game.

The game continues until 1) the code is broken and “uncovered.” 2) “Q” is entered. signifying ‘quit.’ or 3) all nine tries are used.

Conversion

This program is designed for a 2K system. but can be reduced to 1K by doing the following:

Delete lines 10-140, 250-320, 720-770.

Change lines:

"ROYGRW " (3 C+2144+2KE, B (E) C+203+E,9 C+205+E, 128 FOKE C+DRZO+2XE+11,0 PORE C+Dk20+2KkR+12,0 (B) FORE C+Dk204+19, 0 STOF

SAO 480 360 660 800 al B20) 34.0

PRINT FOKE FORE FOKE

Raymond Fowkes. P.O. Box 336, Coalinga, CA 93210.

20

5 RANDOMIZE PRINT ,” ZO PRINT 30 PRINT " I PRINT PRINT PRINT " ñ ZO PRINT " 75 PRINT Be PRINT " 5 PRINT " F0 PRINT PRINT

1 PRIN j PRINT " O PRINT J

)

WILL

BLACK F COLOR IN

A WHITE E COLOR IN

YOU

LINELL ; PRINT " IN A$

Apal Pp

O INPUT 35 IF NOT CLEAR DIM ACS) DIM BCS) DIM CCS) FOR Bat LET ACE) =RND (6) IF ACB)=1 OF IF ACE) =4 IF ACE) =55 OR NEXT Es CLS FRINT FRINT PRINT PRINT ! FOR F=1 TO 11 PRINT CHR& (128) 370 NEXT F FOR Ci PRINT PRINT PRINT NEXT C FOR D=1 TO 9

FOR E=0 TO 3 INFUT Ag

LET B(E)=CODE (A$) GO SUE 900

FORE C+XIO+2XE, Ed IF Age" gn LET © (CE) #@ (CE) NEXT E

LET E=0

FOR Rea TO Z

IF NOT BCR =C (B) LET E=E+2

PORE C+299+E, 9

THE

O š

"B = BLUE "a -=

10 3

10=-C, x i a

300 310 wan TAG 340 wa) JOQ 370 3080

wd FU)

LET MEX T B

TF Ex

610 FOR fest) S20 FOR Feo TO 3

630 IF OCB Ss THEN GO IF NOT Cc)

LET EE +2

FOKE LET

60

THEN GO TO

TO z

600

640 630 60 FORE Ue 2393 E OE B (F) =O

70

680 700

690 NEXT F 700 NEXT B

710 NEXT D

TOO BAD"

FOG

730 60 SUB 760 PORE B+C+De20, 770 NEXT E

¿30 GO SUE

7970 FOR B=0 TO Š 800 FORE C+DkAZO+2kE +1 610 FOKE C+D*20+2%k8+1 Gb MEXT E

B20 PORE C+D*e#20+115.,0

640 GO TO 130

COD

PC

700 LET C=PEER (16396) +PEEK (14397

210 RETURN

MASTERMIND"

SE “COLORS AND

ey š Ë: Jara

ACE)

LECT OA

YOU MUST

THE

EG

THE

HAVE 9

Q TO QUIT AND/OR", PF

P PLAY.”

N STOP

T ey OR) se

THEN LET

iaa Le Seed

Y =

E)

TO 720

THEN GG

"ESE 7 tht

TO 700 THEN GC

ppp SS sei (neck

E (A$)

ES 7 13 DEE

03, AE)

(At ter

RIG

MEANS

WRONG FOS IT ION. "

YELLOW 0 = BLACK PEG",CHR$(128)3" =

¿A a Shift ñ)

" leave 3

CODE OF FOUR"

TRY

HT

A RIGHT" ¿(2

í `

TRIES." (& sp.)

> THEN LET

(ere ake

TO 890 (Check

LET B(B)=O (Destroy matching pairs)

TO 6%0 white

pedt )

Foar

AE, SEL

CO E)

ORANGER

= GP. TO BREAK IT

MEANS A RIGHT" (3 sp. POSITION.” ©:

E ee HLR) mpi

AB) =A CB) ATA ZO

f Gr”

RED

WHITE FEG

black

USING THE

Cruces a

CLUES

G = GREEN

mec

I GIVE

YOU. "

WHITE

SYNC Magazine

[Instructions] B = BLUE Y = YELLOW O = ORANGE R = RED G = GREEN W = WHITE Sample Runs (2K) W = BLACK PEG O= WHITE PEG MASTERMIND TOO BADO R B O GD I WILL SELECT A CODE OF FOUR COLORS AND YOU MUST TRY TO 9 BREAK IT USING THE CLUES I GIVE YOU. 8 A BLACK PEG MEANS A RIGHT 7 O [Quit] COLOR IN THE RIGHT POSITION. A WHITE PEG MEANS A RIGHT ROQ DETER COLOR IN THE WRONG POSITION. SO OOOUBRGO YOU HAVE 9 TRIES. 4BOOOBORG INPUT Q TO QUIT AND/OR P TO PLAY AGAIN. a = aye TYPE IN P TO PLAY. a= i Cas ! g BBBY 9:135 B = BLUE Y = YELLOW O = ORANGE R = RED G = GREEN W = WHITE B -= BLACK PEG O= WHITE PEG YRBW [Code is only “uncovered” after it is Sample Runs (1K) guessed, all turns are used, or a quit] 9 ROYGBW D GR G Y O [Code is only “uncovered” after it is 8 guessed, a quit, or all turns are used] 7 9 6 8 W @ MB Y R BW [Correct answer] 8 58E 0O Y Y GR 7 48 B Y Y OW 3m G WG w Mischr9 68 BBAEAGCRGY [Correct answer] . G WEB R 2. O R O R Dischr 128 >m O 48 8 G WO Y 10 O B B Y Y LA 30m Y B BY O Creative Computing 20 RORO 18 O G G WW 9:840

“It says the odds of you making that hand are 2,385,000 to 1, and the odds are 3 to 2 that a nut like you will try for it.”

May/June 1981 21

Graphics Surprises

James H. Parsons

When we combine the uncertainty of the ZX80's randomizing feature with its graphics capacities. we have the ingredients for a lot of fun. For example. the Crazy Quilt program uses only two instructions, yet it fills the screen with a zany tangle of symbols and spots:

Crazy Quilt

10 PRINT CHRS(RND(9)) +2);

20 GO TO 10

Using “((RND(9)+2)” to assign the characters to be printed insures that only the keyboard graphics symbols. CHR$(2) through CHRS(11). will be selected; and it avoids the blank space. CHR$(0). and the null string. CHRS(1). By changing the range of numbers being randomly selected. we can fill the screen with letters. numbers. punctuation marks. inverse characters. or any combination of these so try numbers other than 9 and/or 2.

Walls and Dikes

A more challenging application of graphics and randomizing is found in “Walls and Dikes.” This program generates a maze in which the configuration of the baffles is fixed randomly within parameters which the player can set. In order to make spaces for traveling within the maze. the program alternates rows of “walls” with rows of “dikes.” The wall rows are solid with just a few randomly-placed spaces to pass through. The dike rows are com- pletely open. except for several randomly- placed dikes. To keep maze travelers from sneaking around the ends of wall lines. there is a 19 x 23-space frame around the whole maze. A randomly-placed opening in the top of the frame lets maze travelers in. In the bottom of the frame is a randomly-located treasure marked by a $.

James H. Parsons. 2575 Eastcleft Dr.. Columbus. OH 43221.

22

The prospective maze traveler enters the densities (from 1 to 100) of the walls and dikes. When the computer draws a maze according to the densities specified. the maze traveler must try to find a way from the door at the top of the frame through the maze to the treasure at the bottom. Relatively “thin” densities of walls and dikes (for example. W=10. D=5) present no challenge, while extremely dense configurations (for example. W=95. D=65) cease to be passable mazes at all. Densities of about W=88 and D=9 seem to give the most satisfactory results. At these

densities, some of the mazes produced will be ridiculously easy to get through, while some others will be impassible. Most will be somewhere in between.

The blank line just above the bottom of the frame avoids the frustration of finding a wall or dike sitting right on top of the treasure, and sealing it in. With the blank line, the treasure is always accessible from some part of the maze.

Try experimenting with different densities for the walls and dikes. Try using different symbols for the parts of the

maze.

SYNC Magazine

Typical Run of “Walls and Dikes”

The player starts the program running by pressing RUN and NEWLINE and the display on the screen says:

WALLS AND DIKES

WALL DENSITY?

The player enters a number from 1 to 100, indicating the percentage of space to

be filled in by solid horizontal walls. DIKE DENSITY?

FRINT . "WALLS AND 20 PRINT "WALL oO) TNFUT U PRINT INFUT D eS

LET Ath Fe GBO LET Fa: CHE GO SUB. 1000 FOR Ci TO 8

Lac)

$1 S (y)

` 7

Lio PRINT Ass La FOR Ke "I Le Les. | 140 TE + | IF NOP FE< D | BEKT E

| ELBIT 1 PRINT ror (2 es Lisi ait IF ww! IF HAN MEX T G PRAD

oA oe > fot Y, L

tas lee

oe

jt En F. is, Je y £ NOT PISIN THEN

MEDIOS THER PRINT

fou PRINT FOR Læt FRINT MEXT La PRINT Let BS weet GO SUE 1 D (at) PRIN

TEEL]

miad Laa

Gi

ig T

BE LEERS

Pose” See? teo”

“WEIL. DME í

ty

ETE PCO 20 1000 LOTTO Loo IO 11040 1030 1060 1070

LET AasRND CZL) FOR Bei TO 21

IF NOT B=ñA THEN

IE Ea THEN PRINT NEXT B PRINT

RETURN

A$

May/June 1981

PRI

PRINT A$; (E

Ck.

t A.

Bens

(Makes ( L OUO 25 C Laine

(|a eaf t.

RE $ n u i se. dp

Right side af dr { F: iu tj "ma

š HI al lo a E be

PRINT

The player enters a number from 1 to 100 indicating the desired percentage of space to be filled in by dikes.

The screen goes blank for a few seconds. and then a maze appears. The maze is framed on all four sides, but there is a gap in the top part of the frame for the player to “enter” by. and a dollar sign in the bottom part of the frame—the “treasure.”

DIKES" DENSITYT™

"DIRE DENI TY?"

the

hep öf ales g

thie A QENE E Wali DALE. )

side of frame

joeg pave Geum, saa REO sq, pisai gave gece Gener aves

Ti a

dik

bog. ets A Eh

E 5 TH E HN FRINT Arz

sts

Or trame for di

rates Wald

sees, JF Me aa Ly rt

Arme Fo

A la ies act Sure in battom of

Lom cir the

me ttm te Deum ne ay ET make) Py a ta] La

“ftreasure out ot

oe? coor Zt

inte the door /treas

door/treasure cut of

ee CUES n

i ee P P, `. ... sore < .... > e .. a i Crp £ PETES orgy Weed 1 j }

The location of the door and treasure is determined randomly. as is the distribution of walls and dikes. once their densities have been set. Under the frame is printed: NEWLINE

When the player presses NEWLINE. the maze is replaced by: WALL DENSITY The game begins again.

E

)

| st a ae ë Umm L k Py gig ee

e Lines. )

10.1)

Pe LTTE 3

+ po z aa po Reminds player how ta get l

T T Z$ (P

tert corners, )

= B Ë: 3 cl “Ll AE ES " )

21 ALI (cA ad

righk corners.)

23

As

Endangered Species

Thirty-six different issues and not one has yet learned to breed in captivity. Their days in qi i el

our warehouse are limited. Could you provide a good home for a magazine: In exchange. led: Mudie Wei ects: suena L r=

you re assured hours of reading pleasure. And. before they disappear. find the missing link ictions: PEE Kine and POR Eme for

in your own collection. ` Video Displays: Interview with

The applications, programming techniques, simulations, problems, commentary, articles fichael Shrayer: Computers and Edu-

hd : . . ation—Questions of Value: Game and fiction are practically timeless. Not only that. but the earlier issues are actually roprams for Gold Mine and Atom 20. Increasing in value.

valuations: Heathkit H-8: Thinker Prices are $2.50 each for all issues after March 1980. $2.00 each for all other issues. $5.00 oys Floppy Disk: Electric Pencil: for three. $15 for ten. Postage is $1.00 for up to 3 issues. $2.00 for 4 or more. Best bet is the eS oe en Eor Super Special: One of everything we have —36 magazines in all—for only $50 post paid.

omputer Music Records. creative compatirg

ol. 5, No. 3—March 1979 39 E. Hanover Avenue Morris Plains, NJ 07950

ol. 5, No. 2—February 1979

ultiple Regression Analysis Simpli-

bir Articles on Data Base Manage- Vol. 3, No. 4—July/Aug 1977

ent: Sports Judging on a Microcom- uter: Shopping for a Payroll System:

Four Dynamic Games: Eliza (in

Basic!) Bocce. Backgammon and

FO. First Part of Dwyer's “8-Hour ourse in Basic.” Writing Your Own CAI: “Structuring the Lesson to the student.” Interview with Lee Felsen- stein, Designer of the SOL (and several machines since!). Computers in Medi-

Vol. 4, No. 4— Jul / Aug 1978

Features on Business Computing and Word Processing: Special Section on Interfacing Your Computer to the Outside World: Three Perspectives on Video Games; ROM Section; High Resolution Graphics for Apple Il: GAMMON and EVILK Motor Cycle Jump Game Programs. Evaluations:

‘ine and Health Care. Evaluations:

Spacewar and TREK

80. “Sherlock

Holmes and Charles Babbage.”

Vol. 3, No. 5—Sept/Oct 1977

Dynamic Debugging System for 8080 Assembly Language: Bibliography of “Limits to Growth” Models: Dwyer: 8 Hour Course in Basic—Part 2: Pro- gramming Approaches to Solving Complex Equations: Computerized Conterencing. Symmetric Art on your Computer. Games: Nomad. Rotate. Lissajous. Evaluations: 5 Microcom- puter Basics: Software Technology Music System.

ol. 3, No. 6—Nov/Dec 1977

rogramming Techniques: File Struc- ures: CAI: Multiple Problem Types:

ii a

omputer History Quiz: Final Exams by Computer: Dwver: 8 Hour Course

in Basie— Part 3,

Mastermind il.

Othello. and Inorganic Chemistry Pro-

grams. Evaluations:

Nine Microcom-

puter-based Toys: Comp IV: S-100 Compatible Kits: TDL Xitan: and three

$080 SK Basics.

Vol. 4, No. 1—Jan/Feb 1978

Fast Sorting Algorithm: How to Write a Computer Simulation: More File Structures: LOGO: Murphy's Laws: Dwyer: 8 Hour Course in Basic Part 4. Programs for World Population Model. Biorhythms in Basic and APL. Yahtzee. Van Gam. Kirkof, and Net- work. Evaluations: 3 Electronic Games: Radio Shack TRS-80: Heath H8 System.

Pet: Apple II: Atari Video Pinball:

Atari Video Computer.

Vol. 4, No. 5—Sept/Oct 1978

Educational Features: 4 Simulation Articles: Accounts Receivable Sys- tems: Real World Games:A Real-Time Clock You Can Build: All about PAS- CAL: Intelligent Videodiscs; 40 Pro- gramming Ideas: ROM Section: Hex and Star War Games. Evaluations: Exidy Sorcerer: Radio Shack TRS-80: Bally Arcade: Speak & Spell and Spell- ing B: Computalker Speech Synthe- sizer: Peninsula Pet Cassettes. Merlin Video Interface.

ol. 4, No. 6— Nov/Dec 1978

Consumer Computers Buying Guide: ritical Path Analysis; Experiment in eaching Strategic Thinking: ROM ection, Subject Index and File Index n Basic. Programs for Mail Lists, Pat- erns, Plotting, Corral, Joust, Puzzle. nd a Christmas Letter. Evaluations: P/M Disk Operating Systems: North tar Horizen: Backgammon Compu- rs: Smart Electronic Games and ideo Games.

- Vol. 5, No. 1/January 1979

Computers and Robots in Fiction: Guidance Counselor System: Survey of Educator's Attitudes: How to Hide Your Basic Program. A Program to Calculate Depreciation for Taxes. and

the Space Maze Game. Counterfeit

Cursor and Speed Reading for the Pet. Evaluations: Microsoft Fortran 80:

Structured Programming with Tiny c: Smoke Signal's Text Editor: Exid y Sorcerer: Ohio Scientfic Superboard i. a

rogramming the Game of Go: Busi- ness Computing with the Sorcerer: Social Science Survey Program. Eval- uations: Terrapin Turtle: Videobrain: Pet Monitor: TRS-80 Floppy Disk: Apple Floppy Disk.

ol. 5, No. 4— April 1979

Safeguarding Your Computer: Inter- pretive Programming: Elements of a Good Computer Game: Music Com- position: Marin Computer Center. Programs for An Intelligent Calendar. Vertical Graphs and Bar Graphs, Flowers for the PET. Evaluations:

heckbook Maintenance System: Whatsit Data Base Management Pro:

Word Processing Systems: Pilot Tutor- al: Writing User-Oriented Programs: Amoritization Schedules, Reading and

omprehension Exams: Hiding Your. Basic Program: Cribbage and Mille Bornes Game Programs. Evaluations: WP Daisy Word Processing: Word- master Text Editor: PDI IQ Builder; Malibu 160 Line Printer

Vol. 5, No. 6— June 1979

signt Articles on Computer Graphics nd Plotting: Using Basic Strings: Microcomputers in the Hospital: Billing Program for the Sorcerer. Ink- blot and Greed Game Programs. Eval- uations: TRS-80 Voice Synthesizer: HIPLOT Digital Plotter: Structured Systems. Name and Address Program: ALF/Apple Music Synthesizer.

o. 7— July 19 Four features on Sorting. Files and Data Bases: Creativity Test: World ower Systems: Personal Finance odel: Two Ecological Simulations: rograms for an Ecological. Game. Niche. Brain Teaser. dnd Zone X. Evaluations: BrighterWriter. SWTPC T-82 Graphics Terminal: APF PeCos ne: Heuristics Speechlab: Micro Pro Super Sort: Diagnostic Programs for the Pet.

Vol. 5, No. 8—August 1979

Can Computers Think”: 5 Basic Lan- guage Programming Techniques: The Law and Your Computer: muMath: Image Processing: Manipulating Pen-

cil Files: Adventure. a new type of

computer game simulation. The Games HVOLT and FORT. Evalua- tions: Texas Instruments 99/4: Radio Shack TRS-80 Model Il: SWTPC PR- 40 for the Pet: IMSAI VIO.

k.

Nol. 5, No. 11— November 1979 Vol. 6, No. 6— June 1980

Adventure: Complete Listing in Basic. Fourteen Graphics Articles: Polar Controlling Household Devices: Car Plots. 3-D Graphics. Animation, Pooling: Mumps language: Computer Graphic Mazes. Motion Simulation. Í art Exhibition: Build Your Own Joy- Inside Space Invaders. 7 Music Arti- “sticks: Telephone Dialer for TRS-80 “les: Digital Audio, Computer-Aided or Northstar: Teacher-Made Tests: | Sight Reading. Design of a Synthe- Evaluations: Comparison Chart of 6 Sizer. Digital Enhancement of Old Popular Personal Computers: Com- Recordings. Comparison ot Printers: parison of 26 Single Board Computers: | Evaluations: The Atari Machine: Electronic Games & Toys: Quick Neelcos Music Box for the PET: Printer Il: Interact Computer: User- HeathKit-Thomas Electronic Organ

Definable Character Generators: Kit.

TRS-80 Level 111 Basic: Pet Software Vol. 6, No. 7—July 1980

from Creative Software: Word Proces- Four Articles on Adventure Games:

sor: Introl X-10 Home Control System. Dragon, Dungeon. How to Fit a Large Program into a Small Machine. How

to Write an Adventure. 6 Simulation Vol. 9, No. 12—December 1979 Features: Genetics. Electric Manage-

Controlling Household Devices: Part ment. Medical. Ecological. Sports. 2: LOGO: Computerized Biofeed- Self-Reproducing Programs: Man-

back: Computers at the Rodeo: Crea- Machine Dialogs: Selecting a Compu-

ting Digitized Video Images. Programs

for using the Microcomputer as an Investment Tool: Animation on the

Apple. Magic Tricks. “Turn-Key”™

CP/M System. Evaluations: More

Electronics Games: Language Trans- lators: APF MP1000 Video Game Sys-

tem: 6 Word Processing Printers: Satellite Tracking Software; SysKit for the 8080: Assemblers: CP/M vs. TSC: Statistics for the TRS-80.

Vol. 6, No. 1—January 1980

Interviews with Donald E. Knuth and William Wulf; Six Features on Artifi- cial Intelligence: Air Traffic Contro!- ler; Computerized Resume: GROW: A Program that Learns: Evaluations: Six Basics: NEWDOS and TRSDOS:

Auto Scribe: Micro Music.

Vol. 6. No. 2—February 1980

Six Articles on Investment Analysis:

David Levy: Intelligent Computer

Games: Programs: Geneology. Graphing. Genetics: Evaluations: Word Star vs Electric Pencil: Pascal for the TRS-80: Micro Composer:

Data Dubber: Sorcerer Word Pro-

cessing Pac: Trivia Contest Results.

Vol. 6, No. 3—March 1980

Networks for Personal Computers: Artificial Intelligence: How to Make a Basic Tree: Interview with Joel Birn- baum: Three Mile Island Game; Extended Precision Computation; ‘Rolodex’ Data Base Program: Photo- graphing Your Computer System. Evaluations: TI 99/4, Modems, Cobol. Tiny c. 10 Software Packages.

Vol. 6, No. 4—April 1980

sonal Recreational Micro Computer Data Interface World Journal—the ¿Famous 73 page April Fool parady. 8 ¿Articles on Reading and Language: nterview with Gordon Bell: Evalua- ions: Heath WH-89: Atari 800 vs PET: Chatworth Mark Sense Card Reader: Adventure.

Vol. 6, No. 5— May 1980

Seven Features on Saving Money with vour Computer: Analysis of Stock Options. Budgeting Model. Shopping Lists. Home Inventory. Home Pur- chase. Retirement Planning. Compu- ter-Aided Model Rocket Design: Two Natural Language Systems: Evalua- tions: PET 2022 Line Printer: APF Imagination Machine: Personal Soft- ares Desktop Plan: Universal Data ntrv System.

ter Dealer. Evaluations: Super-Text vs. Easy Writer: Mountain Hardware ROM PLUS+: Toolkit for the Pet: Chart Comparing Basics of 8 Popular Computers.

Vol. 6, No. 8— August 1980

Games Features: Computer Bismarck. Knights Tour. Guess My Animal. Turnablock Game, Fifteen and Hot. Mind Exerciser. Marketing Your Own Program: Computer Graphic Designs: Robotics Conference; Insertion Sort: Stocks and Listed Options. Evalua- tions: Magic Wand: VisiCalc: Beta-80: Asteroids in Space.

Vol. 6, No. 9— September 1980

Twenty Educational Applications and Features: Language Arts CAI Devel- opment, Grading Program, Computers in the Classroom. Asimov: Point of View: How to Heapsort: New Consu- mer Electronic Products: TRS-80 hopping List for Schools. Evalua- ions: Milliken Math Sequences: Exa- ron Stringy Floppy: EDS Videotape eries “Little Computers—See How

hey Run”: 8 Apple JI Software Pack- Ya

ves: Educational Packages.

Vol. 6, No. 10—October 1980

Symposium on Actor Languages and Smalltalk: Linked Merge Sort: How to Solve It: 9 New Applications and Games: Election Prediction. The Pres- dential Campaign. Computer Division “valuations: OSI C2-4P Computer. TRS-80 Voxbox. Two Text Editors. -1ve Music Systems. 15 Software Pack- ves. BASEX.

Vol. 6, No. 11—November 1980

Actor Languages and Smalltalk Part 2: Effective Documentation: Bomb- proof Data Entry: Interactive Systems and Virtuality: Fast Sorting: Control- led Input in Basic: Loosening Packed Basic. Future of Small Business Com- puting: Planning Your Diet. Evalua- tions: Electronic Games: Computer Ambush: TR Copy.

Vol. 6, No. 12— December 1980 A Comparison of Basic Systems: Buving Guides to Personal Computers and Electronic Toys and Games: Legal Protection of Computer Pro- grams: Nuclear Power Plant Simula- tion: Superman Game: Logic Problem

Solver: Interview with the inventor of

the ZX80. Clive Sinclair: Alvin Toff-

ler: The Electronic Cottage. Evalua-

tions: Sinclair ZX80. Atari. Apple Pas- cal. CBM2022 Smart Printer. Pearl. Apple II and Apple II Plus. Pet. TRS- 80.

July 1977

SOL. The Inside Story: Braille and the

Computer Video Newspaper: A Chip

is Born: The Care and Feeding o!

Your Home Computer. Digital Foam the peripheral of the future.

August 1977

The Kit and I, Part I, by someone who's never soldered before: Intro- luction to the Fundamentals of Com-

puter Memory: Tips for the Do-it-Y our-

self Hardware Beginner; Binary clocks; APLomania.

September 1977

Xeroxes and other hard copy off your CRT; Payroll Program: How Compu- ters Work: The Kit and I, Part I]: or Power to the Computer: CCD`s How They Work and How They re Made: A look at PLATO, an Educational Com- puter System; IBM 5100.

October 1977

Binary Arithmetic For the Beginner; Microprocessor Aid for the Deaf and Blind: The Kilobyte Card: Scott Joplin on Your Sci-Fi Hi-Fi; Building a Basic Music Board: Flowcharting: Payroll Program. :

November 1977

Solar Energy Measurement; A Begin- ners Introduction to BASIC: The Kit and I. Part HI: More Music to Play on Your Computer: Micro Maintenance; Solomon and Viet: Putting Together a Personal Computing System: Time Sharing on the Family MICRO.

December 1977

A Beginners Guide to Peripherals: The Best Slot Machine Game Ever: Artificial Intelligence’: An Electronic Jungle Gym for Kids: File Copy Pro- gram: Better Health Through Elec- tronics: The Kitand I Part IV.

January 1978

Synthetic Skin for Your Robot and How to Make It: TLC: A Visual Pro- gramming Language: The Code That Can't Be Cracked: Beginner's Guide

to Computer Graphics: The Computer and Natural Language: First-Timer':

Guide to Circuit Board Etching.

Variable Conversions

in the ZX80

Joseph Sutton

There are many cases when it is conven- ient to convert one type of variable to another, such as numeric to string, or string to numeric. In the ZX80 variable conver- sions from numeric to string are done with the STR3S( ) function. The reverse conver- sion is not available with the 4K Basic. Given a string variable containing numbers, the program below looks at each number individually to determine its magnitude. The CODES for the numbers go from 28 to 37 (CODE (“0”) = 28, CODE (“1”) =

29, etc) so that by subtracting 28 from the CODE you get the number itself. By using CODE (A$) - 28

then remove the first character with TLS

( ).

108 LET A$ = TLS (AS) X is then tested with an IF statement to verify that it isa number from 0 to 9, and if it is, it is put into the numeric N with LET N = (N * 10) * X.

109 IF NOT X < 0 AND X < 10 THEN

LET N = (N * 10) + X

10 LE gant) 101 Le PT Ysa Li DiM Pc) Line Le? Ni) ite GE TP Rd 3) io LEY Ni i 106 Lidl c Oy LET Kepi fay) - 2S 1068 LET AS=TLSe (Ass 0%? TF NOT Ka Mii & Ed Lots | L's) its) READ + X Llo TF Kale THER 17 pine 1 111 YF Xu L TREN Liz! Lila 11 cid THEN LES bia 1F x GO Tt! 11 bie TF Ae AND =i AND Mqiló=Ó THEN LET ed

Lim 60 VO 107

i i le 117 IF Y=3

LIB RETURN

This is the full subroutine with all the fancy things added and a small “main”

program.

ENTERING PE S E 3 LA

“SO, Gee

= OC RE

26

PRINTS ON SCREEN ` si 3 sd ke 4 oag ke abo ate l. bd AR LORA

i

(A T YK TOR KO

Let's assume we have a string containing “123.” Line 107 sets X equal to 1 (29-28), then line 108 removes the “1” from AS, and line 109 sets X equal to 1 (N = (0 * 10) + 1). If we return to 106 and start again, A$ = “23”, X = 2and N = 12 (N = (1 * 10) + 2). If we go through a third time, A$ = “3”, X = 3 and N = 123 (N = (12 * 10) + 3). Now we need something to test for the end of the string.

113 IF X = -27 THEN RETURN

115 GO TO 107 In the ZX80 all strings end with a “null” character with a CODE of 1. Line 113 tests for this and returns to the main program when the end is detected. Line 115 keeps the routine going until line 113 finds the end. Now, with one more line, we have a Basic subroutine for doing the missing con- version.

103 LET N = 0

107 LET X = CODE (A$) - 28

-108 LET A$ = TLS (AS)

109 IF NOT X < 0 AND X < 10 THEN

LET N = (N * 10) + X

113 IF X = -27 THEN RETURN

115 GO TO 107 This subroutine will search the string A$ until it finds a number. It will then put the numbers into N, stopping when it finds the end of the string, ignoring all other charac- ters. The routine will also destroy the contents of A$, so A$ must be saved if you want it for later use.

With only minor modifications it can be made to accept decimal numbers and scientific notation. First N becomes an ARRAY containing the integer portion in N (0), the fractional portion in N (1), and the exponent (for scientific notation) in N (2). To use this routine as a subroutine all three portions of the ARRAY must be set to zero at the beginning. S is the counter to tell the ZX80 in which part of the ARRAY to place the numbers. We also have to add lines to detect decimal points and “E” if scientific notation of the form 1.5 E 3 is required (1.5 * 103 ). Line 110 is added to detect minus signs and lines 116 and 117 properly locate the minus signs. When the fractional portion of the number is pro- cessed, the leading zeros are removed. If they are not kept track of, errors will occur; 1.005 would become 1.5, etc. Line 114 detects leading zeros and Z equals the number of leading zeros. In line 30 of the main program you will notice the expression TLS (STR$ (10 ** Z)). IF Z = 2 (2 leading zeros), 10 ** Z = 100 and the expression becomes the string “100” with the “1” removed or “00”. This replaces the zeros in the print statement. No more than four leading zeros can be used (10 ** 5 = 100,000 and you get error message 6, arithmetic overflow). O

Joseph Sutton, 170 S. Hillside Ave., Succasunna,

NJ 07876.

SYNC Magazine

W;

Graphics, Games and Gold

Games can be divided into three broad classes. The first has a clearly defined play area which remains the same each time the game is played. Chess. back- gammon. tic-tac-toe. and all the card games fall into this category. The second class requires a random area which regenerates differently each time the game is played. Into this group fall the adventure. hunt and seek classics. The last class encom- passes all the animated games involving flight and shooting. such as Star Wars and Space Invaders. which require real- time inter-action.

I decided to write my own game using as much of the ZX80 graphics as possible. but without waiting for the 8K Basic ROM and 16K RAM expansion to become available. My choice of game was influenced by several considerations. Everyone knows what the successful outcome of a chess.. backgammon. or card game should be. so there is little room for invention. The game either meets expectations or fails. Since the computer

Martin Oakes, 2100 Oriole Dr.. Freeport, IL

61032.

May/June 1981

Martin Oakes

SSS

NEWLINE

Figure 1. The Game Area.

CONSTANTS

MAIN PROGRAM -CONT-

SQUARE GAME AREA

RANDOM WOOD

PEEK IN DISPLAY

POKE IN DISPLAY

RANDOM PATH

MOVE CHARACTER SEARCH FOR CHARACTER

FIND AND REPLACE GOOD OR EVIL?

Figure 2. Organization of Program.

10

is to be a player. it must be a worthy opponent. A dynamic game would have to wait until the 8K ROM becomes avail- able because the screen goes blank during computation with the 4K Basic.

My choice then was to plan an “adven- ture” type of game. which has the added bonus that the writer can make, his own rules.

From the beginning I did not expect to fit all the features I wanted into 1K of memory. So instead I wrote a series of subroutines which could be independently de-bugged and set aside to wait for the arrival of more memory. At that time they would be at joined together to make a working program.

The hero is to roam within a randomly generated wood. cave. or castle. In the final version the monsters and treasures he encounters may appear as drawings. The game area is a rectangle 15 characters or columns by 10 lines. Later it can be expanded to occupy as much of the screen as required. See Figure 1.

Each feature of the game is written as a subroutine starting at a line number which is a multiple of 100. See Figure 2.

27

Our hero is going to begin his journey

in a wood:

400 FOR L = 1 TO 10

405 LET M = L

410 IF L > 5 THEN M = 10-L 415 LET A = RND (3) + 5- M 420 FOR C = 1 TOA

425 PRINT CHRS (128);

430 NEXT C

435 LET B = RND (3) + 2 + M

440 FOR C = 1 TOB 460 PRINT CHRS (9); 465 NEXT C

470 LET D= 15-A-B 475 FOR C = 1 TOD 480 PRINT CHRS (128); 485 NEXT C

490 PRINT

495 NEXT L

RUN this program.

We now have a grey wood surrounded by a black border. Each time this is run it Is generated differently. We now add randomly dispersed clearings where our hero will find treasures and do battle.

445 LET F = 9

450 LET E = RND(12)

455 IF E = 10 THEN LET F = 0

460 PRINT CHRS (F); Note that line 460 is replaced. RUN this part. Now let’s make it into a subroutine called from a main program.

100 GO SUB 400 299 STOP

497 RETURN RUN this.

The Jan/Feb 1981 issue of SYNC describes on p. 23 how to use the memory address stored in D-FILE to locate the display file.

600 POKE ( PEEK (16396) + PEEK (16397) * 256 +01, T 605 RETURN

101 LET Q = 12 102 LET T = 58 103 GO SUB 600

RUN this. The letter U appeared in the top line of the display. Let’s change this to place the U at different points. The

28

game area is a matrix of 15 x 10 characters. but because of the NEWLINE character. each line is really 16 characters long.

101 INPUT Q

104 GO TO 101

RUN this. The program waits for an input. Try each of the following.

1(NL)

3(NL)

17(NL)

32(NL) Oops! We destroyed the NEW- LINE character. Enter two alphabetic characters to exit with error 2/101. Delete lines 101. 103. 104.

Now we will develop a subroutine to allow our hero to move around within the wood.

900 INPUT A$

901 IF A$ = “0” THEN STOP

905 LET Q = P + 16

910 IF A$ = “N” THEN LET Q = P - 16 915 IF A$ = “E” THEN LET Q =P + 1 920 IF AS = “W” THEN LET Q = P- 1 940 LET T = 58

945 GO SUB 600

970 LET P = Q

975 RETURN

125 GO SUB 900 101 LET P = 152 150 GO TO 125

RUN and enter E.N.W.S to get a string of U's. Type 0 to exit from line 901.

Now we want to erase the trailing (old) positions of U to leave only one in the

display. 950 LET T =9 955 LET R = Q 960 LET O = P 965 GO SUB 600 970 LET P = R RUN this.

Our hero must be confined to the wood until he has earned the right to move on to other adventures.

9251FQ (10R Q ) 160 THEN GO TO 973

930 GO SUB 500

935 IFNOT T = 9 THEN GO TO 975

Look in location Q. to which we will move from the present position P.

500 LET T = PEEK (PEEK (16396) + PEEK (16397) * 256 + Q)

505 RETURN

RUN and try to move our hero into a

clearing or out of the wood. Exit with O(NL).

This subroutine searches for a specific character on a line and replaces it.

1200 LET P =L* 16 1205 FOR C = 1 TO 15 1210LETQ = P + C 1215 GO SUB 500

1220 IF T = S THEN GO TO 1235 1225 NEXT C

1230 RETURN

1235 LET P = Q

1240 LET T = U

1245 GO SUB 600

1255 RETURN

Our hero is fated to be cast randomly into the wood to begin his journey.

105 LET L = RND (10) 110 LETS =9

115 LET U = 38

120 GO SUB 1200 RUN this.

Now that we have some working sub- routines we can set them aside and delete them from memory to make space for new ones.

We will work with a less fancy wood. so delete lines 400-497. and substitute:

300 LET F = 9

305 FOR L = 1 TO 10 310 FOR C = 1 TO 15 315 IF RND (10) = 10 THEN LET F = 0

320 PRINT CHRS (F); 325 LET F = 9

330 NEXT C

335 PRINT

340 NEXT L

345 RETURN

For the purpose of checking out the next subroutines. our hero can begin at the bottom of the game area. so delete lines 1200-1255.

Simplify the main program to read:

100 GO SUB 300

101 LET P = 152

125 GO SUB 900

150 GO TO 125

299 STOP

RUN this and exit with O(NL).

Our hero cannot enter a clearing in the wood. but he needs to know when he has found one. For this we need a search for a neighboring character routine.

1000 LET O = P - 16

1005 GO SUB 500

1010 IF T = S THEN GO TO 1060 1015 LET Q=P + 16

1020 GO SUB 500

1025 IF T = S THEN GO TO 1060 1030 LETQ =P +1

1035 GO SUB 500

1040 IF T = S THEN GO TO 1060 1045 LET Q=P-1

1050 GO SUB 500

1055 IF T = S THEN GO TO 1060 1060 RETURN

SYNC Magazine

When our hero finds the clearing, we will replace it with an inverse X.

1300 LET T = 189

1305 GO SUB 600

1310 RETURN

Since a clearing is a blankspace, S = 0. Add to the main program:

102 LETS = 0

130 GO SUB 1000

135 IF T = S THEN GO SUB 1300

RUN this program and move our hero around with N, S, E, or W.

We can do something more interesting when our hero finds a clearing. This routine POK Es a random number into the clearing representing gold, which our hero collects.

1302 LET V = V + X 1303 LET T = X + 28 1305 GO SUB 600 1310 RETURN

104 LET V = 0

901 IF A$ = “0” THEN GO TO 980

980 PRINT “GOLD”, V

985 STOP

As you RUN this and move our hero around, he collects the gold. When O(NL) is typed, his treasure is displayed. At this point we have all the rudiments of an adventure game. From here we can use Our imagination to change the options in subroutine 1300. L]

Are you in SYNC?

If not,you should be. We would like any programs, translations of existing pro- grams, games or tips which you have to pass on to fellow Sinclair ZX-80 or Micro- Ace owners. Articles are much more lively if accompained by photos (black and white), diagrams, and illustrations. If you do not have an output printer, please type program listings and carefully check them against the listing on the screen. Sample runs should be included with pro- grams rather than just a description of what the program does. Articles should be typed, double space. Your name and address, with phone number should be on first page; all other pages should be num- bered. All submissions should include re- turn postage. Payment ranges from $15 to $40 per printed page.

Please send all submissions to:

SYNC 39 E. Hanover Avenue Morris Plains, New Jersey 07950

May/June 1981

Sourcebook

of Ideas

Many mathematics ideas can be better illustrated with a computer than with a text book.

N NS Se AN NN

SS > Z

Š AQ

OR

Creative Computing Pres

Consider Baseball cards. If there are 50 cards in a set, how many packs of bubble gum must be purchased to obtain a complete set of players? Many students will guess over 1 million packs yet on average it’s only 329.

The formula to solve this problem is not easy. The computer simulation is. Yet you as a teacher probably don't have time to devise programs to illustrate concepts like this.

Between grades 1 and 12 there are 142 mathematical concepts in which the com- puter can play an important role. Things like arithmetic practice, X-Y coordinates, proving geometic theorems, probability, compounding and computation of pi by inscribed polygons.

Endorsed by NCTM

The National Council of Teachers of Mathematics has strongly endorsed the use of computers in the classroom. Unfortunately most textbooks have not yet responded to this endorsement and do not include pro- grams or computer teaching techniques. You probably don't have the time to develop all these ideas either. What to do?

For the past six years, Creative Computing magazine has been running two or three articles per issue written by math teachers. These are classroom proven, tested ideas complete with flowcharts, programs and sample runs.

Teachers have been ordering back issues with those applications for years. However,

many of these issues are now sold out or in very short supply.

So we took the most popular 134 articles and applications and reprinted them ina giant 224-page book called Computers in Mathematics: A Sourcebook of Ideas.

Ready-to-use-material

This book contains pragmatic, ready to use, classroom tested ideas on everything from simply binary counting to advanced techniques like multiple regression analysis and differential equations.

The book includes many activities that don't require a computer. And if you're considering expanding your computer facilities, you'll find a section on how to select a computer complete with an invalu- able microcomputer comparison chart.

Another section presents over 250 problems, puzzles, and programming ideas, more than are found in most “problem collec- tion” books.

Computers in Mathematics: A Sourcebook of Ideas is edited by David Ahl, one of the pioneers in computer education and the founder of Creative Computing.

The book is not cheap. It costs $15.95. However if you were to order just half of the back issues from which articles were drawn, they would cost you over $30.

Satistaction Guaranteed

If you are teaching mathematics in any grade between 1 and 12, we're convinced youll find this book of tremendous value. If, after receiving it and using it for 30 days you do not agree, you may return it for a full refund plus your return postage.

To order, send your check for $15.95 plus $1.00 postage and handling to Creative Computing Press, Morris Plains, NJ 07950. Visa, MasterCard, and American Express orders may be called in toll-free to 800- 631-8112 (in NJ 201-540-0445). School purchase orders should add an additional $1.00 billing fee for a total of $17.95.

Don't put it off. Order this valuable source- book today.

creative computing

Morris Plains, NJ 07950 Toll-free 800-631-8112 (In NJ 201-540-0445)

29

A Trick and a Graphic System

by Keith Comer

The ZX80 version of Basic is missing a few statements you may used to using. Getting those graphic characters to do anything really impressive seems downright impossible. The potential is there, but how do you squeeze it out? Using a simulated DATA statement. I have developed a graphic system to allow easy production of graphic displays.

First, let us consider the pseudo-DATA Statement. Suppose you need the values 6.4.9 and 7 for some obscure task. Watch:

10 LET A$="6497”

20 LET X=CODE(AS$)-28

30 GOSUB 1000

40 LET AS=TLS(AS)

50 IF A$+*” THEN STOP

60 GOTO 20

Now, line 10 is the “DATA” statement. The terms are just slammed together in a string (AS).

Line 20 fetches the ASCII code for the first character in the string (which is 34) and by subtracting 28 gets the real number you want (which is 6).

Line 30 goes to the part of the program that is to perform that obscure task. The variable X is holding the value you want.

Line 40 clips off the first data element in order to get at the next one.

Line 50 checks to see if the string is empty. in which case we are done and can STOP.

Line 60 starts the whole thing over again (in traditional reiterative fashion).

Obviously, if you need data with more than one digit per entry, you need to trim the digits off one at a time and reconstruct the number from those digits. If you needed 27,32, 2, and 23, you would use:

10 LET A$=“27320223”

20 LET X=(CODE(AS$)-28) * 10

30 LET A$=TL5 (A$)

40 LET X = X + CODE(AS$) -28

50 GOSUB 10000

60 LET A$ = TLS (A$)

70 IF A$ = “" then STOP

80 GOTO 20 Notice that there are no commas between the data elements and that the 2 has to go in as 02.

=== ee U ll = == ee Keith Comer, 16889 Nichols St. #d, Huntington

Beach, CA 92647.

30

So how does all this number crunching help you realize those incredible graphic displays you have been dreaming about? Watch again:

10 LET A$= “E£££££££5ESIETE£BB BBEEBBBBEBBBBEABBBBEEBBBBE£ PBBBEAA3AA4ABBBBAAA£BBBBAA A3APBBBEAPBBBAAA”

20 LET X= CODE (A$)

30 IF X=12 THEN PRINT

40 IF X=12 THEN GOTO 80

45 IF X Ç 38 THEN GOTO 110

50 IF X < 48 THEN LET X=X-36

60 IF X > 47 THEN LET X=X+80

70 PRINT CHRS(X);

80 LET AS=TLS(AS)

90 IF A$ = “” THEN STOP

100 GOTO 20

110 FOR N=1 TO X-28

120 PRINT ”;

130 NEXT N

140 GOTO 80

Line 10 is the data, as before.

Line 20 fetches the first (or next) character, as before.

Lines 30 and 40 look for the ASCII code 12, which is the £ symbol. It is used to effect a line feed. (Imagine a cross between an “L” and an “F”.) This allows you to proceed down the page without typing spaces to the end of each line.

Line 45 checks for an ASCII code which would indicate a number. The routine at 110 will print that many spaces, up to 9 of course; remember, only one digit per data element. This is mainly a convenience, but I have noticed that many pictures I have done are mostly spaces.

Line 50 and 60 convert the ASCII codes of letters from the data line to ASCII codes of graphic symbols. You can save a few bytes (and forsake clarity) by using:

50 IF X < 48 THEN LET X= X-116

60 LET X=X +80

Line 70 prints the selected graphic symbol.

Lines 80, 90, and 100 obvious.

Lines 110 to 140 are the spacing routine referred to by line 45, a simple FOR- NEXT loop.

Now the system works like this: Turn to page 78 in the Z X80 instruction manual and put the letters A through J next to graphic symbols 2 through 11 (ASCII). Put letters M through V next to symbols 130 through 139. The reason that K and L are skipped is so that K can be converted to ASCII code 128 which is the inverted space or a Solid black square.

should be

That completes the program. The system allows the use of all the graphic symbols with equal ease, not just the ones on the keyboard. They are all available with one keystroke of typing each. The result is that the screen can be used with the effect of double the resolution, because symbols are used that access any quarter, or any combination of quarters, of each graphic block.

All you do to construct your picture is to draw what you want on graph paper. Your field is 64 squares wide and 46 squares high.

So get your drawing the way you want it. It helps to fill in the squares of the graph paper “all or nothing” (Figure 1). Then divide the picture up into “four squares.” This is where the resolution gets halved into the 32 by 23 screen (Figure 2). I just draw over the original lines of the graph paper with ink of another color, every other line. Then convert each “four square” to its corresponding letter from the graphic symbol chart you have just written (Figure 3). Remember to use the £ sign when you get to the end of a line. Now just string the letters together into a data statement for line 10 like this:

10 LET A$=“GNE£ACALDN”

The advantage of this system is that the program itself is fairly short so you can store a rather elaborate (and/or big) picture in line 10. It cannot hold enough characters to do a full screen (at least not with 1K) but it will hold more than 200. Since it is storing them as one byte each, I doubt that there is a way to store it any tighter. When you save a program, you have also stored the picture.

A few examples are probably in order: INVADERS: “FBKKBE£KROROK£NK

ROKN£DPDCOC”

“IBOKPB£MKNKNKA£D

OKNKRC£BNININB”

“FKEOP£KKKKKA£OKK

KKC£1IQKKC£20C” “2BRNPE£10C3QE£MC5SQ£

R2CICIDA£AIEICIEIA£

Q1S2FCMC£DP1NNCFR£

IDPEIBR£3INNC”

More extreme is the CASTLE: —“£78F£78M£77FKP£65M1F KKKP£650E1lM1M£550KK EMIM6A£65AA1M1MBE3 FP£65AA101MR40KE£65 AAOC1M40KKKE£6BBB 2ANC2M5A1A£5FA1M2A 3KM4FA 1P£502M2A3KM 4M2M£4FA2DNNC4M4R2 DA£L4MBBE8MBBBBA3P£ 7A1K20NNP7K1M£7A30C 2DP6K 1M£7A3A4M8M£7 A3A4M8M£7A3A4M8M£7 PBBBA4MBBBBBBBBO”

HEART:

FACE:

SYNC Magazine

If you want to do wider spacing, you can use this routine to get two digit’s worth of spaces. Eliminate lines 30 and 40 if you want to save space; just space all the way to the end of each line. Replace lines 110 to 140 with:

110 LET Z =(X-28) * 10

120 LET A$ = TLS (A$)

130 LET Z = Z +(CODE (A$) -28) 140 FOR X = 1 TO Z

150 PRINT *”;

160 NEXT X

170 GOTO 80

Figure 1.

May/June 1981

Using this modification you can “draw”

a U.S. MAP “3232323226E12PRNNNNN NNNQCO060K 11MCO9DNRSOBROC 1101 2ARA01OSO12A12PAPRCM13A17M13 Q17R13ME16A 14PE140C15PE13A170 BBBEO3FBRNNPA21QBEFR04DK23PR 06QA22DA” O

Figure 2.

Sample Output “Castle”

Figure 3.

31

Gauntlet

Ken Berggren

REM SPACE PRINT "HOW MANY MONSTERS? (1-4)" INPUT N

LET C=O

LET D=0

CLS

IF N>4THEN GO TO 70

DIM 5(N)

FOR L=1 TO 6

FOR K=1 TO 20

PRINT CHR$(-(RND(8)>5)*9);

NEXT K

PRINT

NEXT L

FOR J=1 TO N

LET B(J)=RND(L-1)*K-2-(K/5)*(J-1) NEXT J

LET G=K*3

GO SUB 900

GO TO 430

LET S=G

INPUT C$

FOR J=1 TO 2

LET C=CODE (C$)

IF C=58 THEN LET S=S-K

IF C=41 OR S<O THEN LET S=S+K

IF C=43 OR C=39 AND S=(S/K)*K THEN LET IF C=39 THEN LET S=S-1

IF S>(L-1)*K THEN LET S=S-K

IF S+1=((S+1)/K)*K THEN GO TO 700 LET C$=TL$(C$)

NEXT J

GO SUB900

IF PEEK(S+D)=61 THEN GO TO GOO POKE D+G,0

IF PEEK(S+D)=0 THEN LET G=S

POKE D+G,52

FOR J=1 TO N

POKE D+B(J),0

LET C=K

IF B(J)/C=G/C THEN LET C=1

IF B(J)-G<O THEN LET C=-C

IF PEEK(D+B(J)-C)=9 AND RND (9)>4 THEN LET B(J)=B(J)-C

IF PEEK(D+B(J))=52 THEN GO TO 600 IF RND(9)>7 THEN GO TO 460

POKE D+B(J),61

NEXT J

GO TO 280

600 610 700 800 810 840 850 900 910

PRINT "GOTCHA" GO TO 800

PRINT "YOU ARE FREE" GO SUB 900

POKE D+G,20

INPUT C$

IF C$="" THEN RUN

LET D=USR(16427) RETURN

Subroutine Loader

100 POKE 16403,100 110 FOR J=1 TO 5 120 INPUT C

130 POKE 16426+J,C 140 PRINT J,C

150 NEXT J

S=5+1

DECIMAL LISTING

O (N P

LET

42 12 64 35 201

C=0

Gauntlet is a game played on a rectangle 19 spaces by 6 spaces. The object is to run a gauntlet of random obstacles and monsters, beginning on the left side and crossing the rectangle. You win when you have successfully moved your marker to the right side.

First you must decide how many monsters you think you can handle, from one to four. Then .. . the screen is randomly sprinkled with blocks. You (0) start at the extreme left. The monsters (X) are between you and your goal, the extreme right.

You move by entering the letters U,D,F or B. For example, to move down and back diagonally you would enter DB or BD. A single letter moves you one space and a Newline alone maintains your position. It is possible to jump an obstacle but if you try to land on one you will not move at all. The monsters frequently blast through the barriers and sometimes that can help you.

The monsters drool green drool, never bathe and have very bad breath. They are also lazy. Except when angry they move only one space at a time. But for all their faults these guys are not dumb. They are very cautious and try to get in front of you before they advance.

When the game is over a NEWLINE will run it again. Any key before the NEWLINE will stop it.

Here are the major sections of the pro- gram:

Line 1 is a machine language routine. Lines 70-120 set the number of monsters. Lines 130-210 set the starting positions. Lines 280-430 move the man. Lines 440-530 move the monsters. Lines 600-850 end the game or start another. Lines 900-910 a routine to call the routine.

The machine language routine finds the first character in the display file. It saves

Ken Berggren, 104 Ridgeway Ave., Louisville. KY 40207.

SYNC Magazine

about ten bytes over PEEKing and, with only 1K, every little byte counts.

To load the routine, enter REM and five spaces. Then type in the “loader program” and run it. Enter the five numbers from the “decimal listing” and double check them when you are through. Then type in the main program. You will find that various letters appear around the place newlines are entered. This can be ignored. The condition will disappear when the program lines replace the subroutine loader.

Some of the values for the routine are not character codes, and they do strange things when the ZX80 tries to put them on the screen. Some codes will crash a program. To play it safe push the REM statement off the screen with more program lines or use POKE 16403,100. Then do not use LIST without a line number, at least not until you have the program on tape. I do not like that, but I have not found another way to protect a routine and still be able to save it with a program. Any suggestions?

Here are some ways to tailor the program to your own tastes. The TO value in line 140 determines the length of the lines that form the gauntlet. The TO value in line 130 determines the number of lines or the height of the gauntlet. You can change the shape of the display by adjusting those values. However, in 1K this program allows only about 125 characters in the display file. The size of the display file will roughly equal the length of a line plus one, times the number of lines. If you get an error number 4 or 5, it is probably because your display file is too large. To adjust your starting position, change the constant in line 250. A zero starts you on the top line. Adding one to the constant drops you down one line. Be sure that this constant is less than the height of the gauntlet! Finally, if you want to be able to move farther in each turn, increase the TO value in line 300. A three lets you move like a knight in chess. More than three and you are practically unbeatable.

D

May/June 1981

SYNC Reader Survey

In our first issue of SYNC we asked you to tell us about yourselves so that we will be able to make SYNC the magazine you want. Your response to our survey has been very positive and enthusiastic. This is what you told us.

First. you told us that you did not like to have surveys printed on the other side of pages you want to keep!

Next. we found that for four out of five of you the ZX80 (or MicroAce) is the only computer you own. About half of you are having your first computer experience with the ZX80. Many admitted yielding to the desire to have a personal computer because of the low price. This enabled you to break into the computer field without making a heavy investment in equipment before you were sure that computers would be a part of your personal activities. The other half have access toa computer at work or at school.

Topping the request list for SYNC content is a strong desire for programming tips (four out of five). So if you have a program to submit. remember that your fellow SYNC readers are clearly having great fun with their ZX80s. but they are also very eager to learn how to get the most out of their machine. They see every program as a learning opportunity. You will have their deepest appreciation if you share what you have learned about pro- gramming through notes in which you point out special tips and explain the main elements in your program.

A close second in requests is for new product information. While we make every effort to find out about new products. our advertisers and readers are the main sources of information. If you have found a new product that helps you with your Z X80. please tell the seller. distributor. or manufacturer about SYNC so that we can get the news around.

About 75% of our readers want to know more about interfacing techniques and to have software tutorials. Hardware tutorials. graphics software. device control. hardware evaluations. and software evaluations are in the “very much” column for about 60%. Educational. mathematics. and business software are lower on the list with about 40%. While games make the “very much ` column for 40%. “very much" and “okay” together include 90% of our readers.

Fiction. puzzles. and advertising came in at the bottom of your list for highest choice. but near the top for your second choice.

For most of our readers additional memory tops the list of planned equipment purchases for 90% with disk and printer capabilities next for 60%. Creative Com- puting and Byte are the most widely read computer magazines other than SYNC.

The age distribution checks show that 14% are under 20; 27%. 21-30; 31%. 31- 40: 13%. 41-50; 13%. 51-60; 1% over 60. Males outnumber females 37 to 1.

Of course. all these are averages based on our survey compilations. It is clear from not only the survey. but also your letters that you have an amazing variety of interests involving your ZX80. Even though the survey summary may not show that other readers have the same special interests as you (and your comments mentioned a number of them). we invite you to share what you find with us. Your fellow readers are always looking for new things to do with their ZX80s. You may open up whole new interests. possibilities. and challenges. O

Try This

This column will feature short programs to show off your ZX80, impress your family and friends, and tickle your imagination when SYNC arrives at your place. We invite your contributions. Address them to SYNC, 39 E. Hanover Ave., Morris Plains, NJ 07950.

10 PRINT CHR$(RND(3));

20 GOTO 10 Press RUN and NEWLINE. Disregard the error code which will be displayed. After you have fully absorbed the results of the routine, press any key and then RUN and NEWLINE again. Our thanks to:

Nigel Searle

Sinclair Research Ltd.

50 Staniford St.

Boston, MA 02114 O

33

Forest Treasure x Paul Frahm

10 FOR I=1 TO 20 20 FOR J=} TO ZO 30 PRINT ©" "3 40 NEXT j

50 PRINT

60 NEXT I

70 DIM AĖ(50)

ivea poose joe

ASO

wd AC

34

LES Eee RD ii) |

ET Tee (617)

Ia A i ; ie oe Š met bee Ú 7 $e EAT Piss REDD 0.5 72 I w" bites oe oe pad ak _ g eN “CEI REE OL Ee RA ACTORA PEER GL em BY Z yt, SO

t t .... Ess ` EOR el YO í IE ACID =N THEN GOTO 460 NEXT |

ao . ` H ares ya °. - oe mm + + : - = -F e. were te : : sora tes nm 233 "3 8 one _ ` - ae 1 e pore > Ae me. a

f IF BID =N THEN GOTO 400 a

ove E ss : Saik

t IE Afs U" AND Epl THEN LET Beie] GOTO 170 LET Pam PRMD (F) =H I I

Es eR ED (7) 3

GOTO 10 PORE FEE CLOs96) +A XFEER (16397347, 146 PRINT "YOU HAVE TAKEN THE TREASURE"

CV +

GOTO E PORE PEER (16396) +25OPEER (16397) +H, 19

PRINT "THE MONSTER HAS KILLED you"

GOTO 500

PRINT "THE MONSTER HAS STOLEN THE TREASURE Z PRINT "ANOTHER GAME? ¿YN

NEUT EB

IF Bé="Y" THEN RUN LIS

“Forest Treasure” is based upon “Ran- dom Graphics” by Gary McGath in the Jan/Feb 1981 issue of SYNC. You are riding through a forest, seeking the gold treasure. You are represented by “£” and the treasure is a blank space. During your ride you may encounter enchanted (invi- sible) walls. When touched, these walls will alter your path, sending you in different directions (sometimes even leaping over the wall!) You may also encounter a monster, represented by the “M” square. This monster has the magical ability to duplicate itself in its search for you. If you run into a monster, or if the monster lands on you, or if the monster steals the treasure, you lose. If you get the treasure, you win. You control your movements by entering U, D, R, or Lfor up, down, right, or left, and then pressing NEWLINE. Entering S will exit you from the pro- gram.

Paul Frahm, 21123 Dettmering, Matteson, IL 60443.

SYNC Magazine

Translating From Other Basics

David Lubar

A command found in many versions of Basic, but not in the Sinclair, is ON ... GOTO. This is usually found in the form ON X GOTO 110, 120, 130. The command makes a jump depending on the value of X. In this example, if X is 1. the program will jump to 110, if X is 2, control goes to line 120. and if X is 3. the program continues at 130. If X is outside the expected values, the program will fall through to the next line. In other words, for any value N of X, the program will jump to the Nth line listed in the expres- sion.

The simplest way to replace this com- mand is to use a series of IF... THEN statements. The above example is equiva- lent to

10 IF X = 1 THEN GOTO 110 20 IF X = 2 THEN GOTO 120 30 IF X = 3 THEN GOTO 130

If there are many numbers involved, this process can get tedious. Fortunately, there are other ways to Sync the cat. The Sinclair allows for the use of expressions with a computed GOTO. For example, the above command can be replaced with GOTO 100 + 10 * X. In many cases, you can renumber a translation so the lines

used in ON...GOTO will be part of a simple progression. But there are cases where the progression is not simple. Take a line such as ON X GOTO 90. 450. 376, 10. Rather than look for an algorithm that will produce the correct number, it is easier to set up an expression. Using the logical capabilities of the Sinclair, we can produce an expression that has the desired sum for any X value. What we need is a series where the sum of each member is zero unless it matches the desired X value. When there is a match, the sum will be the value of the desired line for the jump. The above line can be replaced with GOTO ABS ( (X=1) * 90 + (X=2) * 450 + (X=3) * 376 + (X=4) * 10). This expression will produce the desired results. Those parts of the expres- sion where the equality fails will produce a value of 0. When there is a match, the result will be correct except for having a negative value. This is caused by the use in the Sinclair of -1 to signify true. The

` ABS takes care of that.

Another common Basic operation is the LEN function. The expression LET X = LEN (A$) will give X a value equal to the number of characters in A$. If A$ is HELLO, then X will be 5. This expression has many uses. Once you know the length

of a string, you can manipulate it in various fashions. While the Sinclair does not have the LEN function, it does have TL$ which removes the first character of a string. Using TL$ in a loop. the length of any string variable can be determined. The basic approach is to keep chopping off the first character of a string until there is nothing left. If you count how many beheadings have occurred, you will know the length of the string. Here's one way to do it.

10 INPUT A$

20 LET L = 0

30 LET B$ = A$

40 IF B$ = *” THEN GOTO 100 50 LET B$ = TLS (B$)

60 LETL=L+1

70 GOTO 40

100 PRINT A$; “HAS A LENGTH OF”; L

The program is fairly straightforward. Since TL$ destroys the variable, A$ is preserved by using B$ for the operation. When B$ has only one character left, the result of TL$ (B$) will produce a null string (represented in line 50 as a pair of quotes with nothing between them).

That’s all for now. If you have any specific functions you would like to see covered here, drop me a line.

puzzle answers

A Building Problem:

A

May/June 1981

Lucky Number: Multiply the selected num- ber by 9, and use the product as the multiplier for the larger number. It will be found that the results will be respectively as under:

12345679 x 9= 111 111 1H x 18 = 222 222 222 x 27 = 333 333 333 x 36 = 444 444 444 x 45 = 555 555 555 x 54 = 666 666 666 = x 63 = 777 777 777 W x 72 = 888 888 888 x 81 = 999 999 999

It will be observed that the result is in each case the “lucky” number, nine times repeated.

The Puffer-Belly Problem: The speed of the two trains in relation to one another is 45 + 36 = 81 miles per hour. This equates out to:

le ee 118.8 feet per second

The length, then, of the Dover train is 6x 118.8 = 712.8 feet.

A Seven-Letter Charade: The answer is the word ENGLAND. The other words are END, GLAD, ANGEL, LAND.

The Three Jealous Husbands: For the sake of clearness, we will designate the three husbands A, B, and C, and their wives a, b, and c, respectively. The passage may then be made to the satisfaction of the husbands in the follow- ing order:

l. a and b cross over, and b brings back the boat.

2. b and c cross over, c returning alone.

3. c lands and remains with her husband, whileA and B cross over. A lands, Band b return to the starting point.

4. Band C cross over, leaving b and c at the Starting point.

5. a takes back the boat and b crosses with her.

6. a lands and b goes back for c.

The Four Jealous Husbands: Distin- guishing the four husbands as 4, B, C, and D, and the four wives as a, b, c, and d, respectively, the answer to this version is:

l. a, b, and ccross over; c brings back the boat.

2. c and d cross over; d brings back the boat.

3. A, B, andC cross over; C and c bring back

the boat. 4. C, D, and c cross over. 5. c takes back the boat and fetches d.

35

Sinclair ZX80

SK Basic ROM and 16K-Byte RAM Pack Specifications

The 8K Basic ROM and the 16K-Byte RAM pack are now available from Sinclair Research (see Resources column). The specifications for these units are as follows.

ZX80 8K BASIC ROM

The 8K Basic ROM for the ZX80 is designed for high-level, full-facility computing. The chip—a drop-in replacement for the existing 4K Basic ROM—comes with a new keyboard template and a supplementary operating manual.

Key features of the new 8K BASIC ROM include - e fully floating-point arithmetic to 9-digit accuracy. e logs, trig, and their inverse functions, e graph plotting facility, e animated displays using PAUSE n, e full set of string-handling facilities. e n dimensional arrays, e n dimensional string arrays, e cassette LOAD and SAVE with named programs.

Full specification follows.

Numbers

Stored in 5 bytes in floating point binary form giving 9 x 10" to 1.1 x 10% accurate to 9 1/2 decimal digits.

Variables

Numeric: Any letter, followed by alphanumerics. String: A$ - Z$.

FOR-NEXT: A - Z.

Numeric arrays: A - Z.

String arrays: A$ - Z$.

Arrays

Numeric arrays: ‘n’ dimension, subscript range starts at 0.

‘n’ dimension, subscript range starts at 0. If the last subscript is omitted it’s treated as a fixed length string.

String arrays: (more correctly, character arrays)

Strings

Undimensioned strings can be any length. Can be concatenated (+).

Substring eg B$ = A$ (2 TO 4).

Literal strings eg C$ = “QWERTY”.

Statements available

In this list.

v represents a variable.

xyz represent numerical expressions.

m.n represent numerical expressions that are rounded to the nearest integer.

e represents an expression.

f represents a string valued expression.

S represents a statement.

Note that arbitrary expressions are allowed everywhere (except for the line number at the beginning of a statement). Thus “GOTO LN A ** 2” is valid.

READ RESTORE REM

05 06 Ge G5 M8 G5 (8 tg tg

al CODE a?

TT WE, RETO GE

SIN

NEW

Sa a Ags & aa ARCCOS ae

CLEAR

EDIT AND THEN TO <J ZON r GRAPHICS RUBOUT B

INPUT POKE PRINT

“a LIST

FUNCTION

SCR a “eG ake BREAK

co ts rs ra rs ru

> f TE EE P TU

Sinclair ZX80 8K BASIC

Keyboard template for new 8K BASIC ROM.

36

SYNC Magazine

CLEAR

Deletes all variables, freeing the space they occupied.

CLS (Clear Screen) deletes all PRINT output | in the display file. l PAUSE n Sends the display file to the TV screen CONTINUE Resumes execution of the last run pro- for n trames | s iames per second) or gram—repeats the last statement if an until a key is pressed. error was detected, otherwise restarts at the areca Note that a command PLOT m,n Sends the PLOT position (a system vari- (immediate execution) statement counts : . able) to (m.n) and blacks in that pixel. as a praat ano So desitoys Thë we Also changes the PRINT position. entry data. DATA... Standard, but no unquoted strings. Poeemi AS AMA, PRINT... Mostly standard. The display file has 22 DIM... Deletes any array or string with the same lines of 32 characters each (2 zones of 16 name, sets up space for a new array in characters) and when this is filled it is the usual way, and initialises its element sent to the TV with error 5. CONTINUE to 0 or ”. carries on with the program with no loss of data. DRAW m.n Let (u,v) be the current PLOT (q.v.) posi- tion. Draws a line as straight as possible PRINT AT m.n Moves the PRINT position to line m, from (u,v) to (u + m. v + n) by blacking character n. in pixels (quarter character squares). Changes the PLOT and PRINT posi- PRINT TO de Alters the PRINT format. Here d is an tions. optional digit between 1 and 8 (default f value 8) and e is an optional letter E. FORA TOB Generally standard, but entirely From now until another such formatting STEP C dynamic in its action. Item, numbers will be printed to d signi- f ficant digits. and if E is present they will NEXT The effect of a NEXT statement is to always be printed using scientific nota- look up the corresponding FOR-vari- tion. able, increment its value by the STEP, check whether the limit is exceeded and On switch-on, the format is initialised so if not jump to the looping line number. that numbers are printed to 8 digits and f scientific notation is avoided where pos- GOSUBn Transfers control to BASIC subroutine. sible. Note that PRINT does not change the PLOT position. GOTOn Jumps to line n. RANDOMIZE Standard IFx THENs If x is true (defined to mean greater in absolute value then 27”) then s is RANDOMIZE n Ifnis given this is made the value of the executed. The standard values of true seed of the random number generator. and false as yielded by relational opera- tors are 1 and 0. READ v Reads v from a data statement. INPUT v Outputs the display file to the screen REM... Remember, for program comments. with no special INPUT prompt; the rest is standard. Cannot be used as a com- RESTORE Reinitialises the data (so it can be read mand (immediate execution) statement. again). LIST Lists from start of program. RETURN Return from subroutine. LIST n Lists program starting at line n with pro- RUN RUNs the BASIC program. gram cursor pointing at line n. RUN n CLEAR followed by GOTO n. LOAD f Looks for a program called f on tape and loads it and its variables. SAVE f Saves program and variables on tape and calls it f. NEW Default n = 0. Erases BASIC program and variables. SCROLL Scrolls display file up one line, losing top line and making space at bottom. NEW n n is used to alter a system variable known as RAM TOP, which is the STOP address of a byte in RAM. The area from RAM TOP on is untouched by the UNDRAW m,n These are like DRAW and PLOT, but BASIC system, and POKEd programs UNPLOT m,n blank out pixels instead of blacking them

can be left there in safety.

In.

May/June 1981 ar

LL. LLCLCC——s .a—————————— o y €O€ H

Functions

ABS

ARCOS

ARCSIN

ARCTAN

CHR$

CODE COS

BAP

INKEY $

INT LEN LN

NOT

PEEK

PI

RND

SGN SIN SORT

STR$

TAN

USR

38

Type of Operand

number number number number number number number number number

number

number string number

number

number

number number number

number

number

number

Result Negate Absolute magnitude In Radians In Radians

In Radians The character whose code IS X.

The code of the first char- acter is x (or 0 if x is empty) In radians.

ex,

Reads the keyboard. The result is a character repre- senting the key pressed, otherwise the empty string. Integer.

The length of x. Natural log

Exclusive—ORs the first byte of x with 113, so that NOT 0 = 1, NOT 1 -0.

Unlike the other functions. NOT has binding power 4 (between AND and the rela- tional operators) NOT A = B has the same value as NOT (A=B) (and A < >B).

The value of the byte in store whose address is x.

TT (3.1415927)

A random number between O and 1.

Yields -1,0, +1. In Radians. Square root.

The string of characters that would appear on the screen if x were PRINTed.

In Radians.

Converts x to an address in store and calls that address as a machine code sub- routine. On return. the result is the contents of the hl register pair.

Functions Type of Operand Result

VAL string Evaluates x as a numerical expression (x must not con- tain the quote image char- acter).

AND Logical AND

OR Logical OR

Relational operators

= Equal

> Greater than

< Less than <= Less than or equal to => Greater than or equal to

<> Not equal

Graphics

All characters, their reverses, and all graphics can be entered directly from the keyboard.

ZX80 16K-BYTE RAM PACK

The complete module is designed to provide massive add- on memory capacity.

The 16K-BYTE RAM pack can be used for program storage or as a database. Yet it costs up to half the price of competitive additional memory.

Measuring approximately 3” x 3” x 1.25” the RAM pack plugs into the existing expansion port on the rear of the Sinclair ZX80 via an edge connector. No additional power supply is needed. L]

@Creative Computing

“This one is called ‘Kafka’. It is programmed to try to present the user from figuring out how to play it.”

SYNC Magazine

David Ahl, Founder and Publisher of Creative Computing

You might think the term "creative com- puting’ is a contradiction. How can some- thing as precise and logical as electronic computing possibly be creative? We think it can be. Consider the way computers are being used to create special effects in movies—image generation, coloring and computer-driven cameras and props. Oran electronic “sketchpad” for your home computer that adds animation, coloring and shading at your direction. How about a computer simulation of an invasion of killer bees with you trying to find a way of keep- ing them under control?

Beyond Our Dreams

Computers are not creative per se. But the way in which they are used can be highly creative and imaginative. Five years ago when Creative Computing magazine first billed itself as “The number 1 maga- zine of computer applications and soft- ware, we had no idea how far that idea would take us. Today, these applications are becoming so broad, so all encompassing that the computer field will soon include virtually everything]

In light of this generality, we take “appli- cation to mean whatever can be done with computers, ought to be done with comput- ers or might be done with computers. That is the meat of Creative Computing.

Alvin Toffler, author of Future Shock and The Third Wave says, | read Creative Com- puting not only for information about how to make the most of my own equipment but to keep an eye on how the whole field is emerging.

Creative Computing, the company as well as the magazine, is uniquely light- hearted but also seriously interested in all aspects of computing. Ours is the maga- zine of software, graphics, games and sim- ulations for beginners and relaxing profes- sionals. We try to present the new and im- portant ideas of the field in a way thata 14- year old or a Cobol programmer can under- stand them. Things like text editing. social

May/June 1981

A REMARKABLE MAGAZINE

Greative GOlepatirg

“The beat covered by Creative Computing is one of the most important, explosive and fast-changing.” Alvin Toffler

simulations, control of household devices, animation and graphics, and communica- tions networks.

Understandable Yet Challenging

As the premier magazine for beginners, it is Our solemn responsibility to make what we publish comprehensible to the new- comer. That does not mean easy; our readers like to be challenged. It means providing the reader who has no prepar- ation with every possible means to seize the subject matter and make it his own.

However, we don't want the experts in Our audience to be bored. So we try to publish articles of interest to beginners and experts at the same time. Ideally, we would like every piece to have instructional or informative content—and some depth— even when communicated humorously or playfully. Thus, our favorite kind of piece is acessible to the beginner, theoretically non-trivial, interesting on more than one level, and perhaps even humorous.

David Gerrold of Star Trek fame says, “Creative Computing with its unpreten- tious, down-to-earth lucidity encourages the computer user to have fun. Creative Computing makes it possible for me to learn basic programming skills and use the computer better than any other source.

Hard-hitting Evaluations

At Creative Computing we obtain new computer systems, peripherals, and soft- ware as soon as they are announced. We put them through their paces in our Soft- ware Development Center and also in the environment for which they are intended home, business, laboratory, or school.

Our evaluations are unbiased and accur- ate. We compared word processing printers and found two losers among highly pro- moted makes. Conversely, we found one computer had far more than its advertised capability. Of 16 educational packages, only seven offered solid ¡earning value.

When we say unbiased reviews we mean

it. More than once, our honesty has cost us an advertiser—temporarily. But we feel that our first obligation is to our readers and that editorial excellence and integrity are our highest goals.

Karl Zinn at the University of Michigan feels we are meeting these goals when he writes. “Creative Computing consistently provides value in articles, product reviews and systems comparisons...inamagazine that is fun to read.”

Order Today

To order your subscription to Creative Computing send payment to the appropri- ate address below. Customers in the continental U.S. may call toll-free to charge a subscription to Visa, MasterCard or American Express.

Canada and Term USA Foreign Surface Foreign Air l year $20 $29o0r £12.50 $500r£ 21 2 years $37 $550r £24.00 $970r £ 41 3 years $53 $800r £3450 $1430rf 61

We guarantee your satisfaction or we will refund your entire subscription price.

Join over 80,000 subscribers like Ann Lewin, Director of the Capital Children's Museum who says, “| am very much im- pressed with Creative Computing. It is helping to demystify the computer. Its arti- cles are helpfu!, humorous and humane.

The world needs Creative Computing.”

creative GOlepatirg

P.O. Box 789-M Morristown, NJ 07960 Toll-free 800-631-8112 (In NJ 201-540-0445)

27 Andrew Close, Stoke Golding Nuneaton CV13 6EL, England

39

Key Click Generator

by Matthew J. Johnson

This simple circuit will produce an audible tone whenever the ZX80 screen is blanked, yielding a click to indicate key closure, or a steady tone during processing.

Examination of the “SYNC” line (IC 19—PIN 5) with an oscilloscope reveals three constituent signals: Line Sync (denoted LS); Frame Sync (FS); and Keyboard (KBD). These signals are low assertion, as indicated, and have period and repetition rates as follows:

Signal Period Rep. Rate LS 6us 58us PS 380us 18ms

BD 6ms N/A

The time constant of the RC low pass filter was chosen to allow the second gate to switch only on signals long with respect to FS, i.e.. KBD. When SYNC returns high. the first gate sinks the discharge current of the capacitor via the Germanium diode. resetting the circuit. Germanium is used here to insure that the minimum negative-going threshold voltage (V< Ç 0.6V) of the second gate is reached. turning off the buzzer. The Schmitt-trigger was chosen for its high positive-going threshold, enabling a less critical circuit design than would be possible using standard TTL.

The buzzer (a piezoelectric job from Radio Shack #273-064) drive circuit is taken directly from the blister pack except for the diode added to PIN 8 to clamp positive oscillations to the five volt rail.

Circuit Diagram for the Key click Generator

1/6-74LS 14

6 O JT. IK5 IN lu F

40

1/6-74LS14

A 74LS121 one-shot could be used instead of the 74LS14 to eliminate the steady tone during processing. but I prefer having the sound as an indication of processing activity.

The Schmitt-trigger was “piggy-backed” on IC 19, picking up power and the common (PIN 5) SYNC signal with a dab of solder. I used that “double sided stick ‘em stuff” intended for wall hangings to mount the buzzer across two other IC’s. The balance of the circuit was “sky-wired” and the entire modification was neatly fitted within the standard ZX80 case. so as not to obtrude in an obvious manner. A bit of insulating tape may be needed on the inside of the cover to prevent shorts.

The audio feedback has made life with the ZX80 passive keyboard enjoyable and has freed my attention to concentrate on

what—as opposed to how—I am typing. E Matthew J. Johnson, 92 Devir St.. Malden. MA 02148.

A

[TJ

O YAZZNA

General-Purpose

NPN transistor

SYNC Magazine

aye Can criminals be caught b Are we ali part of a larger o

Skillfully drawn illustrations

Burchenal Green, is a beauti

PO. Box 789-M, Morristown, American Express orders are

Only Fiction .. .

or is if?

Tales of the Marvelous Machine: 35 Stories of Computing

A robot friend. A computer God. Artificial intelligence challenging human intelligence in a life and death struggle. A detective solving a computer murder. Computers tricking people or people tricking people with computers. A computer with a soul. Or power. A lonely computer. Or one in love with its operator.

In thirty-five wonderful stories about computers, authors such as Frederick Pohl, Charles Mosmann, MV. Mathews, Carol Cail, and George Chesbro depict a life in which computers affect the way people live, think, and relate to each other. Interested in what the effect of computer saturation might be? Only fiction can so wonderously dramatize future life.

The book is fun, and will provide wonderful hours of entertainment. For the reader interested in a structured approach to understanding the potential roles of the computer, or wanting quickly to locate stories that support or challenge his viewpoint, a multiple table of contents is provided. This lists the stories in fourteen different categories.

For example, a list of stories in which the computer takes on the attributes of a human separates them from those in which the computer is only an intelligent machine. The stories are categorized by whether they clarify, improve, or worsen the human lot. Stories in which the computers have capabilities available today are separated from those in which the capabilities could be available in the future. There is a listing of the wildly whimsical stories and those in which the computer is utilized in a unique fashion.

y computer? Does computer crime pay? Do computers fall in love? rganic computer? Here are 35 tantalizing tales that will open your

eyes to a new perspective Of computers.

augment the stories, giving glimpses of scenes as envisioned by 20

talented artists. This artwork adds another dimension to the text. Tales of the Marvelous Machines: 35 Stories of Computing, edited by Robert Taylor and

ful big 8%” x 11” sofrtbound anthology of 272 pages. 12B

It is available for $7.95 plus $2.00 shipping and handling per order from Creative Computing,

NJ 07960. NJ residents add 5% sales tax. Visa, MasterCard and welcome. For faster service, call in your bank card order toll free

to 800-631-8112 Cin NJ call 201-540-0445). Or use the handy order form bound into this magazine.

creative compatirg press

The ZX80 Keyboar dl James H. Parsons

The ZX80's keyboard is of the simple membrane type which is matrix scanned to read a key. The principle behind a membrane keyboard is relatively simple and is illustrated below in Figure 1. The base layer is a printed circuit board which has a matrix of circular contacts, like those shown in Figure 2, laid out in a grid. Each contact has two traces running from it.

The top layer of the system is the flexi- ble keyboard template. Located above each contact on the base layer is a small, circular contact. When a key is pressed, the contact on the bottom side of the template presses down on its respective keyboard contact, creating a conductive path, and thus closing the switch.

The process by which a key closure is located is called matrix scanning, and it works as follows. As you will note by looking at the schematic diagram of the keyboard in Figure 3, the rows of the keyboard are connected to the anodes of a group of diodes. The cathodes of the diodes are connected to the higher eight address lines. The columns of the key- board are connected to the inputs of IC10. a 74LS365 tri-state bus driver. The diodes are used to inhibit sinking of the address lines by the pull-up resistors (R13-R17). The resistors are used just on good design principle and do not make any major functional difference in the machine; in fact, the system works with- out them.

To scan for a key, sequence through each address line. setting it low and all other high. Read the column data from ICIO. When an address line is low, its respective diode will allow a logic 0 to pass through; when an address line is high, its respective diode will create an output similar to that of a tri-stated out- put.

James H. Parsons, 1921 Flintlock Terrace West. Colorado Springs, CO 80918.

42

Adhesive

Conductive Material

Underside of keyboard template

Keyboard Template

A | e PC Board pe a À

Figure 1.

When a key closure is made. either a low signal or a tri-state signal is sent to the input of IC10. IC10, being a standard 74LSxx gate, has internal pull-up resistors on its inputs. A tri-state type signal pre- sented as input to IC10 will, therefore. allow the pull-up resistor to pull-up the

Figure 2.

input line and turn the input transistor on, thus causing a logic 1 to be the effect- ive input. When a logic O input is received, the input line becomes grounded, and the internal input pull-up is disabled, thus causing a logic 0 to be the effective input.

SYNC Magazine

From Cassette Circuitry

To CPU Data Bus

IC10 is enabled when the signal KBD (see Figure 3) is active (i.e., low). As you will note, the signal is derived from two OR gates. Logically, the signal is KBD = A0 + RD + IORQ. Essentially, all of the three inputs must be low to enable IC10. This means that an I/O read (a Z80 IN instruction) is being done from any even address (i.e., any address with AO = 0).

During an I/O request (IORQ=0), the contents of the A register are placed on the higher eight bits of the address bus. During a keyboard read, the higher eight bits of the address are referred to as the keyboard mask. Executing an IN A, FEh instruction will output the keyboard mask and then read the value of IC10 into the A register. (NB FEh is not the only possible port address; any even value will work.)

A simple routine to test for the BREAK key is shown below:

LD A,7Fh

JR NC, BRKPRS

May/June 1981

Figure 3.

The first instruction loads the keyboard mask into A. This particular mask has all but the ms bit of A (bit 7) set (i.e.. 0111 1111 binary). The IN instruction puts out the mask and reads a column from the keyboard. With a mask of 7Fh. the col- umn read is BREAK, EDIT. P. RUB- OUT, NOT, NEW, LIST, SHIFT.

When the IN terminates, if no keys were hit, all of the keyboard bits (i.e., d0- d4 of A) will be set. If a key is pressed. then its corresponding bit in A will be a logic 0. provided it was in the selected column. After the IN instruction. the data for the BREAK key will. therefore. reside in bit 0 of A.

The RRA instruction rotates the con- tents of register A one bit to the right. Bit 7 comes from the data in the carry flag. The carry flag is set to the data in bit 0 position of A (i.e., the data for the BREAK key). Now the carry flag will contain a 0 if BREAK was pressed; other- wise it will hold a 1. The next instruction. if the carry flag is clear, will jump to BRKPRS.

The keyboard and display subroutine scans the keyboard to see if a key was pressed; if not, it passes a frame to the display and loops back to the keyboard scan section. If a key is pressed. then the routine will return to its caller. This rou- tine is shown in Listing 1.

To use the routine, execute a CALL 13Ch instruction. It will return a value in the BC register pair, which corresponds to the keyboard mask and column input for the key pressed. Bits 5. 6. and 7 will be set to ones by the OR OEOh instruction at 5$:. Bit 0 of B will be zero if SHIFT was pressed; otherwise it will be a 1. C will hold the keyboard mask. For example. if the Z key is pressed, B will hold F7h (i.e., 1111 0111) and C will hold FEh (i.e.. 1111 1110).

Listing 2 shows a method for obtaining a ZX80 character in A. The subroutine FILLDF assures that there are enough NewLines in the display file.

I hope that this article has provided some insight into the workings of the ZX80 keyboard. L]

43

5$

44

RESULT: EQU FRAMES: EQU CH_ADD: EQU LOOP: Call Show; DISP:

LD B.&

DJNZ $

LD HL. (FRAMES) INC HL LD (FRAMES).HL LD HL.-1 LD B. ÓFEh LD C.B

IN A. (C) OR 1

OR GEph LD D.A CPL

CP 1

SBC A.A ORB AND L LD L.A

LD A.H AND D

LD H.A RLCB

IN A. (C) JR C.5$ RRA

RLH

RLA

RLA

RLA

SBC A.A

Listing 1.

4022h OR E 401Eh RET Z 4026h Space between last line of chars and fram sync LD A.B Enter here from BASIC to get a CP 254 key and display the current SBC A.A. display file AND B RRA Address 319 decimal LD (HL). A I3F hex DEC B 2$: DINZ 2$ Blow away 99 T-States OUT (@FFh). A Get old frame counter LD A.-29 Increment it LD B.25 Put it back LD HL. (D FILE) SET TH CALL SHOW Start frame sync LD A.-13 INC B DEC HL

Zero bit for each key pressed

(X_PTR)=BC. a key is

depressed and count = f). exit with A.D.E=0

frame sync ends at next M1

Get HL= first byte of display file

Insure Interrupt

Display space above picture and

lines of text

One less line below picture than above

#picture lines in first line of text

(31)

Value for R in subsequent lines

Will return to caller at end of picture

AND 24: @ if US. 24 if UK

ADD A.32

LD(RESULT+1).A :

LD BC. (CH_ADD)

LD (CH ADD). HL LD A.B ADD A.2

SBC HL.BC

EX DE HL

LD HL. RESULT LD A. (HL)

OR D

Flip bits DEC (IY + RESULT T*1-Y) ; i ressed. else FFh Øf if any key pressed. else IBOR SHOW: LD C. (IY+RESULT +1-Y) LD R.A LD A.-35 Rotate mask left El JP (HL) IF f in mask hasn't reach carry 32 if US. 56 if UK KB TAB: EQU 06Ch no L has a ñ for each row in FILLDF: EQU 05C2h which a key. other than SHIFT. DISP: EQU 013Fh was pressed; H similarly for KWLOW: EQU 0E6h columns in dl-d5, d6d7 are GETKEY: Call FILLDP ones. dó=f. if SHIFT pressed. Call DISP else d§=1 SRA B 717 T-States since start of frame SBC A.A sync. 545 before end OR 38 Pick up last times key hits. or a LD L.5 value with SUB L d15414=01 if first time around $1: ADD A.L SCF RRC Now either carry is clear and BC JR C.S1 indicates a key was pressed INC C or carry Is set and BC=FFFFh JR NZ.GETKEY or FEFFh. LD HL.KB__TAB-1 N.B. Neither 0000h nor FF00hisa LOPA possible value for HL. since d6 ADD HL.DE d7 are set and. if all of d1 to d5 LD A. (HL) of H JR.Z.$2 L=-] ADD A.0COh HL:= if HL=BC and C=FFH CP KWLOW JR N C.$2 LD A. (HL) $2: RET

Listing 2.

Fill display file w/reqd N/Ls

If more than one bit set

Here if in KW state: i.e.. convert from letter to keyword

Here with char in A

SYNC Magazine

°

1 a MY THAT'S RIGHT; ADVENTURE F AM mr

AO

DROIL, SYNK, HAVE BEEN WHY, AS EVER, BRUTALLY CAPTURE BY ONE OF

THE EVIL DING THE Nt ioe TET MERC/FULNESSLESS, VEAK ID.

AND HIS MAD. CREATIONS, a:

NASTY, SOON -TO-BE- ee HOUSEBROKEN=- k: GLITCHOIPZ ... Ff

e sts sts. Pe

HOUR LIL

; E ui u ra AGA A ° ¿ : eee j 3 sal ON Ly 7H, Y 5 TI AA E le S met NY š | : NOTHING CAN ' 5 . < z £ SAVE YOU! a ' = x = `.. SOON A DIVISION VO: ~ OF MY ‘GLITCHOIDZ' Ü a | A (T™) WILL HURTLE

SCHEME > PATE... Y

--] COULON'T INTEREST YOU IN A LITTLE CASH COLLY A T, DING, OL BOXES

HAVOK w, a EUR TES Ñ

CAN... pe PD

pita ° Ç m...

WATCH THA SGAE SPEAR, SHORTY! IM NOT PROGRAMEDV

og ...... .... 0°? o0 ..... ..... eee .....

ss > 3 WHAT ‘S YOUR 2 ; so P E: fee Ñ Š aa AY 12 "AQ 397 A EA E, DING: e = . uf a Ñ : i, > SA AXE de Z a i i 372) s 0966 palais A es NE! SOE

YY. E A? OA OY AR è . ie, E a. MEA AA

COPYRIGHT ©1981 TIMO) TRUMAN = 4/8107 AAA Pas

SOON, THEY DESCEND... 11! RIPPING, GNASHING, KNOSHING, 1" RENDING, TEARING, ANU GENERALLY 7 4 foe, VONG UNERIENDLY STUFF TO A ` THE INNAKDS OF ALL EARTH’S PRECIOUS E) ea

S.A HINK OF T! COMPUTER O GAMESTERS WILL LURCH, D PUMBEOUNDED, FROM NAA

BS THEIR FAVORITE ROUNDS scian wee ODER? SUPER INVAVERS" AND ADVENTURE “.. “y

WHERE'S THE CURSOR? WHERE’ S THE i?

CORPORATE EMPIRES WILL CRUMBLE OVER- NIGHT, UNABLE TO MAKE DECISIONS OR JUGGLE BUPGETS...

= IM OUT = $ OF MEMORY!

MY TAPE WON'T LOA!

—— -

E GEORGE! YA SCREWED UP //

OH, THENK KYEW! THENK KYEW! IT WUZ. NLUTHIN’? KILL. ..?

“AND IN THE END, ONLY L WILL REIGN SUPREME..

WHARZ `

x EARTH'S COMPUTER-

YES... THEY Wik x IEEE AT EVERY |

VEL... I

Az TRAFFIC valle; L FALL, UNGLIPER, FROM THE SKY...

ONE | = Poi. L o a

~.. LING! onc THE, ING! ome THE,

MASTER OF EVIL. LORD OF MEN. BINDER OF m N LAEMONS. ETC.ETC.ETC..4 EO (Z;

My GLITCHOIDZ kas WILL TOTALLY SABATOGE yole

GUTTEV FACE!

ocd Mer a ES

Z/ vs

ARTH WILL BEINA PANIC NO ONE

WILL BE ABLE 70 CASH A CHECK! CREDIT - CARDS WILL BE USE- LESS! LIBRARY- CARDS WILL BE REVOKED! *‘REAVERS A ae WILL HAVE 2,000,000 WINNERS! YES! 4 THE SUPREME CHAOS! THE ULTIMATE FANDEMONILIM! BEULAM ON EARTH 111

COMPUTER- RAGE 'S HERE ITI!

BOT, SUPPENLY.. 13 MO?! me COMP] -

PROD HAS FREED HIS

OAFISH MASTER! THEY VE Y

BURST THENRZ GONDPS

<,

se 4

FREE AT LAST.’ FREE 70 PISPELL THESE NOISE y, PP THER ONHYGEN/C LOYTS

THOROUGHLY HEROIC IE HASTY, ESCAPE

A U a (72

7,

i’

° Y ATM DADAS °... .....

eo. | COUL? HAVE BEEN ANYTHING...!

A e THE EMPERDK!... i SIMPLE DATA STORAGE SIRENESQUE E 7 . ` f: COMPUTER !... A SS ty = TOASTER... A WASHER- HOOKED |Z f fe WW WG SITY F. ty

ANV-VRYER-ZOMBO?... ANYTHING Z. HAY

OH, BE STILL. AT

LEAST WE'RE

WARM. AND PRY...

a eee AM P E AR, FAR FROM THE AWFUL, MATRIMONIAL CLUTCHES OF THAT SIRENESQUE FL00ZY ON PSORIOSIS I£... 7

FLOOZY YY 1222 A

HAIRBAG Le OF INDUSTRIAL SN

WHAT HO...!

A | == y a

NO SPEECHES / JUST PO

i

ZZ =

|

, Les > a = SJ

N i

2~ `< a n a

Ae a) l

Y SS

IF THAT MEANS WE'RE LEAVING, THEN IM ALL FOR IT!

. . . oe

W > °... oo soso eve ° oe je

. OAD . . s 0e o... ... ooo fete? RARO e PA

OH, BUT IT f$, CRASHY f CURSOR! ..AND YOUR m | TROUBLES HAVE TUST FE

A

FULL

WASTE Lf?

o (HRILLO ! SPILLS? o is FRILLS!

My E MATKIMONyY7 SUE 3 PREVAILS”

BE THERE ! ALOHA.. PEL

Resources for the ZX80 and MicroAce

We welcome entries from manufacturers and readers for the resources column. Please include the name of the item. a brief description, price. and complete data on how to obtain it. Send contributions to SYNC Resources. 39 East Hanover Avenue. Morris Plains. New Jersey 07950.

Software

° Moving graphics games

Super ZX80 Invasion (1K and 2K) and Double Breakout, Cassettes, $14.95 each plus $1.50 shipping. Check or money order to:

SOFTSYNC, INC.

P.O. Box 480

Murray Hill Station

New York, NY 10156

e Games and educational software. Hardware and technical information in the near future.

TENSOR TECHNOLOG Y 4 Morning Dove Irvine, CA 92714

e ZXBUG (144K) A machine code degugging program; useful for programming in machine code. An annotated disassembled listing of the 4K Basic. Much more software. Artic Computing 396 James Reckett Avenue Hull HU8 OHA England

e 1K games:

Adventure Cassette (Dragonslayer; Lunar Landing; graphics) Vegas Cassette (Black Jack. Slots) $6.95 per cassette (postage included); check or money order only.

J. Schwitalla

1235 Pickwick Place

Flint. MI 48507

48

° Games. subroutines. and teaching aids in Basic and Machine Code. SASE for complete list.

Zeta Software P.O. Box 3522 Greenville. SC 29608

e 7 Games for the ZX80 and MicroAce (one cassette) $11 from: New England Software Box 691 Hyannis. MA 02601

e ZX80Software on cassette. Games. edu- cational. programming course. Bug-Byte 251 Henley Road Conventry CV2 1BX

Users Groups

e Educational ZX80/1 Users's Group Highgate School Birmingham B12 9DS U.K. (Publishes a newsletter)

e ZX80 Amateur Radio Users’ Group (for licensed amateur radio operators) c/o K2MI. Martin H. Irons 46 Magic Circle Drive Goshen. NY 10924

e National ZX80 Users Club Membership free; publishes Interface magazine; send large. stamped. addressed envelope plus one 10p stamp to: National ZX80 Users Club 44-46 Earls Court Road London. W8 6EJ England

Hardware

e Super Isolator, Model ISO-11 A control for severe AC power line spikes, surges, and hash. $94.95. Call (617) 655-1532 Electronic Specialists, Inc. 171 S. Main St. Natick, MA 01760

e 16K-Byte RAM for massive add-on memory. $99.95 + $4 shipping. 8K Basic ROM (replacement chip for ZX80). $39.95 + $4 shipping. Phone orders (Visa, Master Card): 800-543-3000, op. 508 Mail orders: Sinclair Research Ltd. 1 Sinclair Plaza Nashua, NH 03061

e Keyboard beeper, $12 Burnett Electronics 908 Morris St. Cincinnati, OH 45206

e 33 Key keyboards for the ZX80 or Micro-

Ace. Complete plans for $5: keyboard $14.95. Complete kit (keyboard, parts. etc.): $29.95.

Schultz Systems

1026 Ferdinand

San Antonio. TX 78245

SYNC Magazine

*

Eoo G

The Sinclair ZX80 is innovative and powerful. Now there’s a magazine to help you get

the most out of it.

SYNC magazine is different from other personal computing magazines. Not just different because it is about a unique computer, the Sinclair ZX80 (and kit ver- sion, the MicroAce). But different be- cause of the creative and innovative phi- losophy of the editors.

A Fascinating Computer

The ZX80 doesn't have memory map- ped video. Thus the screen goes blank when a key is pressed. To some review- ers this is a disadvantage. To our editors this is a challenge. One suggested that games could be written to take advan- tage of the screen blanking. For exam- ple, how about a game where characters and graphic symbols move around the screen while it is blanked? The object would be to crack the secret code gov- erning the movements. Voila! A new game like Mastermind or Black Box uniquely for the ZX80.

We made some interesting discoveries soon after setting up the machine. For instance, the CHR$ function is not limit-