This location is used during the tape BASIN routine to hold the offset to the next character to be read from the cassette buffer. This location is incremented after each character is read from the buffer. When the value here reaches 192/$C0, all characters have been read from the buffer, so another block of data will be read into the buffer (if another is available) and the value here will be reset to 0/$00. During the tape BSOUT routine, this location holds the offset of the next available po- sition in the cassette buffer. This location is incremented each time a character is added to the buffer. The buffer is consid- ered filled when the value here reaches 192/$C0, at which the
163 $A3 $A6 166
systems, so these locations are incremented 60 times per sec- ond regardless of whether interrupts occur at the North Amer- ican rate of 60 times per second or the European rate of 50 times per second.) Thus, location 162/$A2 will be incre- mented every 1/60 second; location 161/$A1 every 1/60 * 256 = 4.27 seconds; and location 160/$A0 every 4.27 * 256 = 1092 seconds, or every 18.2 minutes. All three locations (along with the rest of zero page) are reset to 0/$00 during the reset sequence. The UDTIM routine will also reset the lo- cations to 0/$00 if the value here reaches $4F1AO1, cor- responding to 24 hours after the start of the count. The Kernal RDTIM routine [$F65E] can be used to read these locations, and the SETTIM routine [$F665] can be used to change the value here. From BASIC, the reserved variables TI and TI$ can be used to read the values here (TI$ converts the value to hours:minutes:seconds format). TI$ can also be used to change the value here.
Although this timer is easy to use, especially from BASIC with TI and TI$, it's not particularly accurate for timekeeping applications. These locations depend on the system IRQ inter- rupt, which is affected by a number of operations. For ex- ample, the system interrupt is turned off during loads and saves to tape or disk, effectively stopping the clock. The more tape or disk operations you perform, the more inaccurate your clock time becomes. If you need more reliable timekeeping, re- fer to the discussion of the CIA chips' time-of-day clocks in Chapter 8.
1 6 3 $ A 3 P C N T R / R 2 D 2 Tape: Count of bits to be read or written
Serial: EOI flag
When characters are being read from or written to tape, this location is used as a countdown for the number of bits re- maining to be received or sent.
When characters are being sent over the serial bus, this location is used to indicate when an EOI (end or identify) hand- shake should be performed to mark the end of the file. The EOI sequence is added when bit 7 of this location is set to % 1 .
164 $A4 FIRT/BSOUR1
Tape: Half-cycle indicatorSerial: Byte received
When bits are being read from or written to tape, this location is used to indicate which half-cycle for the bit is currently be- ing received or sent.
When characters are being received over the serial bus, this location is used to assemble received bits into complete bytes.
165 $A5 CNTDN/COUNT
Tape: Leader synchronization countdownSerial: Count of bits to send / burst mode byte count
During the routines which write blocks of data to tape, this lo- cation is used to provide the countdown characters that come at the end of each leader segment. The value here is initialized to 9; it will then be repeatedly written to tape and decremented until the value reaches zero.
When characters are being sent over the serial bus, this location is used as a countdown of bits to be sent. The value here is initialized to 8 for each byte and decremented each time a bit is sent. When bytes are being read from the serial bus, this location is used to indicate whether an EOI hand- shake has been detected. The value is initialized to 0/$00, then incremented after the first EOI is received. During high- speed burst mode loads, this location is used as a count of the number of bytes read from the current disk sector.
166 $A6 BUFPT
Pointer into cassette bufferThis location is used during the tape BASIN routine to hold the offset to the next character to be read from the cassette buffer. This location is incremented after each character is read from the buffer. When the value here reaches 192/$C0, all characters have been read from the buffer, so another block of data will be read into the buffer (if another is available) and the value here will be reset to 0/$00. During the tape BSOUT routine, this location holds the offset of the next available po- sition in the cassette buffer. This location is incremented each time a character is added to the buffer. The buffer is consid- ered filled when the value here reaches 192/$C0, at which the
167
$A7
$AC-$AD
172-173block of data will be written to tape and the value here will be reset to 0/$00.
1 6 7 $ A 7 SHCNL/INBIT Tape: Leader dipole count / block indicator
RS-232: Current bit received
During the routines which write to tape, this location is used as one counter in a timing loop to specify the number of lead- er dipoles to be written. When reading from tape, this location is used to indicate which block is being read.
When characters are being received over the RS-232 inter- face, this location holds the most recently received bit.