KEYBOARD DRIVER
For a
string
key
the
data
pointed
to
by
the
IS-bit
string
pointer
has
the
following format:-
Bytes
1
and
2 = String type
and
character
count
word.
Bits
0 - 7 is
the
count
of
characters
in
the
string
(zero is
a
null
string)
Bits 8
-13
correspond
to
the
above types.
Bits 14
-15
are
not
used
Byte
3 ......
Byte
n =
Character
1
to
Last character.
Program 5 allows a
multi-string
key
to be
set
up
from
Basic.
The
key
numbers
are
held
in
DATA,
and
the
routine
is called
by
GOSUB.
10
GOSUB
50000:STOP
999
REM--SOME
SAMPLE
KEY
DATA
1000
DATA
4
'NUMBER
OF
KEYS
1010
DATA
"0:8:RUN-":
'MEMBRANE
KEY
1
IS
RUN
WITH
A
CR
1020
DATA
"1:13:LIST-":
'SHIFT
MEMBRANE
KEY
6
IS
LIST
CR
1030
DATA
"0:
2:
DIR/W-"
:
'REPEAT
IS
DIR/W
CR
1040
DATA
"0:
0:
HELP":
'HELP
IS
HELP,
NO
CR
1050
REM--THE
DATA
IS
HELD
AS
FOLLOWS:
MODE:KEYNUM:STRING
[-]
MODE
-
O=UNSHIFTED,
l=SHIFTED,
2=CONTROL
KEYNUM
-
THE
NUMBER
OF
THE
KEY
TO
BE
RE-DEFINED
FROM
1
TO
96
STRING
-
THE
NEW
STRING
TO
APPEAR
ON
THE
KEY,
IF
A
"_,,
IS
APPENDED,
THEN
A
CARRIAGE
RETURN
IS
ADDED
TO
THE
CODE
50000
READ
N:FOR
E=l
TO
N:READ
KEY$
50010
IF
RIGHT$(KEY$,
1)="-"
THEN
MID$(KEY$,LEN(KEY$))=CHR$(13)
50020
GOSUB
50030:NEXT
E:RETURN
50030
DEF
SEG=0:ST=PEEK(&H0712)+256*PEEK(&H0713)
50040
TL=PEEK(&H0716)+256*PEEK(&H0717)-1'
50050
KB=PEEK(&H0714)+256*PEEK(&H0715):DEF
SEG=KB
50060
M=VAL
(KEY$)
:
Y=VAL
(MID$
(KEY$,
INSTR
(
INSTR
(KEY$,
" : " ) +
1)
)
50070
O$=MID$(KEY$,INSTR(INSTR(KEY$,":")+l,KEY$,":")+l):SL=LEN(O$)
50080
L=(ST+(M*208)+Y*2)
:FOR
K=ST+TL
TO
ST+623
STEP
-1:
IF
PEEK(K)=O
THEN
50090
ELSE
50100
50090
NEXT
K:IF
K=ST+623
THEN
K=K+2
50100
K=K+l:POKE
K,SL:POKE
K+l,O:FOR
P=l
TO
SL:
POKE
P+K+l,ASC(MID$(O$,P)
):NEXT
50110
DEF
SEG:G%=K:Pl=PEEK(VARPTR(G%))
:P2=PEEK(VARPTR(G%)+1)
50120
DEF
SEG=KB:POKE
L,Pl:POKE
L+l,P2:RETURN