The Pet Revealed and Library of Pest Subroutines
By Nick Hampshire
Computabits Ltd., England
Available at Commodore dealers
Reviewed by Elizabeth Deal
It looks like the Pet's library is growing in the right direction. Commodore should be congratulated for making two new books available. These books supply some much needed, useful and correct documentation.
THE PET REVEALED
This book brings together some useful materials that have appeared previously and adds to it some very fine new material. The text clearly shows the relationship between technical and programming information. In terms of difficulty it falls between books that only teach Basic and books that describe the engineering aspects of the Pet. The text is written clearly and has a nice rhythm to it - just as you begin to come to grips with some hardware concept, the author gives an illustration of its use.
The book begins with a summary of the system hardware: address bus, data bus, clock, interrupt system, memory organization and video system. This is followed by a description of the 6502 CPU. This clear and fascinating introduction to the architecture of the Pet, followed by the logic of machine code programming will help me understand the more difficult text - Leventhal's Programming The 6502. The description of SYS, WAIT and USR commands is more thorough than any other I have seen. The book does not go into great detail on the basics of machine code programming, but it does show how to break up a task into steps much smaller than we do in BASIC, shows a few examples and give hints for debugging.
The next chapter describes the operating system, again merging the hardware with software. It contains an accurate description of array storage, the first text I have seen to do so. It is full of hints on how to do unusual things on the Pet. It shows, for instance how to use the interrupt system, how to beat the old Pet's array size limitation, how to insert commands before a BASIC command is interpreted, and so on.
And finally, the two ports. Every register and its function is described and tied to the previous sections in the book. It is a gold mine of interfacing examples. Enough illustrations are given to help you understand how the Pet can be used in situations other than just grinding data. A short machine code program for music making is included. Use of serial CB2 line to do bit parallel I/O looks interesting. The description of how cassette units function looks good.
The computer user must be alert to confusion in designating operating states, such as: high-low voltage, 0-1 logic and event on-off. For example, there is a routine that allows the Pet to monitor an outside event, such as a mouse breaking a photo-electric cell beam, while the Pet is running another program. I had to make a minor change in coding, since I wanted to count how many times the line was grounded rather than the other way around.
Index, circuit diagrams, list of machine code instructions and a short errata sheet make information quite easy to look up. A table of Pet's six codes compactly lined up in decimal order is invaluable to me (decimal, hex, ASCII, screen, Basic and 6502 machine code). All in one place!. The printing has been done by use of a word processor, and the output is of type quality. The book is tightly written with little wasted space.
I have a few minor complaints:
- I would have liked to see more circuit diagrams that show how to interface the user port for OUTPUT to devices that consume more power than the Pet can provide.
- Several routines have been typeset rather than taken directly from the Pet printer. This invites errors. I found one on page 99. Two "FO 16" should be replace by "FO 17" and "FO 15", in that order.
- In chapter 3 several section subtitles are missing and there are few typographical errors. But you should have no trouble understanding what the author is saying. Commodore, Butler and Butterfield are cited as information sources, but other sources are not identified. For example, Tessler's Unlist, Cooke's IEEE handshake procedure, and Merrit's hooking up a TV monitor are familiar to me from the Pet User Notes. A map of VIA registers was published in Commodore User Club notes.
LIBRARY OF PET SUBROUTINES
This book contains 55 subroutines. Among them are input edit, trace, repeating key, sequential and random access systems, sorting by various methods, including a machine code sort, graphics in high resolution, and plotting from point to point, to cite just a few. Some routines are in BASIC, some in machine code, and many are mixes of the two. All routines are short, thus you can design your system for whatever application you want. All are written with a complete explanation of their purpose and methods of calling from the main program.
There is a program for appending a series of routines from a disk to form a larger program. The disk allocation is about 9K so that the entire package can be saved in the same place.
All program listings are copies of printer output and therefore free from typesetting errors. The listings are very readeable, the code is not tight and comments are provided. This allows modifications to be made without much trouble. There is a thumb index on the side of the page which helps you locate any listing in a jiffy.
I would like to recommend that in the routines that change the pointer to top of the Pet you perform the change in direct mode. There is always a danger that the machine code may get wiped out by strings. POKE52, xxx : POKE53, xxx : CLR will guarantee the safety of the code.
I've tried many of these routines and they worked without any problems. They are well prepared, fun to use, and will help in better program development.
It is my understanding that these subroutines will be provided on disks or cassette tapes (about 50 minutes total length) without extra cost to those who purchase both books.