Chapter Seven
COMMODORE COMPUTERS
The instructions in this chapter apply to the following Commodore computers:
Introduction
The
reading and
writing of programs in the BASICODE-2 standard is possible via the use of the translation programs supplied with this handbook. Each of the computers mentioned above has a separate translation program specifically designed for that model. The translation program checks that it is being loaded into the correct model, and if not, it will automatically stop and give a relevant instruction. The working of the translation program is slightly different with each model. However, as far as the user is concerned, the instructions which follow apply to all Commodore models. If there are comments specific to certain models, these appear on the screen.
There is no need to make any changes to your computer to use BASICODE-2, since the programs work with the standard hardware supplied by the manufacturer.
Description of the accompanying cassette translation program.
Proceed as follows: first
LOAD the specific BASICODE-2 translation program for your model of computer. When this is complete, type in the command
RUN whereupon a menu will appear on the screen. You now have a choice of two functions:
- Preparating of the Reading program to read a BASICODE-2 program from tape.
- Preparation of the Writing program to put a program in BASICODE2 onto tape.
Once you have chosen a number, the selected program is prepared in the top 512 bytes of the available computer memory. While this is happening, you will see a counter displayed on the screen which follows the progress of this preparation process. When the counter reaches 0, the job is complete and the relevant translation program is ready. On the screen you will see which SYS instructions you can call up. We suggest you write these down on a piece of paper, since you can use these instructions at any time until you switch the computer off.
The chosen translation program is in fact taken from the strange texts in the DATA lines and converted into machine language. This is then placed in the top 512 bytes of the memory, and the available space for BASIC interpretation is therefore reduced by the same amount.
After noting the SYS instructions, if you then press the SPACE key, the menu appears again. If you wish to load the other translation program at this point, you may do so. However, if you are using either a VIC-20, or a PET with limited memory capacity, then it is advisable to load the second translation program only when it is needed.
If you have already listed the program as read from the cassette, you may have been surprised by the first 50 lines. These are the fixed subroutines described in
Chapter Four. These are used in all BASICODE-2 programs, so be careful that you do not erase them by accident with the use of NEW. You will probably need these routines at a later stage.
Reading BASICODE-2 programs
With the first SYS instruction displayed on the screen after setting up the Reading program, you can start up the BASICODE-2 Reading program. The memory is then cleared from line 1000 onwards, where the BASICODE-2 program will be stored. If you are using either a VIC-20 or a PET, then the statement 'READY' will appear on the screen, after which you should type in the second SYS instruction. With the Commodore 64 and CBM 3000 and higher the program automatically goes further without a second instruction. The screen now displays an instruction to press the PLAY button on the cassette tape-recorder. As soon as this is done, the statement 'SEARCHING FOR BASICODE' or simply 'SEARCHING' appears. The computer is now looking for the header tone on the tape. Anything which does not resemble a header tone (such as speech before it) is ignored.
When the header is located, the computer will indicate 'FOUND' and will try to load the BASICODE program. If you are using a Commodore 64 computer, then at this point the screen will go blank. This is normal. On other computers you will see flashing characters at the top of the screen. This is text being read from the tape, and although it goes very fast, you may be able to follow some of it. As soon as everything has been read, the recorder will stop and the computer gives the statement 'READY'. In the case of the Commodore 64 computer, the screen will now return to normal. You can now
LIST the program if you wish,
RUN it, or otherwise adjust it.
If something has gone wrong during the readin process, then after the recorder has stopped, the statement 'LOAD ERROR' will appear. On the PET this is simply displayed as 'ERROR'. Despite this though, everything has been read from tape, so by listing you can check whether the program can be corrected.
Errors such as 'PRUNT' instead of 'PRINT' should show up clearly. If for any reason you wish to interrupt the loading process, press the STOP key which will stop your tape recorder. On some computers you may need to press the STOP and RESTORE key. The section which has been read from tape, up to the interruption, has been stored. You can then type further lines in the normal way.
If desired, the loading procedure can be started using the second SYS instruction which appears on the screen. In this case, everything which is already in the memory remains untouched: the computer simply puts what it reads from the tape
after what is already in the memory. So be careful that line numbers are in the right sequence, if you are doing this deliberately, otherwise you will have problems running the program!
The Reading program checks to see if there is sufficient memory during the reading process. If this is not the case, the loading process stops and the statement 'OUT OF MEMORY ERROR' appears. The program on the tape is then too large for your computer memory.
The Reading program makes use of the (first) cassette buffer during reading of a BASICODE tape.
Because Commodore computers work with upper and lower case letters in a non-ASCII way, the Reading translation program offers two methods of processing lower case letters from the tape. One possibility is that lower case letters on the tape are converted to 'Commodore' capital letters. The other alternative is that lower case letters will be converted to 'Commodore' lower case letters, and capitals into 'Commodore' capitals. The latter is performed only when letters are in strings, i.e. between inverted commas.
To inform the Reading translation program how to proceed, you must set your computer either in text mode or in graphics mode. The computer will then adjust the incoming program to the mode you have selected. If you set the computer to recognise both upper and lower case letters, incoming programs will be presented with both types as appropriate. However, this may not always be the most desirable form. If it is not, then you can try again using the graphics mode.
Writing in BASICODE
Like the Reading program just described, the Writing translation program is designed to resemble the ordinary SAVE as much as possible. You can start the Writing program using the SYS instruction which appears on the screen after you have loaded it. Before you can save in BASICODE of course, you will need to load the program that is to be saved in the BASICODE format. When this is done, you can select the suitable SYS instruction and the computer will ask you to press the
record buttons on your cassette recorder. Once you have done this, the computer will then start to save the program on tape using the BASICODE standard. In the case of the Commodore 64 computer, the screen will go blank during this saving process. In the case of other computers, you will see flashing characters in the top left hand corner of the screen, indicating what is being saved on tape. After the last character, 5 seconds of trailer tone is recorded. The recorder then stops and the statement 'READY' appears. On the Commodore 64, the screen then becomes active again.
Points to bear in mind!
In order for this system to work, you must follow these guidelines for BASICODE:
- A program line may not be longer than 60 characters in length. If you try to make it longer, then the Writing translation program will stop the saving process when you try to save your BASICODE program. It will give the statement 'LONG LINE ERROR IN …' followed by the line number in question. LIST this line numer, make it shorter, or split it in two using two line numbers. Then you can use the SYS instruction to re-save the BASICODE program.
- Those characters which you see in reverse-field on the screen, such as clear-screen and all graphic characters are forbidden in BASICODE. If they appear on your screen, then as you try to save it in BASICODE, the process will stop. The statement 'ILL.CHR.ERROR IN …' will appear, together with the line number of the offending character. ILL.CHR. simply stands for ILLEGAL CHARACTER.
If you decide to save in BASICODE using the graphics mode, then all letters in your program will be saved as upper case. If you use the text mode, then upper and lower case letters that appear in strings will be saved without any change. PET owners can thus save a program using BASICODE knowing that it will appear in the correct form on other Commodore computers as well.
There is a possibility that the statement 'ILL.CHR.ERROR IN …' may appear when there does not seem to be anything wrong. It may be that you have made a space by pressing the SPACE bar while in the shift mode. Simply re-type the spaces, making sure you use the SPACE bar in its normal setting.
- Remember that the trailer tone lasts five seconds, so make an allowance for this on the tape. If the tape is too short, the computer may try to put this onto the plastic leader at the end of your tape.
You should see now that the first SYS instruction means that only line numbers 1000 and above are saved on tape, following the BASICODE-2 protocol. The second SYS instruction gives you the option to save everything.