-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKSCAN.asm
54 lines (50 loc) · 1.15 KB
/
KSCAN.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
DEF KSCAN
*
REF KEYTIM,CURKEY,PRVKEY
REF WS
*
* Constants
*
COPY 'CONST.asm'
COPY 'CPUADR.asm'
* Amount of time to wait between key repeats
WAIT DATA 30
NOKEY BYTE >FF
EVEN
*
* Public Method:
* Scan Keyboard
*
KSCAN
DECT R10
MOV R11,*R10
* Reduce time to wait before key repeat
DEC @KEYTIM
JGT KSCAN1
CLR @KEYTIM
* Call console Key Scan routine
KSCAN1 LWPI >83E0 can't change WS with BLWP as R13-R15 are in use
DECT R10 save GPL R11
MOV R11,*R10
BL @>000E call keyboard scanning routine
MOV *R10+,R11 restore GPL R11
LWPI WS
* Store scanned key in R2
MOVB @KEYCOD,R2
* Has any key been pressed?
CB R2,@NOKEY
JEQ KEYRT
* Is this the same as previous key?
CB R2,@PRVKEY
JNE KSCAN2
* Yes, has enough time passed?
MOV @KEYTIM,R0
JNE KEYRT
* Retain key and mark that it is also the previous key
KSCAN2 MOVB R2,@CURKEY
MOVB R2,@PRVKEY
* Reset repeat timer and store previous key
MOV @WAIT,@KEYTIM
KEYRT
MOV *R10+,R11
RT