Subversion Repositories Kolibri OS

Rev

Rev 486 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;**************************************
  2. ;* IRQ HANDLER FOR PS/2 MOUSE         *
  3. ;**************************************
  4.  
  5. proc irq_handler
  6.  
  7.         call    Wait8042BufferEmpty  ;clear buffer
  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.         cwd
  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.         cwd
  89.  
  90.     @@:
  91.         mov     [YMoving],eax
  92.         stdcall SetMouseData, [ButtonState], [XMoving], [YMoving], [ZMoving], 0
  93.  
  94.        
  95.         jmp   .exit
  96.  
  97.   .error:
  98.         mov   [mouse_byte],0
  99.  
  100.   .exit:
  101.         ret
  102. endp
  103.  
  104.  
  105. ;***********************************************
  106. ;*   Waiting for clearing I8042 buffer         *
  107. ;* Retutned state:                             *
  108. ;* ZF is set - good ending,                    *
  109. ;* ZF is cleared - time-out error.             *
  110. ;***********************************************
  111. Wait8042BufferEmpty:
  112.         push ecx
  113.         xor  ecx,ecx
  114.       @@:
  115.         in     al,64h
  116.         test   al,00000010b
  117.         loopnz @b
  118.         pop    ecx
  119.  
  120.         ret
  121.