First simple steps:
ESC,X - with this combination you can switch active screen (40/80 columns), active means where is cursor
Creating window with ESC key:
-set the cursor position on screen where you want to have top-left corner and press ESC, then T
-set the cursor position on screen where you want to have right-bottom corner and press ESC, then B
Now is window created
To cancel the window press CLR/HOME twice
Using key ESC:
@ - clear line from cursor to end
D - clear line where is cursor
P - clear line from begin to cursor
Q - clear line from cursor to end
I - instert line
J - to begin of line
K - END = to end of text on current line
A - INSERT mode ON
C - INSERT mode OFF
O - cancel INSERT, UNDERLINE, FLASH, REVERSE modes
E - cursor flash OFF
F - cursor flash ON
G - BELL ON (Control + G)
H - BELL OFF
L - SCROLL ON
M - SCROLL OFF
V - SCROLL UP one line
W - SCROLL DOWN one line
N - RVS OFF (only in 80 columns mode)
R - RVS ON (only in 80 columns mode)
S - cursor type: standard
U - cursor type: undeline (only in 80 columns mode)
Y - resume TAB stops
Z - cancel TAB stops
X - switch cursor between 40/80 columns mode
T - window top-left corner
B - window right-bottom corner
Recognize ARROW keys between CRSR keys:
- with PEEK(212):
83 - ARROW up
84 - ARROW down
85 - ARROW left
86 - ARROW right
07 - CRSR up/down
02 - CRSR left/right
System keys:
PEEK(211)
0 - normal
1 - SHIFT
2 - Commodore
4 - Control
8 - ALT
16 - CAPS LOCK
-combinations of keys can have values e. g. ALT+SHIFT = 1 + 8 = 9
Directing keys:
PEEK(212)
ESC = 72
TAB = 67
ALT = PEEK(211) = 8 (4. bit)
CAPS LOCK or ASCII/DIN or ASCII/CC = PEEK(211) = 16 (5. bit)
HELP = 64
LINE FEED = 75
40/80 DISPLAY = 7.bit PEEK(54533)AND128 - 128=up/0=down
NO SCROLL = 87
ARROW UP = 83
ARROW DOWN = 84
ARROW LEFT = 85
ARROW RIGHT = 86
Holding keys during turn ON/RESET computer:
Commodore key = GO64
RUN/STOP = MONITOR
CONTROL = activate internal EPROM if is socket (on-board) not free
Full keyboard codes by PEEK(212) are here:
(no key pressed = 88)
Advanced method is scan of keyboard matrix:
e.g.:
LDA #%XXXXXXXX
STA $DC00
LDA $DC01
AND #%YYYYYYYY
BNE/BEQ...
X = all tested bits equals 0
Y = all tested bits equals 1
Recognize between LEFT and RIGHT SHIFT:
LEFT SHIFT & SHIFT LOCK in assembler:
test:
lda #$fd
sta $dc00
lda $dc01
and #$80
bne test
RIGHT SHIFT in assembler:
test:
lda #$bf
sta $dc00
lda $dc01
and #$10
bne test
Using BASIC for recognizing:
0 ifpeek(211)<>1then0
1 poke56323,255:x=peek(56320):poke56323,0
X = 125 - left shift
X = 63 - right shift
You can see that there's no way to detect between LEFT SHIFT and SHIFT LOCK.
Keys LEFT SHIFT and SHIFT LOCK are hardwired, so it seems like they're the same keys.
But it's possible! Here's technique:
test:
lda #$fd // test l.shift(lock)
sta $dc00
lda $c001
and #$80
bne test
lda #$02 // set data registers to OUTPUT
sta $dc02
lda #$80
sta $dc03
lda #$00 // set A to 0
sta $dc00
lda #$ff // set B to 1
sta $dc01
lda $dc01 // test if bit is 1
and #$80
bne test // if yes test l.shift(lock) again
lda #$00 // set B to INPUT
sta $dc03
lda #$ff // set A to OUTPUT
sta $dc02
rts
Have you national Commodore 128? National keyboard with no key CAPS LOCK, but with key ASCII/DIN or ASCII/CC?
And want you to use CAPS LOCK function?
Here's soluton:
CAPS LOCK on ASCII/DIN (ASCII/CC):
lda $0ac5
ora #$80
sta $0ac5
You do the disabling by setting bit 7 in the memory location at address $0AC5 equal to 1. One side effect of doing this is that if you do it when the ASCII/CC or ASCII/DIN key is not pressed and afterwards press the key, you will get the same effect as when pressing the CAPS LOCK key on an international keyboard, i.e. letter keys will be SHIFTed while numbers will not be SHIFTed.
It's possible also create any switcher between CAPS LOCK and ASCII/DIN (ASCII/CC):
lda 211
cmp #8 // ALT is switcher
bne out
lda $0ac5
eor #$80
sta $0ac5
out: rts
Simple POKE for switch to national charset and back (without pressing ASCII/DIN or ASCII/CC):
poke0,peek(0)or64:poke1,peek(1)and191 = national font
poke0,peek(0)and191:poke1,peek(1)or64 = standard font
ASCII/DIN should be Bit 6 of the CPUs I/O Port at $0001. 1=ASCII/0=DIN
This bit is used to select either the ASCII or the DIN character ROM of a C128. When data direction is set to INPUT, the charset is selected externally with the ASCII/DIN key. If is set to OUTPUT, ASCII/DIN key works not.
How to check that RESTORE key is pressed?
On both the Commodore 128 and the Commodore 64, NMI (Non Maskable Interrupt) is used to detect that the RESTORE key has been pressed. So, simple technique is reroute NMI vector to own routine.
Vector is at $0318 - $0319.
Write own routine and end it with these commands:
pla
sta $ff00
pla
tay
pla
tax
pla
rti
Usable CHR$ codes:
CHR$(2) CTRL B Underline (80)
CHR$(5) CTRL 2 or CTRL E Set character color to white (40) and (80)
CHR$(7) CTRL G Produce bell tone
CHR$(8) CTRL H Disable character set change
CHR$(9) CTRL I Enable character set change
CHR$(10) CTRL J Send a carriage return with line feed
CHR$(11) CTRL K Disable character set change
CHR$(12) CTRL L Enable character set change
CHR$(13) CTRL M Send a carriage return and line feed to the computer and enter a line of BASIC
CHR$(14) CTRL N Set character set to lower/upper case set
CHR$(15) CTRL O Turn flash on (80)
CHR$(17) CRSR DOWN or CTRL Q Move the cursor down one row
CHR$(18) CTRL 9 characters to be printed in reverse field
CHR$(19) HOME or CTRL S Move the cursor to the home position (top left) of the display (the current window)
CHR$(20) DEL or CTRL T Delete last character typed and move all characters to the right one space to the left
CHR$(24) CTRL X Tab set/clear
CHR$(27) ESC or CTRL [ Send an ESC character
CHR$(28) CTRL 3 or CTRL / Send character color to red (40) and (80)
CHR$(29) CRSR RIGHT or CTRL ] Move cursor one column to the right
CHR$(30) CTRL 6 or CTRL ^ Set character color to green (40) and (80)
CHR$(34) " Print a double quote on screen and place editor in quote mode
CHR$(129) C= 1 Set character color to orange (40); dark purple (80)
CHR$(130) Underline off (80)
CHR$(131) Run a program. This CHR$ code does not work in PRINT CHR$(131), but works from keyboard buffer
CHR$(133) F1 Reserved CHR$ code for F1 key
CHR$(134) F3 Reserved CHR$ code for F3 key
CHR$(135) F5 Reserved CHR$ code for F5 key
CHR$(136) F7 Reserved CHR$ code for F7 key
CHR$(137) F2 Reserved CHR$ code for F2 key
CHR$(138) F4 Reserved CHR$ code for F4 key
CHR$(139) F6 Reserved CHR$ code for F6 key
CHR$(140) F8 Reserved CHR$ code for F8 key
CHR$(141) SHIFT RETURN Send a carriage return and line feed without entering a BASIC line
CHR$(142) Set the character set to upper case/graphics
CHR$(143) Turn flash off (80)
CHR$(144) CTRL 1 Set character color to black (40) and (80)
CHR$(145) CRSR UP Move cursor or printing position up one row
CHR$(146) CTRL 0 Terminate reverse field display
CHR$(147) HOME Clear the window screen and move the cursor to the top left position
CHR$(148) INST Move character from cursor position right one column
CHR$(149) C= 2 Set character color to brown (40); dark yellow (80)
CHR$(150) C= 3 Set character color to light red (40) and (80)
CHR$(151) C= 4 Set character color to dark gray (40); dark cyan (80)
CHR$(152) C= 5 Set character color to medium gray (40) and (80)
CHR$(153) C= 6 Set character color to light green (40) and (80)
CHR$(154) C= 7 Set character color to light blue (40) and (80)
CHR$(155) C= 8 Set character color to light gray (40) and (80)
CHR$(156) CTRL 5 Set character color to purple (40) and (80)
CHR$(157) CRSR LEFT Move cursor left one column
CHR$(158) CTRL 8 Set character color to yellow (40) and (80)
CHR$(159) CTRL 4 Set character color to cyan (40); light cyan (80)
Usable keycodes:
working modes: (1) 80 display / (2) C128 mode / (3) C64 mode / (4) 40 display
2 underline on (1)
5 white
7 bell tone (2)
8 disable SHIFT-Commodore (3)
9 tab (2) / enable SHIFT-Commodore (3)
10 linefeed (2)
11 disable SHIFT-Commodore (2)
12 enable SHIFT-Commodore (2)
13 RETURN
14 switch to lowercase
15 flash on (1)
16 cursor down
17 reverse on
18 home
20 delete
24 tab set/clear (2)
27 ESCape
28 red
29 cursor right
30 green
31 blue
32 space
129 orange (4) / dark purple (1)
130 underline off
133 Fl
134 F3
135 F5
136 F7
137 F2
138 F4
139 F6
140 F8
141 SHIFT-RETURN
142 switch to uppercase
143 flash off (1)
144 black
145 cursor up
146 reverse off
147 clear screen
148 insert
149 brown (4) / dark yellow (1)
150 light red
151 dark gTay (4) / dark cyan (1)
152 medium gray
153 light green
154 light blue
155 light gray
156 purple
157 cursor left
158 yellow
159 cyan
160 SHIFT-space
Decode keyboard tables:
830-841 / $033E-$0349 DECODE TABLES VECTORS
Keyboard table pointers
These six 2-byte pointers hold the starting addresses of the 89-byte tables used to translate the matrix code for the current keypress into a character code:
Vector - Key
-----------------
830-831/$033E-$033F Unshifted
832-833/$0340-$0341 SHIFT
834-835/$0342-$0343 Commodore
836-837/$0344-$0345 CONTROL
838-839/$0346-$0347 ALT (same as unshifted)
840-841/$0348-$0349 CAPS LOCK
Address: International - National
-------------------------------------------
64128/$FA80 - 64809/$FD29 Unshifted
64217/$FAD9 - 64898/$FD82 SHIFT
64306/$FB32 - 64987/$FDDB Commodore
64395/$FB8B - 64395/$FB8B CONTROL
64128/$FA80 - 64809/$FD29 ALT (same as unshifted)
64484/$FBE4 - 64809/$FD29 CAPS LOCK (in case of ASCII/DIN same as unshifted)
Here's layout matrix:
Programmable Key Definition String Area
4096-4351/$1000-$10FF
This 256-byte area is used to hold the strings for the ten programmable keys supported by the 128's screen editor routines:
F1-F8, SHIFT-RUN/STOP, and HELP.
Each of the first 10 bytes of the area (4096-4105/$1000-$1009) holds the length of one of the definition strings:
4096/$1000=F1
4097/$1001=F2
4098/$1002=F3
4099/$1003=F4
4100/$1004=F5
4101/$1005=F6
4102/$1006=F7
4103/$1007=F8
4104/$1008=SHIFT+RUN/STOP
4105/$1009=HELP
The remaining 246 bytes (4106-435l/$100A-$10FF) are available for definition strings. There is no particular limit on the length of an individual definition string, except that the combined length of all the definition strings cannot exceed 246 bytes. The definition strings correspond to keys in the order shown above. The offset to the first character in a particular string is found by adding the lengths of all preceding definitions. No special characters are used to separate the strings. It is possible for a key to have no associated definition string, in which case the length location for the key should be set to 0/$00. The default definitions for the keys are as follows:
Fl GRAPHIC
F2 DLOAD"
F3 DIRECTORY[RETURN]
F4 SCNCLR[RETURN]
F5 DSAVE"
F6 RUN[RETURN]
F7 LIST[RETURN]
F8 MONITOR[RETURN]
SHIFT-RUN/STOP DL"*[RETURN]RUN[RETURN]
HELP[RETURN]
These definitions, along with the corresponding length values, are copied from locations 52904-52980/$CEA8-$CEF4 in screen editor ROM during the Kernal CINT routine [$C07B]. In BASIC, the KEY statement can be used to change definitions.
From machine language, the Kernal PFKEY routine [$FF65] (or screen editor KEYSET routine [$C021]) can be used. Programmable keys are handled by a subroutine [$C6CA] within the screen editor keyscan routine.
Sources of all items of this section © Robert Willie