Subversion Repositories Kolibri OS

Rev

Rev 3542 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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