May/June 1981 Volume 1 , Number 3 $2.50 (USA) £1.20 (UK) The magazine for Sinclair ZX80 users Graphics: • Automatic Display Changes • Graphics Tricks • Hunt for Gold • Walls and Dikes Translating from Other Basics Keyclick Generator Adventures of Crash Cursor d31S3DaOM 3HN3AV 13W01VD 2 7CQ55 6CC5T 9091018*1 / in/PTK.xg Games: • Hammurabi • Black Hole • Gauntlet • Forest Treasure • 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 tor you. We bring you news, reviews and forecasts of hardware, software and applications for your ZX80 or MieroAee. 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 • Syntactic Sums™ to check input for errors • Printing characters four times normal size • Programs to explore computer memory • Cassette eavesdropping to locate files on tape and simplify loading • How to build their own external additional RAM • How to add an 82 1 2 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 t hut I anxiously await the next issue . . . keep up the good work! .. . . Martin Irons Goshen, NY Congratulations on the brass- tacks, clown- to-earth approach of your newsletter. Ill he looking forward to future twins Otis I m bod en Washington. IX Many readers get their first issue and immediately order the back issues - more proof that they like what they see. 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. test each program to make sure it works, it i its 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 i men ted 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: • Latest news of Z80 hardware and software • Programs to organize information, calculate, entertain, or instruct • Do-it-yourself additions to the ZX80/Micro- Acc • 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 S25 in US funds (plus S13 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 Micro Ace 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 sen ice. phone your credit card order to 61 1 456-3661. Don't miss SYNTAX! HVRXARD GROCP Bolton Road. Harvard Mass 0I4SI I own a D Sinclair ZX80 □ MieroAee computer. YES! Please send me I 2 issues of SYNTAX for $25. U My ( hec k for $2 r > is em losed. □ Please charge my □ MasterCard Visa [ J American Express □ Diner's Club account. account number exp date signature Name ^ bank number (MC only) Title - Organization Address City Phone No A L State Zip_ Home Phone No. i L S681 The magazine for Sinclair ZX80 users May/June 1981 Mil Volume 1 . Number 3 2 Letters 3 Glitchoidz Report Q First Aid for Your Keyboard Bridges Dealing with key problems 4 ZX81 Announced in Great Britain C Unfriendly Skies Lubar *" A software review C Handling of Character Strings in the ZX80 Taube u Using USR(47) 7 More Truth in Programming Lubar Using NOT Q Black Hole Eckel Shoot out the stars to escape -| The SYNC Challenge Winners announced; and winning program -1 O Auto-Display-Changing Logan Second in a series on machine language 1 g Looking Inside the ZX80 Shanko Memory listing program *| Q Puzzles and Problems Townsend Of) Mastermind Fowkes Nine chances to beat the ZX80 22 Graphics Surprises Parsons Randomizing graphics for "Walls and Dikes" 26 27 30 32 33 33 34 35 36 40 42 45 48 Variable Conversions in the ZX80 Sutton From one variable to another Graphics, Games, and Gold Oakes Building program units A Trick and a Graphic System Comer Draw your own pictures on the ZX80 Gauntlet Berggren A dash between monsters and walls SYNC Reader Survey Try This 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 1 6K-Byte RAM Specifications Key Click Generator Johnson Making entries audible ZX80 Keyboard Ornstein Locating key closures Crash Cursor Truman The Glitchoidz strike Resources Staff Publisher Editor-in-Chief Editorial Director Managing Editor Associate Editor Secretary Production Manager I ypesetter Financial Coordinator Bookkeepei Customer Service ( )rdcr Processing Circulation MEMBER E3 David H. Ahl George Blank Paul Grosjean David Lubar Elizabeth Ma win Laura Mackenzie Jean Ann Vokoun William L. Raumann Patricia Kennedy Patricia Brown Joan S^ihari Suzanne Guppy Frances Miskovieh Dorothy Staples Index to Advertisers Advertiser Pa tie Artie Computing 1 H.i sic Computer ( rames l° Bum Byte CAI Instruments Covet I Computers in Mathematics 29 five ( omputing 39 Creative Computing Back Issues 24. 25 Harvard Group Cover 2 Hewson t Consultants 4 I amo-1 em I insac 7 I .HI Enterprises New England Sol tware lit < hjtbound I ngineering 17 Peripherals Plus 16 \) \( vet 3 s> \< I Shut 12 rales ol the Marvelous Machine 41 I en ski Technology 1(1 Am. i Software 17 Volume 1, Number 3 S^ NC is published bi-monthl> for 110.00 per year by Creative Computing, 39 i . Hanover Ave., Mor- ris Plains. N.I 07950. Second class postage paid at Moms Rains, New leise\ 07950, anil atklilion.il cntrv offices. Postmaster: Send address changes to SYNt . P.< ). Box 789-M, Morristown, NJ 07960. Subscriptions in USA: b issues SID. 12 issues S18; 18 issues S24. IK and foreign airmail subscrip- tions: 6issues£l0; I2issues£18; 18 issues £25. Call (800) 631-8112 toll-free (in NJ, 201-540-044 begin your subscription. ( opyrighi NM b\ Creative Computing. Ml rights reserved. Reproduction prohibited in an> form. May/June 1981 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. 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 IK RAM is the same as for H'l K'H 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 E 1.01 - LCM & HCF. Prime factors, Statistics, Bar-chart plotter 1K U1 .01 - Line renumberer, Stopwatch, LEN( $) 1K M1 .01 - Day finder, Sequence guesser, Scetcher 1 K M2.02 - LIFE: 1/7 second per generation, with demo program 2K G1 .01 - Hangman. Matchstick game. Battleships. Hi-low 1 K 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: UK USA £950 $29.50 £320 $9.50 £3.50 $10.75 £2.70 $825 £5.00 $16.00 £3.20 $950 £3.70 $11.50 £4 00 $13 00 £4.00 $13.00 ARTIC COMPUTING 396, James Reckitt Avenue, Hull, N.Humberside, HU8 0JA England TO ORDER MAKE CHEQUES, P.O. Payable to ARTIC COMPUTING. the ZX80, it can be expanded by plugging in the new 16K memory unit. (So can the ZX80.) 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 Name: Super ZX80 Invasion UKand2K) Type: Fantasy Game System: Sinclair ZX80; Micro Ace Format: Cassette Language: Basic Summary: Best action game we have seen for the ZX80. Price: $14.95 plus $1.50 shipping Manufacturer: SOFTSYNC, INC. P.O. Box 480 Murray Hill Station New York. NY 10156 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 IK and 2K versions of the game. Let's start with the IK 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 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 IK 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 IK 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 IK of space. □ ciicit or cuissics FOUR CLASSIC COMPUTER GAMES FOR THE ZX80 AND MICRO ACE. LUNAR LANDER MINDMASTER ALL FOUR GAMES ON ONE CASSETTE, WITH GAME MANUAL, CHARTS, COLOR KEYBOARD OVERLAYS, COMPLETE LISTING IN BASIC, AND MORE! JUST POP IN THE CASSETTE AND PLAY! (REQUIRES 4K BASIC & IK MEMORY OR MORE). K-TREK LIFE J9.9S 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! ^ FREE! WRITE FOR OUR FREE CATALOG & RECEIVE ZX80 & j MICROACE CODING / SHEETS. j/ LAMOLEM LABS CODE 203, BOX 2382, LA JOLLA, CA 92038 im May/June 1981 Character Strings in the ZX80 Hasse Taube From the first day I tried to operate my new ZXHO. 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 Basie. An idea mentioned by Michael Kirk land in Personal Computer World. February, lW. on using USR(47> to obtain the address ^\ the end of the variables provided me with the key to start mv programming trieks in the ZX80. Consider the following piece of eode: 100 LET AS- ABCDEFGHIJKLMNOPQ" 200 LET A=USR(47) Then A is the address of the byte after the last Consider also: 100 LET AS- ABCDEFGHUKLMNOPQ" 200 LET A=USR<47K2 A will eontain the address of the last byte of the previous character string; in this ease. A will be the address of the letter Q. In order to use this facility, you should not have an\ other statements between 100 and 200 in the examples mentioned above. To test this on your ZX80. enter the following short proeram: 100 LET AS="ABCDEFCr 200 LET A = USR(47) 3(K) PRINT CHRS». Numb*. Bwi 6*. Cham. Siai.mct IJKM - Computer Aiuited Learning Qu.f Package wilh three umule data wi\ Mtmory Ditplay. H*> Cod* Monitor Renumber. Mhikh* Starch LINSAC 68 Barker Road, Linthorpe, Middlesbrough, Co. Cleveland TS5 5ES NOW AVAILABLE Keyboard . x Conversions • Standard Computer Keyboard • Type programs in half the time • Minimize errors • Wired keyboard hooks up in minutes Plans for keyboard conversion with reverse video $10.00 ^^^ 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 (71 4) 772-1595. Shipping charge for U.S. — $5.00. May/June 1981 SOFTWARE on cassette IP3$ BUmPfiPfth-135 25 programs for the unexpanded 2X80 on 3 cassettes. These are made up from the best of our cassettes 1-8, and include biorhythms , moon-landing , hangman , ZX80 art f stopwatch, treasure hunt, battle ships and many others complete with instructions. Purchased together in this way, they represent incredible value, and an enormous saving. UK £12 US £29 EDUCflTlDnflL FRENCH VOCAB Ihis program requires 16K and contains 200 French words with their translations. Reference & testing modes in both direct! oris (F-E & E-F) MULTIPLE CK 01 CE Allows you to enter any set of up to 25 multiple choice questions and performs testing, marking & correct- ing. By SAVEing the complete program, a large number of tests may be derived from this program - very easy to use. l6K JUNIOR MATHS 3-12 yrs . Tables, division, aadition & subtraction, or a mixture may b€s tested in this self-contained, easy to use program. Variety cf question types, a^-c-dependent timing, scoring etc. 6K UK £8.50 US #L9 UK £7.50 US j*17 UK £7.50 us #17 Programming Course Second edition The course consists of a book and a cassette of program, and has been designed to auppleuent the Sinclair manual. It la assumed that this has alroady been studied, and that the reader Is capable of constructing very elementary programs. In our book, the ZXSO'b BASIC Is explained in more detail, with special attention being given to those aspects likely to cause difficulty, for example, the use of JEEK and POKE and the USR function. An Introduction to machine code la given, removing some of the mystery vhlch surrounds this subject, and there is also a section explaining the workings of the ZoO microprocssBor. The accompanying cassette contains ready to run programs, which are dealt with in the text, which also includes many other useful prograaming examples. The emphasis is on understanding, and the course should give you the confidence to construct your own involved prograjjc, thereby getting the most out of your Z-X80. UK £8.95 US jfel PkLCMJ INCLUSIVE 251 HENLEy ROAD couEMTRy cue IBM ENGLAND BUG-BbTE IIP Black Hole Bill Eckel Black Hole is a game based on a machine language program an my Elf II 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 IK 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. * A * * * * * * 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. lx. x2x.x3 x.. .x. xx. ... .xx 4 . . x5x • • • x . . . X . x • . 6 xx x 1 x x 8 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 0*0 1 2 3 4 5 6 7 8 9 Shoot star 5 will result in this * * * 0*0 2 3 5 6 8 9 Do not end with all black holes or you will be lost in space forever! 00 The lowest possible number of turns to solve the problem is eleven. There are manv ways to solve it: here are two: 5.2.8.1. 7 .3.5.9.2.8.5 5.2.1.3.8.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 Kckel. 7336 South 71st Ave.. Omaha. NB 68157. SYNC Magazine 5 REM BLACK HOLE WRITTEN BY BILL ECKEL APRIL 2. 1981 10DIMX(9> 14 FOR I = 1 TO^ 1 16LETX(I)=0 18 NEXT I 20 LET Xl 5) = 1 25 CLS 30 PRINT. " BLACK HOLE" 32 PRINT 34 PRINT 35 LET I = 1 40 PRINT.; 42 FOR A = 1 TO 3 640 RETURN 980 IF X = THEN GOTO 986 44 IF X(I) = 1 THEN PRINT "*": 700 LET B = 4 983IFXIB) = 1 THENX(B) =0 ' 46 IF X(I) = THEN PRINT "0": 710 GOSUB 980 984 RETURN 48 LET 1 = 1 + 1 720 LET B = 5 986LETX(B) = 1 49 PRINT M "; 730 GOSUB 980 990 RETURN 50 NEXT A 740 LET B = 8 1000 FOR I = 1T0 9 52 PRINT.; I -3; ""I -2.""; I- 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 60GOSUB 1000 830 GOSUB 980 1050 IF X(5) = 1 THEN RETURN 65 PRINT "WHICH STAR?" 840 RETURN 1060 FOR I = 1TQ4 \ 70 INPUT S 900 LET B = 5 1070 IF X(I) = THEN RETURN 75 IF S 1 OR S 9 THEN GOTO 70 910 GOSUB 980 1080 NEXT I 78 IF X(S) = THEN GOTO 70 920 LET B = 6 1090 FOR I = 6 TO 9 85LETX(S) = 930 GOSUB 980 1100 IF X(I) = THEN RETURN 90 GOSUB S* 100 940 LET B = 8 11 10 NEXT I 95 GOTO 25 950 GOSUB 980 1120 PRINT "CONGRATULATIONS" 100 LET B = 2 960 RETURN 1 130 PRINT "YOU FOUND THE BLACK HOLE" 110GOSUB980 1140 STOP 120 LET B = 4 t in nn^T ir qkh 140 LET B = 5 150GOSUB980 160 RETURN SAMPLE RUN 200 LET B = 1 210 GOSUB 980 220 LET B = 3 230GOSUB980 BLACK HOLE 240 RETURN 12 3 300 LET B = 2 * 4 5 6 310GOSUB980 320 LET B = 5 7 8 9 330 GOSUB 980 WHICH STAR? 340 LET B = 6 5 350 GOSUB 980 360 RETURN 1 400 LET B = 1 410 GOSUB 980 BLACK HOLE 420 LET B = 7 o * 12 3 1 430 GOSUB 980 1 440 RETURN * * 4 5 6 f 500 LET B = 2 * 7 8 9 510 GOSUB 980 WHICH STAR? 520 LET B = 4 2 530 GOSUB 980 540 LET B - 6 550 GOSUB 980 N>0LETB = 8 570 GOSUB 980 BLACK HOLE 580 RETURN * * 12 3 600 LET B = 3 * * 4 5 6 610GOSUB9 620 LET B = 9 * 7 8 9 630 GOSUB 980 WHICH STAR? i ■"- 9 NEW ENGLAND SOFTWARE 7 GAMES FOR THE ZX80 \ND MICROACE ON CASSETTE MASTERMIND DOUBLEMIND SLOT MACHINE CRAPS TIC TAC TOE SUB RESCUE WHITE HOT NUMBER ALL RUN IN 1K RAM Now England SoftWan Box 691 Hyannis, MA. 0260 I $*1"1 ftft ORDERS BAILED I.UU rirst Class (U.S.AJ Air Mail (England} £6.00 YOUR BEST VALUE IN QUALITY SOFTWARE lAAJ * * * FOR THE IK AND 2K ZX SO. MICROAGE * * * CASSETTE i • 5L0T MACHINE - BRING PLE NTY OF MONEY • ROBOT FIGHT - WHOs THE FASTEST LASER • CORPORATION - CAN YOU KEEP A COMPANY AROAT • TANK BATTLE - TANK AGAINST TANK ON A MINE FIELD CASSETTE 2 IK • LUCKY LINDY - MAKE IT ACROSS THE ATLANTIC • CROP OUSTER - SPRAY A FIELD FROM TWO FEET • NUKE em - BOMB ENEMY MISSILE SILOS • CARRIER LANDING - DON'T LAND IN THE DRINK PHARAOHS THEASJHE EXPLORE THE PHARAOHS PYRAMID FOR TREASURE TRAVERSE THE INTRICATE MAZE SEARCHING FOR ANCIENT TREASURE BEWARE THE PHARAOHS CURSE THAT NO ONE SHALL COME OUT ALIVE ! IK T Elisor iTecntinl 33 P.O. BOX 17868 IRVINE. CA 92713 7141770-8239 EACH CASSETTE $10.00 COMING SOON: - z-aoAssEmiR - ADVENTURE WES - *£HDCHWE... SE3D FOR UUR F2L BflDCHJRE CALIF. RESIDENTS ADD S SALES TAX FOREIGN ORDERS: - ADD 12.00 FOR SHIPPING - SEND U.S. RAIDS W PfOfT SERVICE Challenge In our first issue we challenged our readers to fit the Ham- murabi game from Creative Computing's Basic Computer Games into the IK 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 KanLi 1620 MeElderry St. 12D-4 Baltimore. MD 21205 Third place (a SYNC T shirt i: Ken Berggren 104 Ridgeway Ave. Louisville. KY 40207 Honorable mentions Dennis A. Adcock 9516 -76 Street Edmonton. Alberta T6C 2K9 Canada Lester S. Cottrell. Jr. 108 River Heiyhts Drive Cocoa, FL 32922 Bob Ferguson 19 Fa tring ton 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 1 1 25 Tuskegee Institute. AL 36088 10 Ian 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 .^h2h Eastway Drive Island Lake. IL 60042 Ephraim Vishniac 38 Gorham Street Arlington. MA 02174 SYNC Magazine Hammurabi 1 k Michael Hodgkins 4 B ! 3 60 150 LET LEI I LL: 1 G-A*3 PRIN1 "WE I ISHEL 11 "POPUI ;P -! "LAND PRICE I ■ 1!- F«0 iHi:i LE ! ( • -R*9 .1 F F I F F I . !• i ■ RIN1 " I ., "WE OWN SEED FOR " : G PR tNT : N I i D • If R~1 rHEN PR ! I : I 1 GOT a PRINT "PLAG1 PRIN LET I GO! L 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-43 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 grain than he has; works out how many people starved and the remaining grain. If the number starved is too large, it jumps to 245, 1 55-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. 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. 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 = l. thus avoiding the complications caused by "1 PEOPLE" entering the city. □ May/June 1981 11 HOW IS It Done? A series of articles Auto-Display-Changing Dr. I. S. Logan Introduction The standard ZX80 is supplied with a 4K ROM and IK 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. l.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 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. INITIAL [St COMPLETE A DISPLAY lit I 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. Dr - I- S. L Nurses Lane. Skellingthorpe, Lincoln LN6 OTT England. This article is the second in a series. U I ON KEY e.g., Mine cursor, huikl up I -lin c RUN BASIC. i__ i ^ I s 12 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 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: 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 I Enter the following lines and then SAVE: 2 REM 12345678901234567890123456789 1 234567890 1 234567890 1 234567890 1 234 567890 1 234567890 1 234567890 1 23456789 1 234567890 1 234567890 1 234567890 1 234 4 GO TO 28 6LETA=USR(16428) 8CLS Reserve 134 locations. Do not use all spaces! A will return the Keyboard codes. From now on NEVER use LIST or HOME. i r ACTON KE\ I RUN BASIC RUN BASIC PROGRAM INITIALIZE TIMER CONSTRUCT DISPLAY IN BASK cn.MPLETF DISPLAY FILE PRODI « i DISP1 O NEW SCREEN & Kl \ BOARD ROI ! INI 1)1 CRI \si riMi r The magazine for Sinclair ZX80 users Hn 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 CV1 3 6EL. May/June 1981 13 r Step 2 Make the following cheek: 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 3 Enter the following lines and then SAVE. 10LETA=16428 12 POKE A.205 14 POKE A+ 1.59 16POKEA + 2.64 18 POKE A + 3. 33 20 POKE A +4. 1W 22 POKE A + 5.64 24POKEA+6,34 26POKEA+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+ 1347 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 52POKEA + 20.50 54POKEA + 21.43 56 POKE A + 22. 64 58 FOR 1=319 TO 427 60 POKE 16132+I.PEEKd) 62 NEXT I 64 POKE A + 2+4 66 POKE A + 132. 135 68LETT=0 70 FOR 1 = A TO A+ 132 72 PRINT PEEK(I); 74LETT=T + PEEK(I> 76 NEXT I 78 PRINT 80 PRINT "CHECKSUM = ";T SAVE. 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 Keyl 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 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 5 Eriter the rest of the Basic program: 10 POKE 16427.255 12 POKE 16421.24 14 RETURN 16 LET A = PEEK( 16421 H 18IFA=0 THEN RETURN 20 FOR A = l TO A 22 PRINT 24 NEXT A 26 RETURN 28 GO SUB 8 30 REM AUTO-DISPLAY-CHANGING ! Optional REM line. Initialize tinier 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 1st display. The program is now complete, so SAVE this version carefully. Remember, never use LIST or HOME. 14 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" 1% GO SUB 16 198 GO SUB 6 200 PRINT "DISPLAY TWO" 2% GO SUB 16 298 GO SUB 6 ^(X)GOTO 1(H) l N(> CLS W 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 IK ZXK0. KK) FOR 1=1 TO 550 102 PRINT"*"; 104 NEXT I 106 PRINT 1% GO SUB 16 198 GO SUB 6 200 GO TO 198 l >% CLS W 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 am changes. 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 (he next line. Complete display. Produce display. LOOP BACK." May/June 1981 Find ///c 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. KK) REM FIND THE NUMBER 102LETN=RND<5) I04LETN = 521*(N=1)()R I033*(N= 2) OR 2057*(N=3) OR 4105*(N=4) R8201*(N=5) 106LETT=1 1 « GO TO 204 2(Hi PRIM "SORRY. TRY AGAIN 202LETT=T+1 204 PRINT 20b PRINT "I KNOW THE KEY. DO YOU?(l-5f 2% 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=l THEN PRINT "ES" 308 PRINT 310 PRINT "PRESS NEWLINE TO RES TART" 312 INPUT AS 314 IF NOT AS-"* 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 H-line' routine these key values are changed to the range 1 to 7 LET X = N 62 GO SUB BO 64 PR I NT 6fo BO SUB P 6S PRINT 70 NEXT A 1 NPUT N* 7 A IF N*=^ lEN GO TO 52 75 IF N*= " " THEN STOP ?£> go ra BO PRINT CHR*(X/4096*2B) 82 LET X~X~(X/4096)*4096 34 PR I NT CHR* ( X , 256 + 28 ) ; 86 LET X«X~*256 88 PRINT CHR*'.X/ 1 fc>+ 1 90 LET X=X-(X/ 16) *16 RINT CHR*'. X+28) ; 94 RETURN 95 LET X=PEEK (N) 97 GO TO 8b ioo fur l« i ra 8 1 10 GO GUI 120 GU TO 250 LIR L*l TO 16 210 LET X«PEEK (N) T HFN LET ' ■ | i , 240 PRINT 250 LET N 260 NEXT L RE 1 URN 30O GO SU1 IT, • I Li N*N-» iRN T est i r sel ec Enter be< Set selection BOSUB address Set ttline Get address I d i spl civ 1 1 plus SFACE selection subroutine do "CRLF" -f.or each line until done Get keyboard eni r v I "stop " Otherwise is "now selection M 4-hex entry + •/_.; conv. l: al c ul ate nex t hex d i u i t 3— be* entry e i entry t—hex entry Get . Set for 8 by tee/ line b y t e p uni i ] di Set fen 16 ch Ge t. ; rent) inverted ,'ideo" exclude non-1 Display char. Increment addf and loop until done Bet b y I b a ' addf ef do SP ACE an d d i 3 p 1 a y C D DE 16 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, foUow 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 6 in 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. ci i ange Figure 2. add . . . 4=PYT- . . I merit ch»n >. - - to . . ,8>4. . . ' • - tu ... 3 >2. . . . Ir ess HEN GO rO 400 Loop until match . . . 4 1 . . . to b ; (N) Bet ra s " ">p f ' • bit /ert "spac LET X»X-128 Remove rrmb, it UNE • Do le+t tthift F 1 Display dot /no dot L Loop urtti 1 done LEf N=N+1 Then incr. address 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 through 0FFF; 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 [0010J $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 fabricin 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: 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 TV. 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/1 K RAM Games, subroutines, and teaching aids in 4 K BASIC and MACHINE CODE. All listings include statement/ subroutine logic and 8K ROM/1 6K RAM appendix PRICE; $1 00 per program listing (minimum order 10, plus $2 50 S & H ) PARTIAL LIST • (4K/1K) * FLIP-A COIN * 1 KEY BANDIT * TURRET GUNNER * ZX80 BASIC TEST * BLACKJACK * FIBONACCI SEQUENCE * COORD GRAPHICS * BARRAGE * ACEY DUCEY II * LINE RENUMBER * TEST PATTERN * CASSINDEX * FOIL FENCING * BANG' FOR 1 * EASTER DATE * STATE CAPITALS TEST * MACHINE CODE DISPLAY * GUILLOTINE * KEYBOARD GRAPHICS * 81 BOXES Specify programs wanted and enclose payment. ZETA SOFTWARE PO 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 lright, 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 hi* 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 A 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 \ Puzzler 3) If you have a favorite puzzle that you would like to share with our readers, then send 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 g'/T x 1 1" in size. There's a world of "puz- zling" entertainment in these three volumes. Until next time. Merlin says, "Have a happy !" You fill in the blank. Your editor, Charles Barry Townsend Answers on page 35. tfZ-^&^P-- SYNC Magazine The story behind the two best selling computer games books I n the world. Computer Gaines by David H. Ah! Everybody likes games. Children like tic tac toe. Gamblers like blackjack. Trekkies I ike Star Trek. Almost everyone has a favor- ite game or two. It Started in 1971 Ten years ago when I 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. So I put out a call to ail our customers to send us their best computer games. The response was overwhelming. I got 21 ver- sions of blackjack, 15 of nim and 12 of battleship. From this enormous outpouring I se- lected the 90 best games and added 1 1 that I had written myself for a total of 101. I edited these into a book called 101 Basic Computer Games which was published by DEC. It still is. When I left DEC in 1974 I asked for the rights to print the book independently. They agreed as long as the name was changed. Contents of Basic Computer Games (right) and More Basic Computer Games (below). Artillery-3 Baccarat Bible Quiz Big 6 Binary Blackbox Bobstones Bocce Boga II Bumbrun Bridge-It Camel Chase Chuck-A-luck Close Encounters Column Concentration Condot Convoy Corral Countdown Cup Dealer's Choice Deepspace Defuse Dodgem Doors Drag Dr. Z Eliza Father Flip Four In A Row Geo war Grand Prix Guess-It ICBM Inkblot Joust Jumping Balls Keno L Game Life Expectancy Lissajous Magic Square Man-Eating Rabbit Maneuvers Mastermind Masterbagels Matpuzzle Maze Millionaire Minotaur Motorcycle Jump Nomad Not One Obstacle Octrix Pasart Pasart2 Pinball Rabbit Chase Road race Rotate Safe Scales Schmoo Seabattle Seawar Shoot Smash Strike 9 Tennis Tickertape TV Plot Twonky Two-to-Ten UFO Under & Over Van Gam Warfish Word Search Puzzle Wumpus 1 Wumpus 2 Introduction Hi-Lo The Basic Language High l-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 Converted to Microsoft Basic The games in the original book were in many different dialects of Basic. So Steve North and I 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 1 974. 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 called in toll-free to 800-631 -81 12 (in N J 201-540-0445). Order today to turn your computer into the best game player on the block. creative computing Morris Plains, NJ 07950 Toll-free 800-631 -81 12 (In NJ 201-540-0445) May/June 1981 19 Mastermind » 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 Liuess 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 RBWB, 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 IK by doing the following: Delete lines 10-140. 250-320. 720-770. Change lines: sp. ) 330 PRINT "RQYBBW 480 Put- E C *J14 + 2*E, B < E 560 PCM E O203+E,9 660 1 .128 8 OO P OK E C + D * 2 +2*B+ 1 1 , 810 POKE L+D* B30 Pin E ODI B40 STOP Raymond Fowkes, P.O Box 336, Coalinga CA 93210. 5 RANDOM 1 t E 70 PRIN1 R \\\\ ! 10 . 135 IF NOT Ai .LEAR 150 DIM A Ml FOR ! 190 : WIND" 1 M I I ] I U YUll. BHT" ( COLOR IN I LI [ON. A WHl , ) . sp . and 7 sp . I N THEN STOP 'B = BLUE Y - YELLOW - " ■ - BLACK PEG" ,CHR*< 128) j t F A < B ) 300 PRINT 310 PRINT PRINT CHI I ■ r f 380 I i Q 9 390 PRINT 400 PRINT 410 PRINT iO-C, , : NEXT C 430 FOR D=l TO 9 440 FOR E»0 TO 3 NPUT A* 460 LET B■ ■ ■ ■ G R G Y | Correct answer] 5 ■ a G W B R 4 ■ ■ G W O Y 3 ■ Y B B Y 2 a R R O i ■ a G G WW 9:840 May/June 1981 21 Graphics Surprises James H. Parsons When we combine the uncertainty of the ZXHO's randomizing feature with its graphics capacities, we have the ingredients for a lot of fun. For example, the Crazv Quilt program uses only two instructions. yet it fills the screen with a zany tangle oi symbols and spots: Crazy Quilt 1()>RINT CHRS(RND<9n + 2i; 20 GO TO 10 Using "<(RNDl9) + 2l" to assign the characters to be printed insures that only the keyboard graphics symbols. CHRSlii through CHRSl 1 1 ). will be selected; and it avoids the blank space. CHRSiOi. and the null string. CHRS( I >. By changing the range oi 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 die frame lets maze travelers in. In the bottom of the frame is a randomly-located treasure marked in a S. James II. Parsons, 2575 I astelefi Dr., Columbus OH 43221. The prospective maze traveler enters the densities (from 1 to 1(H)) 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=1G\ D — 5 1 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 = l ) seem to give the most sat isf acton results. At these densities, some of the mazes produced will be ridiculously easv 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 oi the treasure, and sealing it in. With the blank line, the treasure is always accessible from some part oi the maze. Try experimenting with different densities for the walls and dikes. Try using different symbols for the parts of the maze. i I NEWLIiME 22 SYNC Magazine Typical Run of "Walls and Dikes" The player starts the program running by pressing RUN and NEWLINE and the display on the sereen says: WALLS AND DIM S WALL DENSITY'.' The player enters a number from 1 to 1(K). indicating the percentage of space to be filled in by solid horizontal walls. DIKE DENSITY? 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." 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: NEWL1NE When the player presses NEWLINE. the maze is replaced by: WALL DENSITY The uame bee ins again. □ 10 PRINT ."WALLS AND DIKES'* 20 PRINT "WALL DENSITY?" 30 INPUT W 40 PRINT "DIKE DENSITY?" 50 INPUT D 60 CLS 70 LET AS«CHR*(128) 80 LET B*»CHR*<0) 90 30 SUB ■ 1000 100 FOR Ol TO 8 (hakes the top of the frame., ) ( 1 - 2 50 q e n ©rates 8 wa 1 1 1 i h e / d i k e 1 i n e p a i r s - ) ( L e f t s i d e of frame f o r d i k e I :i. n e s - ) ( 1 2 - 1 60 ge n e r a t e s d i k e i i n es, ) 110 PRINT A*; 120 FOR K»i TO 21 130 LET E-RMD(IOO) 140 IF E ol ■Limits to drouth" Models: Dwyer: H Hour Course in Basic Part 2; Pro- gramming Approaches to Solving Complex Equations: Computerized Conferencing. Symmetric Art on your Computer. Games: Nomad, Rotate. Lissajous. t valuations: 5 Microcom- puter Basics; Software Technology Musk Svstem. :• 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; Hiuh Resolution Graphics for Apple II: GAMMON and EVILK Motor Cycle Jump Game Programs. Evaluations: Pet: Apple II: Atari Video Pinball: Alan Video computer. Vol. 4, No. 5— Sept/Oct 1978 Educational features: 4 Simulation Articles: Accounts Receivable S\s- terns: Real World Games: A Real-Time Clock \ on Can Build; All about PAS- CAL: Intelligent Videodiscs: 40 Pro g ramming Ideas: ROM Section. Hex and Star War Games. Evaluations: I \ul\ Sorcerer. Radio Shack TRS-80: Ballv Arcade: Speak A Spell and Spell- ing ti: computalker Speech Synthe- sizer: Peninsula Pet Cassettes. Merlin I Video Interlace. Vo!. 3, No. 6— Nov/Dec 1977 ! mniMu: I echniques: I ilc Struc- tures: CAP Multiple Problem fypes: Computer Histon Quiz: Final I xams b\ Computer: Dwyer: H Hour Course in Basic Pan V Mastermind II. Othello, and Inorganic Chemistr> Pro grams. I valuations: Nine Microcom- puter-bused I oys: ( omp IV: s ion Compatible Kits: I I)l Xitan: and l hrcc K08() sK Basics. Vol. 4, No. 1- I ust Sorting Algorithm: How to Write a Computer Simulation: More Fi Structures: LOGO: Murphy's La us: Dwyer: H Hour Course in Basic Pan 4. Programs for World Population Model. Biorhythms in Basic and A PL. Yahtzee. Van Gam. Kirkof. and Net- work. Evaluations: 3 Electronic MvMV Games: Radio Shack I RS-NO N.-.-u lis System. 24 Heath "Vol. 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 Basic. Programs for Mad Lists, Pat- rns. Plotting, Corral. Joust. Pu/zle. n^\ a Christmas Letter. Evaluations: P M Disk Operating Systems: North tar Horizen; Backgammon Com pu- rs: Smart I lee t route Games and ideo Games. Vol. 5, No. 1 /January 1979 Computers and Robots in Fiction: Guidance ( ounselor System: Survej ol .Educator's Attitudes \U^\k to Hide Your Basic Program. A Program to Calculate Depreciation tor Faxes, and the Space Maze Game. Counterfeit Cursor and Speed Reading for the Pet Evaluations: Microsoft Fortran mi Structured Programming with Tin} c: Smoke Signal's Feu I ditor; I \id\ Sorcerer; Ohio Scientfic Superboard foL 5, No. 2— February 1979 Multiple Regression Analysis Simpli- fied: Budget Management: Sports Pre- dictions PE1 King and POKEing for /ideo Displays: Interview with lichael Shrayer: Computers and I dil- ution Questions ol Value; Game grams for Gold Mine and Atom 20. valuations. Heath kit H-8; Thinker 1 Iopp> Disk; I lectric Pencil: Western Digital Pascal Chip Set: Lour lomputer Music Records M.5, No. 3-Mareh1979 Articles on Data Base Manage- ment: Sports Judging on a Microcom- puter: Shopping lor a Payroll Svstem: Programming the Game of Go: Busi- ness Computing with the Sorcerer: Social Science Survey Program. I val- uations: Terrapin Turtle: Videohrain Monitor: TRS-HO Floppy Disk vpple I loppv Disk. /ol. 5, No.4-April 1979 uarding Your Computer; inter " pretive Programming; Elements Good Computer Game: Music Com- position: Marin Computer Center. tms for An Intelligent Calendar. IVertical Graphs and Bar Graphs. lowers for the PET. Evaluations: hecker Challenger; Video Checkers: "heck book Maintenance Svstem Vhatsil Data Base Management Pro [Vol. 5, No. 5— May 1979 Vord Processing Systems; Pilot Tutor- il Writing User-Oriented Programs; vmoritization Schedules. Reading and Comprehension Exams; Hiding Your J a sic Program; Crib huge and Mille tornes Game Programs. I valuations ^P Daisv Word Processing; Word- naster Text Editor; PDl io Builder: la Li hu IdO Line Printer [Vol. 5, No. 6— June 1979 rgnt Articles on Computer Graphics! nd Plotting; Using Basic Strings: Microcomputers in the Hospital: Billing Program for the Sorcerer. Ink- blot and Greed Game Programs. I val- uations IRSMi Voice Synthesizer: HIPLOl Digital Plotter: Structured v stems. Name and Address Program; LF Apple Music Synthesizer. 7 — July 19 Lour features on Sorting, files and Data liases. Creativity lest: World Power Systems: Personal Finance Model: I wo I cological Simulations: Programs lor an f cological Game. Sic he. lira in leaser, and Zon valuations Brighterv\ riter, Sv\ I p< :T-82 Graphics Terminal: API PeCos one: Heuristics Speechlab; Micro Pro Super Sort: Diagnostic Programs tor khe Pet. Vol. 5, No. 8 — August 1979 f Can Computers I hink '.': 5 Basic guage Programming Techniques: I he La* and Your Computer: muMath: Image Processing: Manipulating Pen eil Files: Adventure, a new type ol computer same simulation I he Games H\ OL I and I or i j xa | lM . tions: Texas Instruments yy 4: Radio Shack I RS-80 Model II: SVV1 PC PR 40 lor ihe Pet: IMS \ I VIO SYNC Magazine Vol. 5. No. 11 — November 1979 I Adventure: Complete Listing in Basic. ( ontrolting Household De\ ice Pooling: Mumps language: Computer \n I xhibition: Build Your Own Joy- sticks; Telephone Dialer for 1 Ks 80 or Northstar; Teacher-Made rests: I valuations: Comparison Chart of 6 Popular Personal Computers: Com pari son ol 2<> Single Board Computers: Electronic Games \ roys: Quick Primer 11: Interact Computer: User- Definable Character Generators: 1 ks 80 1 evel ill Basic: Pet Software from Creative Software: Word Proces- sor: Intro! X-H) Home Control System. Vol. 5, No. 12— December 1979 Controlling Household Devices: Pari | 2: L< >(.< ); Computerized Biofeed back: Computers at the Rodeo: Crea- ting Digitized Video Images. Programs for using the Microcomputer as an Investment Tool: Animation on the \pple. Magic Tricks. "Turn-Key" CP M System. Evaluations: More Electronics Games: Language Trans- lators: APF MPIOIM) Video Came Svs- tern: 6 Word Processing Printers; Satellite Tracking Software: SysKil tor the 8080: Assemblers: CP M vs. I SC. Statistics lor 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 Control- ler: Computerized Resume: GROW: A Program that Learns: Evaluations Six Basics: M WDOS and TRSDOS: Auto Scribe: Micro Music. Vol. 6. No. 2 — February 1980 I Six Articles mi Investment Analysis: David Levy: Intelligent Computer Games: Programs: Geneology. Graphing, Genetics; Evaluations: Word Star \s Electric Pencil: Pascal for the I KS so. Micro Composer: Data Dubber; Sorcerer Word Pro- cessing Pac: Trivia Contest Results. Vol. 6, No. 3 — March 1980 Networks tor Personal Computers: r 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- Igraphing Your Computer System. 1 valuations: 11 99 4, Modems. Cobot, ■Tinyc. 10 Software Packages. Vol. 6, No. 4 — April 1980 Dr. K i loin II "s Creative Popular Per- gonal Recreational Micro Computer Data Interlace World Journal the Famous 73 page April j ool parady. H Articles on Reading and Language: Interview with Cord. mi Bell: I valua- tions: Heath WH-89; Atari 800 vs PI 1 Chatworth Mark Sense i. Reade r ; A d \ e n t u re , Vol. 6, No. 5 — May 1980 Seven I eatures on Saving Mone> with lyour Computer: Analysis ol Stock Options. lWd|^^iu: Model. Shopping lists. HonielW^Kirv. Home Pur- Bchase. Retirement Planning Compu- ted Model Rocket Design: I"wo ■Natural Language Systems: I valua- 2 I me Printer. VPI ■Imagination Machine: Personal Soft- . ware's Desktop Plan Universal Data I nir\ S\stem. Vol.6, No. 6 — June 1980 Fourteen Graphics Articles Polar Plots. 3-D Graphics. Animation. Graphic Mazes. Motion Simulation. Inside Space Invaders. 7 Music Arti- cles: Digital Audio. Computer- Aided Sight Readme Design ol a Synthe- sizer, Digital Enhancement ol Old Recordings. Comparison ol Printers: Evaluations: The Alan Machine: Neelco's Music Box for the PI I : Heath Kit-Thomas Electronic Kit. Vol.6, No. 7 — July 1980 Four Articles on Adventure Games: Dragon. Dungeon, How to Fil a Lame Program into a Small Machine. How to Write an Adventure, <■> Simulation Features: Genetics, Dec trie Manage- ment. Medical. Ecological. Sports Self-Reproducing Programs: Man- Machine Dialogs: Selecting a Compu- ter Dealer. Evaluations: Super-Texl vs I iisv Writer; Mountain Hardware K< >M PLUS+: I oolkit for the Pet: Chan Comparing Basics ol 8 Popular Computers. Vol. 6, No. 8 — August 1980 (lames Features: Computer Bismarck, Knight's lour. Guess Mj \mmal. Turnablock Came, fifteen and Hot. Mmd Exerciser. Marketing "tour Own Program; Computer Graphic Designs: Robotics Conference; Insertion Sort: Stocks and Listed Options. Evalua- tions: M.i.ik Wand: VisiCalc; Beta-80: \ steroids in Space. Vol. 6, No. 9 — September 1980 Twenty Educational Applications and Features: Language Arts CAl Devel- opment. Grading Program. Computers in the Classroom. Asimov: Point ol View; How to Heapsort; New Consu- mer Electronic Products: TRS-80 JShoppinu List for Schools. Evalua- tions: Milliken Math Sequences: I \a kron String) Floppy: HDS Videotape Series "Little Computers See How They Run": 8 Apple II Software Pack- ages: Educational Packages. JVol. 6, No. 10— October 1980 Symposium on Actor Lanuuaues and • |i j >l_ t fc* — : - p_ _, ; ; l)VV Solve It: l > New Applications and Games: I lection Prediction, The Pres- idential Cam pa i mi. ( omputer Division I valuations OS! I 2-4P Computer. I Voxbox, I wo rext Editors, I iv e Music Sv stems. 15 Software Pack ■ages, B \Sl \ Vol. 6, No. 11 — November 1980 Actor Languages and Smalltalk Wm Effective Documentation: Bomb I proof Data I ntrv: Interactive Systems and Virtuality: Fasi Sorting: Control led Input in Pa sic: Loosening Packed Basic. Future ol Small Business Com puting: Planning Your Diet. Evalua- tions: Electronic (tames. Computer \mbush . I R Cop> . Vol. 6, No. 12— December 1980 \ Comparison ol Basic Systems: Buying < ruides to Personal Computers and Electronic Toys and Games Legal Protection ol (omputer Pro- grams: Nuclear Power Plant Simula lion. Superman Game: Logic Problem Solver: Interview with the inventor ol the ZX80. Chve Sinclair: Ahm Fofl lei I he f lectronic ( lottage. I valua turns Sinclair ZX80. Atari Apple Pas- cal. CBM2022 Smart Printer. I Apple 11 and Apple II Plus. Pet. I RS July 1977 SOL. The Inside Story: Braille and the Computer Video Newspaper; A Chip is Born: The Care and Feeding of Your Home Computer. Digital Foam the peripheral of the future. August 1977 I he Kit and I, Part I. by someone who*S never soldered before: Intro- duction to the Fundamentals ol Com- puter Memorv : I ips for the [)o-it-\ our sell Hardware Beginner; Bmarv clocks APLomania, September 1977 Xeroxes and other hard cop> oil your CRT: Payroll Program; How Compu- ters Work: The Kit and I, Part II: or Power to the Computer: (CDs How , I he v Work and How They're Made \ look at PLATO, an Educational Com- puter System; IBM 5100. October 1977 For the Beu inner Binary Arithmetic Blind: The Kilobyte Card; Scoti Joplin on Your Sci-I i Hi I i Building a Basic Music Board; Flowcharting: Payroll Program. November 1977 Solar I nerg} Measurement: A Ileum ners Introduction to BASIC; 'I he Kn and I. Part 111: More Music to Plav on Your Computer; Micro Maintenance:. Solomon and Viet: Putting Togethei u Personal Computing System: rime Sharing on the i amilj MICRO. December 1977 A Beginners Guide to Peripherals: The Best Slot Machine Game l ver: Artificial Intelligence?: An Electronic Jungle ( >vm For Kids: I ile Cop> Pro gram: Better Health Through Kle< ironies: I he Kit and I Part W January 1978 Synthetic Skin lor Your Robot and \\i>* to Make It: I 1 c \ V isual Pro gramming Language: I he Code Rial ( .mi Be Cracked: Beginner's Guide to ( omputer ( iraphics: I he Computer and Natural Language: First-Timer's (mule to< ircuit Board I tching. May/June 25 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 STR${ ) 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 usinu CODE (AS) - 28 then remove the first character with TLS ( ). 108 LET AS = TLS (AS) X is then tested with an IF statement to verify that it is a number from to 9, and if it is, it is put into the numeric N with LET N = (N * 10) * X. 109 IF NOT X< 0ANDX< 10 THEN LET N = (N * 10) + X 10 INf 20 BOSUE STOP **" ; N C 100 LE 1 1 103 LE ! N 104 LET N 106 LE IDE < AH) 108 LET A*=TL$ (A*) NO ! X<0 AN! i) *x If X«192 THEN LEI 111 IF ; HEN Li THEN I 113 IF - ? GO TO :i 1 14 IF X«0 AND E [ ET Z~] GO TO 107 ii6 :hen ;o) =n<0) * \ 117 IF I N-2)^!(?)|-j LN This is the full subroutine with all the fancy things added and a small "main" program. ENTERING 1- 414E-3 150 . 003E 9 1 .. 414* 1 0* I 150. 01 - I 5, 003*10#*~9 Lets assume we have a string containing "12..V* Line 107 sets X equal to 1 (29-28). then line 108 removes the "F from AS. and line 109 sets X equal to 1 (N = (0* lOi + 1 ). If we return to 106 and start again. AS = "ZT, X = 2 and N = 12(N = (1 * 10) + 2). If we go through a third time. AS = •\V\ X = 3 and N = 123 (N = (12 • 10) + 3). Now we need something to test for the end of the string. 113 IFX = -27 THEN RETURN 115 GO TO 107 In the ZX80 all strings end with a "null" character with a CODE of 1. Line 1 1 3 tests for this and returns to the main program when the end is detected. Line 1 15 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 = 107 LET X = CODE (AS) -28 -108 LET AS = TLS (AS i 109 IF NOT X < OANDX < 10 THEN LETN = (N* 10) + X 1 13 IF X = -27 THEN RETURN 115 GO TO 107 This subroutine will search the string AS 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 AS. so AS 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). 1 o 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 ZX80in 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 * 10 3 ). Line 1 10 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 (STRS ( 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. N^ ' r^^ ur leading zeros can hr . l * - * 1 ^^ 5 = 100.000 and y< - ' fifrror message 6, arithmetic overflow). □ Joseph Sutton. 170 S. Hillside Ave. Succasunna N.I 07876. 26 SYNC Magazine Graphics, Games and Gold Martin Oakes 15 ( irmti'v. i':»n hp . ti\ i,t.>,t infn iIt-..,- bfOSd classes, fhe 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 different!} 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 mv own game using as much of the ZX80 graphics as possible. but without waiting lor the 8K Basic ROM ami lbk RAM expansion to become available. My choice o\ game was influenced b\ several considerations. Everyone knows what the successful outcome of a chess., backgammon, or caul game should be. so there is little room lor invention. The game either meets expectations or fails. Since the computer NEWLINE \ Figure I. The Game Area. 10 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 10 CONSTANTS MAIN PROGRAM -C0NT- SQUARE GAME AREA RANDOM WOOD PEEK IN DISPLAY POKE IN DISPLAY RANDOM PATH MOVE CHARACTER SEARCH FOR CHARACTER FIND AND REPLACE GOOD OR EVIL? -1 . K .**jrs Martin Oakes, 2100 Oriole I»i MO.12. f reeport. IL Figure - < Organization of Pi. mi.i.11 t;c a WUI i 1 1 v opponent. A dynamic game would have to wait until the Sk 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 1 did not expect to tit all the features 1 wanted into IK 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 mav appear as drawings. The game area is a rectangle 13 characters or columns by 10 lines. Later it can be expanded to occupy as much of the screen as required. See Figure 1. bach leal ure oi the game is written as a subroutine starting at a line number which is a multiple of KM). See Figure 2. May/June 1981 27 This subroutine searches for a specific character on a line and replaces it. 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 TO A 425 PRINT CHR$ (128); 430 NEXT C 435 LET B = RND (3) + 2 + M 440 FOR C = 1 TO B 460PRINTCHR$(9); 465 NEXT C 470 LET D = 15- A -B 475 FOR C = 1 TO D 480 PRINT CHR$ (128); 485 NEXT C 490 PRINT 495 NEXT L RUN this program. We now have a grey wood surrounded In a black border, bach 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 = RNDH2) 455 IF E = 10 THEN LET F = 460 PRINT CHR$ (F); Note that line 460 is replaced. RUN this part. Now let's make it into a subroutine called from a main program. [00 GO SUB 400 299 STOP 497 RETURN RUN this. The Jan Feb 1981 issue oi SYNC describes on p. 23 how to use the memory address stored in D-FILE to locate the display file. 600 POKE ( PEEK (163%) + PEEK H6397) *256 + Q).T 605 RETURN 101 LETQ = 12 102 LETT = 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 game area is a matrix o{ 15 x 10 characters, but because of the NEW LINE character. each line is realk 16 characters long. 101 INPUT 104 GO TO 101 RUN this. The program waits for an input. Try each of the following. KNL) 3(NL) 17(NL) 32CNL) Oops! We destroyed the NFW- l INI character. Inter 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 AS 901 IF AS = "0" THEN STOP 905 LETQ = P+ 16 910 IF AS = "N" THEN LET = P - 16 915 IF AS = "E" THEN LET = P + 1 920 IF AS = "W" THEN LET = P - 1 940 LET T = 58 945 GO SUB 600 970 LET P = 975 RETURN 125 GO SUB 900 101 LETP= 152 150 GO TO 125 RUN and enter E.N.W.S to get a string o\ I "s. Type to exit from line 901. Now we want to erase the trailing I old) positions of U to leave only one in the display. 9501 ITT = 9 l -) z o LET R = » LET = 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. 925 IFQ< IORQi 160 THEN GO TO 975 930 GO SUB 500 935 IF NOT T = 9 THEN GO TO 975 Look in location 0- to which we will nunc from the present position P. 500 LET T = PEEK (PEEK 1 16396) + PEEK (16397) * 256 + Qi 505 RETURN RUN and try to move our hero into a clearing or out of the wood. Exit with OiNLi. 1200 LET P = L* 16 1205 FOR C = 1 TO 15 1210 LET = P + C 1215 GO SUB 500 1220 IF T = S THEN GO TO 1235 1225 NEXT C 1230 RETURN 1 235 LET P = 1 240 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 = RNDUOi 110 LETS = 9 115 LET U = 58 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 LIT F = 9 305 FOR L = I 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 LETP- 152 125 GO SUB 900 150GO TO 125 299 STOP RUN this and exit with 0(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 = P- 16 1005 GO SUB 500 1010 IF T = S THEN GO TO 1060 1015 LET = 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 LETQ = P-1 1050 GO SUB 500 1055 IF T = S THEN GO TO 1060 1060 RETURN 28 SYNC Magazine When our hero finds the clearing, we will replace it with an inverse X. 1300 LETT = 189 1305 GO SUB 600 1310 RETURN Since a clearing is a blankspace, S = 0. Add to the main program: 102 LET S = 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 POKEs 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 = 901 IF AS = "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 0(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. □ Are you in j i i\\~t 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 n um- 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 Sourcebook off Ideas Many mathematics ideas can be better illustrated with a computer than with a text book. Computers i Ma ma dcs: of ideas Creative Computing Pre*: 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 teacner 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 1 34 articles and applications and reprinted them in a 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 II 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, thev would r.n^t you over $30. Satisfaction Guaranteed If you are teaching mathematics in any grade between 1 and 12, we re convinced you'll 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 -81 12 (In NJ 201-540-0445) May/June 1981 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 AS="6497" 20 LET X=CODE(AS)-28 30GOSUB 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 oi 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$="273202ZT 2()LETX = (CODE(A$)-28i* 10 30 LET A$=TL$ (AS) 40 LET X = X 4- CODE(AS) -28 50GOSUB 10000 60 LET AS = TLS (AS) 70 IF AS = ""then STOP HO GOTO 20 Notice that there are no commas between the data elements and that the 2 has to go in as 02. Keith Comer. 16889 Nichols St. »d. Huntinuion 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 AS= M ££££££££5E55E5E£BB BBFFBBBBFBBBBEABBBBEEBBBBE£ PBBBEAA3AA4ABBBBAAA£BBBBAA A3APBBBEAPBBBAAA" 20LETX= CODE (AS) 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); 801 ETA$=T1 WAS) 90 IF AS = '"THEN STOP 100 GOTO 20 1IOFORN=1 TOX-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".l 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 al 1 10 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-l 16 60LETX=X+80 Line 70 prints the selected graphic symbol. Lines 80. 90. and 100 should be obvious. Lines 1 10 to 140 are the spacing routine referred to by line 45. a simple FOR- NEXTloop. Now the system works like this: Turn to page 78 in the ZX80 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. 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 uraphic 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 AS="GNE£ACA£DN" 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 IK) 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 probablv in order: INVADERS: "FBKKBE£KRQRQK£NK RQKN£DPDCOC" " 1 BOKPB£MKNKNK A£D QKNKRC£BN!N1NB" HEART: "FKEOP£KKKKKA£QKK KKC£TQKKC£2QC" FACE "2BRNPEX10C3QE£MC5Q£ R2C1C1DA£A1E1C1E1A£ Q1S2FCMC£DP1NNCFR£ 1DPE1BR£3NNC" More extreme is the CASTLE: "£78F£78M£77FKP£65M 1 F KKKP£650E1M1M£530KK EM 1 M6A£65AA 1 M 1 MBE3 FP£63AA101MR40KE£65 A AOC 1 M40KKKE£6BBB 2ANC2M5A1A£5FA1M2A 3KM4FA 1 RC302M2A3KM 4M2M£4FA2DNNC4M4R2 DA£4MBBE8MBBBBA3P£ 7A1K20NNP7K1M£7A30C 2DP6K 1 M£7A3A4M8M£7 A3A4M8M£7A3A4M8M£7 PBBBA4MBBBBBBBBO 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$ = TL$ (A$) 130 LET Z = Z -HCODE (AS) -28) 140 FOR X = 1T0Z 150 PRINT ■"; 160 NEXT X 170 GOTO 80 Using this modification you can "draw" a U.S. MAP "3232323226E12PRNNNNN NNNQC06OK 1 1 MC09DNRS03RQC 1101 2ARA01OSO12AI2PAPRCM13A17M13 017R13ME16A14PE14OC15PE13A170 BBBE03FBRNNPA21QBEFR04DK23PR 06QA22DA" D Q N E A C A £ £ D N Figure I. Figure 2. Figure X Sample Output Castle" May/June 1981 31 Gauntlet Ken Berggren i 70 80 90 100 110 115 120 130 140 170 180 190 210 220 230 2 40 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 395 400 405 410 430 440 450 460 470 48 490 500 510 515 520 530 540 32 REM SPACE PRINT "HOW MANY MONSTERS? ( 1-4) " INPUT N LET C=0 LET D=0 CLS IF N>4THEN GO TO 70 DIM ,(N) FOR L=l TO 6 FOR K=l TO 20 PRINT CHR$(-(RND(8)>5)*9) ; NEXT K PRINT NEXT L FOR J=l TO N LET B(J)=RND(L-l)*K-2-(K/5)*(J-l) NEXT J LET G=K*3 GO SUB 900 GO TO 430 LET S=G INPUT C$ FOR J=l TO 2 LET C=CODE (C$) IF C=58 THEN LET S=S-K IF C=41 OR S(L-1)*K THEN LET S=S-K IF 3+l=( (S+1)/K)*K THEN GO TO 700 LET C$=TL$(C$) NEXT J GO SUB900 IF PEEK(S+D)=61 THEN GO TO 600 POKE D+G.O IF PEEK(S+D)=0 THEN LET G=S POKE D+0,52 FOR J=l TO N POKE D+B(J),0 LET OK IF B(J)/C=G/C THEN LET C=l IF B(J)-G<0 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 PRINT "GOTCHA" 610 GO TO 800 700 PRINT "YOU ARE FREE" 800 GO SUB 900 810 POKE D+G,20 840 INPUT C$ 850 IF C$="" THEN RUN 900 LET D=USR( 16427) 910 RETURN Subroutine Loader 100 POKE 16403,100 110 FOR J=l TO 5 120 INPUT C 130 POKE 16426+J,C 140 PRINT J,C 150 NEXT J 5^3+1 DECIMAL LIS'! 1 42 2 12 3 64 4 35 5 201 LET 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 Ber^ren, 104 Ridgeway Ave., Louisville K\ 10207. SYNC Magazine about ten bytes over PEEKing and, with only IK. 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 IK 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 to a 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 ZX80. 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 eontrol. 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" eolumn 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. □ 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 S tan i ford St. Boston. MA 021 14 Q 33 M M e M M _ M Forest Treasure 2K Paul Frahm 10 FOR 1 = 1 TO 20 20 FOR J -I. TO 30 30 PRINT " "j 40 NEXT J 50 PRINT 60 NEXT I 70 DIM A (50) 80 DIM BC75) 90 LET [>() 100 LET E~RND(20) 110 LET F=RND(30) 120 LET T=RND<619) 1 3 P D K E P E E K ( J. 6 3 9 6 ) + 2 5 6 * P E E K ( 1 6 3 9 7 ) <■• I , 140 FOR ]>1 TO 75 150 LET B(I) -RND ( 1 500 160 NEX1 L70 ! ET M*=RND<6193 POKE £i*PEEK<163- 190 LET OC+1 200 LET A (L) »PEEK ( 1639 b) ' 256*PEEK ( 16397) +M 2 1 1 i :: A ( C ) = P E E K ( 1 6 3 • H E ! •■! G Q i LE r N-F +31* (E~ 2 3 P Q l< E P E E K ( 1 6 3 9 6 ) + 2 5 6 % P E E K ( 1 6 3 9 7 5 + H , I 240 LET N=PE! >#PEEH 2-! 250 FOR 1-1 rQ l, 260 IF A(I)=N ri IOT0 460 r i 280 IF IM»PEEK ( 16396) : I EEK ( I 290 INPUT 300 IF A*="S ■ I ITEM L3 POKE PEEK <:!.< i6*PEEK ( 163 - ' FOR 1=1 TO 330 IF B1 THEN LET" F«F-1 1 F Afc^'D" AND E<30 ["HI ♦ .;. 380 IF A*--*" Li" AND E>1 THEN LE 390 BOTQ 1 70 400 LET F^F+RND (9) 5 410 LE i E=E+RND (9) 5 i GOTO 1 4 3 F' K E P E E K ( 1 6 3 9 6 ) +■ 2 5 6 * P E E K ( 1 6 • 5 9 1 ) + I , 1 440 PRINT "YOU HAVE TAKEN THE TREASURE 450 GOTO 500 4 6 P K E P E E K ( 1 6 3 9 6 ) + 2 5 6 * F' E E K ( 1 6 3 9 7 ) + H , 1 9 470 PRINT" "THE MONSTER HAS KILLED YOU 1 ' 480 GOTO 5 '60 490 PRINT' "THE MONSTER HAS STOI EN THE TREASURI 500 PRINT "ANOTHER GAME? (Y/N) " 510 INPUT' B* 520 Ci S 530 IF B*= ,, Y U THEN RUN 540 LIST "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 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 L for up, down, right, or left, and then pressing NEWLINE. Entering S will exit you from the pro- gram. Paul Frahm. 21123 DettmerinK. Matteson. IL 60443. 34 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 1 10. 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. Trie 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 eases where the progression is not simple. Take a line such as ON X GOTO 90. 430. 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=l) * 90 + (X = 2)*450 + (X = 3l*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 -I to signify true. The ABS takes care of that. Another common Basic operation is the LEN function. The expression LET X = LEN (AS) 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 = 30 LET B$ = AS 40 IF BS = "" THEN GOTO 100 50LETBS = TLS(BS) 60 LET L = L 4- 1 70 GOTO 40 100 PRINT AS; "HAS A LENGTH OF" : L The program is fairly straightforward. Since TL$ destroys the variable, AS is preserved by using BS for the operation. When BS has only one character left, the result of TLS (BS) 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: Lucky Number: Multiplv. 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: 12145679 x 9 = III 111 HI x 18 = 222 222 222 x 27 = 333 .W 333 x 36 = 444 444 444 x 45 = 555 555 555 x 54 = 666 666 666 x 63 = 777 777 777 X 72 = 888 888 888 x 8 I = 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 m relation to one anothei 45 + 36 = 8 1 miles per hour. This equates out to: 5,280 x 81. 60 \ 60 = 1 18.8 feet per second I he length, then, of the Dover train is 6 x 1 18.8 = 712.8 feet. A Seven-Letter Charade: The answei is the word ENGI WD I he other words are 1 \I> (.1 \I>. \\(,1 I . 1 AND The Three Jealous Husbands: For the sake of clearness, we will designate the three husbands A. B, and C, and their wives a, h. and r. respectively. The passage may then be made to the satisfaction of the husbands in the follow- ing order: 1. a and b cross over, and b brings back the boat. 2. h and c cross over, c returning alone. 3. f lands and remains with her husband, while,4 and Across over. A lands, flandA return to the starting point. 4. B and C cross over, leaving h and r at the starting point. 5. a takes back the boat and h crosses with her. 6. a lands and b goes back lor r. The Four Jealous Husbands: Distin- guishing the lour husbands as J. B. C. and D. and the four wives as a, h, r. and d, respectively, the answer to this version is: 1. a, 6, and c crossover;* brings back the boat. 2. c and d cross over; (/ brings back the boat 3. A, 5. and (cross over: ( and c bring back the boat. 4. C, D, and f cross over. 5. < takes back the boat and fetches it. May/June 1981 35 Sinclair ZX80 8K Basic ROM and 1 6K Byte RAM Pack Specifications Numbers Stored in 5 bytes in floating point binary form giving 9 x 10"" 44 to 1.1 x 1CF accurate to 9 1/2 decimal digits. Variables Numeric: String: FOR-NEXT: Numeric arrays: String arrays: Arrays Numeric arrays: String arrays: (more correctly, character arrays) Any letter, followed by alphanumerics. AS - Z$. A-Z. A-Z. A$ - Z$. 'n' dimension, subscript range starts atO. 'n' dimension, subscript range starts at 0. If the last subscript is omitted it's treated as a fixed length string. 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 - • fully floating-point arithmetic to 9-digit accuracy. • logs. trig, and their inverse functions. • graph plotting facility. • animated displays using PAUSE n. • full set of string-handling facilities. • n dimensional arrays. • n dimensional string arrays. • cassette LOAD and SAVE with named programs. Full specification follows. READ RESTORE REM RUN IS SIN Strings Undimensioned strings can be any length. Can be concatenated ( + ). Substring eg BS = A$ (2 TO 4). Literal strings eg C$ = "QWERTY". Statements available In this list. v x.y.z m.n e f s represents a variable, represent numerical expressions, represent numerical expressions that are rounded to the nearest integer, represents an expression, represents a string valued expression, 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. RAND RET INPUT POKE COS TAN INT RND STR$ CHRS CODE PEEK TAB NEW SAVE DIM EOR GOTO GO SUB LOAD LIST LET BREAK ARCSIN ARCCOS ARCTAN SGN ABS SORT VAL LEN DATA CLEAR CONT CLS SCROLL NEXT PAUSE USR LN EXP AT IN KEYS NOT 7T S.nrlair ZX80 8K BASIC Keyboard template for new 8K BASIC ROM. 36 SYNC Magazine CLEAR CLS CONTINUE DATA... DIM- DRAW m.n FOR A TO B STEPC NEXT GOSUB n GOTOn IF x THEN s INPUT v LIST LISTn LOADf NEW NEWn Deletes all variables, freeing the space they occupied. (Clear Screen) deletes all PRINT output in the display file. Resumes execution of the last run pro- gram—repeats the last statement if an error was detected, otherwise restarts at the next one. Note that a command (immediate execution) statement counts as a program and so destroys the re- entry data. Standard, but no unquoted strings. Deletes any array or string with the same name, sets up space for a new array in the usual way. and initialises its element toOor M ". Let (u.v) be the current PLOT (q.v.) posi- tion. Draws a line as straight as possible from (u.v) to (u 4- m. v + n) by blacking in pixels (quarter character squares). Changes the PLOT and PRINT posi- tions. Generally standard, dynamic in its action. but entirely The effect of a NEXT statement is to look up the corresponding FOR-vari- able. increment its value by the STEP, check whether the limit is exceeded and if not jump to the looping line number. Transfers control to BASIC subroutine. Jumps to line n. If x is true (defined to mean greater in absolute value then 2 - " 2 ) then s is executed. The standard values of true and false as yielded by relational opera- tors are 1 and 0. Outputs the display file to the screen with no special INPUT prompt; the rest is standard. Cannot be used as a com- mand (immediate execution) statement. Lists from start of program. Lists program starting at line n with pro- gram cursor pointing at line n. Looks for a program called f on tape and loads it and its variables. Default n = 0. Erases BASIC program and variables. n is used to alter a system variable known as RAM TOP. which is the address of a byte in RAM. The area from RAM TOP on is untouched by the BASIC system, and POKEd programs can be left there in safety. PAUSE n PLOT m.n POKE m.n PRINT... PRINT AT m.n PRINT TO de RANDOMIZE RANDOMIZE n READ v REM... RESTORE RETURN RUN RUNn SAVEf SCROLL STOP UNDRAW m.n UNPLOT m.n Sends the display file to the TV screen for n frames (50 frames per second) or until a key is pressed. Sends the PLOT position (a system vari- able) to (m.n) and blacks in that pixel. Also changes the PRINT position. Writes n in byte m in RAM. Mostly standard. The display file has 22 lines of 32 characters each (2 zones of 16 characters) and when this is filled it is sent to the TV with error 5. CONTINUE carries on with the program with no loss of data. Moves the PRINT position to line m. character n. Alters the PRINT format. Here d is an optional digit between 1 and 8 (default value 8) and e is an optional letter E. From now until another such formatting item, numbers will be printed to d signi- ficant digits, and if E is present they will always be printed using scientific nota- tion. On switch-on. the format is initialised so that numbers are printed to 8 digits and scientific notation is avoided where pos- sible. Note that PRINT does not change the PLOT position. Standard If n is given this is made the value of the seed of the random number generator. Reads v from a data statement. Remember, for program comments. Reinitialises the data (so it can be read again). Return from subroutine. RUNs the BASIC program. CLEAR followed by GOTO n. Saves program and variables on tape and calls it f . Scrolls display file up one line. losing top line and making space at bottom. These are like DRAW and PLOT, but blank out pixels instead of blacking them in. May/June 1981 37 Functions Type of Operand Result Functions Type of Operand Result ABS ARCOS ARCSIN ARCTAN CHR$ CODE COS EXP INKEY $ INT LEN LN NOT PEEK number number number number number number number number number number number string number number number 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 if x is empty) In radians. 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 NOT0= l.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)(andA< >B). The value of the byte in store whose address is x. PI 71 (3.1415927) RND A random number between Oand 1. SGN number Yields -1.0. 4-1. SIN number In Radians. SORT number Square root. STR$ number The string of characters that would appear on the screen if x were PRINTed. TAN number In Radians. USR number 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 hi register pair. VAL AND OR string Evaluates x as a numerical expression (x must not con- tain the quote image char- acter). Logical AND 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 T 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. □ tfiON/C CAA/ ©Creative Computing "This one is called 'Kafka'. It is programmed to try to present the user from figuring out how to play it. " 38 SYNC Magazine A REMARKABLE 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. Or an 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 Toff ler, author of Future Shock and The Third Wave says. I 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 that a 1 4- year old or a Cobol programmer can under- stand them Things like text editing, social creative comporting "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, ft 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 learning 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 . . in a magazine 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 1 year $20 $29 or £12.50 $50or£21 2 years $37 $55 or £24.00 $97 or £41 3 years $53 $80 or £34.50 $143 or £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. I am very much im- pressed with Creative Computing. It is helping to demystify the computer. Its arti- cles are helpful, humorous and humane. The world needs Creative Computing.'' creative computing PO Box 789-M Mornstown NJ 07960 Toll-free 800-631-8112 (In NJ 201-540-0445* 27 Andrew Close. Stoke Golding Nuneaton CV13 6EL England J May/June 1981 39 Key Click Generator by Matthew J. Johnson This simple circuit will produce an audible tone whenever the ZXNO screen is blanked, yielding a click to indicate key closure, or a steady tone during processing. I lamination i^i the "SYNC" line (IC 19 — PIN 5) with an oscilloscope reveals three constituent signals: Lin£ Sync (denoted LS); F rame 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 bus 58us FS 380us 18ms KBD (vms N/A The time constant of the RC low pass filter was chosen to allow the second gate to switch on ly 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 2 Devir St.. Maiden. MA 02148. Circuit Diagram for the Key click Generator 1 6-74LS14 SYNC + SVDC 220K 470ft Cir. K5> A 4 H N J< 10K BLUE CO REDN m 30 BLK. General-Purpose NPN transistor IMF \ r/7 1 6-74LS14 40 SYNC Magazine &/ ^ —Only Fiction • .^_ or is it? Tales of the Marvelous Machine: 35 Stories of Computing ■ > / f A robot friend. A computer God. Arrificiol intelligence challenging human intelligence in o 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, AAV. Mathews, Carol Coil, 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. Can criminals be caught by computer? Does computer crime pay? Do computers fall in love? Are we all part of a larger organic computer? Here are 05 tantalizing tales that will open your eyes ro a new perspective of computers. Skillfully drawn illustrations augment the stories, giving glimpses of scenes as envisioned by 20 talented arrists. This artwork adds another dimension to the text. Tales of the Marvelous Machines: 35 Stories of Computing, edited by Robert Taylor and Durchenal Green is a beautiful big 8 1 2" * 1 1" softbound anthology of 272 pages. 12 D It is available for $7,95 plus $2.00 shipping and handling per order from Creative Computing, P.O. Box 789-M Mornstown, NJ 07960. NJ residents add 5% sales tax. Visa MasterCard and American Express orders are welcome. For faster service, call in your bank card order roll free to 800-631 -81 12 (in NJ call 201-540-0445). Or use the handy order form bound into this magazine. creative corapatiRg press The ZX80 Keyboard James H. Parsons The ZXHO'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 arc connected to the inputs of [CIO, a 74LS365 tri-state bus driver. The diodes arc used to inhibit sinking of the address lines by the pull-up resistors (R LVR17}. The resistors are used just on £in\\ 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 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. I ruler side ol keyboard template Adhesive ■ Conductive Material Key hoard Template J U PC Board Figure 1. When a key closure is made, either a low signal or a tri-state signal is sent to the input of IC10. ICIO. being a standard 74LSxx gate, has internal pull-up resistors on its inputs. A tri-state type signal pre- sented as input to ICIO will, therefore. allow the pull-up resistor to pull-up the input line and turn the input transistor on. thus causing a logic 1 to be the effect- ive input. When a logic input is received, the input line becomes grounded, and the internal input ,pull-up is disabled, thus causing a logic to be the effective input. Figure 2. 42 SYNC Magazine I row Cassette Circuitry l| 1K Vcc vcc it to ■ -or . . . o* - _ - DJ - - - 02 - - - DO . - - 01 GK'D IT a. ^ L. . KBO s=r B ]0RQ WR hi • * 1 RO OH M ' r^ 5 r^^r^h- ' K>H RO Address Bus Ala YJmj -< r-O^ ' If !C!0 is enabled when the signal KBD (see Figure 3) is active (i.e., low). As you will note, the signal is derived f rom tw o OR .g ates. L ogically , the signal is KBD = AO + RD + IORQ. Essentially, all of the three inputs must be low to enable IC10. This means that an I () read (a ZKO IN instruction) is being done from any even address (i.e.. any address with AO = 0). During an I/O request (I0RQ=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. I A simple routine to test tor the BREAK key is shown below: LD A.7Fh IN A. (FEh) RRA JRNCBRKPRS May/June 1981 Figure X i he first instruction loads the keyboard mask into A. This particular mask has ail 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., dO- 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 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 position o{ A (i.e., the data for the BREAK key). Now the carry flag will contain a if BREAK was pressed: other- wise it will hold a 1. The next instruction, if the carrv 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 ifie 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 In the OR 0E0h instruction at 5$:. Bit 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 ke\ 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 I ILLDF 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. □ 43 I istiiu; I. 15 5S RESULT: EQU FRAMES: EQU CH_ADD: EQV LOOP: Call Show; DISP: LDB.8 DJNZ $ LDHL. (FRAMES) 1NCHL LD22h 4()lEh 4026h Space between last line of chars and fram sync Enter here from BASIC to get a key and display the current display file Address 319 decimal 13Fhex Blow away 99 T -States Get old frame counter Increment it Put it back Start frame sync Zero bit for each key pressed Flip bits 00 if any key pressed, else FFh OR F RETZ Rotate mask left IF in mask hasn't reach earn, LDBC.(CH_ADD) LD(CK_ADD>,HL LD A.B ADD A. 2 SBC HL.BC EX DE HL LD HL. RESULT LDA.(HL) OR D IK 32 if US. 36 if UK no L has a for each row in which a key. other than SHIFT. was pressed: H similarly for columns in dl-d5. d6d7 are ones. d0=0. if SHIFT pressed. else d0= 1 717 T-States since start of frame sync. 345 before end Pick up last times key hits, or a value with dl 3d 14=01 if first time around Now either carry is clear and BC indicates a key was pressed or carry is set and BC = FFFFh orFEFFh. N.B. Neither (XKX)h nor FFOOh isa possible value for HL. since d6 d7 are set and. if all of dl to d3 of H L=-l HL:=0 if HL = BC and C = FFH LD A.B CP 254 SBC A.A. ANDB RRA LD(HL). A DECB 2S: [)JNZ 2S Ol I <0I I hi. A LD A. 20 LD B.25 LDHLlDFILE) ; SET 7.H CALL SHOW LDA.-13 INC B DECHL DECCIY + Kt SI I I + l-Y> : JR LOOP SHOW: LDC.dY + RESULT + 1-YI ; LD R.A LD A. 35 ; EI JP(HL) ; If ATE...r ~*NKtCRO-MIMATURIZEP> MY LE&tOMS W/LL IH<RATE THE COMRLEXX CIRCUITRY OF EVERY COMPUTER-SYSTEM ON EARTH ' r * /£r/Vl WBEAK/MG HAVOK WHERE- EVER THEy CAA/...f" < anp ^apventure r~ //a 17iJRN. 00 Corporate empires will crumble over- NIC/HT, UNABLE 7Z> MAKE PECI SIGNS OR JUGGLE 3UP&ErS~J\ ^^^^JjHi^VJl P^^Pl ^^r ^.^^^ <■* oeorge: ya screw ec? up// I'M our : MEMORY .' MY PROGRAM £E*SHEp\' *&ARTH WILL BE IN A ^ PANIC/ NO ONE WILL3E ABLB TO CASH A CHECK? CREP/T- CARpS VS/LL BE USE- LESS/ L/BRARY-CARPS W/LL BE REVOK&Pf REAPERS WCi EST' W/Z.£. //4l/£* 2,000,000 W/NMERS/YE*S! TWE- SUPRBME CHAOS! THE ULTIMATE FKNPEMONtaMt BEPLAM ON EARTH fff C0MPUTER~RA6E WHAR'Z BlSSONf i 461 -F NO! '-am c^u PRO/P HAS FREEPH/S *R££ ATIAST/fxeb to P/SPBLL THBSB NOtSBY, RATHBR UNMy&BMC LOOTS ANP MAX^ &OCC> A r.ALAS... ...f COULV HAVE 6»EEN ANYrMN6. m .{ ...A SERV£o/.. , ANYTH ING Wtf/I?f BUT NO -0000' f HAP TO GET HOOKEP up w/rtt A# ALLEP6EP SPACB- APVENTURER WMPOESN'T KNOW VCNUS FROM m i'& ;x« r WBLL L 6UB$S , A&AlN t VAOVBR )PAPPBC? &/& HA/R&A& FULL ^/HPaST&AL- OH n &E STILL. AT LEAST WE'RE WARM. AH\P p/zy... ANP FAR, FAR FROM THB AWFUL , MAT&tMONfA L £L UTCHBS OF THAT S/RBNESOUE Fboozy O/V PSoK?OS/$ 1Z..„ fl J^fl W> ^' •# T&WUfc'Z 47 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 (IK 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 Games and educational software. Hardware and technical information in the near future. TENSOR TECHNOLOGY 4 Morning Dove Irvine. CA 92714 ZXBUG (lftK) A machine code degugging program; useful for programming in machine code. An annotated disassembled listing of the 4K Basic. Much more software. Artie Computing 396 James Reckett Avenue HullHUHOHA England IK games; Adventure Cassette (Dragonslaver: 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 • Games, subroutines, and teaching aids in Basic and Machine Code. SASE for complete list. Zeta Software P.O. Box 3522 Greenville. SC 29608 • 7 Games for the ZX80 and MicroAce lone cassette) SI I from: New England Software Box 691 Hyannis. MA 02601 • ZX80 Software on cassette. Games, edu- cational, programming course. Bug-Byte 251 Henley Road ConventrvCV2 1BX Users Groups • Educational ZX80/1 Users 's Group Highgate School Birmingham B12 90S U.K. (Publishes a newsletter) • ZX80 Amateur Radio Users* Group (for licensed amateur radio operators) c/o K2ML Martin H. Irons 46 Magic Circle Drive Goshen. NY 10924 • National ZX80 Users Club Membership free; publishes Interface magazine; send large, stamped, addressed envelope plus one lOp stamp to: National ZX80 Users Club 44-46 Earls Court Road London. W8 6EJ England Hardware • Super Isolator. Model ISO-l 1 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 • 16K-Byte RAM for massive add-on memory. $99.95 4- $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 • Keyboard beeper, $12 Burnett Electronics 908 Morris St. Cincinnati. OH 45206 . 55 Key keyboards for the ZX80 or Micro- Ace. Complete plans for $5: keyboard $14.95. Complete kit (kevboard. parts, etc.): $29.95. Schultz Systems 1026 Ferdinand San Antonio. TX 78245 48 SYNC Magazine The Sinclair ZX80 is innovative and powerful. Now there's a magazine to help you get the most out of it. Get in sync 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 1 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- ed to 3 value between and 255, but cycles repeatedly through the code CHR$ (9) and CHR$(265) will produce identical values. In other words, CHR$ operates in a MOD 256 fashion. We found that the - sign can be used se- veral times on a single line, allowing the logical evaluation of variables In the Sinclair, LET X - Y = Z = W is a valid ex- pression Or consider the TL$ function which strips a string of its initial character At first, we wondered what practical value it had Then someone suggested it would be perfect for removing the dollar sign from numerical inputs Breakthroughs 9 Hardly But indicative of the hints and kinds you'll find in every issue of SYNC We intend to take the Sinclair to its limits and then push be- yond, finding new tricks and tips, new applications, new ways to do what couldn t be done before SYNC functions on many levels, with tutorials for the be- ginner and concepts that will keep the pros coming back for more Well show you how to duplicate commands avail- able in other Basics And, perhaps, how to do things that can t be done on other machines. Many computer applications require that data be sorted But did you realize there are over ten fundamentally differ- ent sorting algorithms 9 Many people settle for a simple bubble sort perhaps because it's described in so many pro- gramming manuals or because they've seen it in another program However, sort routines such as heapsort or Shell- Metzner are over 100 times as fast as a bubble sort and may actually use less memory Sure, 1K of memory isn't a lot to work with, but it can be stretched much further by using innovative, clever coding. You'll find this type of help in SYNC Lots of Games and Applications Applications and software are the meat of SYNC. We recognize that along with useful, pragmatic applications, like finan- cial analysis and graphing, you'll want games that are fun and challenging In the charter issue of SYNC you'll find se- veral qames Acey Ducey is a card game in which the dealer (the computer) deals two cards face up. You then have an op- tion to bet depending upon whether you feel the next card dealt will have a value between the first two. In Hurkle, another game in the charter issue, you have to find a happy little Hurkle who is hiding on a 10 X 10 grid In response to your guesses, the Hurkle sends our a clue telling you in which direction to look next One of the most ancient forms of arith- metical puzzle is called a boomerang The oldest recorded example is that set down by Nicomachus in his Arithmetics around 100 A D You'll find a computer version of this puzzle in SYNC Hard-Hitting, Objective Evaluations By selecting the ZX80 or MicroAce as your personal computer you've shown that you are an astute buyer looking for good performance, an innovative design and economical price However, select- ing software will not be easy Thats where SYNC comes in SYNC evaluates software packages and other peripherals and doesn't just publish manufacturer descriptions We put each package through its paces and give you an in- depth, objective report of its strengths and weaknesses SYNC is a Creative Computing pub- lication Creative Computing is the num- ber 1 magazine of software and applica- tions with nearly 100.000 circulation The two most popular computer games books in the world, Bssic Computer Gsmes and More Bssic Computer Games (combined sales over 500,000) are published by Creative Computing Creative Computing Software manufac- tures over 1 50 software packages for six different personal computers Creative Computing, founded in 1974 by David Ahl, is a well-established firm committed to the future of personal com- puting We expect the Sinclair ZX80 to be a highly successful computer and correspondingly, SYNC to be a respect- ed and successful magazine Order SYNC Today To order your subscription to SYNC, in the USA send $10 for one year (6 issues), $18 for two years (12 issues) or $24 for three years (18 issues). Send order and payment to the address below or call MasterCard, Visa or American Ex- press orders to our toll-free number. Subscriptions in the UK are mailed by air and cost £ 10 for one year, £ 18 for two years or £ 25 for three years. Send order and payment to the UK address below. Canadian and other foreign surface subscriptions cost $15 per year or $27 for two years and should be sent to the USA address. We guarantee your satisfaction or we will refund your entire subscription price. Needless to say. we can't fill up all the pages without your help So send in your programs, articles, hints and tips Remember, illustrations and screen photos make a piece much more inter- esting Send in your reviews of peripher- als and software too-but be warned re- views must be in-depth and objective We want you to respect what you read on the pages of SYNC so be honest and forthright in the material you send us Of course we pay for contributions— just don't expect to retire on it The exploration has begun Join us 39 East Hanover Avenue Morris Plains. NJ 07950. USA Toll free 800-631 -81 12 (In NJ 201-540-0445) 27 Andrew Close. Stoke Golding Nuneaton CV1 3 6EL. England THE CAI 'WIDGET'® SERIES OF PERIPHERALS FOR THE ZX-80 OPENS THE DOOR TO REAL COMPUTING J^ Check Our Specifications WIDGET® *49 95 WIDGIPRINT®*^ 5 WIDGITAPE® $3& 5 PARALLEL TTL INPUT PORT • Eight bits non-latched • Draws one low power Schottky load • Uses: Interface to user designed circuits Sensing alarm conditions Interpreting limit switches Accepting user switches or other input devices PARALLEL TTL OUTPUT PORT • Eight bits concurrently latched • Supplies up to ten (10) low power Schottky loads • Uses: Interface to user designed circuits Activating Led's, Lamps and Indicators Powering relays, SCRS and TRIACS for high current 110 VAC loads Sounding alarms SERIAL RS-232 INPUT /OUTPUT PORT • Three wire bi-directional serial line • Baud rates strappable at 110, 300, 1200, 2400. 9600 • Communicate with: Serial printers Modems (transmit and receive data only) Terminals (teletypes and CRT's) Graphic plotters ADDRESS AND CONTROL SIGNALS from the ZX-80 are all buffered to allow ease of expansion. WIDGET INTERFACES DIRECTLY TO THE WIDGIPRINT and WIDGITAPE and the 16K RAM and 8K ROM by simply, plugging one into another. The WIDGET, like all CAI devices, comes with complete schematics and instructions. HIGH QUALITY THERMAL PRINTER at a very affordable price THE WIDGIPRINT PROVIDES THIRTY-TWO (32) COLUMNS OF OUTPUT in compliance with the for- mat shown on the television screen EASY INSTALLATION • The CAI Printer is designed to plug directly into its own poit on the Widget board. This leaves all eight I/O bits on the WIDGET board available to the user. There is no soldering or modifications necessary • The printer is equipped with its own power supply SPECIFIC PRINTER SPECIFICATIONS • Full alpha-numeric capabilities with limited graphics • Thirty-two (32) characters per line • Self-contained power system • Two-hundred lines / minute print speed • Long life — few moving parts • Paper size 3.15" roll style readily available • Size 6.4" x 1.9" x 3.7" The PRINTER comes with a complete instruction and operations manual. The WIDGITAPE is designed as a highly reliable mass storaae device for the data generated with The ZX-80. This de- vice interfaces through the CAI WIDGET Board, and is completely independent of the tape connections on the ZX-80. The WIDGITAPE provides much of the functionality found in floppy disks for a fraction of the cost. THIS INCLUDES • Writing a file • Reading a file • Extending or modifying a file • Deleting a file • Each tape also maintains its own file directory which can be viewed on the television screen All these functions are programmati- cally accessable to the user via simple keyboard commands. INSTALLATION • The WIDGITAPE plugs into its own plug on the WIDGET Board with no need to solder or modify the ZX-80. r" USE THIS FORM TO ORDER YOUR WIDGET R PERIPHERALS Send Check, Money Order Or Credit Card Number To: Quantity Description Unit Price Total WIDGET $49.95 III WIDGIPRINT" $99.95 CAI Instruments, Inc. P.O. Box 446 Midland, MI 48640 517/835-6145 WIDGITAPE * $99.95 TOTAL Mastercharge Exp. Date Name Address City Add $5.00 for shipping and handling Michigan residents add 4% sales tax Visa . State . ZIP