Subversion Repositories Kolibri OS

Rev

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

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