Kernal address pointer
The contents of the X and Y registers upon entry to the Kemal LOAD routine [$F265] are stored here. If the secondary ad- dress that preceded the LOAD was 0/SOO, a relocating load was specified, so this address is used as the starting address for the loaded data.
These locations are also used as a working pointer in the routine [$E1FO] to initialize the soft reset vector,
197 $C5 DATA
Bit read from tape / checksum of block written to tape
During routines which read from tape, this location is used to indicate the value of the bit most recently read. During routines which write to tape, this location is used for working storage of the checksum being calculated for the block.
198 $C6 BA
Bank where data for save, load, or verify is found
This location holds the bank number from which data will be saved by the Kernal SAVE routine or to which data will be loaded or verified by the Kernal LOAD routine. The value
here doesn't affect the current system configuration; it only specifies the bank for load, save, or verify operation data. The Kernal SETBANK routine [$F73F] can be used to set the value here.
199 $C7 FNBANK
Bank where filename for open, save, load, or verify is found This location holds the bank number in which the filename for the current I/O operation is found. The value here can be set using the Kernal SETBANK routine [$F73F].
200-201 $C8-$C9 RIBUF
Pointer to RS-232 input buffer
The value in these locations determines the starting address of the 256-byte RS-232 input buffer—the area where characters are stored as they are received via the RS-232 interface. The value here is initialized to 3072/S0C00 by the RAMTAS rou- tine [$E093], part of the reset sequence. This places the input buffer at its default position, and no system routine changes this setting.
202-203 $CA-$CB ROBUF
Pointer to RS-232 output buffer
The value in these locations determines the starting address of the 256-byte RS-232 output buffer—the area where characters are stored while they await transmission via the RS-232 inter- face. The value here is initialized to 3328/S0D00 by the RAMTAS routine [$E093], part of the reset sequence. This places the output buffer at its default position, and no system routine changes this setting.
204-205 $CC-$CD KEYTAB
Pointer to current keyboard decode table
The value in these locations determines the starting address of the 89-byte area of memory which will be used to decode the current keyboard matrix code in location 212/$D4. The SCNKEY routine [$C55D], part of the normal IRQ sequence, checks on the shift-key status (in location 211/$D3) and se- lects the proper value from the list of keyboard table pointers at $83u-841/$033E-$0349.
193-194 $C1-$C2 $CC-$CD 204-205
tains a 0/$00, the port bit is set to turn off the power. Thus, the cassette motor can't be powered when no button is
pressed or while this location contains 0/$00. When this loca- tion is set to any nonzero value, the setting of the port bit is not affected by the IRQ subroutine, so—as long as a button is pressed—the motor can be turned on and off, changing the setting of the port bit.
193-194 $C1-$C2 STA
Kernal address pointer
These locations are used by the Kernal SAVE routine [$F542] to hold the starting address of the area of memory to be saved to disk or tape, The value is loaded from the zero-page pointer specified in the accumulator upon entry to the routine.
These locations are also used by the Kemal BOOT_CALL routine. Location 193/$C1 holds the track number and loca- tion 194/$C2 holds the sector number for the block currently being read from disk.
195-196 $C3-$C4 TMP2/MEMUSS
Kernal address pointer
The contents of the X and Y registers upon entry to the Kemal LOAD routine [$F265] are stored here. If the secondary ad- dress that preceded the LOAD was 0/SOO, a relocating load was specified, so this address is used as the starting address for the loaded data.
These locations are also used as a working pointer in the routine [$E1FO] to initialize the soft reset vector,
197 $C5 DATA
Bit read from tape / checksum of block written to tape
During routines which read from tape, this location is used to indicate the value of the bit most recently read. During routines which write to tape, this location is used for working storage of the checksum being calculated for the block.
198 $C6 BA
Bank where data for save, load, or verify is found
This location holds the bank number from which data will be saved by the Kernal SAVE routine or to which data will be loaded or verified by the Kernal LOAD routine. The value
here doesn't affect the current system configuration; it only specifies the bank for load, save, or verify operation data. The Kernal SETBANK routine [$F73F] can be used to set the value here.
199 $C7 FNBANK
Bank where filename for open, save, load, or verify is found This location holds the bank number in which the filename for the current I/O operation is found. The value here can be set using the Kernal SETBANK routine [$F73F].
200-201 $C8-$C9 RIBUF
Pointer to RS-232 input buffer
The value in these locations determines the starting address of the 256-byte RS-232 input buffer—the area where characters are stored as they are received via the RS-232 interface. The value here is initialized to 3072/S0C00 by the RAMTAS rou- tine [$E093], part of the reset sequence. This places the input buffer at its default position, and no system routine changes this setting.
202-203 $CA-$CB ROBUF
Pointer to RS-232 output buffer
The value in these locations determines the starting address of the 256-byte RS-232 output buffer—the area where characters are stored while they await transmission via the RS-232 inter- face. The value here is initialized to 3328/S0D00 by the RAMTAS routine [$E093], part of the reset sequence. This places the output buffer at its default position, and no system routine changes this setting.
204-205 $CC-$CD KEYTAB
Pointer to current keyboard decode table
The value in these locations determines the starting address of the 89-byte area of memory which will be used to decode the current keyboard matrix code in location 212/$D4. The SCNKEY routine [$C55D], part of the normal IRQ sequence, checks on the shift-key status (in location 211/$D3) and se- lects the proper value from the list of keyboard table pointers at $83u-841/$033E-$0349.
206-207
$CE-$CF
2 0 6 - 2 0 7 $CE-$CF IMPARM
Pointer for Kernal PRIMM routine
These locations are used as a working pointer to the character to be printed during the Kernal PRIMM routine [$FA17].
208 SD0 NDX
Number of characters in the keyboard buffer
This location holds the number of characters awaiting process- ing in the keyboard buffer at 842/$034A. The value here is initialized to zero by the CINT routine, part of the RESET se- quence. This location is also reset to zero by the STOP routine if the STOP key is pressed. It is incremented during the
SCNKEY routine [$C55D] whenever a character is added to the buffer, and decremented whenever a key is removed (by the Kernal BASIN or GETIN routines). The value here is not allowed to exceed the maximum keyboard buffer length speci- fied in location 2592/$0A20.
209 $D1 KYNDX
Number of characters pending from programmable key string This location holds the number of characters remaining to be read from the string for the most recently pressed programma- ble key. The value here is initialized to zero by the CINT rou- tine, part of the RESET sequence. When the press of a
programmable key is detected during the SCNKEY routine [$C6CA], the length of the string for that key is stored here. The value is then decremented as each character is read from the string (by GETIN or BASIN).
210 SD2 KEYIDX
Pointer into the programmable key definition area
This location holds the offset to the next character to be read from the programmable key definition string area at 4106-4351/ $100A-$10FF. When the press of a programmable key is de- tected during the SCNKEY routine [$C6CA], the offset to the definition string for that key is stored here. The value here is incremented as each character is read from the string.
5D4
212
211 $D3 SHFLAG
Shift key status flag
This location is set during the SCNKEY routine [$C55D] to in- dicate which of the shift keys—SHIFT, Commodore, CTRL, ALT, or CAPS LOCK—are currently being pressed. Each key has a corresponding bit which is set to %1 when the key is pressed: Key SHIFT Commodore CONTROL ALT CAPS LOCK
Bit Bit value 0 l/$01 1 2/$02 2 4/$04 3 8/$08 4 16/$10
The values are cumulative; if both SHIFT and CONTROL are pressed simultaneously, the value here will be 5 (4 + 1). Based on the value here, the SCNKEY routine chooses a key- board table pointer value to be stored in 204-205/$CC-$CD.
Bit 7 of this location is also used as a flag to indicate when the extra characters read using the VIC chip lines are being scanned.
212 $D4 SFDX
Current key pressed
This location is used during the SCNKEY routine [$C55D], part of the system jiffy IRQ sequence, to hold a value indicat- ing which key was pressed. Each key has a unique keyscan matrix code here, but the code values are different from either character codes or screen codes. Refer to Appendix C for a list of keyscan codes. The key's keyscan code (0-87) serves as an offset into the keyboard decoding table pointed to by locations 204-205/$CC-$CD to select the character code to be added to the keyboard buffer at 872/$034A. A scan code of 88 indicates that no key was pressed.
It's possible to read this location as an alternative to using the BASIC GET or GETKEY statements or the machine lan- guage GETIN routine when you want to check for the press of a particular key. For example, the two following statements produce the same result, a delay until the X key is pressed: 100 IF PEEK(212)<>23 THEN 100
100 GET K$:IF K$o"X" THEN 100
206-207
$CE-$CF
2 0 6 - 2 0 7 $CE-$CF IMPARM
Pointer for Kernal PRIMM routine
These locations are used as a working pointer to the character to be printed during the Kernal PRIMM routine [$FA17].
208 SD0 NDX
Number of characters in the keyboard buffer
This location holds the number of characters awaiting process- ing in the keyboard buffer at 842/$034A. The value here is initialized to zero by the CINT routine, part of the RESET se- quence. This location is also reset to zero by the STOP routine if the STOP key is pressed. It is incremented during the
SCNKEY routine [$C55D] whenever a character is added to the buffer, and decremented whenever a key is removed (by the Kernal BASIN or GETIN routines). The value here is not allowed to exceed the maximum keyboard buffer length speci- fied in location 2592/$0A20.
209 $D1 KYNDX
Number of characters pending from programmable key string This location holds the number of characters remaining to be read from the string for the most recently pressed programma- ble key. The value here is initialized to zero by the CINT rou- tine, part of the RESET sequence. When the press of a
programmable key is detected during the SCNKEY routine [$C6CA], the length of the string for that key is stored here. The value is then decremented as each character is read from the string (by GETIN or BASIN).
210 SD2 KEYIDX
Pointer into the programmable key definition area
This location holds the offset to the next character to be read from the programmable key definition string area at 4106-4351/ $100A-$10FF. When the press of a programmable key is de- tected during the SCNKEY routine [$C6CA], the offset to the definition string for that key is stored here. The value here is incremented as each character is read from the string.
5D4
212
211 $D3 SHFLAG
Shift key status flag
This location is set during the SCNKEY routine [$C55D] to in- dicate which of the shift keys—SHIFT, Commodore, CTRL, ALT, or CAPS LOCK—are currently being pressed. Each key has a corresponding bit which is set to %1 when the key is pressed: Key SHIFT Commodore CONTROL ALT CAPS LOCK
Bit Bit value 0 l/$01 1 2/$02 2 4/$04 3 8/$08 4 16/$10
The values are cumulative; if both SHIFT and CONTROL are pressed simultaneously, the value here will be 5 (4 + 1). Based on the value here, the SCNKEY routine chooses a key- board table pointer value to be stored in 204-205/$CC-$CD.
Bit 7 of this location is also used as a flag to indicate when the extra characters read using the VIC chip lines are being scanned.
212 $D4 SFDX
Current key pressed
This location is used during the SCNKEY routine [$C55D], part of the system jiffy IRQ sequence, to hold a value indicat- ing which key was pressed. Each key has a unique keyscan matrix code here, but the code values are different from either character codes or screen codes. Refer to Appendix C for a list of keyscan codes. The key's keyscan code (0-87) serves as an offset into the keyboard decoding table pointed to by locations 204-205/$CC-$CD to select the character code to be added to the keyboard buffer at 872/$034A. A scan code of 88 indicates that no key was pressed.
It's possible to read this location as an alternative to using the BASIC GET or GETKEY statements or the machine lan- guage GETIN routine when you want to check for the press of a particular key. For example, the two following statements produce the same result, a delay until the X key is pressed: 100 IF PEEK(212)<>23 THEN 100
100 GET K$:IF K$o"X" THEN 100
213 $D5 $D8 216
Certain keyscan codes will not normally be recorded here. The codes for the left and right SHIFT keys, the CONTROL key, the Commodore key, and the ALT key—codes 15, 52, 58, 61, and 80, respectively—-are normally intercepted during the SCNKEY routine and used to generate the value at 211/SD3. The CAPS LOCK, 40/80 DISPLAY, and RESTORE keys are not part of the keyscan matrix, and the SHIFT LOCK key is just a switch that has the effect of holding down the left SHIFT key.
$D5 LSTX
213
Last key pressed
At the end of the SCNKEY routine [$C55D], the value in 212/$D4 is transferred here. This value is then used during the next pass through SCNKEY to determine if the same key is still being pressed. If so, no additional character code will be added to the keyboard buffer unless key repeating is enabled.
$D6 CRSW
214
Input source flag
This location is used during the screen editor BASIN routine [SC29B] to indicate whether the line of input is to come from the keyboard or from the screen. The default value of 0/S00 selects input from the keyboard, while a nonzero value selects input from the screen. The Kernal BASIN routine [$EF06] will set this location to 3/$03 before calling the screen editor rou- tine when screen input is requested. Bit 7 of this location is used as an end-of-input flag; however, this is not handled properly for input from the screen. See the entry for the screen editor routine in Chapter 7 for details.
$D7 MODE
215
Active screen flag
Bit 7 of this flag determines which text screen is considered the active display. While the bit is % 1 , the 80-column display is selected. While the bit is %0, the 40-column display is ac- tive. Note that the inactive screen isn't actually turned off; it retains whatever display it had when the other screen was se- lected. However, only the active screen has a "live" cursor, and all printing is directed there. During the reset and
68
RUN/STOP-RESTORE sequences, the screen editor initializa- tion routine [$C07B] sets this flag according to the position of the 40/80 DISPLAY key.
While it is often useful to check this flag to determine which display is active, it shouldn't be changed to switch ac- tive displays. Instead, use the escape sequence (ESC X) or the Kernal SWAPPER routine [$FF5F]. There's more to changing active displays than just toggling the flag bit—the active and inactive screen editor variable tables, line link bitmaps, and tab stop bitmaps must also be exchanged.
2 1 6 $ D 8 GRAPHM
Mode flag for 40-column screen
This location is used during the screen IRQ routine [$C194] to determine which display mode is selected for the 40-column (VIC) screen. The value here has no effect on the 80-column (VDC) screen. When this location contains 0/$00, text mode is selected. Bits 5-7 control the graphics mode configurations:
Bit Bit value Mode selected 5 32/$20 bitmapped
6 64/$40 split bitmapped/text 7 128/$80 multicolor
More than one of these can be selected at one time. The stan- dard graphics modes place the following values here:
Mode Value GRAPHIC 0 0/$00 GRAPHIC 1 32/$20 GRAPHIC 2 96/$60 GRAPHIC 3 160/JAO GRAPHIC 4 224/$E0
While the standard screen editor interrupt routine is in use, the value here determines how the screen mode will be set up. As a result, you cannot directly change the bitmapped or multicolor mode control bits of the VIC chip, since those bits will be set according to the value here. You can turn off the screen-setup portion of the screen editor IRQ routine by storing the value 255/$FF here. This gives you direct control over the VIC chip register settings, but disables BASIC'S ability to change display modes.
213 $D5 $D8 216
Certain keyscan codes will not normally be recorded here. The codes for the left and right SHIFT keys, the CONTROL key, the Commodore key, and the ALT key—codes 15, 52, 58, 61, and 80, respectively—-are normally intercepted during the SCNKEY routine and used to generate the value at 211/SD3. The CAPS LOCK, 40/80 DISPLAY, and RESTORE keys are not part of the keyscan matrix, and the SHIFT LOCK key is just a switch that has the effect of holding down the left SHIFT key.
$D5 LSTX
213
Last key pressed
At the end of the SCNKEY routine [$C55D], the value in 212/$D4 is transferred here. This value is then used during the next pass through SCNKEY to determine if the same key is still being pressed. If so, no additional character code will be added to the keyboard buffer unless key repeating is enabled.
$D6 CRSW
214
Input source flag
This location is used during the screen editor BASIN routine [SC29B] to indicate whether the line of input is to come from the keyboard or from the screen. The default value of 0/S00 selects input from the keyboard, while a nonzero value selects input from the screen. The Kernal BASIN routine [$EF06] will set this location to 3/$03 before calling the screen editor rou- tine when screen input is requested. Bit 7 of this location is used as an end-of-input flag; however, this is not handled properly for input from the screen. See the entry for the screen editor routine in Chapter 7 for details.
$D7 MODE
215
Active screen flag
Bit 7 of this flag determines which text screen is considered the active display. While the bit is % 1 , the 80-column display is selected. While the bit is %0, the 40-column display is ac- tive. Note that the inactive screen isn't actually turned off; it retains whatever display it had when the other screen was se-