YELLOW BRICK ROAD
By PETER ELLISON
By PETER ELLISON
The Cassette, like the disk is a good and inexpensive way to store computer programs, and when used in the right way, can even become an asset to those already owning a disk drive.
The Cassette HandlerThe Cassette Handler is similar to the disk manager in that files can be written to or read from the cassette. Programs can be loaded by using BASIC or using an autoload command and the buffer can be opened for get and put commands. One thing you must remember, there are still a few big differences between a disk drive and a cassette. One is:the price. The second is: when a program is saved to cassette it is saved in one continuous stream. You cannot specify tracks as you can point to sectors and bytes on a disk. The cassette can only read what is passing under the cassette head, meaning that you cannot point to only one section of tape as you can read in one sector from a disk.
Write a short program (it doesn't matter how long) and then save it to your cassette recorder. After you have the program saved, rewind the tape and enter these commands in the direct mode (meaning you don't need a line number):
OPEN #7,4,0,"C:":FOR A=1 TO 128 :GET #7,B:? B;" ";:NEXT A:CLOSE #7
The cassette is now open for us to read from it. Now press the play button on the recorder and return on the keyboard. You will then hear one tone. Press the return key again. After you hear a record of data being read in, you will see numbers being printed onto the screen. These numbers are the ones for which the program was saved to the cassette. The computer is printing it from the cassette buffer in the same way it was printed from the disk buffer.
Now enter the line below without clearing the screen:
FOR A=0 TO 130:? PEEK(1021+A);" ";:NEXT A
You will have noticed that the first three bytes printed on the screen are different from the first three bytes that were printed from the buffer. Then, if you will look at the fourth byte, you'll notice both numbers are the same. Memory location 1021 is where the cassette buffer begins. The buffer is 131 bytes long. The first two bytes(85) are fixed and are used by the computer to measure the speed of the cassette. The third byte is the control byte,meaning if this byte is 252, the record is full-128 bytes. A 250 in this position indicates a partially full record and a 254 is an end of file record.
The first bytes after the speed and control bytes for the first record consist of the table entries. This includes the variable table, the value table,etc. The values are adjusted by the amount of memory in your computer. This is why a program that requires more storage memory than your machine has, will produce an error message immediately, when you try loading it, rather than half way through the load.
The last byte that the computer reads from the cassette is a checksum. When the program was saved to a cassette, every byte that was sent to it in the 128 byte record was added to the previous bytes. The two markers are also included in the addition. After the two markers, the control byte, and the record were sent to the cassette, the sum of the bytes were also sent. When the records are read in,the bytes are added together again. If the sum of the bytes match the checksum byte that is read in, then the record is assumed to be correct and the computer will continue with the loading process. If the two byes do not match, the load will stop and an error message will appear on the screen.
Each record of 128 bytes is considered to be frame. The speed at which the data is sent or received is called the baud rate. The ATARI uses a baud rate of 600 (600 bits per second(each byte is 8 bits)). The two marker bytes are read in by the computer. It then determines how long it took to read them in and calculates the correct baud rate for the tape. It does this with every frame of data that is read in. The input baud rates can be adjusted to read faster or slower. This adjustment process allows for variations in motor speeds, stretched tape, etc. It does not, however, allow for alignment problems between the recorder that the program was originally saved on and the one that it is being read on.
You probably noticed that when you CSAVE a program to cassette, the records seem to be sent faster than when you used the list command. There are two different modes that the computer can use when sending records to the cassette. One is called the normal IRG(Inter-Record Gap), and the other is the short IRG. The computer uses the short IRG for CSAVE and CLOAD commands. The computer reads in the record, checks the checksum, places it in RAM, and goes back for another record. The recorder is running the entire time. The computer must do its work so that it won't miss the next record.
When the computer uses the normal IRG for saving records to the tape, the recorder stops after every record is read into the computer. The information can be processed; then the next record can be read in. The baud rate for saving and reading the data is the same for both modes. It is the time between records that varies. In the normal mode there there is about 3 seconds of tone between records. In the short mode there is about 1/4 of a second of tone time between records. The IRG is set up by the computer when the save or load command is entered. If the wrong command is entered for the tape, the program will not load and an error message will be displayed on the screen.
That ends the first part of a two part tutorial on the cassette recorder. In the next issue I will talk about making an autoboot on your cassette and making your recorder sing.