The keyboard is treated as a set of switches organized into a matrix of 8 columns by 8 rows. The keyboard matrix is scanned for key switch- closures by the KERNAL using the CIA #1 I/O chip (MOS 6526 Complex Interface Adapter). Two CIA registers are used to perform the scan: register #0 at location 56320 ($DC00) for keyboard columns and register #l at location 56321 ($DC01) for keyboard rows.
Bits 0-7 of memory location 56320 correspond to the columns 0-7. Bits 0-7 of memory location 56321 correspond to rows 0-7. By writing column values in sequence, then reading row values, the KERNAL decodes the switch closures into the CHR$ (N) value of the key pressed.
Eight columns by eight rows yields 64 possible values. However, if you first strike the <RVS ON>, <CTRL> or <C=> keys or hold down the <SHIFT> key and type a second character, additional values are generated. This is because the KERNAL decodes these keys separately and "remembers" when one of the control keys was pressed. The result of the keyboard scan is then placed in location 197.
Characters can also be written directly to the keyboard buffer at locations 631-640 using a POKE statement. These characters will be processed when the POKE is used to set a character count into location 198. These facts can be used to cause a series of direct-mode commands to be executed automatically by printing the statements onto the screen, putting carriage-returns into the buffer, and then setting the character count. In the example below, the program will LIST itself to the printer and then resume execution.
10 PRINT CHR$(147)"PRINT#1: CLOSE 1: GOTO 50" 20 POKE 631119: POKE 632,13: POKE 633,13: POKE 198,3 30 OPEN 114: CMD1: LIST 40 END 50 REM PROGRAM RE-STARTS HERE
The SCREEN EDITOR provides you with powerful and convenient facilities for editing program text. Once a section of a program is listed to the screen, the cursor keys and other special keys are used to move around the screen so that you can make any appropriate changes. After making all the changes you want to a specific line-number of text, hitting the <RETURN> key anywhere on the line, causes the SCREEN EDITOR to read the entire 80-character logical screen line.
|This page has been created by Sami Rautiainen.|
|Read the small print.||Last updated November 15, 1998.|