Rev 1036 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
492 | kastigar | 1 | ;************************************** |
2 | ;* IRQ HANDLER FOR PS/2 MOUSE * |
||
3 | ;************************************** |
||
4 | |||
5 | proc irq_handler |
||
6 | |||
1036 | diamond | 7 | ; call Wait8042BufferEmpty ;clear buffer |
492 | kastigar | 8 | in al,0x60 ;get scan-code |
9 | |||
10 | cmp [mouse_byte],0 |
||
11 | je .byte1 |
||
12 | cmp [mouse_byte],1 |
||
13 | je .byte2 |
||
14 | cmp [mouse_byte],2 |
||
15 | je .byte3 |
||
16 | cmp [mouse_byte],3 |
||
17 | je .byte4 |
||
18 | jmp .error |
||
19 | |||
20 | .byte1: |
||
21 | test al,1000b ;first byte? |
||
22 | jz .error |
||
23 | mov [first_byte],al |
||
24 | inc [mouse_byte] |
||
25 | jmp .exit |
||
26 | |||
27 | .byte2: |
||
28 | mov [second_byte],al |
||
29 | inc [mouse_byte] |
||
30 | jmp .exit |
||
31 | |||
32 | .byte3: |
||
33 | mov [third_byte],al |
||
34 | cmp [MouseType],MT_3B |
||
35 | je .full_packet |
||
36 | inc [mouse_byte] |
||
37 | jmp .exit |
||
38 | |||
39 | .byte4: |
||
40 | mov [fourth_byte],al |
||
41 | |||
42 | |||
43 | .full_packet: |
||
44 | mov [mouse_byte],0 |
||
45 | mov al,byte [first_byte] |
||
46 | and eax,7 |
||
47 | mov byte [ButtonState],al |
||
48 | |||
49 | cmp [MouseType],MT_3B |
||
50 | je .xy_moving |
||
51 | mov al,[fourth_byte] |
||
52 | cmp [MouseType],MT_3BScroll |
||
53 | je .z_moving |
||
54 | |||
55 | mov ah,al |
||
56 | and ah,00110000b |
||
57 | shr ah,1 |
||
58 | or byte [ButtonState],ah |
||
59 | and al,00001111b |
||
60 | bt eax,3 |
||
61 | jnc .z_moving |
||
62 | or al,11110000b |
||
63 | |||
64 | .z_moving: |
||
65 | movsx eax,al |
||
66 | mov [ZMoving],eax |
||
67 | |||
68 | .xy_moving: |
||
69 | mov ah,0 |
||
70 | mov al,[first_byte] |
||
71 | test al,10000b |
||
72 | jz @f |
||
73 | mov ah,0FFh |
||
74 | |||
75 | @@: |
||
76 | mov al,[second_byte] |
||
77 | cwde |
||
78 | mov [XMoving],eax |
||
79 | |||
80 | mov ah,0 |
||
81 | mov al,[first_byte] |
||
82 | test al,100000b |
||
83 | jz @f |
||
84 | mov ah,0FFh |
||
85 | |||
86 | @@: |
||
87 | mov al,[third_byte] |
||
88 | cwde |
||
89 | |||
90 | @@: |
||
91 | mov [YMoving],eax |
||
92 | |||
93 | mov eax,[ZMoving] |
||
94 | test eax,1 |
||
95 | jnz .vert |
||
96 | |||
97 | sar eax,1 |
||
98 | push eax |
||
99 | push 0 |
||
100 | jmp @f |
||
101 | |||
102 | .vert: |
||
103 | push 0 |
||
104 | push eax |
||
105 | |||
106 | @@: |
||
107 | |||
108 | stdcall SetMouseData, [ButtonState], [XMoving], [YMoving] |
||
109 | |||
110 | jmp .exit |
||
111 | |||
112 | .error: |
||
113 | mov [mouse_byte],0 |
||
114 | |||
115 | .exit: |
||
3542 | clevermous | 116 | xor eax, eax |
117 | inc eax |
||
492 | kastigar | 118 | ret |
119 | endp |
||
120 | |||
121 | |||
122 | ;*********************************************** |
||
123 | ;* Waiting for clearing I8042 buffer * |
||
124 | ;* Retutned state: * |
||
125 | ;* ZF is set - good ending, * |
||
126 | ;* ZF is cleared - time-out error. * |
||
127 | ;*********************************************** |
||
1036 | diamond | 128 | ;Wait8042BufferEmpty: |
129 | ; push ecx |
||
130 | ; xor ecx,ecx |
||
131 | ; @@: |
||
132 | ; in al,64h |
||
133 | ; test al,00000010b |
||
134 | ; loopnz @b |
||
135 | ; pop ecx |
||
136 | ; |
||
137 | ; ret |