Verify! 

Atari BASIC and BASIC XL listings by Derryck Croker

 

Issue 23

Sep/Oct 86

Next Article >>

<< Prev Article

 

 

Don't lose your programs

One of the problems that cassette based systems suffer from is loading errors. That 32K masterpiece that you have just CSAVE'd just won't load, and unfortunately pressing RETURN just ONCE after typing CLOAD deletes the program currently in memory. No chance to try again!

The utility presented here will help ensure the loading ability of your tapes WITHOUT the loss of the original program, which will remain in memory for you to try again if necessary.

FOR BASIC AND BASIC XL!

Listing 1 is the Basic XL version. If you have this fine language then you will need no explanation of how it works, and for the less fortunate the program should be clear. I would point out though that Dpeek(88) is the same as PEEK(88)+256*PEEK(89) in Atari BASIC, which is the start of screen write memory.

Listing 2 is the Atari BASIC version. Please be sure that you type in the correct version. Although listing 2 will function just as well under BASIC XL, listing 1 will not work with the Atari BASIC.

A problem with Atari BASIC is the slowness of I/O using the cassette. Using GET or INPUT requires that cassettes have long gaps between records to allow processing time, during which the motor may stop. The long gaps (LIRG or Long Inter Record Gaps) allow the motor time to reach the correct speed before the next record is reached. On the other hand, tapes produced with CSAVE have short gaps, SIRG. It follows, then, that the GET command will not be able to process such tapes. We have to use GET for this form of data access rather than INPUT as the former allows us to read data without regard to whether there are any carriage returns, which will terminate INPUT. The machine code routine poked in on Page 6 empties the cassette buffer rapidly enough so that when the routine is called again by the loop, the Operating System thinks that BASIC has finished processing the information contained within the buffer, so rapidly that there is no requirement for LIRG.

Listing 3 is the source program for the machine code. You do not type in this program, it is provided merely for those readers interested in machine code. Please note that this routine is not relocatable as it contains internal jumps. Reassemble it to a different origin if this is required.

When you have typed in the listing, save it on tape using LIST "C:". BASIC XL users should note that strings in quotes are not converted to normal uppercase by the editor, so ensure that you enter filespecs in capitals when they follow LIST statements where quotes are mandatory. I like to enter my listings in lowercase!

Listing 1 - BASIC XL

AtariLister - requires Java

Listing 2 - ATARI BASIC CHECK FIRST!

Check the loading ability of the tape by issuing a RUN command, rewinding the tape and press PLAY and Return. The tape will load into the first 128 bytes of screen memory (listing 1) or the cassette buffer will be shown screen centre (listing 2) and will continue until the End Of File (EOF) is reached or a fatal error condition is detected. In this case you will not be able to load the tape later.

If you do run into trouble then check that the heads, capstan and pinchwheel are clean and try again. 400/800 users may like to type LPRINT (without a printer present), and ignore the resulting error message before resaving the program as above. This helps overcome a bug in the OS which results in the occasional presence of garbage in the cassette buffer. Rerun the program until you are satisfied with the results.

10 ;Equates
20 BLIM = $028A ;# active bytes
30 ;in cassette buffer,
40 ;read from marker of each record
50 CASBUF = $0400 ;cassette buffer
60 BPTR = $3D ;pointer to current
70 ;byte being read or written
80 *= $0600
90 PLA ;reqd by BASIC
100 LDX BLIM ;# bytes in buff
110 STX BPTR ;pointer to byte
120 LDY #$00 ;init index
130 READ LDA CASBUF,Y ;get byte
140 INY ;bump up index
150 CPY BLIM ;same as #bytes?
160 BEQ OUT ;yes
170 JMP READ ;no,back for more
180 OUT RTS ;out to BASIC
190 .END

Listing 3 - Source Code

VERIFY IN USE

Using the utility is very simple. After saving your masterpiece to tape, ENTER the utility so that it merges with the program in memory. If your program uses lines 0-4 (listing 1) or 0-7 (listing 2) then you will have to renumber it first. Issue a RUN and repeat the checking process as described above. You will be informed on the status of the recording as appropriate. Restore the screen borders to normal with RESET before re-running the utility.

A tape reporting a load error may be dealt with as discussed, however this time you will have to remove the utility's lines from your program before resaving it.

Inveterate adventure clue seekers may like to know that they can also use this utility to search through any length of tape for help!

top