Subversion Repositories Kolibri OS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. $Revision: 996 $
  9.  
  10.  
  11. ;   check mouse
  12. ;
  13. ;
  14. ;   FB00  ->   FB0F   mouse memory 00 chunk count - FB0A-B x - FB0C-D y
  15. ;   FB10  ->   FB17   mouse color mem
  16. ;   FB21              x move
  17. ;   FB22              y move
  18. ;   FB30              color temp
  19. ;   FB28              high bits temp
  20.  
  21. uglobal
  22.   mousecount  dd  0x0
  23.   mousedata   dd  0x0
  24. endg
  25.  
  26. iglobal
  27. mouse_delay         dd 10
  28. mouse_speed_factor: dd 3
  29. mouse_timer_ticks   dd 0
  30. endg
  31.  
  32. align 4
  33. draw_mouse_under:
  34.         ; return old picture
  35.  
  36.            cmp [set_hw_cursor], 0
  37.            jz .exit
  38.            pushad
  39.            mov  eax, [x_under]
  40.            mov  ebx, [y_under]
  41.            stdcall [hw_restore], eax, ebx
  42.            popad
  43. .exit:
  44.            ret
  45.  
  46. save_draw_mouse:
  47.  
  48.            cmp [set_hw_cursor], 0
  49.            je .exit
  50.  
  51.            pushad
  52.  
  53.            mov [x_under], eax
  54.            mov    [y_under], ebx
  55.            movzx  eax,word [MOUSE_Y]
  56.            movzx  ebx,word [MOUSE_X]
  57.            push eax
  58.            push ebx
  59.  
  60.            mov ecx, [Screen_Max_X]
  61.            inc ecx
  62.            mul ecx
  63.            add eax, [_display_data]
  64.            movzx edx, byte [ebx+eax]
  65.            shl edx, 8
  66.            mov esi, [edx+SLOT_BASE+APPDATA.cursor]
  67.  
  68.            cmp esi, [current_cursor]
  69.            je .draw
  70.  
  71.            push esi
  72.            call [select_hw_cursor]
  73.            mov [current_cursor], esi
  74. .draw:
  75.            stdcall [set_hw_cursor], esi
  76.            popad
  77. .exit:
  78.            ret
  79.  
  80.  
  81. __sys_disable_mouse:
  82.       cmp  [MOUSE_VISIBLE], 0
  83.       je    @f
  84.       ret
  85. @@:
  86.       pushad
  87.       cmp  [CURRENT_TASK],dword 1
  88.       je   disable_m
  89.       mov  edx,[CURRENT_TASK]
  90.       shl  edx,5
  91.       add  edx,window_data
  92.       movzx  eax, word [MOUSE_X]
  93.       movzx  ebx, word [MOUSE_Y]
  94.       mov  ecx,[Screen_Max_X]
  95.       inc  ecx
  96.       imul  ecx,ebx
  97.       add  ecx,eax
  98.       add  ecx, [_display_data]
  99.       mov   eax, [CURRENT_TASK]
  100.       movzx ebx, byte [ecx]
  101.       cmp   eax,ebx
  102.       je    yes_mouse_disable
  103.       movzx ebx, byte [ecx+32]
  104.       cmp   eax,ebx
  105.       je    yes_mouse_disable
  106.       mov   ebx,[Screen_Max_X]
  107.       inc   ebx
  108.       imul  ebx,10
  109.       add   ecx,ebx
  110.       movzx ebx, byte [ecx]
  111.       cmp   eax,ebx
  112.       je    yes_mouse_disable
  113.       movzx ebx, byte [ecx+32]
  114.       cmp   eax,ebx
  115.       je    yes_mouse_disable
  116.       jmp   no_mouse_disable
  117. yes_mouse_disable:
  118.       mov  edx,[CURRENT_TASK]
  119.       shl  edx,5
  120.       add  edx,window_data
  121.       movzx  eax, word [MOUSE_X]
  122.       movzx  ebx, word [MOUSE_Y]
  123.       mov  ecx,[edx+0]   ; mouse inside the area ?
  124.       add  eax,10
  125.       cmp  eax,ecx
  126.       jb   no_mouse_disable
  127.       sub  eax,10
  128.       add  ecx,[edx+8]
  129.       cmp  eax,ecx
  130.       jg   no_mouse_disable
  131.       mov  ecx,[edx+4]
  132.       add  ebx,14
  133.       cmp  ebx,ecx
  134.       jb   no_mouse_disable
  135.       sub  ebx,14
  136.       add  ecx,[edx+12]
  137.       cmp  ebx,ecx
  138.       jg   no_mouse_disable
  139. disable_m:
  140.       cmp  [MOUSE_VISIBLE], 0
  141.       jne  no_mouse_disable
  142.       pushf
  143.       cli
  144.       call draw_mouse_under
  145.       popf
  146.       mov  [MOUSE_VISIBLE], 1
  147. no_mouse_disable:
  148.       popad
  149.       ret
  150.  
  151. __sys_draw_pointer:
  152.         cmp   [mouse_pause],0
  153.         je    @f
  154.         ret
  155. @@:
  156.         push   eax
  157.         mov     eax,[timer_ticks]
  158.         sub     eax,[MouseTickCounter]
  159.         cmp     eax,1
  160.         ja      @f
  161.         pop    eax
  162.         ret
  163. @@:
  164.         mov     eax,[timer_ticks]
  165.         mov     [MouseTickCounter],eax
  166.         pop     eax
  167.         pushad
  168.     cmp    [MOUSE_VISIBLE], 0  ; mouse visible ?
  169.         je     chms00
  170.     mov [MOUSE_VISIBLE], 0
  171.         movzx  ebx,word [MOUSE_Y]
  172.         movzx  eax,word [MOUSE_X]
  173.         pushfd
  174.         cli
  175.         call   save_draw_mouse
  176.         popfd
  177. nodmu2:
  178.         popad
  179.         ret
  180. chms00:
  181.     mov  ecx, [x_under]
  182.     mov  edx, [y_under]
  183.         movzx  ebx,word [MOUSE_Y]
  184.         movzx  eax,word [MOUSE_X]
  185.         cmp    eax,ecx
  186.         jne    redrawmouse
  187.         cmp    ebx,edx
  188.         jne    redrawmouse
  189.         jmp    nodmp
  190. redrawmouse:
  191.         pushfd
  192.         cli
  193.         call   draw_mouse_under
  194.         call   save_draw_mouse
  195.         popfd
  196. nodmp:
  197.         popad
  198.         ret
  199.  
  200. proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
  201.  
  202.     mov  eax,[BtnState]
  203.     mov  [btn_down],eax
  204.  
  205.     mov  eax,[XMoving]
  206.     call mouse_acceleration
  207.     add  ax,[MOUSE_X]    ;[XCoordinate]
  208.     cmp  ax,0
  209.     jge  @@M1
  210.     mov  eax,0
  211.     jmp  @@M2
  212. @@M1:
  213.     cmp  ax, word [Screen_Max_X]   ;ScreenLength
  214.     jl   @@M2
  215.     mov  ax, word [Screen_Max_X]   ;ScreenLength-1
  216.  
  217. @@M2:
  218.     mov  [MOUSE_X],ax     ;[XCoordinate]
  219.  
  220.     mov  eax,[YMoving]
  221.     neg  eax
  222.     call mouse_acceleration
  223.  
  224.     add  ax,[MOUSE_Y]   ;[YCoordinate]
  225.     cmp  ax,0
  226.     jge  @@M3
  227.     mov  ax,0
  228.     jmp  @@M4
  229. @@M3:
  230.     cmp  ax, word [Screen_Max_Y]  ;ScreenHeigth
  231.     jl   @@M4
  232.     mov  ax, word [Screen_Max_Y] ;ScreenHeigth-1
  233.  
  234. @@M4:
  235.     mov  [MOUSE_Y],ax     ;[YCoordinate]
  236.  
  237.     mov  eax,[VScroll]
  238.     add  [mouse_scroll_v], eax
  239.  
  240.     mov  eax,[HScroll]
  241.     add  [mouse_scroll_h], eax
  242.  
  243.     mov  [mouse_active],1
  244.     mov  eax,[timer_ticks]
  245.     mov  [mouse_timer_ticks],eax
  246.     ret
  247. endp
  248.  
  249. mouse_acceleration:
  250.         push  eax
  251.         mov   eax,[timer_ticks]
  252.         sub   eax,[mouse_timer_ticks]
  253.         cmp   eax,[mouse_delay]
  254.         pop   eax
  255.         ja    @f
  256.         ;push  edx
  257.         imul  eax,[mouse_speed_factor]
  258.         ;pop   edx
  259. @@:
  260.         ret
  261.  
  262.  
  263. ;[ecx]     x
  264. ;[ecx+4]   y
  265. ;[ecx+8]   w
  266. ;[ecx+12]  h
  267.  
  268. align 4
  269. lock_cursor:
  270.  
  271.            pushfd
  272.            cli
  273.  
  274.            xor eax, eax
  275.            mov edx, [ecx]
  276.            mov ebx, [ecx+4]
  277.            cmp edx, [cur.right]
  278.            jg .done
  279.  
  280.            cmp ebx, [cur.bottom]
  281.            jg .done
  282.  
  283.            add edx, [ecx+8]
  284.            add ebx, [ecx+12]
  285.            cmp edx, [cur.left]
  286.            jle .done
  287.  
  288.            cmp ebx, [cur.top]
  289.            jle .done
  290.  
  291.            mov ecx, [CURRENT_TASK]
  292.  
  293.            mov ebx, [cur.left]
  294.            mov eax, [cur.top]
  295.            add ebx, [_display_data]
  296.            mul [_screen_width]
  297.            add ebx, eax
  298.  
  299.            cmp cl, [ebx]
  300.            je .disable
  301.  
  302.            cmp cl, [ebx+31]
  303.            je .disable
  304.  
  305.            mov eax, [_screen_width]
  306.            shl eax, 5
  307.            sub eax, [_screen_width]
  308.  
  309.            cmp cl, [ebx+eax]
  310.            je .disable
  311.  
  312.            cmp cl, [ebx+eax+31]
  313.            jne .done
  314.  
  315. .disable:
  316.            call draw_mouse_under
  317.  
  318.            mov eax, 1
  319. .done:
  320.            inc eax
  321.            mov [cur.lock], eax
  322.            popfd
  323.            ret
  324.  
  325. align 4
  326. unlock_cursor:
  327.            pushfd
  328.            cli
  329.            cmp [cur.lock], 2
  330.            jne .done
  331.  
  332.            call save_draw_mouse
  333. .done:
  334.            mov [cur.lock], 1
  335.            popfd
  336.            ret
  337.