Programming the Program Recorder: Data Files, Motor Control and the Audio Track
The Atari 410 and 1010 Program Recorders are stereo machines. The right track carries data, and the left track carries ordinary sound that plays through the TV speaker. That second track made Atari cassettes unusual: publishers put narration and music on tapes, and Atari's own Talk and Teach and conversational-language courses mixed voice with on-screen text. This guide covers the programmer's side of the recorder: data files from BASIC, the motor-control and silencing POKEs, and two ways to use the audio track in your own programs.
What you'll learn: how the cassette handler stores data, OPEN modes and the continuous-record option, the traps (silent failures, noise before the first record), the motor-control register, and John Victor's techniques for voice tracks.
What you need: Atari BASIC, and a recorder (or an emulator with cassette support) for the file examples. Loading and Saving Atari Cassettes covers the hardware, tape images and CLOAD/CSAVE.
1. How the handler stores data
The C: handler writes everything in fixed records of 128 data bytes. Each record on tape is two speed-measuring bytes ($55), a control byte, the 128 data bytes and a checksum. The control byte is $FC for a full record, $FA for a partly filled one (only the record before end-of-file), and $FE for the end-of-file record. A file is a 20-second leader tone, any number of records, and the EOF record. The handler gives no special meaning to the bytes you write, so PRINT # records ending in RETURN (155) are just data.
Between records there is an inter-record gap. In the normal stop/start mode the motor stops and restarts between records, and each record is preceded by 3 seconds of mark tone. In continuous mode, each record gets only 0.25 seconds of tone and the motor keeps running, but then your program has to keep up with the tape.
2. Writing and reading a data file
10 REM WRITE A CASSETTE DATA FILE
20 DIM N$(20)
30 OPEN #1,8,0,"C:"
40 FOR I=1 TO 5:READ N$:PRINT #1;N$:NEXT I
50 CLOSE #1
60 DATA APPLE,BANANA,CHERRY,DATE,ELDERBERRY
10 REM READ IT BACK
20 DIM N$(20)
30 OPEN #1,4,0,"C:"
40 TRAP 70
50 INPUT #1,N$:PRINT N$
60 GOTO 50
70 CLOSE #1:TRAP 40000
What happens at the OPEN:
- Open for writing (mode 8): the computer beeps twice. Press PLAY and RECORD together, then any key (not BREAK). Nothing can check that RECORD is really down. If it isn't, the file is silently never written.
- Open for reading (mode 4): one beep. Rewind to the start of the file, press PLAY, then any key.
- CLOSE after writing flushes the last partial record and writes the end-of-file record. Forget it and the file is unreadable at the end. Reading past the end gives ERROR 136, which the TRAP in the reader catches.
The third OPEN parameter (AUX2) selects the gap type: 0 for stop/start and 128 for continuous (OPEN #1,8,128,"C:"). Continuous mode saves tape and time, but if the program pauses too long between records while reading, it misses data. Use it for files that are written and read in one go. Location 62 (FTYPE) holds the gap type the handler is using.
3. The traps
The Operating System User's Manual documents two traps worth knowing:
- A long pause before the first record ruins the file. After an OPEN for writing, the motor runs until the first 128 bytes have been written. If that takes more than about 30 seconds, or other serial I/O happens first, noise is recorded before the first record and the file won't read back. If your program might pause (waiting for user input, say), write a dummy record of 128 harmless bytes straight after the OPEN.
- Whistling after cassette I/O. POKEY can be left in its two-tone (FSK) mode.
POKE 53775,3(SKCTL) stops it.
4. Motor control and silence
Two locations give a program direct control over the recorder:
| POKE | Effect |
|---|---|
POKE 54018,52 |
Motor on (PACTL). PLAY must already be pressed |
POKE 54018,60 |
Motor off |
POKE 65,0 |
Silence the beeping of serial I/O (SOUNDR). Default 3 |
With the motor on, whatever is on the tape plays through the TV: the audio track as speech or music, and the data track as the familiar warble, unless SOUNDR is 0. Carl Evans described using these POKEs in his Antic tape column, both to hunt for a file on an unlabelled tape and to listen to an alignment tone while adjusting the recorder's head. The same column explains why CLOAD and CSAVE need two presses of RETURN: the first accepts the command and the second starts the motor. POKE 764,12 puts a RETURN into the keyboard buffer in advance, so a program can start a CLOAD without that second keypress.
5. A voice track that plays while a program loads
John Victor's company, Program Design Inc., used the left track to talk to players during the four and a half minutes a game took to load. In "Audio While You CLOAD" (The Best of Antic, Volume 1) he describes the method:
- A short loader program comes first on the tape. It shows a title screen, does
POKE 65,0so the data warble is silent, and then automatically loads and runs the main program from the tape (his CRUN routine usesPOKE 764,32to supply the keypress). - While the main program loads, the left track plays the narration: in Moonbase 10, a "recorded message" from Earthbase control setting up the mission.
- Timing matters. Every program on tape ends with about two seconds of zeros, and loading stops just before them, so the voice must finish at least two seconds before the end of the program's data.
The 410 can play the left track but cannot record it, so masters were made on a stereo deck. Program data went to the right channel from the SIO connector's Data Out (pin 5) and ground (pin 6), and a microphone went to the left channel, on a deck with separate record buttons for each track so that recording one didn't erase the other. For commercial duplication, Victor recommended reel-to-reel masters, because cassette masters had too much speed variation and too little separation between the tracks.
6. Syncing narration to a running program
In "Adding a Voice Track to Atari Programs" (COMPUTE!'s First Book of Atari), Victor describes a "timed BASIC" method for lessons. The program and the narration tape run together. The program switches the motor on and off with PACTL and changes the screen at measured moments. The recipe:
- Write a script, as for a filmstrip, and a BASIC program that produces each screen.
- Record the narration, making sure every copy starts at the same point.
- Measure the cue times. Play the tape and press a key at each moment the screen should change. Time with the system clock, not FOR loops. Victor warns that empty loops don't take a fixed time in Atari BASIC: their speed depends on the program's length and where the loop is. Location 20 counts jiffies (1/60 second) and location 19 counts each 256 of them.
- Put the times into the lesson program. Switch the tape off while the student answers a question and back on afterwards.
Our version of the timing tool:
10 DIM T(15):POKE 54018,52
20 ? "PRESS SPACE AT EACH CUE, RETURN TO END"
30 N=0:POKE 19,0:POKE 20,0:POKE 764,255
40 IF PEEK(764)=255 THEN 40
50 K=PEEK(764):POKE 764,255:IF K=12 THEN 80
60 N=N+1:T(N)=PEEK(19)*256+PEEK(20):POKE 19,0:POKE 20,0
70 ? "CUE ";N;": ";T(N);" JIFFIES":IF N<15 THEN 40
80 POKE 54018,60:? "DONE"
It starts the motor, then reports the time in jiffies since the previous key press each time you press SPACE (key code 33). RETURN (key code 12) stops the tape. In the lesson itself, a waiting routine is simply POKE 19,0:POKE 20,0, then a loop until PEEK(19)*256+PEEK(20) reaches the stored value. On PAL machines a jiffy is 1/50 second, so measure on the same kind of machine you'll run on.
Over a long tape, small speed differences between recorders build up. Victor's fix is to re-synchronise now and then: put a beep on the narration and have the student press RETURN when they hear it, or simply resume the tape only after each answer.
Mapping the Atari suggests another way to cue a program from the tape itself: record tones on the data track and watch for them in SKSTAT (53775), which changes as tones are received.
7. Today
Emulators handle the data track well, and Altirra 4.30 and later can pair a CAS image with a compressed audio track, so narrated tapes can be preserved with their sound. To keep both tracks of an original tape, record it in stereo as WAV or FLAC (see Loading and Saving Atari Cassettes).
Troubleshooting
- File won't read back: RECORD wasn't pressed, the file wasn't CLOSEd, or there was a long pause before the first record. Write a dummy record straight after OPEN if the program might wait.
- Reading stops with ERROR 136: the end of the file. Trap it.
- Data missed in continuous mode: the program was too slow between INPUTs. Use stop/start mode (AUX2 0).
- No sound from the audio track: the motor isn't running (POKE 54018,52 with PLAY down), or the tape has no left-track recording.
- Whine after tape use:
POKE 53775,3.
Further reading
- John Victor, "Adding a Voice Track to Atari Programs", COMPUTE!'s First Book of Atari (1981).
- John Victor, "Audio While You CLOAD", The Best of Antic, Volume 1.
- Carl Evans, "Tape Topics: PACTL Poker", Antic, February 1983, and "Get Your Head Straight", Antic, August 1983.
- Atari, Inc., Operating System User's Manual: Cassette Handler (C:), record and file formats.
- Ian Chadwick, Mapping the Atari: locations 19–20, 61–65, 764, 53775 and 54018.
Credits
- Picture: The cue-timing program measures the gaps between key presses in sixtieths of a second, the first step in syncing a program to a narration tape. — Program authors; screenshot by the site
- Atari Operating System User's Manual — Cassette Handler (C:): OPEN options, continuous mode, record format, file structure, 30-second warning, SKCTL whistle — ksquiggle
- John Victor, "Audio While You CLOAD", The Best of Antic Volume 1 — John Victor; AtariMagazines.com (Kevin Savetz)
- John Victor, "Adding a Voice Track to Atari Programs", COMPUTE!'s First Book of Atari — John Victor; AtariArchives.org
- Carl Evans, Tape Topics: PACTL Poker (Antic v1n6, Feb 1983) — Carl Evans; AtariMagazines.com (Kevin Savetz), 1983
- Carl Evans, Tape Topics: Get Your Head Straight (Antic v2n5, Aug 1983) — Carl Evans; AtariMagazines.com (Kevin Savetz), 1983
- Mapping the Atari — 19-20 RTCLOK, 61-65 BPTR/FTYPE/FEOF/FREQ/SOUNDR, 764, 53775 SKCTL/SKSTAT, 54018 PACTL — AtariArchives.org
