Subversion Repositories Kolibri OS

Rev

Rev 389 | Rev 431 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. $Revision: 425 $
  2. ;   check mouse
  3. ;
  4. ;
  5. ;   FB00  ->   FB0F   mouse memory 00 chunk count - FB0A-B x - FB0C-D y
  6. ;   FB10  ->   FB17   mouse color mem
  7. ;   FB21              x move
  8. ;   FB22              y move
  9. ;   FB30              color temp
  10. ;   FB28              high bits temp
  11. ;   FB4A  ->   FB4D   FB4A-B x-under - FB4C-D y-under
  12. ;   FC00  ->   FCFE   com1/ps2 buffer
  13. ;   FCFF              com1/ps2 buffer count starting from FC00
  14.  
  15. uglobal
  16.   mousecount  dd  0x0
  17.   mousedata   dd  0x0
  18. endg
  19.  
  20. mouse_delay     dd  10
  21. mouse_speed_factor dw 3
  22.  
  23. include 'm_ps2.inc'
  24. include 'm_com1.inc'
  25. include 'm_com2.inc'
  26.  
  27.  
  28. ;test_mario79:
  29. ;        push   esi
  30. ;        push   eax
  31. ;        mov    [write_error_to],process_test_m79+43
  32. ;        movzx  eax,al  ;[DevErrorCode]
  33. ;        call   writehex
  34. ;        mov    esi,process_test_m79
  35. ;        call   sys_msg_board_str
  36. ;        pop    eax
  37. ;        pop    esi
  38. ;        ret
  39. ;process_test_m79 db 'K : Process - test Mario79 error    00000000',13,10,0
  40.  
  41. draw_mouse_under:
  42.         ; return old picture
  43.  
  44.         cmp [set_hw_cursor], 0
  45.         jz @F
  46.         pushad
  47.         movzx  eax,word [X_UNDER]
  48.         movzx  ebx,word [Y_UNDER]
  49.         stdcall [hw_restore], eax, ebx
  50.         popad
  51.         ret
  52. @@:
  53.         pushad
  54.         xor    ecx,ecx
  55.         xor    edx,edx
  56.         align  4
  57. mres:
  58.         movzx  eax,word [X_UNDER]
  59.         movzx  ebx,word [Y_UNDER]
  60.         add    eax,ecx
  61.         add    ebx,edx
  62.         push   ecx
  63.         push   edx
  64.         push   eax
  65.         push   ebx
  66.         mov    eax,edx
  67.         shl    eax,6
  68.         shl    ecx,2
  69.         add    eax,ecx
  70.         add    eax,mouseunder
  71.         mov    ecx,[eax]
  72.         pop    ebx
  73.         pop    eax
  74.         mov    edi, 1 ;force
  75.         call   [putpixel]
  76.         pop    edx
  77.         pop    ecx
  78.         inc    ecx
  79.         cmp    ecx, 16
  80.         jnz    mres
  81.         xor    ecx, ecx
  82.         inc    edx
  83.         cmp    edx, 24
  84.         jnz    mres
  85.         popad
  86.         ret
  87.  
  88. save_draw_mouse:
  89.  
  90.         cmp [set_hw_cursor], 0
  91.         jz @F
  92.         pushad
  93.  
  94.         mov    [X_UNDER],ax
  95.         mov    [Y_UNDER],bx
  96.         movzx  eax,word [MOUSE_Y]
  97.         movzx  ebx,word [MOUSE_X]
  98.         push eax
  99.         push ebx
  100.  
  101.         mov ecx, [ScreenWidth]
  102.         inc ecx
  103.         mul ecx
  104.  
  105.         movzx edx, byte [display_data+ebx+eax]
  106.         shl edx, 8
  107.         mov ecx, [edx+SLOT_BASE+APPDATA.cursor]
  108.  
  109.         cmp [ecx+CURSOR.magic], 'CURS'
  110.         jne .fail
  111. ;        cmp [ecx+CURSOR.size], CURSOR_SIZE
  112. ;        jne .fail
  113.         push ecx
  114.         call [set_hw_cursor]
  115.         popad
  116.         ret
  117. .fail:
  118.         mov ecx, [def_cursor]
  119.         mov [edx+SLOT_BASE+APPDATA.cursor], ecx
  120.         push ecx
  121.         call [set_hw_cursor]
  122.         popad
  123.         ret
  124.  
  125. @@:
  126.         pushad
  127.         ; save & draw
  128.         mov    [X_UNDER],ax
  129.         mov    [Y_UNDER],bx
  130.         push   eax
  131.         push   ebx
  132.         mov    ecx,0
  133.         mov    edx,0
  134.         align  4
  135. drm:
  136.         push   eax
  137.         push   ebx
  138.         push   ecx
  139.         push   edx
  140.         ; helloworld
  141.         push  ecx
  142.         add    eax,ecx  ; save picture under mouse
  143.         add    ebx,edx
  144.         push   ecx
  145.         call   getpixel
  146.         mov    [COLOR_TEMP],ecx
  147.         pop    ecx
  148.         mov    eax,edx
  149.         shl    eax,6
  150.         shl    ecx,2
  151.         add    eax,ecx
  152.         add    eax,mouseunder
  153.         mov    ebx,[COLOR_TEMP]
  154.         mov    [eax],ebx
  155.         pop  ecx
  156.         mov    edi,edx       ; y cycle
  157.         shl    edi,4       ; *16 bytes per row
  158.         add    edi,ecx       ; x cycle
  159.         mov    esi, edi
  160.         add    edi, esi
  161.         add    edi, esi       ; *3
  162.         add    edi,[MOUSE_PICTURE]      ; we have our str address
  163.         mov    esi, edi
  164.         add    esi, 16*24*3
  165.         push   ecx
  166.         mov    ecx, [COLOR_TEMP]
  167.         call   combine_colors
  168.         mov    [MOUSE_COLOR_MEM], ecx
  169.         pop    ecx
  170.         pop    edx
  171.         pop    ecx
  172.         pop    ebx
  173.         pop    eax
  174.         add    eax,ecx       ; we have x coord+cycle
  175.         add    ebx,edx       ; and y coord+cycle
  176.         push   ecx
  177.         mov    ecx, [MOUSE_COLOR_MEM]
  178.         mov    edi, 1
  179.         call   [putpixel]
  180.         pop    ecx
  181.         mov    ebx,[esp+0]      ; pure y coord again
  182.         mov    eax,[esp+4]      ; and x
  183.         inc    ecx          ; +1 cycle
  184.         cmp    ecx,16       ; if more than 16
  185.         jnz    drm
  186.         xor    ecx, ecx
  187.         inc    edx
  188.         cmp    edx,24
  189.         jnz    drm
  190.         add   esp,8
  191.         popad
  192.         ret
  193.  
  194.  
  195. combine_colors:
  196.       ; in
  197.       ; ecx - color ( 00 RR GG BB )
  198.       ; edi - ref to new color byte
  199.       ; esi - ref to alpha byte
  200.       ;
  201.       ; out
  202.       ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) )
  203.       push eax
  204.       push ebx
  205.       push edx
  206.       push ecx
  207.       xor ecx, ecx
  208.          ; byte 2
  209.       mov eax, 0xff
  210.       sub al, [esi+0]
  211.       mov ebx, [esp]
  212.       shr ebx, 16
  213.       and ebx, 0xff
  214.       mul ebx
  215.       shr eax, 8
  216.       add ecx, eax
  217.       xor eax, eax
  218.       xor ebx, ebx
  219.       mov al, [edi+0]
  220.       mov bl, [esi+0]
  221.       mul ebx
  222.       shr eax, 8
  223.       add ecx, eax
  224.       shl ecx, 8
  225.          ; byte 1
  226.       mov eax, 0xff
  227.       sub al, [esi+1]
  228.       mov ebx, [esp]
  229.       shr ebx, 8
  230.       and ebx, 0xff
  231.       mul ebx
  232.       shr eax, 8
  233.       add ecx, eax
  234.       xor eax, eax
  235.       xor ebx, ebx
  236.       mov al, [edi+1]
  237.       mov bl, [esi+1]
  238.       mul ebx
  239.       shr eax, 8
  240.       add ecx, eax
  241.       shl ecx, 8
  242.          ; byte 2
  243.       mov eax, 0xff
  244.       sub al, [esi+2]
  245.       mov ebx, [esp]
  246.       and ebx, 0xff
  247.       mul ebx
  248.       shr eax, 8
  249.       add ecx, eax
  250.       xor eax, eax
  251.       xor ebx, ebx
  252.       mov al, [edi+2]
  253.       mov bl, [esi+2]
  254.       mul ebx
  255.       shr eax, 8
  256.       add ecx, eax
  257.       pop eax
  258.       pop edx
  259.       pop ebx
  260.       pop eax
  261.       ret
  262.  
  263.  
  264. __sys_disable_mouse:
  265.       cmp  dword [MOUSE_VISIBLE],dword 0
  266.       je    @f
  267.       ret
  268. @@:
  269.       pushad
  270.       cmp  [CURRENT_TASK],dword 1
  271.       je   disable_m
  272.       mov  edx,[CURRENT_TASK]
  273.       shl  edx,5
  274.       add  edx,window_data
  275.       movzx  eax, word [MOUSE_X]
  276.       movzx  ebx, word [MOUSE_Y]
  277.       mov  ecx,[ScreenWidth]
  278.       inc  ecx
  279.       imul  ecx,ebx
  280.       add  ecx,eax
  281.       add  ecx, display_data
  282.       mov   eax, [CURRENT_TASK]
  283.       movzx ebx, byte [ecx]
  284.       cmp   eax,ebx
  285.       je    yes_mouse_disable
  286.       movzx ebx, byte [ecx+16]
  287.       cmp   eax,ebx
  288.       je    yes_mouse_disable
  289.       mov   ebx,[ScreenWidth]
  290.       inc   ebx
  291.       imul  ebx,10
  292.       add   ecx,ebx
  293.       movzx ebx, byte [ecx]
  294.       cmp   eax,ebx
  295.       je    yes_mouse_disable
  296.       movzx ebx, byte [ecx+16]
  297.       cmp   eax,ebx
  298.       je    yes_mouse_disable
  299.       jmp   no_mouse_disable
  300. yes_mouse_disable:
  301.       mov  edx,[CURRENT_TASK]
  302.       shl  edx,5
  303.       add  edx,window_data
  304.       movzx  eax, word [MOUSE_X]
  305.       movzx  ebx, word [MOUSE_Y]
  306.       mov  ecx,[edx+0]   ; mouse inside the area ?
  307.       add  eax,14
  308.       cmp  eax,ecx
  309.       jb   no_mouse_disable
  310.       sub  eax,14
  311.       add  ecx,[edx+8]
  312.       cmp  eax,ecx
  313.       jg   no_mouse_disable
  314.       mov  ecx,[edx+4]
  315.       add  ebx,20
  316.       cmp  ebx,ecx
  317.       jb   no_mouse_disable
  318.       sub  ebx,20
  319.       add  ecx,[edx+12]
  320.       cmp  ebx,ecx
  321.       jg   no_mouse_disable
  322. disable_m:
  323.       cmp  dword [MOUSE_VISIBLE],dword 0
  324.       jne  no_mouse_disable
  325.       pushf
  326.       cli
  327.       call draw_mouse_under
  328.       popf
  329.       mov  [MOUSE_VISIBLE],dword 1
  330. no_mouse_disable:
  331.       popad
  332.       ret
  333.  
  334. __sys_draw_pointer:
  335.         cmp   [mouse_pause],0
  336.         je    @f
  337.         ret
  338. @@:
  339.         push   eax
  340.         mov     eax,[timer_ticks]
  341.         sub     eax,[MouseTickCounter]
  342.         cmp     eax,1
  343.         ja      @f
  344.         pop    eax
  345.         ret
  346. @@:
  347.         mov     eax,[timer_ticks]
  348.         mov     [MouseTickCounter],eax
  349.         pop     eax
  350.         pushad
  351.         cmp    dword [MOUSE_VISIBLE],dword 0  ; mouse visible ?
  352.         je     chms00
  353.         mov     [MOUSE_VISIBLE], dword 0
  354.         movzx  ebx,word [MOUSE_Y]
  355.         movzx  eax,word [MOUSE_X]
  356.         pushfd
  357.         cli
  358.         call   save_draw_mouse
  359.         popfd
  360. nodmu2:
  361.         popad
  362.         ret
  363. chms00:
  364.         movzx  ecx,word [X_UNDER]
  365.         movzx  edx,word [Y_UNDER]
  366.         movzx  ebx,word [MOUSE_Y]
  367.         movzx  eax,word [MOUSE_X]
  368.         cmp    eax,ecx
  369.         jne    redrawmouse
  370.         cmp    ebx,edx
  371.         jne    redrawmouse
  372.         jmp    nodmp
  373. redrawmouse:
  374.         pushfd
  375.         cli
  376.         call   draw_mouse_under
  377.         call   save_draw_mouse
  378.         popfd
  379. nodmp:
  380.         popad
  381.         ret
  382.  
  383.