Rev 8 | Rev 92 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8 | Rev 40 | ||
---|---|---|---|
1 | ;// mike.dld [ |
1 | ;// mike.dld [ |
2 | 2 | ||
3 | VKEY_LSHIFT = 0000000000000001b |
3 | VKEY_LSHIFT = 0000000000000001b |
4 | VKEY_RSHIFT = 0000000000000010b |
4 | VKEY_RSHIFT = 0000000000000010b |
5 | VKEY_LCONTROL = 0000000000000100b |
5 | VKEY_LCONTROL = 0000000000000100b |
6 | VKEY_RCONTROL = 0000000000001000b |
6 | VKEY_RCONTROL = 0000000000001000b |
7 | VKEY_LALT = 0000000000010000b |
7 | VKEY_LALT = 0000000000010000b |
8 | VKEY_RALT = 0000000000100000b |
8 | VKEY_RALT = 0000000000100000b |
9 | VKEY_CAPSLOCK = 0000000001000000b |
9 | VKEY_CAPSLOCK = 0000000001000000b |
10 | VKEY_NUMLOCK = 0000000010000000b |
10 | VKEY_NUMLOCK = 0000000010000000b |
11 | VKEY_SCRLOCK = 0000000100000000b |
11 | VKEY_SCRLOCK = 0000000100000000b |
12 | 12 | ||
13 | VKEY_SHIFT = 0000000000000011b |
13 | VKEY_SHIFT = 0000000000000011b |
14 | VKEY_CONTROL = 0000000000001100b |
14 | VKEY_CONTROL = 0000000000001100b |
15 | VKEY_ALT = 0000000000110000b |
15 | VKEY_ALT = 0000000000110000b |
16 | 16 | ||
17 | uglobal |
17 | uglobal |
18 | align 4 |
18 | align 4 |
19 | kb_state dd 0 |
19 | kb_state dd 0 |
20 | ext_code db 0 |
20 | ext_code db 0 |
21 | 21 | ||
22 | keyboard_mode db 0 |
22 | keyboard_mode db 0 |
23 | keyboard_data db 0 |
23 | keyboard_data db 0 |
24 | 24 | ||
25 | altmouseb db 0 |
25 | altmouseb db 0 |
26 | ctrl_alt_del db 0 |
26 | ctrl_alt_del db 0 |
27 | 27 | ||
28 | kb_lights db 0 |
28 | kb_lights db 0 |
29 | endg |
29 | endg |
30 | 30 | ||
31 | align 4 |
31 | align 4 |
32 | irq1: |
32 | irq1: |
33 | pushad |
- | |
34 | push ds es |
33 | save_ring3_context |
35 | mov ax, os_data |
34 | mov ax, os_data |
36 | mov ds, ax |
35 | mov ds, ax |
37 | mov es, ax |
36 | mov es, ax |
38 | 37 | ||
39 | movzx eax,word[0x3004] ; top window process |
38 | movzx eax,word[0x3004] ; top window process |
40 | movzx eax,word[0xC400+eax*2] |
39 | movzx eax,word[0xC400+eax*2] |
41 | shl eax,8 |
40 | shl eax,8 |
42 | mov al,[0x800B4+eax] |
41 | mov al,[0x800B4+eax] |
43 | mov [keyboard_mode],al |
42 | mov [keyboard_mode],al |
44 | 43 | ||
45 | in al,0x60 |
44 | in al,0x60 |
46 | mov [keyboard_data],al |
45 | mov [keyboard_data],al |
47 | 46 | ||
48 | mov ch,al |
47 | mov ch,al |
49 | cmp al,0xE0 |
48 | cmp al,0xE0 |
50 | je @f |
49 | je @f |
51 | cmp al,0xE1 |
50 | cmp al,0xE1 |
52 | jne .normal_code |
51 | jne .normal_code |
53 | @@: mov [ext_code],al |
52 | @@: mov [ext_code],al |
54 | jmp .no_key.end |
53 | jmp .no_key.end |
55 | .normal_code: |
54 | .normal_code: |
56 | mov cl,[ext_code] |
55 | mov cl,[ext_code] |
57 | mov [ext_code],0 |
56 | mov [ext_code],0 |
58 | and al,0x7F |
57 | and al,0x7F |
59 | @@: cmp al,0x2A |
58 | @@: cmp al,0x2A |
60 | jne @f |
59 | jne @f |
61 | cmp cl,0xE0 |
60 | cmp cl,0xE0 |
62 | je .no_key.end |
61 | je .no_key.end |
63 | mov eax,VKEY_LSHIFT |
62 | mov eax,VKEY_LSHIFT |
64 | jmp .no_key |
63 | jmp .no_key |
65 | @@: cmp al,0x36 |
64 | @@: cmp al,0x36 |
66 | jne @f |
65 | jne @f |
67 | cmp cl,0xE0 |
66 | cmp cl,0xE0 |
68 | je .no_key.end |
67 | je .no_key.end |
69 | mov eax,VKEY_RSHIFT |
68 | mov eax,VKEY_RSHIFT |
70 | jmp .no_key |
69 | jmp .no_key |
71 | @@: cmp al,0x38 |
70 | @@: cmp al,0x38 |
72 | jne @f |
71 | jne @f |
73 | cmp cl,0xE0 |
72 | cmp cl,0xE0 |
74 | je .alt.r |
73 | je .alt.r |
75 | mov eax,VKEY_LALT |
74 | mov eax,VKEY_LALT |
76 | jmp .no_key |
75 | jmp .no_key |
77 | .alt.r: |
76 | .alt.r: |
78 | mov eax,VKEY_RALT |
77 | mov eax,VKEY_RALT |
79 | jmp .no_key |
78 | jmp .no_key |
80 | @@: cmp al,0x1D |
79 | @@: cmp al,0x1D |
81 | jne @f |
80 | jne @f |
82 | cmp cl,0 |
81 | cmp cl,0 |
83 | jne .ctrl.r |
82 | jne .ctrl.r |
84 | mov eax,VKEY_LCONTROL |
83 | mov eax,VKEY_LCONTROL |
85 | jmp .no_key |
84 | jmp .no_key |
86 | .ctrl.r: |
85 | .ctrl.r: |
87 | cmp cl,0xE1 |
86 | cmp cl,0xE1 |
88 | jne .ctrl.r.2 |
87 | jne .ctrl.r.2 |
89 | mov [ext_code],cl |
88 | mov [ext_code],cl |
90 | jmp .no_key.end |
89 | jmp .no_key.end |
91 | .ctrl.r.2: |
90 | .ctrl.r.2: |
92 | mov eax,VKEY_RCONTROL |
91 | mov eax,VKEY_RCONTROL |
93 | jmp .no_key |
92 | jmp .no_key |
94 | @@: cmp al,0x3A |
93 | @@: cmp al,0x3A |
95 | jne @f |
94 | jne @f |
96 | mov bl,4 |
95 | mov bl,4 |
97 | mov eax,VKEY_CAPSLOCK |
96 | mov eax,VKEY_CAPSLOCK |
98 | jmp .no_key.xor |
97 | jmp .no_key.xor |
99 | @@: cmp al,0x45 |
98 | @@: cmp al,0x45 |
100 | jne @f |
99 | jne @f |
101 | cmp cl,0 |
100 | cmp cl,0 |
102 | jne .no_key.end |
101 | jne .no_key.end |
103 | mov bl,2 |
102 | mov bl,2 |
104 | mov eax,VKEY_NUMLOCK |
103 | mov eax,VKEY_NUMLOCK |
105 | jmp .no_key.xor |
104 | jmp .no_key.xor |
106 | @@: cmp al,0x46 |
105 | @@: cmp al,0x46 |
107 | jne @f |
106 | jne @f |
108 | mov bl,1 |
107 | mov bl,1 |
109 | mov eax,VKEY_SCRLOCK |
108 | mov eax,VKEY_SCRLOCK |
110 | jmp .no_key.xor |
109 | jmp .no_key.xor |
111 | @@: |
110 | @@: |
112 | test ch,0x80 |
111 | test ch,0x80 |
113 | jnz .no_key.end |
112 | jnz .no_key.end |
114 | movzx eax,ch ; plain key |
113 | movzx eax,ch ; plain key |
115 | mov bl,[keymap+eax] |
114 | mov bl,[keymap+eax] |
116 | mov edx,[kb_state] |
115 | mov edx,[kb_state] |
117 | test dl,VKEY_CONTROL ; ctrl alt del |
116 | test dl,VKEY_CONTROL ; ctrl alt del |
118 | jz .noctrlaltdel |
117 | jz .noctrlaltdel |
119 | test dl,VKEY_ALT |
118 | test dl,VKEY_ALT |
120 | jz .noctrlaltdel |
119 | jz .noctrlaltdel |
121 | cmp bl,134+48 |
120 | cmp bl,134+48 |
122 | jne .noctrlaltdel |
121 | jne .noctrlaltdel |
123 | mov [ctrl_alt_del],1 |
122 | mov [ctrl_alt_del],1 |
124 | jmp .no_key.end |
123 | jmp .no_key.end |
125 | .noctrlaltdel: |
124 | .noctrlaltdel: |
126 | test dl,VKEY_CONTROL ; ctrl on ? |
125 | test dl,VKEY_CONTROL ; ctrl on ? |
127 | jz @f |
126 | jz @f |
128 | sub bl,0x60 |
127 | sub bl,0x60 |
129 | @@: test dl,VKEY_SHIFT ; shift on ? |
128 | @@: test dl,VKEY_SHIFT ; shift on ? |
130 | jz @f |
129 | jz @f |
131 | mov bl,[keymap_shift+eax] |
130 | mov bl,[keymap_shift+eax] |
132 | @@: test dl,VKEY_ALT ; alt on ? |
131 | @@: test dl,VKEY_ALT ; alt on ? |
133 | jz @f |
132 | jz @f |
134 | mov bl,[keymap_alt+eax] |
133 | mov bl,[keymap_alt+eax] |
135 | ; alt mouse ? |
134 | ; alt mouse ? |
136 | xor edx,edx |
135 | xor edx,edx |
137 | cmp bl,178 |
136 | cmp bl,178 |
138 | jnz .no_alt.up |
137 | jnz .no_alt.up |
139 | mov edx,5*65536 |
138 | mov edx,5*65536 |
140 | jmp .mouse.change |
139 | jmp .mouse.change |
141 | .no_alt.up: |
140 | .no_alt.up: |
142 | cmp bl,177 |
141 | cmp bl,177 |
143 | jnz .no_alt.down |
142 | jnz .no_alt.down |
144 | mov edx,251*65536 |
143 | mov edx,251*65536 |
145 | jmp .mouse.change |
144 | jmp .mouse.change |
146 | .no_alt.down: |
145 | .no_alt.down: |
147 | cmp bl,176 |
146 | cmp bl,176 |
148 | jnz .no_alt.left |
147 | jnz .no_alt.left |
149 | mov edx,251*256 |
148 | mov edx,251*256 |
150 | jmp .mouse.change |
149 | jmp .mouse.change |
151 | .no_alt.left: |
150 | .no_alt.left: |
152 | cmp bl,179 |
151 | cmp bl,179 |
153 | jnz .no_alt.right |
152 | jnz .no_alt.right |
154 | mov edx,5*256 |
153 | mov edx,5*256 |
155 | jmp .mouse.change |
154 | jmp .mouse.change |
156 | .no_alt.right: |
155 | .no_alt.right: |
157 | cmp bl,' ' |
156 | cmp bl,' ' |
158 | jne @f |
157 | jne @f |
159 | xor [altmouseb],1 |
158 | xor [altmouseb],1 |
160 | .mouse.change: |
159 | .mouse.change: |
161 | mov byte[0xF604],1; ps2 data |
160 | mov byte[0xF604],1; ps2 data |
162 | mov byte[0xFB00],0; ps2 chunk count |
161 | mov byte[0xFB00],0; ps2 chunk count |
163 | mov word[0x2E0000+4096*12],3; mouse data count |
162 | mov word[0x2E0000+4096*12],3; mouse data count |
164 | mov dl,[altmouseb] |
163 | mov dl,[altmouseb] |
165 | mov [0x2E0000+4096*12+0x10],edx |
164 | mov [0x2E0000+4096*12+0x10],edx |
166 | mov bl,0 |
165 | mov bl,0 |
167 | @@: |
166 | @@: |
168 | cmp [keyboard_mode],0 ; return from keymap |
167 | cmp [keyboard_mode],0 ; return from keymap |
169 | jne .no_key.end |
168 | jne .no_key.end |
170 | mov [keyboard_mode_sys],0 |
169 | mov [keyboard_mode_sys],0 |
171 | cmp bl,0 |
170 | cmp bl,0 |
172 | je .no_key.end |
171 | je .no_key.end |
173 | movzx eax,byte[0xF400] |
172 | movzx eax,byte[0xF400] |
174 | cmp al,120 |
173 | cmp al,120 |
175 | jae .no_key.end |
174 | jae .no_key.end |
176 | inc al |
175 | inc al |
177 | mov [0xF400],al |
176 | mov [0xF400],al |
178 | mov [0xF400+eax],bl |
177 | mov [0xF400+eax],bl |
179 | 178 | ||
180 | jmp .no_key.end |
179 | jmp .no_key.end |
181 | 180 | ||
182 | .no_key: |
181 | .no_key: |
183 | test ch,0x80 |
182 | test ch,0x80 |
184 | jz .no_key.down |
183 | jz .no_key.down |
185 | not eax |
184 | not eax |
186 | and [kb_state],eax |
185 | and [kb_state],eax |
187 | jmp .no_key.end |
186 | jmp .no_key.end |
188 | .no_key.xor: |
187 | .no_key.xor: |
189 | test ch,0x80 |
188 | test ch,0x80 |
190 | jnz .no_key.end |
189 | jnz .no_key.end |
191 | xor [kb_state],eax |
190 | xor [kb_state],eax |
192 | xor [kb_lights],bl |
191 | xor [kb_lights],bl |
193 | call set_lights |
192 | call set_lights |
194 | jmp .no_key.end |
193 | jmp .no_key.end |
195 | .no_key.down: |
194 | .no_key.down: |
196 | or [kb_state],eax |
195 | or [kb_state],eax |
197 | .no_key.end: |
196 | .no_key.end: |
198 | cmp [keyboard_mode],1 ; return scancode |
197 | cmp [keyboard_mode],1 ; return scancode |
199 | jne .no_scancode |
198 | jne .no_scancode |
200 | mov [keyboard_mode_sys],1 |
199 | mov [keyboard_mode_sys],1 |
201 | movzx eax,byte[0xF400] |
200 | movzx eax,byte[0xF400] |
202 | cmp al,120 |
201 | cmp al,120 |
203 | jae .no_scancode |
202 | jae .no_scancode |
204 | inc al |
203 | inc al |
205 | mov [0xF400],al |
204 | mov [0xF400],al |
206 | mov [0xF400+eax],ch |
205 | mov [0xF400+eax],ch |
207 | .no_scancode: |
206 | .no_scancode: |
208 | 207 | ||
209 | .exit.irq1: |
208 | .exit.irq1: |
210 | mov [check_idle_semaphore],5 |
209 | mov [check_idle_semaphore],5 |
211 | 210 | ||
212 | mov al,0x20 ; ready for next irq |
211 | mov al,0x20 ; ready for next irq |
213 | out 0x20,al |
212 | out 0x20,al |
214 | 213 | ||
215 | pop es ds |
- | |
216 | popad |
214 | restore_ring3_context |
217 | iret |
215 | iret |
218 | 216 | ||
219 | set_lights: |
217 | set_lights: |
220 | mov al,0xED |
218 | mov al,0xED |
221 | call kb_write |
219 | call kb_write |
222 | mov al,[kb_lights] |
220 | mov al,[kb_lights] |
223 | call kb_write |
221 | call kb_write |
224 | ret |
222 | ret |
225 | 223 | ||
226 | ;// mike.dld ] |
224 | ;// mike.dld ] |