Subversion Repositories Kolibri OS

Rev

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