Subversion Repositories Kolibri OS

Rev

Rev 214 | Rev 230 | 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 [0xfb4a]
  47.         movzx  ebx,word [0xfb4c]
  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 [0xfb4a]
  58.         movzx  ebx,word [0xfb4c]
  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    [0xfb4a],ax
  94.         mov    [0xfb4c],bx
  95.         movzx  eax,word [0xfb0c]
  96.         movzx  ebx,word [0xfb0a]
  97.         push eax
  98.         push ebx
  99.  
  100.         mov ecx, [0xfe00]
  101.         inc ecx
  102.         mul ecx
  103.         movzx edx, byte [display_data+ebx+eax]
  104.         shl edx, 8
  105.         push [edx+PROC_BASE+APPDATA.cursor]
  106.         call [set_hw_cursor]
  107.         popad
  108.         ret
  109. @@:
  110.         pushad
  111.         ; save & draw
  112.         mov    [0xfb4a],ax
  113.         mov    [0xfb4c],bx
  114.         push   eax
  115.         push   ebx
  116.         mov    ecx,0
  117.         mov    edx,0
  118.         align  4
  119. drm:
  120.         push   eax
  121.         push   ebx
  122.         push   ecx
  123.         push   edx
  124.         ; helloworld
  125.         push  ecx
  126.         add    eax,ecx  ; save picture under mouse
  127.         add    ebx,edx
  128.         push   ecx
  129.         call   getpixel
  130.         mov    [0xfb30],ecx
  131.         pop    ecx
  132.         mov    eax,edx
  133.         shl    eax,6
  134.         shl    ecx,2
  135.         add    eax,ecx
  136.         add    eax,mouseunder
  137.         mov    ebx,[0xfb30]
  138.         mov    [eax],ebx
  139.         pop  ecx
  140.         mov    edi,edx       ; y cycle
  141.         shl    edi,4       ; *16 bytes per row
  142.         add    edi,ecx       ; x cycle
  143.         mov    esi, edi
  144.         add    edi, esi
  145.         add    edi, esi       ; *3
  146.         add    edi,[0xf200]      ; we have our str address
  147.         mov    esi, edi
  148.         add    esi, 16*24*3
  149.         push   ecx
  150.         mov    ecx, [0xfb30]
  151.         call   combine_colors
  152.         mov    [0xfb10], ecx
  153.         pop    ecx
  154.         pop    edx
  155.         pop    ecx
  156.         pop    ebx
  157.         pop    eax
  158.         add    eax,ecx       ; we have x coord+cycle
  159.         add    ebx,edx       ; and y coord+cycle
  160.         push   ecx
  161.         mov    ecx, [0xfb10]
  162.         mov    edi, 1
  163.         call   [putpixel]
  164.         pop    ecx
  165.         mov    ebx,[esp+0]      ; pure y coord again
  166.         mov    eax,[esp+4]      ; and x
  167.         inc    ecx          ; +1 cycle
  168.         cmp    ecx,16       ; if more than 16
  169.         jnz    drm
  170.         xor    ecx, ecx
  171.         inc    edx
  172.         cmp    edx,24
  173.         jnz    drm
  174.         add   esp,8
  175.         popad
  176.         ret
  177.  
  178.  
  179. combine_colors:
  180.       ; in
  181.       ; ecx - color ( 00 RR GG BB )
  182.       ; edi - ref to new color byte
  183.       ; esi - ref to alpha byte
  184.       ;
  185.       ; out
  186.       ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) )
  187.       push eax
  188.       push ebx
  189.       push edx
  190.       push ecx
  191.       xor ecx, ecx
  192.          ; byte 2
  193.       mov eax, 0xff
  194.       sub al, [esi+0]
  195.       mov ebx, [esp]
  196.       shr ebx, 16
  197.       and ebx, 0xff
  198.       mul ebx
  199.       shr eax, 8
  200.       add ecx, eax
  201.       xor eax, eax
  202.       xor ebx, ebx
  203.       mov al, [edi+0]
  204.       mov bl, [esi+0]
  205.       mul ebx
  206.       shr eax, 8
  207.       add ecx, eax
  208.       shl ecx, 8
  209.          ; byte 1
  210.       mov eax, 0xff
  211.       sub al, [esi+1]
  212.       mov ebx, [esp]
  213.       shr ebx, 8
  214.       and ebx, 0xff
  215.       mul ebx
  216.       shr eax, 8
  217.       add ecx, eax
  218.       xor eax, eax
  219.       xor ebx, ebx
  220.       mov al, [edi+1]
  221.       mov bl, [esi+1]
  222.       mul ebx
  223.       shr eax, 8
  224.       add ecx, eax
  225.       shl ecx, 8
  226.          ; byte 2
  227.       mov eax, 0xff
  228.       sub al, [esi+2]
  229.       mov ebx, [esp]
  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+2]
  237.       mov bl, [esi+2]
  238.       mul ebx
  239.       shr eax, 8
  240.       add ecx, eax
  241.       pop eax
  242.       pop edx
  243.       pop ebx
  244.       pop eax
  245.       ret
  246.  
  247.  
  248. __sys_disable_mouse:
  249.       cmp  dword [0xf204],dword 0
  250.       je    @f
  251.       ret
  252. @@:
  253.       pushad
  254.       cmp  [0x3000],dword 1
  255.       je   disable_m
  256.       mov  edx,[0x3000]
  257.       shl  edx,5
  258.       add  edx,window_data
  259.       movzx  eax, word [0xfb0a]
  260.       movzx  ebx, word [0xfb0c]
  261.       mov  ecx,[0xfe00]
  262.       inc  ecx
  263.       imul  ecx,ebx
  264.       add  ecx,eax
  265.       add  ecx, display_data
  266.       mov   eax, [0x3000]
  267.       movzx ebx, byte [ecx]
  268.       cmp   eax,ebx
  269.       je    yes_mouse_disable
  270.       movzx ebx, byte [ecx+16]
  271.       cmp   eax,ebx
  272.       je    yes_mouse_disable
  273.       mov   ebx,[0xfe00]
  274.       inc   ebx
  275.       imul  ebx,10
  276.       add   ecx,ebx
  277.       movzx ebx, byte [ecx]
  278.       cmp   eax,ebx
  279.       je    yes_mouse_disable
  280.       movzx ebx, byte [ecx+16]
  281.       cmp   eax,ebx
  282.       je    yes_mouse_disable
  283.       jmp   no_mouse_disable
  284. yes_mouse_disable:
  285.       mov  edx,[0x3000]
  286.       shl  edx,5
  287.       add  edx,window_data
  288.       movzx  eax, word [0xfb0a]
  289.       movzx  ebx, word [0xfb0c]
  290.       mov  ecx,[edx+0]   ; mouse inside the area ?
  291.       add  eax,14
  292.       cmp  eax,ecx
  293.       jb   no_mouse_disable
  294.       sub  eax,14
  295.       add  ecx,[edx+8]
  296.       cmp  eax,ecx
  297.       jg   no_mouse_disable
  298.       mov  ecx,[edx+4]
  299.       add  ebx,20
  300.       cmp  ebx,ecx
  301.       jb   no_mouse_disable
  302.       sub  ebx,20
  303.       add  ecx,[edx+12]
  304.       cmp  ebx,ecx
  305.       jg   no_mouse_disable
  306. disable_m:
  307.       cmp  dword [0xf204],dword 0
  308.       jne  no_mouse_disable
  309.       cli
  310.       call draw_mouse_under
  311.       sti
  312.       mov  [0xf204],dword 1
  313. no_mouse_disable:
  314.       popad
  315.       ret
  316.  
  317. __sys_draw_pointer:
  318.         cmp   [mouse_pause],0
  319.         je    @f
  320.         ret
  321. @@:
  322.         push   eax
  323.         mov     eax,[timer_ticks]
  324.         sub     eax,[MouseTickCounter]
  325.         cmp     eax,1
  326.         ja      @f
  327.         pop    eax
  328.         ret
  329. @@:
  330.         mov     eax,[timer_ticks]
  331.         mov     [MouseTickCounter],eax
  332.         pop     eax
  333.         pushad
  334.         cmp    dword [0xf204],dword 0  ; mouse visible ?
  335.         je     chms00
  336.         mov     [0xf204], dword 0
  337.         movzx  ebx,word [0xfb0c]
  338.         movzx  eax,word [0xfb0a]
  339.         cli
  340.         call   save_draw_mouse
  341.         sti
  342. nodmu2:
  343.         popad
  344.         ret
  345. chms00:
  346.         movzx  ecx,word [0xfb4a]
  347.         movzx  edx,word [0xfb4c]
  348.         movzx  ebx,word [0xfb0c]
  349.         movzx  eax,word [0xfb0a]
  350.         cmp    eax,ecx
  351.         jne    redrawmouse
  352.         cmp    ebx,edx
  353.         jne    redrawmouse
  354.         jmp    nodmp
  355. redrawmouse:
  356.         cli
  357.         call   draw_mouse_under
  358.         call   save_draw_mouse
  359.         sti
  360. nodmp:
  361.         popad
  362.         ret
  363.  
  364.