Classic Computer Magazine Archive COMPUTE! ISSUE 8 / JANUARY 1981 / PAGE 44

ODDS & ENDS
..re PET cassette tape

(ODDS & ENDS is a collection of quick notes on a variety of topics. If you have a quick hint on using any system, send it in to COMPUTE. It need not be new: anything that old timers might have forgotten or newcomers might not have learned is fair game for ODDS and ENDS).

If you're not sure if a cassette tape is blank, try this: press PLAY on the cassette unit, and hold down the < (less-than) key. Don't type LOAD. You'll see right away if there is something on the tape. This works on Original and Upgrade ROMs, but not on the new 4.0 systems.

Original ROM machines have two problems with cassette tape sequential files. First: there's barely enough space between data blocks, and there is a danger of missing a complete block during reading. A quick program can be written to stretch the inter-block space. Second: the end-of-file, as signalled in the ST status word, is non-standard .. it's not compatible with later ROM programs. Watch for it.

You can check with Commodore or with your dealer for fixes to these. If you're going to do much with cassette files, however, you'd be better off moving up to upgrade ROMs.

Original ROM machines perform a Basic SAVE by saving all data from 1024 up. Newer ROMs do the SAVE from 1025 up. No big deal, but the newer ROMs are better.

During cassette tape reading or writing, the keyboard is disabled. This is because the normal interrupt program has been disconnected. The clock is kept up to date, and the RUN/STOP key is still honoured .. special provision is made to do this in the tape routines.

Before writing on a new tape, rewind it completely. This will help unstretch the tape after a long period of storage.

Tape is more delicate and more prone to damage near the ends. It's a good idea to leave extra "leader" by running the tape ahead a short distance before recording.

If you have a speaker connected to CB2 of the Parallel User Port for sound effects, etc., you might find it useful to make an extra connection which allows you to listen to cassette tape. The tape signal is on either pin 6 or pin 8, depending on the PET unit and which cassette you are using. A resistor from the appropriate pin to the same output that CB2 feeds will do the trick. I use a 330K ohm value, which gives a quiet but audible signal; try your own values to fit your system. It's handy for spotting all sorts of tape problems: bad tapes, missed headers, and many others.

Programs are written as two tape blocks: a header of 192 bytes and the program itself which can be any length. Data files can be any number of blocks: again, there's a header of 192 bytes; then the data in 192-byte blocks. The first byte of each data block is reserved, so there are only 191 characters of actual data in each block.

There's a special block called an EOT (end-of-tape) block that can follow either programs or data files. When used, it stops the PET from searching further - the PET stops the tape and reports ?FILE NOT FOUND. This block can be created by giving the value of 2 as the third parameter of a SAVE or OPEN command: for example, SAVE "PROGRAM", 1,2 will write an EOT block behind the program.

Two characters can never be written onto a cassette data file. The Linefeed (CHR$(10)) never reaches tape; it's blocked by the software. The Null (CHR$(0)) must not be used because it will cause a false end-of-file signal during file reading.

Everything that goes on tape - headers, programs, data, everything - is written twice; each block contains two closely-joined pieces. (If you listen to a tape, you'll hear a quick "blip" between the two halves of each block). During a read, the first block is the one that is actually read; the second block is used only to pick up errors spotted in reading the first block. PET can log up to 30 character errors for the second block to correct.

Don't depend on the PET message ?LOAD ERROR to tell you whether or not a program load was good; it won't always tell you about a bad load. Instead, type PRINT ST and look at the value that PET gives you. Zero means a good load; anything else spells trouble.

(Above items were submitted by Jim Butterfield)