Commodore 2001-8 User Manual page 18

Table of Contents

Advertisement

give classical N key roll over but does allow for legitimate rejection of noise and trapping of the keys
in the order that they are struck.
The keyboard Is left scanning the last row, which contains the stop key. This allows the routine in
BASIC, that checks for the stop key to sample the input
1/0
device, Without having to perform any
of the normal functions of scanning. The user can take advantage of this by reading the input character
for that row.
The shift key is a special mUltiple key closure and is treated separately. If either of the two shift keys
Is pressed, the software sets a special shift switch which is used to change the decode of the key.
All key closures are translated using a ROM·based look·up table for the key. The shift key is encoded into
bit 8 of the ASCII character which is then translated into the screen representation in the standard way.
Once the hardware translation is done, the encoded value is transferred Into a 10 character keyboard
queue. The keyboard queue is loaded every time a new key closure is sensed and is unloaded as soon as
characters can be transferred to the screen.
"
ThiS input queue is scanned by the GET routine directly to allow input without going to the screen. The
input stack may be scanned by a user program. The user program can look at the pointer at location 525
to determine whether or not it is greater than zero; if It is, that means that there is data in the keyboard
queue. The keyboard queue is located at 527·536. The first character may be taken out; all subsequent
characters moved down, and a load index pointer decremented by one.
This is a dangerous routine, unless written in a machine language with the interrupt masked, because a
new key closure could store a new value during a time that you are scanning and changing the queue.
Both the GET and keyboard input routine take care of that automatically by only operating during the
interrupt or with the Interrupt masked.
Whenever the screen editor routine is operational, a special two·level operating system is in play. The
first level enables the cursor to flash and writes data from the keyboard to screen memory at the current
cursor position. The routine then moves the cursor one character further down in memory. The process is
repeated, trying to keep th keyboard queue empty.
The second level flashes the cursor and translates and stores characters from the keyboard into the
keyboard queue. Meanwhile, the first level operating system always watches the input stream for a
carriage return. After the carriage return is printed, this routine automatically transfers the entire line to
the operating system. The rest of the operating system does not see the characters until they have been
typed and a carriage return is sent. This allows for total editing of the line, prior to handing it to the
operating system.
An interesting trick for the more advanced programmer is to use the PET to write its own programs. By
printing out a line to the screen, forcing a carriage return into the keyboard queue and then returning
control to BASIC, new line numbers may be entered into the memory. Another example of the use of the
keyboard queue is the LOADJRUN sequence which is implemented by the keyboard scan program when a
shift-run Is encountered, the routine automatically forces "LOAD, CARRIAGE RETURN, RUN CARRIAGE
RETURN" into the keyboard queue. When control is returned to the input routine, the load followed by the
run is automatically transferred in the proper order.
It should
be
noted that this keyboard queue is only ten characters long and if it is exceeded, dramatically
bad effects can happen to your system. The only known recovery from exceeding this queue is to power
13
j

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents