Mercurial > hg > index.cgi
annotate src/keyb.s @ 125:0607e4e20702
Correct offset error for keyword table lookup
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 07 Jan 2024 20:35:51 -0700 |
parents | 2d52cd154ed1 |
children |
rev | line source |
---|---|
73
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1 *pragmapush list |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
2 *pragma list |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
4 ; Check for BREAK; this needs to check the keyboard directly instead of just using the usual key fetching routine so |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
5 ; we don't interfere with keyboard buffering if BREAK isn't pressed. We also need to scan the keyboard directly for this |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
6 ; so we react even if the keyboard buffer is full. If BREAK is pressed, the keyboard buffer is emptied. |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
7 breakcheck lda #0xfb ; strobe column for BREAK |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
8 sta PIA0.DB |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
9 clra ; clear carry for no BREAK |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
10 lda PIA0.DA ; read rows |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
11 bita #0x40 ; is BREAK down? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
12 bne breakcheck0 ; brif not - check for SHIFT-@ |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
13 sync ; wait for interrupt to scan keyboard |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
14 bsr keyb_clearbuff ; reset keyboard buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
15 coma ; flag BREAK |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
16 breakcheck1 rts |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
17 breakcheck0 lda #0x7f ; check for SHIFT |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
18 sta PIA0.DB |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
19 lda PIA0.DA |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
20 bita #0x40 ; shift? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
21 bne breakcheck1 ; brif not |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
22 lda #0xfe ; check for @ |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
23 sta PIA0.DB |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
24 lda PIA0.DA |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
25 bita #1 ; @? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
26 bne breakcheck1 ; brif not |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
27 bsr keyb_clearbuff ; clear buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
28 breakcheck2 sync ; wait for keyboard to actually be scanned |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
29 bsr keyb_getkey |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
30 bcs breakcheck2 ; brif no key down |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
31 bra breakcheck ; go do the break/pause check dance again |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
32 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
33 ; Console keyboard input driver |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
34 ; |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
35 ; Reset the keyboard state, which means clearing the buffer and state flags |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
36 keyb_reset bsr keyb_clearbuff ; clear keyboard buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
37 lda keyb_flags ; reset keyboard state flags but keep capslock |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
38 anda #keyb_caps |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
39 sta keyb_flags |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
40 clr keyb_joystate ; clear joystick button state |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
41 clr keyb_curscan ; stop any keyboard repeating |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
42 ldx #0xffff ; mark all key state as "unpressed" |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
43 stx keyb_state |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
44 stx keyb_state+2 |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
45 stx keyb_state+4 |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
46 stx keyb_state+6 |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
47 rts |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
48 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
49 ; Empty the keyboard buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
50 keyb_clearbuff ldx #keyb_buff ; point to start of buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
51 stx keyb_buffr ; set both pointers to the start |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
52 stx keyb_buffw |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
53 rts |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
54 ; Read character from keyboard ring buffer; return with C set if buffer empty; this doesn't actually need to have |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
55 ; interrupts disabled because the interrupt only ever updates the write pointer and then only to increase it. As a |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
56 ; result, worst case is that we don't detect the contents added to the buffer on this call and have to wait for the |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
57 ; next. |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
58 keyb_getkey pshs x ; save register |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
59 ldx keyb_buffr ; get read pointer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
60 cmpx keyb_buffw ; same as write pointer? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
61 bne keyb_getkey0 ; brif not - we have a result |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
62 coma ; set carry for empty buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
63 puls x,pc ; restore register and return |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
64 keyb_getkey0 lda ,x+ ; get character from buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
65 cmpx #keyb_buff+keyb_bufflen ; did we run off end of buffer? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
66 blo keyb_getkey1 ; brif not |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
67 ldx #keyb_buff ; reset to start |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
68 keyb_getkey1 stx keyb_buffr ; save new read pointer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
69 andcc #0xfe ; flag key retrieved |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
70 puls x,pc ; restore register and return |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
71 ; The PIA reading loop is specifically set up to NOT read PIA0.DB to avoid prematurely clearing the VSYNC interrupt flag |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
72 ; since that could lead to missing interrupts. Reading PIA0.DA will clear the HSYNC interrupt flag but that's less of a |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
73 ; problem because that interrupt is basically useless. |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
74 ; |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
75 ; As a note, doing the PIA read in a loop ends up using an extra 27 CPU cycles for the BCS instruction. However, it |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
76 ; saves 70 code bytes. The trade off seems worth it in this case. |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
77 ; |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
78 ; Once keyboard state is read, we do the following: |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
79 ; |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
80 ; * update the state of SHIFT, CTRL, ALT |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
81 ; * decode all other keys in a loop |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
82 keyb_read0a pshs b ; save flag bit |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
83 ldb a,y ; get state flag |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
84 bitb #0x40 ; did it change state? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
85 bne keyb_read0d ; brif so |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
86 puls b,pc ; clean up and return |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
87 keyb_read0d andb #0xbf ; flag it as not changed |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
88 stb a,y |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
89 ldb a,u ; get current modifier state |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
90 eorb #0x40 ; flip the state bit |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
91 stb a,u ; save new state flags |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
92 bitb #0x40 ; Z set if not down |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
93 puls b ; get back flag bit |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
94 beq keyb_read0b ; brif key is pressed |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
95 comb ; invert bit flag |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
96 andb keyb_flags ; clear bit in flags |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
97 bra keyb_read0c ; finish up |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
98 keyb_read0b orb keyb_flags ; set the flag |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
99 keyb_read0c stb keyb_flags ; update flags |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
100 rts |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
101 keyb_read leas -9,s ; make temporary buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
102 leay 1,s ; point to temporary state buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
103 clra ;* set to 0xff with C clear; start by strobing no columns for joystick |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
104 deca ;* then rotate the 0 bit through to do the actual keyboard columns |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
105 ldu #keyb_state ; point to end of keyboard state buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
106 sta PIA0.DB ; strobe no columns |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
107 ldb PIA0.DA ; get joystick button state |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
108 stb keyb_joystate ; save it for later when needed |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
109 andb #0x7f ; mask off comparator (pretend "button" down) |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
110 stb ,s ; save button/comparator state mask |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
111 rola ; set up for first column |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
112 keyb_read0 sta PIA0.DB ; set column strobe |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
113 ldb PIA0.DA ; read row data |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
114 eorb ,u+ ; set bits if state changed |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
115 andb ,s ; mask off comparator and active buttons |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
116 stb ,y+ ; save state change information |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
117 rola ; shift to next column |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
118 bcs keyb_read0 ; brif we haven't done the last column |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
119 sta PIA0.DB ; reset column strobe to none |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
120 ldd #0xff00|keyb_shift |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
121 bsr keyb_read0a |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
122 ldd #0xfc00|keyb_ctrl |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
123 bsr keyb_read0a |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
124 ldd #0xfb00|keyb_alt |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
125 bsr keyb_read0a |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
126 keyb_read3 ldd #0x0701 ; initialize bit probe and counter |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
127 keyb_read4 leay -1,y ; move pointers to next byte |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
128 leau -1,u |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
129 keyb_read5 bitb ,y ; did this key change state? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
130 bne keyb_read7 ; brif so |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
131 keyb_read6 adda #8 ; adjust scan code |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
132 lslb ; shift bit probe |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
133 bpl keyb_read5 ; brif we haven't done all bits |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
134 ldb ,y ; update state flags for this byte |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
135 eorb ,u |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
136 stb ,u |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
137 ldb #1 ; reset bit probe |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
138 anda #0x07 ; reset scan code |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
139 deca ; adjust for next column |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
140 bpl keyb_read4 ; brif not - do another |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
141 leas 9,s ; clean up stack |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
142 ldb keyb_curscan ; is key repeating? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
143 bne keyb_read9 ; brif so |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
144 keyb_reada rts |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
145 keyb_read7 bitb ,u ; get current state |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
146 bne keyb_read8 ; brif key pressed (make) |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
147 cmpa keyb_curscan ; is it the currently repeating key? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
148 bne keyb_read6 ; brif not - don't need to do anything |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
149 clr keyb_curscan ; clear the current repeat |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
150 bra keyb_read6 |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
151 keyb_read8 sta keyb_curscan ; set the current scan code that is repeating |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
152 pshs d ; save current bit probe and scan code |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
153 ldb #keyb_repdeli ; intialize repeat delay |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
154 stb keyb_repdel |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
155 bsr keyb_tobuff ; decode key to buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
156 puls d ; restore scan code and bit probe |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
157 bra keyb_read6 ; go handle the next bit |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
158 keyb_read9 dec keyb_repdel ; is it time to repeat it? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
159 bne keyb_reada ; brif not |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
160 ldb #keyb_repdelr ; reset repeat delay |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
161 stb keyb_repdel |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
162 lda keyb_curscan ; get current scan code |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
163 keyb_tobuff tsta ; @? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
164 beq keyb_tobuff7 ; brif so |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
165 cmpa #26 ; is it alpha or @? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
166 bhi keyb_tobuff6 ; brif not |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
167 ldb keyb_flags ; get shift flags |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
168 bitb #keyb_ctrl|keyb_alt ; ALT or CTRL? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
169 bne keyb_tobuff4 ; brif one or both |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
170 ora #0x60 ; make lower case |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
171 bitb #keyb_caps ; capslock enabled? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
172 beq keyb_tobuff0 ; brif not |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
173 eora #0x20 ; flip to upper case |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
174 keyb_tobuff0 bitb #keyb_shift ; shifted? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
175 beq keyb_tobuff1 ; brif not |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
176 eora #0x20 ; flip case if shifted |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
177 keyb_tobuff1 ldx keyb_buffw ; get write pointer for keyboard buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
178 sta ,x+ ; put it in the buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
179 cmpx #keyb_buff+keyb_bufflen ; end of buffer? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
180 blo keyb_tobuff2 ; brif not |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
181 ldx #keyb_buff ; reset pointer to start |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
182 keyb_tobuff2 cmpx keyb_buffr ; did we run into the read pointer? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
183 beq keyb_tobuff3 ; brif so - there wasn't room so don't save pointer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
184 stx keyb_buffw ; update the write pointer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
185 keyb_tobuff3 rts |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
186 keyb_tobuff4 bitb #keyb_alt ; is ALT? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
187 beq keyb_tobuff1 ; brif not - scan code is CTRL-<letter> code |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
188 ora #0x80 ; set bit 7 for "ALT" codes |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
189 bitb #keyb_shift ; shifted? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
190 beq keyb_tobuff5 ; brif not |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
191 ora #0x20 ; set bit 5 |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
192 keyb_tobuff5 bitb #keyb_ctrl ; ctrl? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
193 beq keyb_tobuff1 ; brif not - stash it in the buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
194 ora #0x40 ; set bit 6 for "ctrl |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
195 bra keyb_tobuff1 ; stash it the buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
196 keyb_tobuff6 suba #26 ; codes above 26 down to 1; @ will be 0 |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
197 keyb_tobuff7 cmpa #6 ; is it "0"? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
198 bne keyb_tobuff8 ; brif not |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
199 ldb keyb_flags ; get shift flags |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
200 bitb #keyb_shift|keyb_ctrl ; CTRL-0 or SHIFT-0? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
201 beq keyb_tobuff8 ; brif not - not "capslock" |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
202 eorb #keyb_caps ; flip the capslock state |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
203 stb keyb_flags |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
204 keyb_tobuffa rts ; and don't put it in the buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
205 keyb_tobuff8 cmpa #25 ; is it at or above ALT? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
206 blo keyb_tobuff9 ; brif not |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
207 suba #2 ; close gap for ALT/CTRL |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
208 keyb_tobuff9 ldb #8 ;* 8 codes; multiply by 8 and move to B |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
209 mul ;* |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
210 ldx #keyb_codetab ; point to special code table |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
211 abx ; now X points to the base entry in the table |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
212 ldb keyb_flags ; get shift flags |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
213 andb #keyb_shift|keyb_ctrl|keyb_alt ; keep only shift/ctrl/alt |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
214 lda b,x ; fetch key code |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
215 beq keyb_tobuffa ; brif no code to return |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
216 bra keyb_tobuff1 ; go stash it in the buffer |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
217 ; This is the keyboard code table; there are 8 bytes per entry in the following order: |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
218 ; 0: unmodified |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
219 ; 1: shift |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
220 ; 2: ctrl |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
221 ; 3: ctrl-shift |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
222 ; 4: alt |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
223 ; 5: alt-shift |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
224 ; 6: alt-ctrl |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
225 ; 7: alt-ctrl-shift |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
226 ; |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
227 ; No entries for ALT, CTRL, SHIFT, or letters |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
228 keyb_codetab fcb 0x40,0x13,0x40,0x40,0x80,0xa0,0xc0,0xe0 ; @ |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
229 fcb 0x5e,0x5f,0x00,0x00,0x00,0x00,0x00,0x00 ; <UP> |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
230 fcb 0x0a,0x5b,0x00,0x00,0x00,0x00,0x00,0x00 ; <DOWN> |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
231 fcb 0x08,0x15,0x00,0x00,0x00,0x00,0x00,0x00 ; <LEFT> |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
232 fcb 0x09,0x5d,0x00,0x00,0x00,0x00,0x00,0x00 ; <RIGHT> |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
233 fcb 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ; <SPACE> |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
234 fcb 0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; 0 (shift/ctrl variants shadowed above) |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
235 fcb 0x31,0x21,0x00,0x00,0x00,0x00,0x00,0x00 ; 1 ! |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
236 fcb 0x32,0x22,0x00,0x00,0x00,0x00,0x00,0x00 ; 2 " |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
237 fcb 0x33,0x23,0x00,0x00,0x00,0x00,0x00,0x00 ; 3 # |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
238 fcb 0x34,0x24,0x00,0x00,0x00,0x00,0x00,0x00 ; 4 $ |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
239 fcb 0x35,0x25,0x00,0x00,0x00,0x00,0x00,0x00 ; 5 % |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
240 fcb 0x36,0x26,0x00,0x00,0x00,0x00,0x00,0x00 ; 6 & |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
241 fcb 0x37,0x27,0x00,0x00,0x00,0x00,0x00,0x00 ; 7 ' |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
242 fcb 0x38,0x28,0x00,0x00,0x00,0x00,0x00,0x00 ; 8 ( |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
243 fcb 0x39,0x29,0x00,0x00,0x00,0x00,0x00,0x00 ; 9 ) |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
244 fcb 0x3a,0x2a,0x00,0x00,0x00,0x00,0x00,0x00 ; : * |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
245 fcb 0x3b,0x2b,0x00,0x00,0x00,0x00,0x00,0x00 ; ; + |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
246 fcb 0x2c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00 ; , < |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
247 fcb 0x2d,0x3d,0x00,0x00,0x00,0x00,0x00,0x00 ; - = |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
248 fcb 0x2e,0x3e,0x00,0x00,0x00,0x00,0x00,0x00 ; . > |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
249 fcb 0x2f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00 ; / ? |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
250 fcb 0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d ; <ENTER> |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
251 fcb 0x0c,0x5c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c ; <CLEAR> |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
252 fcb 0x03,0x03,0x1b,0x1b,0x9b,0xbb,0xdb,0xfb ; <BREAK> |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
253 fcb 0x1c,0x1d,0x1c,0x1d,0x00,0x00,0x00,0x00 ; <F1> |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
254 fcb 0x1e,0x1f,0x1e,0x1f,0x00,0x00,0x00,0x00 ; <F2> |
2d52cd154ed1
Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
255 *pragmapop list |