Classic Computer Magazine Archive COMPUTE! ISSUE 42 / NOVEMBER 1983 / PAGE 277

VIC/64 Tape Aids

Andrew Au

When you get a LOAD ERROR, what can you do? Can you recover the program? This article deals with the frustrating problem of tape loading errors. Also, there's a technique here which allows you to LOAD programs twice as fast as usual.

When you save your program, the VIC or 64 saves it twice on the tape. When the program is loaded, the first version is put into the computer and checked against the second version. Any mismatch will cause the LOAD ERROR.

If you get a load error, LIST the program. If it LISTs properly to the end, it can probably be recovered. Don't RUN the program yet, or it will be destroyed. The problem here is that the start of variable pointers are not set. Set these pointers by POKEing the value found by PEEKing 831 into locations 45,47,49; and POKEing the value found by PEEKing 832 into 46,48,50. After performing these six POKEs, make sure that you have done everything correctly by typing PRINT FRE(0). If it shows a decrease in free RAM, your program is ready. Type RUN, and it should work.

However, if the computer just locks up, you have POKEd the wrong values. Press RUN-STOP/RESTORE and rewind the tape to the beginning. Type OPEN 1 and play the tape. After the header is loaded, it will stop. Now 831 and 832 should contain the location of the variable pointer. Perform the above POKEs and try again.

The Solution

When the VIC or 64 loads a program, it sets zero page pointers (which tell it how long the program is) and loads the program itself into BASIC RAM. Apparently, the computer sets the pointers after the program is loaded and checked. If the computer detects a load error, it does not update the pointers. So although you can LIST the program, the computer thinks there is nothing in memory. If the program is RUN at this stage, the variables will overwrite the program and destroy it.

The POKEs given above set the variable pointers to the correct values, which are found in the cassette buffer. Locations 829,830 and 831,832 hold the starting addresses (Lo/Hi) of the program and variables, respectively.

This cure works only if the program itself is loaded successfully. If the program is garbled, this method will not work. Fortunately, many load errors result from this pointer problem, so this technique is well worth knowing.

Loading Time Cut In Half

An 8K program takes two and a half minutes to load. Since the computer loads the program and then checks it, the actual loading takes only half the time. The value of the verification is doubtful since it won't correct any detected errors. All it does is report ?LOADING ERROR. As a rule, machine language programs can be stopped at the middle of the load and RUN (or SYSed to) without problems, since there are no zero page pointers involved. On the other hand, BASIC programs need more attention if they are to RUN at "half time." Since the pointers are not set until the end of the load, they must be typed in manually or incorporated into the program.

Let's prepare a program so that it can be stopped at the middle and RUN (and still work). Add a line at the beginning of the program:

POKE 46, PEEK(832) : POKE  48, PEEK(832) : POK
     E 50, PEEK(832) : POKE 45, PEEK(831) : POKE
      47, PEEK(831) : POKE  49, PEEK(831)

Type in the above line (or make it two lines), and make sure it is at the beginning of your program. Now SAVE the program.

When this program is RUN after being stopped at the middle, it will first reset the pointers. Now we don't have to wait for the computer to do it at the end. The result: the program LOADs twice as fast.

This technique can be used with any program to shorten loading time. Use the tape counter to find the middle of the program and allow it to go slightly past.

If you have consistent tape problems, try changing the location of your cassette recorder. Remember that data transmission is sensitive to electrical fields. You should keep the connecting cord away from the back of the TV, which is a strong source. Always verify your programs after saving.