Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | 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. __sys_draw_mouse_under:
  41.         ; return old picture
  42.  
  43.         pushad
  44.  
  45.         xor    ecx,ecx
  46.         xor    edx,edx
  47.         mov    esi,mouseunder-4
  48.  
  49.         align  4
  50.       mres:
  51.  
  52.         add    esi,4
  53.  
  54.         movsx  eax,word[0xfb4a]
  55.         add    eax,ecx
  56.         js     .skip
  57.         movsx  ebx,word[0xfb4c]
  58.         add    ebx,edx
  59.         js     .skip
  60.  
  61.         push   ecx
  62.         push   edx
  63.         mov    ecx,[esi]
  64.  
  65.         mov    edi,1 ;force
  66.         push   esi
  67.         call   [putpixel]
  68.         pop    esi
  69.  
  70.         pop    edx
  71.         pop    ecx
  72.     .skip:
  73.         inc    ecx
  74.         cmp    ecx,32
  75.  
  76.         jnz    mres
  77.         xor    ecx, ecx
  78.         inc    edx
  79.         cmp    edx,32
  80.         jnz    mres
  81.  
  82.         popad
  83.         ret
  84.  
  85.  
  86. save_draw_mouse:
  87.         pushad
  88.         ; save & draw
  89.         mov    [0xfb4a],ax
  90.         mov    [0xfb4c],bx
  91.         push   eax
  92.         push   ebx
  93.         xor    ecx,ecx
  94.         mov    edx,ecx
  95.         mov    esi,mouseunder-4;3
  96.         mov    edi,mousepointer+62-4
  97.  
  98.         mov    dword[0x6900],mouseunder+mousecomb
  99.  
  100.       drm:
  101.  
  102.         add    esi,4;3
  103.         add    edi,4
  104.  
  105.         push   eax ebx ecx edx
  106.  
  107.         push   eax ebx
  108.         add    eax,ecx  ; save picture under mouse
  109.         js     @f
  110.         add    ebx,edx
  111.         js     @f
  112.         push   esi edi
  113.         call   [getpixel]
  114.         pop    edi esi
  115.         mov    [esi],ecx
  116.         pop    ebx eax
  117.  
  118.         push   esi edi
  119.         call   combine_colors
  120.         pop    edi esi
  121.         mov    [0xfb10],ecx
  122.  
  123.         pop    edx ecx ebx eax
  124.  
  125.         xchg   esi,[0x6900]
  126.         push   dword[0xFB10]
  127.         pop    dword[esi]
  128.         add    esi,3
  129.         xchg   esi,[0x6900]
  130.  
  131.         jc     mnext
  132.  
  133.         add    eax,ecx       ; we have x coord+cycle
  134.         js     mnext
  135.         add    ebx,edx       ; and y coord+cycle
  136.         js     mnext
  137.  
  138.         push   ecx edi esi
  139.         mov    ecx, [0xfb10]
  140.         mov    edi, 1
  141.         call   [putpixel]
  142.         pop    esi edi ecx
  143.         jmp    mnext
  144.     @@: add    esp,8
  145.         pop    edx ecx ebx eax
  146.       mnext:
  147.  
  148.         mov    ebx,[esp+0]      ; pure y coord again
  149.         mov    eax,[esp+4]      ; and x
  150.  
  151.         inc    ecx          ; +1 cycle
  152.         cmp    ecx,32
  153.         jnz    drm
  154.         xor    ecx,ecx
  155.         inc    edx
  156.         cmp    edx,32
  157.         jnz    drm
  158.         pop    ebx
  159.         pop    eax
  160.  
  161.         popad
  162.         ret
  163.  
  164.  
  165. combine_colors:
  166.       ; in
  167.       ; ecx - color ( 00 RR GG BB )
  168.       ; edi - ref to new color byte
  169.       ; esi - ref to alpha byte
  170.       ;
  171.       ; out
  172.       ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) )
  173.     ; colors:
  174.     ;   [esp] = background:
  175.     ;   [edi] = cursor
  176.     ;   <ecx> = combined
  177.  
  178.     cmp byte[edi+3],0
  179.     jne @f
  180.     stc
  181.     ret
  182.   @@:
  183.     cmp byte[edi+3],255
  184.     jne @f
  185.     mov ecx,[edi]
  186.     and ecx,0x00FFFFFF
  187.     clc
  188.     ret
  189.   @@:
  190.       push ecx
  191.  
  192.     xor  ecx,ecx
  193.  
  194.     movzx eax,byte[edi+2]
  195.     movzx ebx,byte[esp+2]
  196.     sub   eax,ebx
  197.     movzx ebx,byte[edi+3]
  198.     imul  ebx
  199.     xor   edx,edx
  200.     mov   ebx,255
  201.     div   ebx
  202.     add   al,[esp+2]
  203.     mov   cl,al
  204.     shl   ecx,8
  205.  
  206.     movzx eax,byte[edi+1]
  207.     movzx ebx,byte[esp+1]
  208.     sub   eax,ebx
  209.     movzx ebx,byte[edi+3]
  210.     imul  ebx
  211.     xor   edx,edx
  212.     mov   ebx,255
  213.     div   ebx
  214.     add   al,[esp+1]
  215.     mov   cl,al
  216.     shl   ecx,8
  217.  
  218.     movzx eax,byte[edi+0]
  219.     movzx ebx,byte[esp+0]
  220.     sub   eax,ebx
  221.     movzx ebx,byte[edi+3]
  222.     imul  ebx
  223.     xor   edx,edx
  224.     mov   ebx,255
  225.     div   ebx
  226.     add   al,[esp+0]
  227.     mov   cl,al
  228.  
  229.     add   esp,4
  230.  
  231.     clc
  232.       ret
  233.  
  234.  
  235. __sys_disable_mouse:
  236.       cmp  dword [0xf204],dword 0
  237.       je    @f
  238.       ret
  239. @@:  
  240.       pushad
  241.       cmp  [0x3000],dword 1
  242.       je   disable_m
  243.       mov  edx,[0x3000]
  244.       shl  edx,5
  245.       add  edx,window_data
  246.       movzx  eax,word[0xfb0a]
  247.       movzx  ecx,word[mousepointer+10]
  248.       sub    eax,ecx
  249.       movzx  ebx,word[0xfb0c]
  250.       movzx  ecx,word[mousepointer+12]
  251.       sub    ebx,ecx
  252.       mov  ecx,[0xfe00]
  253.       imul  ecx,ebx
  254.       add  ecx,eax
  255.       add  ecx, display_data
  256. ;     mov   eax, [0x3000]
  257.       movzx eax, byte [edx+twdw+0xe]
  258.       movzx ebx, byte [ecx]
  259.       cmp   eax,ebx
  260.       je    yes_mouse_disable
  261.       movzx ebx, byte [ecx+32]
  262.       cmp   eax,ebx
  263.       je    yes_mouse_disable
  264.       mov   ebx,[0xfe00]
  265.       inc   ebx
  266.       imul  ebx,32
  267.       add   ecx,ebx
  268.       movzx ebx, byte [ecx]
  269.       cmp   eax,ebx
  270.       je    yes_mouse_disable
  271.       movzx ebx, byte [ecx+32]
  272.       cmp   eax,ebx
  273.       je    yes_mouse_disable
  274.       jmp   no_mouse_disable
  275. yes_mouse_disable:
  276.       mov  edx,[0x3000]
  277.       shl  edx,5
  278.       add  edx,window_data
  279.       movzx  eax, word [0xfb0a]
  280.       movzx  ebx, word [0xfb0c]
  281.       movzx  ecx,word[mousepointer+10]
  282.       sub    eax,ecx
  283.       movzx  ecx,word[mousepointer+12]
  284.       sub    ebx,ecx
  285.       mov  ecx,[edx+0]   ; mouse inside the area ?
  286.       add  eax,32
  287.       cmp  eax,ecx
  288.       jl   no_mouse_disable
  289.       sub  eax,32
  290.       add  ecx,[edx+8]
  291.       cmp  eax,ecx
  292.       jg   no_mouse_disable
  293.       mov  ecx,[edx+4]
  294.       add  ebx,32
  295.       cmp  ebx,ecx
  296.       jl   no_mouse_disable
  297.       sub  ebx,32
  298.       add  ecx,[edx+12]
  299.       cmp  ebx,ecx
  300.       jg   no_mouse_disable
  301. disable_m:
  302.       cmp  dword [0xf204],dword 0
  303.       jne  no_mouse_disable
  304.       cli
  305.        call [draw_mouse_under]
  306.       sti
  307.       mov  [0xf204],dword 1
  308. no_mouse_disable:
  309.       popad
  310.       ret
  311.  
  312. __sys_draw_pointer:
  313.         cmp   [mouse_pause],0
  314.         je    @f
  315.         ret
  316. @@:
  317.         push   eax
  318.         mov     eax,[timer_ticks]
  319.         sub     eax,[MouseTickCounter]
  320.         cmp     eax,1
  321.         ja      @f
  322.         pop    eax
  323.         ret
  324. @@:
  325.         mov     eax,[timer_ticks]
  326.         mov     [MouseTickCounter],eax
  327.         pop     eax
  328.         pushad
  329.         cmp    dword [0xf204],dword 0  ; mouse visible ?
  330.         je     chms00
  331.         mov     [0xf204], dword 0
  332.         movzx  ebx,word [0xfb0c]
  333.         movzx  eax,word [0xfb0a]
  334.         movzx  esi,word[mousepointer+10]
  335.         sub    eax,esi
  336.         movzx  esi,word[mousepointer+12]
  337.         sub    ebx,esi
  338.         cli
  339.         call   save_draw_mouse
  340.         sti
  341. nodmu2:
  342.         popad
  343.         ret
  344. chms00:
  345.         movsx  ecx,word[0xfb4a]
  346.         movsx  edx,word[0xfb4c]
  347.         movzx  ebx,word [0xfb0c]
  348.         movzx  eax,word [0xfb0a]
  349.         movzx  esi,word[mousepointer+10]
  350.         sub    eax,esi
  351.         movzx  esi,word[mousepointer+12]
  352.         sub    ebx,esi
  353.         cmp    eax,ecx
  354.         jne    redrawmouse
  355.         cmp    ebx,edx
  356.         jne    redrawmouse
  357.         jmp    nodmp
  358. redrawmouse:
  359.         cli
  360.         call   [draw_mouse_under]
  361.         call   save_draw_mouse
  362.         sti
  363. nodmp:
  364.         popad
  365.         ret
  366.  
  367.