By Larry Isaacs — originally published in COMPUTE!’s Gazette Issue 2, August 1983
In this month’s column I will be reviewing the Commodore 64 Programmer’s Reference Guide and discussing some topics involving the 1541 Floppy Disk Drive. I’ll also introduce a handy disk copy program which will be included in next month’s column.
Commodore 64 Programmer’s Reference Guide
The Commodore 64 User’s Guide which comes with the 64 is written to be an introductory manual. It keeps technical terms to a minimum and tries to keep each discussion on a very simple level. As a result, most topics are not covered in great detail. If you plan to do your own programming, this detail will be essential. Fortunately, a second book is published by Commodore to address this need: the Commodore 64 Programmer’s Reference Guide. This book is available from Howard W. Sams & Co. Inc., of Indianapolis, Indiana, for $19.95. This may seem a bit expensive, but it is well worth the price.
The Reference Guide is written for both the experienced as well as the beginning to intermediate programmer. The information is divided into six chapters and 16 appendices. Six chapters may not seem like much, but a great deal is covered in each chapter, and the book totals 487 pages.
The first two chapters pertain to the BASIC language on the 64. The first chapter, “BASIC Programming Rules,” gives a number of specific details about the BASIC interpreter. One of the most important topics covered in this chapter is a discussion of each operator available for arithmetic and relational expressions. The second chapter, “BASIC Language Vocabulary,” is the primary reference in this book for the BASIC language itself. The majority of the chapter is devoted to describing each of the BASIC commands.
The third chapter covers graphics programming on the 64. This includes how to set up the different graphics screens, plus a very detailed discussion on the operation of sprites. Mostly this involves explaining how the hardware operates. The book does a good job of explaining these technical topics in simple terms. The example programs are written only in BASIC, but hexadecimal addresses for all the memory locations are provided for machine language programmers.
The fourth chapter deals with sound and music. Again, a technical subject, but one covered in fairly simple terms. Primarily this chapter discusses the different features of the 6851 SID (Sound Interface Device) chip. Like Chapter 3, the examples are all in BASIC.
The fifth chapter covers machine language programming on the 64. This includes a discussion of the 6510 instruction set for those who are not yet familiar with it (the 6510 is the main microprocessor chip of the 64). Also discussed are the various memory configurations possible by juggling Random Access Memory (RAM) and Read Only Memory (ROM). The most important part, in my estimation, is the section on the Kernal routines. These are routines which may be used by machine language programs to access various functions of the 64’s operating system. I used this section quite a bit while developing the program presented later in this column.
The sixth chapter, “Input/Output Guide,” discusses the different ways in which the 64 can communicate with the outside world. This includes output to the TV and other devices. It also describes how to use the game, user, and expansion ports. A discussion of the serial bus is included in this chapter as well.
The remaining fourth of the book contains the 16 appendices. These appendices range from a table of abbreviations for BASIC keywords to specifications for most of the special chips in the 64. Throughout, decimal and hexadecimal addresses are given for each important memory location.
If you run into a question about how something should be done, or how something works on the 64, the Commodore 64 Programmer’s Reference Guide is a good place to start looking for the answer. This applies to beginning programmers as well as experienced ones. Again, it is well worth the price.
Cassette Versus Disk
Now to move on to the next topic. Before you can begin doing any serious programming, naturally you will need some way to save your work. With the 64, you have two primary choices. These are the C2N Datassette tape recorder and the VIC-1541 Floppy Disk Drive. I won’t take the time in this month’s column to give an in-depth discussion of the relative merits of cassette versus disk. Future articles in COMPUTE!’s Gazette will cover this.
But briefly, the primary advantage of the cassette unit is its low cost (about $65-$75). What you get for the extra cost of the floppy disk drive (about $375) is primarily improved speed and reliability. It is also much easier to store many files on a floppy disk than on a cassette. Manipulating large data files may be impossible on cassette, but not that difficult if they are stored on floppy disk.
If the 64 is your first computer, or if you are not sure whether to go with cassette or disk, I would recommend starting with the cassette. Even if you later switch to the 1541 disk drive, the cassette unit will still come in handy from time to time. The primary reasons for switching from cassette to disk would be that the slowness of cassette is driving you crazy, or some program you write or buy requires the disk for data storage.
For those who have already chosen the disk drive, I will try to provide some information and advice to augment what you receive with your 1541. First, here is a little background information on the disk drive.
Giving Orders To A Disk Drive
In order for a disk drive to work with a computer, there must be some form of Disk Operating System (DOS – rhymes with floss). DOS consists of the programs and routines which manage and manipulate files on the disk drive. Naturally, this implies there must be some way for people to make their wishes known to the DOS. Usually the DOS is a program which runs in your computer, independent of other programs, allowing disk operations to be called for by the user or by programs.
Commodore, from the beginning, has taken a different approach. The majority of the DOS actually is run in the 1541 disk drive instead of the 64. The 64 contains only routines for the LOAD and SAVE commands, plus routines for some input-output commands (such as PRINT#) which permit transferring data to or from the 1541 disk drive.
To execute a DOS command – for instance, to delete a file or program – the command must be sent as data to the 1541 via a command channel. After receiving the command, the 1541 will try to perform the requested operation. If it is unsuccessful, the small red light on the front of the 1541 will begin to flash. For the computer to receive a signal indicating the command was completed, it must read data from the command channel of the 1541. Unfortunately, the extra work required to start up these channels and send the commands or read the error status can be a bit of a nuisance if you are trying to execute DOS commands directly from the keyboard.
Here is an illustration of what I mean. Suppose you wish to delete a file named “OLD FILE”. The sequence of commands would be:
OPEN 15,8,15,”S0:OLD FILE”
INPUT# 15,EN,EM$,ET,ES
PRINT EN,EM$,ET,ES:CLOSE 15
This includes reading the error status to insure the file was deleted. Since the INPUT# command cannot be executed as a direct command, the middle statement above would have to be entered with a preceding line number and then RUN, just like any other program. This is a lot of typing just to delete a file.
The Wedge
Fortunately, there is a program on the Test/Demo disk that comes with your 1541 disk drive which will minimize the typing. It is called “DOS 5.1” and is accompanied by another program called “C-64 WEDGE.” DOS 5.1 is a machine language program which loads in a free area of memory in the 64 (the 4K region of RAM at $C000 hex, 49152 decimal). Because it is a somewhat special program, you can’t just LOAD and RUN it like a BASIC program. C-64 WEDGE is a very short BASIC program which will load and execute the DOS 5.1 program for you. You may simply LOAD and RUN the C-64 WEDGE program to start up the WEDGE.
