forked from mist64/msbasic
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetupvia.s
More file actions
73 lines (56 loc) · 1.16 KB
/
setupvia.s
File metadata and controls
73 lines (56 loc) · 1.16 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
;VIA addresses
PORTB = $8000
PORTA = $8001
DDRB = $8002
DDRA = $8003
SHCTL = $800A
ACR = $800B ; auxiliary control register
PCR = $800C ; peripheral control register
IFR = $800D
IER = $800E ; interrupt enable register
;VIA config flgs
IMASK = %10000001 ; enable interrupt for CA2
CFGCA = %00000010 ; configure CA2 for negative active edge for PS/2 clock
ACRCFG = %00000011 ; enable latching
; PS/2 keyboard state
KBSTATE = $A0
KBTEMP = $A1
KBCURR = $A2
KBBIT = $A3
KBEXTEND = $A4
KBKEYUP = $A5
KBDBG = $A6
KBDBG2 = $A7
KBBUF = $100
KEYSTATE = $200
.org $3000
reset:
pha
phx
; init PS/2 kb stuff
lda #$00
sta KBSTATE
sta KBTEMP
sta KBCURR
sta KBBIT
sta KBEXTEND
sta KBKEYUP
sta KBDBG
sta KBDBG2
ldx #$00 ; clear the key state and input buffers
loopx:
sta KEYSTATE, x
sta KBBUF, x
inx
cpx #$00
bne loopx
; initialize the LCD via the VIA
lda IMASK
sta IER
lda CFGCA
sta PCR ; configure CB21for negative active edge and independent interrupt
lda ACRCFG
sta ACR
plx
pla
jmp $FF00