Another review, this time one with lots of code to test out. This time we’re doing Computer Battlegames.
- Title: Computer Battlegames
- Subtitle: For ZX Spectrum, ZX81, BBC, TRS-80, Apple, VIC & PET.
- Authors: Daniel Isaaman and Jenny Tyler
- Pages: 48
- Published: 1982
- ISBN 10: 0860206858
- ISBN 13: 978-0860206859
This book is full of BASIC programs to be entered, 13 in all, although the last one involves graphics and there are separate listings for each computer for that one.
After a quick double page introduction to the book and comments about entering, debugging and running the programs we jump straight into them.
To avoid having large chunks of listings in these reviews I have instead made the listing available as a ZIP file here:
The first listing…
Apparently the humans are at war with the robots! Not the friendly ones who teach us how to code in these books I hope? This program is very simple. It just chooses a random letter then you have 4 guesses to find out what it is with the computer telling you if the guess is before or after the letter.
Nothing hard to do here although all these listings are for the ZX81 with modifications for all the other machines. unfortunately the ZX81 doesn’t use standard ASCII codes so in all these listings whenever an ZX81 code is used you have to change the code used in the listing to the proper ASCII value.
Throughout the book the listings are marked with little symbols next to some lines. These indicate the lines that are different on different machines.
The Vital Message.
Next up we have The Vital Message. This is another very simple game. It creates a list of random letters that you have to then enter in. Apparently all it takes to stop a war is entering in the proper simple code. This game uses the CLS command to clear the screen after displaying the code to you so you must remember it then type it in correctly.
Next up we have Shootout. This one was interesting because on line 110 I hit a command Orwell didn’t support. That is the INKEY$ command. Unlike INPUT which waits for you to enter some keys and then hit return the INKEY$ command checks immediately if any key is being pressed on the keyboard. I had to add that functionality into MS Basic running on Orwell.
Since INKEY$ is a function (although it needs no user input) I basically copied how the CHR$ function was done in the code. It has to be a function since INKEY$ needs to return a value. Being a function you do have to specify an input parameter even though it isn’t actually used.
MS Basic doesn’t seem to handle empty strings as you would expect. If you enter a command like A$ = “” then try to compare A$ with “” it doesn’t return true. If you try to get the ASCII value of it with ASC() you get an error. Getting the length with LEN() will return 0. I did try creating an empty string in the code if no key was pressed but that seemed to cause issues so my INKEY$ function will always create a 1 character string (as does CHR$()).
So my INKEY$ will always return a length of 1 and, if no key is pressed, an ASCII value of 0.
Since I can’t seem to do a comparison against an empty string directly the way to check if a key is pressed is to look at the ASCII value and see if it is non zero:
IF ASC(INKEY$(0)) <> 0 THEN a key is pressed….
That seems to work very well.
Desert Tank Battle.
Next we have a game that uses some of the maths functions, namely SIN and ABS. Again a simple little game that worked first time. It is another of the enter some values and it tells you how close you are games.
Battle at Traitor’s castle.
Now this game proved interesting. There is a bug in the listing! Line 130 is supposed to check if the key you pressed matches the position of the O character in a line of dots (battlements – these games need some imagination). The code reads:
130 IF VAL (“O”+I$) = T THEN GOTO 170.
I$ is the key returned from INKEY$. T is the position of the O. VAL() returns a numeric value of a string. So if you press the “1″ key it returns 1 as a number. Why they had “O” in the VAL I don’t know.
This one was interesting. There isn’t anything new here but it was this listing that showed up the bug in my INKEY$ function when trying to return a zero length string. It’s interesting to note the previous listing also used INKEY$ but that worked. This one didn’t and it’s something to do with the fact that INKEY$ is called in a loop. After the first time through the loop the P$ variable was being overwritten (I think) and so was lost. P$ is the random letter the code was generating to represent a robot to ‘shoot’ by matching it with a key press. I don’t fully understand why it broke yet but it works now.
It’s tricky to take a photo of this game as what it does is display a random letter in a random spot on the screen which you have to match. It clears the screen between each one.
Next up is secret weapon. Not much to say about this one. It’s another guess the values one but with two values. It tells you if you are close or not. This code is my first use of the SQR() function.
This is another guess the random number type game. Nothing special here.
This game is a little more interesting as you have to match speed and distance in real time. It keeps looping reading your input and showing you the effect. You press keys adjusting your position until leven then you fire. It clears the screen between updates so there isn’t much to photograph!
This game is a little different and it uses dimensioned arrays. It randomly generates targets and you press the appropriate key to bomb the correct target. It uses a reverse FOR loop to count down and reduce the time you have between goes as the game progresses.
This game uses a 2 dimensional array. It draws a simple grid and you maneuver about inside it trying to get an enemy ship, that always moves directly toward you, to crash into an iceberg. Asterixis represent icebergs. As the book says, strangely the enemy ship can see you but not these whacking great icebergs in front of it. I think perhaps it is better to think of the * as mines it doesn’t know about that you are trying to get it to crash into.
There are actually some un-winnable start positions in this game as the one above shows. You (Y for you) can only move in four directions but they (Z for ‘ze robots’?) can move in eight so can get you on the diagonals. This is however one of the better games in the book.
The Wizard’s Wall.
This game was a bit more typing. Mainly all the bloody text of the instructions! It is the first game in the book to use GOSUBs. Again it is really just a guess the numbers type thing but it uses some tricky maths to spice things up a bit. Being so big (almost 2.5k!) it took some time for me to load the game in since I echo all the loading to the screen which really slows things down. I have started working on a silent load function which should be much faster.
The final game in the book is different to all the rest as it uses graphics (well, simple ones). There are separate listings for each computer. Unfortunately Orwell doesn’t support graphics (yet!) so this one will have to wait until then.
Finally the book gives some tips on adding to the programs as well as information on writing your own. Then if has a fairly good summary of BASIC commands. We then have an ASCII chart (and a ZX81 chart with it’s silly values).
There is also this handy conversion chart for the different versions of Basic each machine uses.
Finally we have answers to some of the questions and puzzles asked in the book along with snippets of code for some of them. We also have a further reading section as a lot of these books do. The books mentioned are:
- Usborne Guide to Computers by Brian Reffin Smith, Usborne.
- Understanding the Micro by Judy Tatchell and Bill Bennett, Usborne
- Introduction to Computer Programming by Brian Reffin Smith, Usborne
- Illustrating Basic by Donald Alcock, Cambridge University Press
- Fred learns about Computers by MacDonald and Evans
- The Computer Book by Robin Bradbeer et al, BBC Publications
This was a fun book. Most of the programs are quick to enter but there are a lot of guess the number type ones. It will be interesting to see if it’s companion book, Computer Spacegames, is similar.
From Orwell’s point of view it was good since we got a new command implemented (INKEY$) and I learnt a little more about the internals of MS Basic. It also showed the need for a faster loading function with the longer programs which I shall continue to work on now.
Here we have another review of one of the 80s Usborne computer books. This time we’ll learn about computer programming.
- Title: Introduction to Computer Programming
- Subtitle: A guide for absolute beginners
- Author: Brian Reffin Smith
- Editor: Lisa Watts
- Pages: 48
- Published: 1982
- ISBN 10: 0860206750
- ISBN 13: 978-0860206750
This book, another of the early ones, is another I remember fondly. I am pretty sure I had this one and seem to remember using it to learn Basic before I even had a computer (as it says on the cover no computer needed)!
The first pages explains how the book is a guide for absolute beginners and it details how Basic keywords will be introduced one at a time. It mentions that there are puzzle programs to solve and suggestions for programs to write and useful alterations to the given programs to try.
Of course I will be using my Orwell computer to test out the programs in the book. If you read my last review on the Usborne Guide to Understanding the Micro you’ll remember I found Orwell didn’t support the Basic CLS command to clear the screen. I’ve now added that command to Basic.
The first page in the book is a double page showing the very basics of how a computer works. Once again we see the cartoon robots that appear in many of these earlier Usborne books.
The next set of pages talk about how we give the computer instructions and a little about computer languages. It mentions BASIC, Pascal and PILOT as example languages. Basic I know of course. Pascall is the language I was taught at university during my degree. PILOT I have never seen anywhere and I have no idea if this language is even used anymore!
Next we learn about writing programs. There is an example here about how the computer needs precise instructions to work correctly. There was a similar example in the last book as well.
There is an interesting comment right at the end of the second page where they discuss bugs. It says ‘Sometimes, a bug makes a program produce a slightly different result which you may prefer. Useful bugs like this are called “pugs”.’
That’s certainly not a term I have ever heard used! Although I have often heard developers saying ‘that’s not a bug, it’s a feature’!
Finally we get onto our first words in Basic: PRINT, RUN and INPUT. These pages are all about using PRINT. I tested out the first program.
Hmm, doesn’t look like theirs. The next few boxes describe debugging the code. Interestingly the debugging example shows a different line 50. It has extra spaces in it. It describes how with Basic you can retype a line to replace it.
Next we learn about some more Basic keywords and variables. We learn about the LET command (which is actually optional in Microsoft Basic) as well as the READ and DATA commands. I tried the simple READ/DATA example code.
That’s the first time I tested the READ and DATA keywords on Orwell.
The next page talks about the INPUT keyword and we have another example program to try. I am manually entering these programs on Orwell itself and this one is worth saving.
The next page describes a little more about PRINT and how you can modify how the printing with a semicolon or a comma. The semicolon I knew about but I must have forgotten all about the comma which has the same effect as doing a TAB really. On Orwell with it’s Microsoft Basic the comma inserts 3 spaces.
We also learn a little about doing sums on the computer. I tested out all the commands shown and they all work on Orwell.
Next we learn about doing comparisons. We have a number of little programs to enter here. I remember being 9 and writing my own variants of a lot of these little sample programs in a small book I made. I didn’t enter these into Orwell as there is nothing new here and because on the next page we get our first decent program to try! I typed this one in on my PC and used the LOAD command to get it into Orwell.
10 PRINT "ALIEN'S SQUARE ALONG" 20 INPUT A 30 PRINT "ALIEN'S SQUARE UP" 40 INPUT B 50 CLS 60 PRINT "COMMANDO'S SQUARE ALONG" 70 INPUT C 80 PRINT "COMMANDO'S SQUARE UP" 90 INPUT D 100 CLS 110 LET X=SQR((A-C)*(A-C)+(B-D)*(B-D)) 120 PRINT "YOU ARE NOW" 130 PRINT X;"SPACE UNITS APART" 140 IF X<1.5 THEN PRINT "ALIEN FOUND" 150 IF X<1.5 THEN STOP 160 GOTO 10 170 END
That one worked perfectly although it is a little boring. We also have a program designed to make the computer look clever. Lets try this one too.
5 LET C=0 10 PRINT "I WOULD LIKE TO TALK TO YOU" 20 INPUT "TELL ME ANYTHING SILLY THAT HAPPENED TO YOU THIS WEEK";A$ 30 READ B$ 40 PRINT B$; 50 INPUT C$ 60 LET C=C+1 70 IF C=6 THEN GOTO 100 80 GOTO 30 90 DATA WHY, WHY IS THAT 95 DATA WHY, CAN YOU EXPLAIN 98 DATA CAN YOU SAY WHY, WHAT WAS THE REASON 100 PRINT "SO THE REASON YOU TYPED" 110 PRINT " ";A$ 120 PRINT "WAS REALLY GIVEN BY YOUR ANSWER" 130 PRINT " ";C$ 140 PRINT "HOW ODD!" 150 PRINT "RUN ME AGAIN FOR FURTHER ENLIGHTENMENT" 160 END
Again I used the LOAD command to get this one running and it ran first time. I used to have a colleague who you’d have conversations like that with in the lunch room. Although the final conclusion would usually happen 10 minutes after you’d finished the rest of the conversation and everyone else had moved onto other things!
The next page is all about drawing pictures. As Orwell has no graphics mode (yet) I skipped this. We then go onto a page describing how the RND function works and there is another example program to try.
10 LET C=0 20 LET A=INT(RND(1)*20+1) 30 LET B=INT(RND(1)*20+1) 40 PRINT "ALIEN SHIP'S CODES" 45 PRINT "ARE ";A,B;"FIRE" 50 INPUT X 60 LET C=C+1 70 IF X=A*B THEN PRINT "ALIEN SHIP DESTROYED" 80 IF X<>A*B THEN PRINT "MISSED" 90 IF C<6 THEN GOTO 20 100 END
That one is just a simple multiplication program really but that too worked first time. The next page discusses loops and it has a simple program to test if RND really works. I tried that one as well.
10 FOR I=1 TO 1000 20 LET R=INT(RND(1)*6+1) 30 IF R=1 THEN LET A=A+1 40 IF R=2 THEN LET B=B+1 50 IF R=3 THEN LET C=C+1 60 IF R=4 THEN LET D=D+1 70 IF R=5 THEN LET E=E+1 80 IF R=6 THEN LET F=F+1 90 NEXT I 100 PRINT "FINISHED" 110 PRINT A, B, C 120 PRINT D, E, F 130 END
That one does take a while to run but run it did!
Next we learn about subroutines with a few more interesting little programs to try and we then go on to learn about some string manipulation commands. I tested these on Orwell and they all worked fine. Then we have a code maker program.
5 LET C$="" 7 LET D$="" 10 PRINT "TYPE IN A SHORT MESSAGE" 20 INPUT M$ 30 PRINT "NOW TYPE IN A SECRET NUMBER BETWEEN 1 AND ";LEN(M$)-1 40 INPUT N 50 LET A$=RIGHT$(M$,N) 60 LET B$=LEFT$(M$,LEN(M$)-N) 70 LET M$=A$+B$ 80 FOR I=1 TO LEN(M$) STEP 2 90 LET C$=C$+MID$(M$,I,1) 100 NEXT I 110 FOR J=2 TO LEN(M$) STEP 2 120 LET D$=D$+MID$(M$,J,1) 130 NEXT J 140 LET M$=C$+D$ 150 PRINT "CODED MESSAGE IS" 160 PRINT M$ 170 END
That one worked as well! Next we have some more code to try. One involves plotting lines which I can’t do yet. The other is a birthdays program where it tallies birthdays against months. We then have another page about graphics again.
Next we get to something that looks familiar. The funny poems program. This was something we saw in the Usborne Guide to Computers and I actually made the paper version of this.
Here we have four pages that explain how to make a Basic version of the same thing. The last page has the complete listing which of course I had to try out. I actually had a couple of bugs in this one involving the commas in the DATA statements but with those sorted out it works fine.
The next page is one with programming tips and it actually mentions this bug there.
Finally the book has the answers to the puzzles asked throughout it and then a summary of the BASIC keywords used in the book and a glossary of computer terms. And, like one of the previous books, there is a list of titles for further reading.
- Usborne Guide to Computers by Brian Reffin Smith, Usborne 1981
- Understanding the Micro by Judy Tatchell and Bill Bennett, Usborne 1982
- The Computer Book by Robin Bradbeer, Peter DeBono and Peter Laurie, BBC 1982
- Illustrating Computers by Colin Day and Donald Alcock, Pan 1982
- Illustrating BASIC by Donald Alcock, Cambridge University Press 1977
- Computer Spacegames by Daniel Isaaman and Jenny Tyler, Usborne 1982
- Computer Battlegames by Daniel Isaaman and Jenny Tyler, Usborne 1982
The latter two I shall review myself soon.
All in all I found this book to be a great introduction to Basic. It describes a lot of the basic concepts of programming and in a fun way. You really don’t need a computer to use this book (and I am sure I didn’t when I first read it) but it is much more fun if you do have one!
Well, after finally making some (painful) progress on Orwell it is time to do another review on one of my stack of Usborne books. This book includes some actual Basic programs to try and Orwell should be up to the task now.
- Title: Usborne Guide to Understanding the Micro
- Subtitle: How it works and what it can do
- Author: Judy Tatchell and Bill Bennett
- Editor: Lisa Watts
- Pages: 48
- Published: 1982
- ISBN 10: 0860206378
- ISBN 13: 978-0860206378
This book is another of the earlier Usborne books. I remember I must have owned this one or else borrowed it a lot from the library as I can distinctly remember much of it. It’s one of the ones with the hand drawn cartoon robots to explain everything. This actual copy seems brand new. In fact it is tricky getting the pages sitting flat enough to photograph. The spine hasn’t been bent at all.
According to the first page this book is for anyone who wants to know about microcomputers. It explains how to use a micro, how to program one then how they work. It talks about how micros can be linked to other computers to bring all sorts of information into your home. It discusses things you can add to your micro then finally it has a handy, up to date, buyers guide.
First we meet the micro.
This gives a handy guide for setting up the machine. It shows the leads required and how you connect it to a tellie for output. I guess the ZAP isn’t meant to mean from the (UK) mains plug! Apparently all the important parts of the micro should be kept inside the keyboard. Seems I am doing that bit wrong at the moment (but am working on it).
Next we jump straight into programming. That’s interesting since I think the first thing almost everyone did after setting up their new micro was use it to play games!
We get to see the robots here. They are often used in the Usborne computer books. In this case it is illustrating how you tell a computer what to do. Actually in this specific case it shows how you have to be very precise about telling a computer what to do. That list of specs in box 1 however is still a better specification than a lot I have seen!
On the facing page we have some weird, two headed robot/computer/vacuum cleaner type thing showing the different types of memory in a computer, RAM and ROM. The memory size sphere reminds me a lot of the Zeroids from the Terrahawks!
Next we look at the keyboard more closely including instructions on how to use the shift key! We then look at where to get programs for micros. According to this page listings in magazines are often not well tested and may contain bugs. Also on this page it mentions Viewdata or Prestel terminals. Viewdata was a kind of forerunner to the WWW. It was a way of displaying pages of information brought down by a modem. The pages were very similar to Teletext pages (where the data was broadcast with the TV signals).
When first building Orwell I actually bought a Viewdata terminal with a view to using it’s keyboard. When I picked it up however I found it was new and completely unused. It didn’t even have a mains plug wired to it yet. I fired it up and it actually works perfectly so I can’t bring myself to destroy it. Of course these days there is nothing for me to connect to with it which is sad but apparently I can use it to create my very own Viewdata pages if I so desire!
Although, somewhat amazingly, Viewdata is still apparently used in the UK by travel agents. I even found an online course where, for a mere 199 UK pounds, you can do a 6 month course on how to use it!
After that shocking revelation we finally get to the good stuff. Writing our own programs!
There are two programs on these pages. I will enter in both and see if I can get them to run on Orwell. Finally his purpose is revealed! The first program is the sort of thing used by the NSA. A program used to keep spies from infiltrating a secret society (what about sys-admins though?). Below is the actual code:
10 PRINT "TELL ME THE PASSWORD, CHIEF." 20 INPUT P$ 30 CLS 40 PRINT "HALT! WHAT IS THE PASSWORD?" 50 PRINT "YOU CAN HAVE TWO TRIES." 60 FOR A = 1 TO 2 70 INPUT A$ 80 IF A$=P$ THEN A=2:GOTO 130 90 PRINT "WRONG." 100 NEXT A 110 PRINT "OUT! YOU MUST BE A SPY!" 120 END 130 PRINT "ENTER, FRIEND." 140 END
Ah, now immediately I see a problem. The CLS command isn’t supported by Orwell. In fact I have no clear screen command. Technically I can do it though. By sending the appropriate escape codes to the Batsocks video generator I can do all sorts of cool terminal emulation things. But I have no way of entering and sending those codes yet. I need to add that command to Basic (which I imagine will take some working out). But lets continue on with line 30 removed for now. For these reviews I will list the programs as they appear in the books.
To load this code into Orwell I simple store it as a text file then enter load mode on the machine (by typing LOAD). It will then accept input over the serial line. I can then use Realterm (terminal emulator software) to send it to Orwell. I use Realterm as I can specify the speed I send the characters. By that I mean the rate they are sent not the actual serial speed (which is 19200 baud). If you read my debugging stories you’ll see why that’s necessary.
OK, I entered the code and loaded it into Orwell.
Then I tried running it. I had completely forgotten that Basic programs are interpreted. That means they get executed a line at a time and the machine works out what to do on each line. This means despite knowing I don’t support the CLS command the program can still be run. It runs happily until it gets to line 30 when the interpreter spits out an error. In this case an SN ERROR or syntax error. Orwell doesn’t understand that command (yet).
I removed that line of code and tried again.
Success! It actually works (apart from the clear screen). My first program entered from an 80s Usborne book on my hand made 80s computer! Onwards and upwards.
The second program is called SPLASH GAME.
10 PRINT "SPLASH GAME" 20 PRINT 30 PRINT "THE STEERING ON THE" 40 PRINT "GOKART HAS FAILED AND" 50 PRINT "YOU ARE HEADING FOR THE" 60 PRINT "DUCKPOND. YOU MUST" 70 PRINT "PRESS THE RIGHT LETTER" 80 PRINT "TO WORK THE BRAKES." 90 PRINT "YOU HAVE 5 CHANCES." 100 LET C$=CHR$(64+INT(RND(1)*26+1)) 110 FOR G = 1 TO 5 120 INPUT G$ 130 IF G$=C$ THEN G=5:GOTO 190 140 IF G$<C$ THEN PRINT "AFTER"; 150 IF G$>C$ THEN PRINT "BEFORE"; 160 PRINT G$ 170 NEXT G 180 PRINT "SPLAAAAAAASH" 190 PRINT "YOU HAVE GOT WET." 200 END 210 PRINT "SCREEEEEEEECH..." 220 PRINT "YOU STOPPED IN TIME." 230 END
Interesting line 100 gives Orwell some trouble. Not the actual code itself, that’s perfectly valid Orwell Basic, but the speed the line is sent. Or rather the speed the following line is sent.
The way Microsoft Basic works is it reads characters into an input buffer until it receives a CR (carriage return). It then processes the entire line. A line like line 100 above takes Basic a little while to process. If there isn’t enough time to process the line characters from the next line can be missed. So unless I made the delays between lines long enough I was missing characters and getting errors. In the end I used 30mS between characters and 30mS between lines. That means a small program like that above takes 24 seconds to load! I really am living like in the 80s!
Anyway, lets see if it runs now.
Well that works. Although there are a couple of bugs in this code! One is obvious if you read the listing carefully. The other, minor one, is there needs to be a space after the “BEFORE” and “AFTER” text. The semicolon after the PRINT means the next PRINT will be on the same line so a space is needed. The second error is the GOTO line number if you choose the right letter. If you choose the right thing it says you got wet. The line number should be 210 and not 190.
Now the next page shows what I just did. Typing in listings and loading. There is also a section on bugs in programs. They should have done that page first! We do however have a third program to enter – Crocodiles.
10 PRINT "HOW MANY CROCODILES IN THE RIVER"? 20 PRINT "YOU HAVE FIVE GUESSES." 30 LET A=6 40 FOR N=1 TO 5 50 INPUT G 60 IF G=A THEN N=5:GOTO 120 70 PRINT "WRONG" 80 NEXT N 90 PRINT "SNAP! YOU HAVE BEEN EATEN UP!" 100 END 110 PRINT "RIGHT. NOW PADDLE AWAY FAST!" 120 END
Obviously a simple little program. Amazingly with the same bug as the previous one! The wrong GOTO line number. Ironic on a page about finding bugs in programs. Especially given that’s one of the lines shown with a bug in it on the drawing and the listing is the ‘correct’ version. Perhaps it was a trick question? It’s not a bug, it’s a feature!
Next the book talks about saving programs. It shows cassette recorders and floppy disks but they really are floppies, 5 1/4s by the looks of it. I still have some somewhere actually. With old Doom levels I created on them!
The next page is about graphics. Although there is another error! The page title is wrong, it should say “Micro Pictures”. This page mentions things such as graphics tablets and light pens. A light pen is not something I ever owned but they always fascinated me. Of course that’s something from the era of CRT screens.
The next page is actually about micro sound. There is a little information here about making music and playing sounds. Also a little discussion on computers talking and recognising speech. Apparently only a computer with a huge amount of memory can store enough information to recognise speech.
Next the book talks about what’s inside the keyboard. The picture seems to be the insides of a Sinclair ZX81. It also mentions more powerful computers such as mainframes and minicomputers. Of course we learned about those in the Usborne Guide to Computers book.
The book then talks about what’s inside the chip. It shows how chips are made from silicon (it’s wafer thin) and some other used of microprocessors. It then goes on to describe counting in binary and how simple logic gates work. It always struck me as a very organic looking diagram for the logic flow.
From there we get a very brief look at how memory inside the computer works and such things as PEEK and POKE. The level of information is interesting as I am sure I didn’t get most of this stuff as a kid. It really just introduces the concepts but you’d need to study more to really grasp it all. Perhaps the later books will explain!
Next we get a little history of the micro starting with valve based machines such as ENIAC then onto transistors and finally microchips.
The next page is interesting as it talks about “Computer chains”. Networking is what we’d call it now. Of course all of this is pre World Wide Web. The Internet itself seems to have been created about the time this book was published but it would not have been widely know about then I imagine. Nor would people imagine what it would become.
I like the comment about doing shopping by computer and how in the future you probably will. The future is now! The page also mentioned eMail although it doesn’t call it that.
The next page talks about micros controlling things. Apparently I can control a model railway with one (if I can get that “Computer model controllers” book that’s missing from my collection) as well as controlling robots. It makes me sad though to see this page talking about how the Space Shuttle uses a micro computer similar to a home computer. The shuttle era has now passed of course.
After a page talking about things to add to your computer (disk drives, printers, joysticks and paddles and so forth) we get to the good bit. A buyers guide of some of the main home computers ‘currently’ available. They are listed in order of price and are as follows below. Each has some specs and some comments along side.
- ZX81 (Sinclair)
- ZX Spectrum (Sinclair)
- PC1500 (Sharp)
- VIC 20 (Commodore)
- TI-99/4 (Texas Instruments)
- Dragon (Dragon Data)
- Atari 400 (Atari)
- TRS-80 Colour Computer (Tandy or Radio Shack in the U.S.A.)
- Atom (acorn)
- BBC Micro (Acorn)
- PET (Commodore)
- Apple II Plus (Apple)
After a short glossary the book ends.
All in all a good little book. It packs a lot in although it doesn’t get into much depth. It’s quite amusing that 2 of the 3 program listings in the book have bugs in them. Especially the one on the page about debugging! Hopefully the books of actual programs will be better.
And I found I need to work on some extra Orwell commands such as CLS. This will probably become necessary in the later books as the programs get more complicated (and less buggy I hope).
Basically the issue is reading the ACIAs status register changes the register. It clears the interrupt bit. My situation is a little different to that in the tip mentioned as I am only doing interrupt driven receive and polled send. But when sending I still need to check the status register to make sure the transmit buffer is empty.
Doing this made it much more reliable but I can still break it by really hammering it. I tried using interrupt driven transmit again (but with the read the status register once fix) and this is still very fragile. It definitely seems if there is a lot of data coming and going it’s easy to get the ACIA into bad states.
I think the safest way is to stick to polled sends and interrupt driven receive. And to disable interrupts when sending so there are no clashes there. Or disable interrupts except for when you want to receive data. Need to experiment there. The receiving routine can beep if it detects errors. So for loading then you can simply adjust the speed until there are no beeps!
I finally realised the random memory corruption I was seeing sometimes before may have been caused by my test code I was uploading. It contained POKEs in it. If I was sending data too fast and characters were being dropped or garbled it’s possible a POKE was being received with no line number. In that case Basic will run it as an immediate command. If the location it was poking too was also corrupt I could have been sticking random things into random memory locations. Very naughty!
I have had enough of punishing this chip now so that’s the compromise I will use. If loading is a little fiddly, well, that’s exactly how things were in the 80s! Anyone who did any loading from cassette tape will remember that. My friend Dave says he can’t remember EVER successfully loading something off tape on his old Apple 2.
So, time to step away from the microcomputer and go do something useful now for a bit!
Right, where am I at now? Still bloody confused, that’s where!
I tried a few more things. I tried changing the file I was sending it. When in load mode all that is really happening is the machine is accepting characters from the serial port instead of the keyboard. Other than that it behaves the same.
So I tried sending it commands instead of a program. The simplest command is just a line number. If you send it “10″ then if line 10 exists in Basic memory it removes that line. If it doesn’t exist it doesn’t do anything.
That falls over fairly quickly.
I also tried an immediate command “REM” which is the basic remark command. It doesn’t do much although the comments in the conde call it a false IF?
That falls over.
I tried sending it a LOAD command. Since I wrote that function I know exactly what it does.
And that falls over.
To eliminate the interrupt handler entirely I tweaked the code to poll the receiver port instead of relying on interrupts. So there were no interrupts at all on the machine. The receiving was a lot worse as you’d expect (missed characters) but that also falls over.
I also tried putting in code that was checking the characters being received and if they were outside the normal range of ASCII values I’d ignore them. That still broke (although I might revisit this as I might not have done the check in the right place).
So basically it just seems no matter what data is being sent if it’s being sent too quickly something breaks. I just can’t see what!
It’s not the interrupt handler. It’s not the code that shuffles Basic lines about in memory. It’s not one particular bad ASCII value being received. If there are no receive errors everything works fine. Characters received are echoed back (as each is received) and when things go wrong there is no evidence of back characters sent back.