Subversion Repositories Kolibri OS

Rev

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

  1. max_buttons=4095
  2. dececx:
  3.     push edx
  4.     push ecx
  5.  
  6.     mov  edx,2
  7.   .loop:
  8.  
  9.     cmp   byte [esp+edx],0x20
  10.     jae   @f
  11.     mov   [esp+edx],byte 0x20
  12.    @@:
  13.     sub   [esp+edx],byte 0x20
  14.  
  15.     dec  edx
  16.     jns  .loop
  17.  
  18.     pop  ecx
  19.     pop  edx
  20.     ret
  21.    
  22. incecx:
  23.     push edx
  24.     push ecx
  25.    
  26.     mov  edx,2
  27.   .loop:
  28.    
  29.     cmp  byte [esp+edx],0xdf
  30.     jbe  @f
  31.     mov  [esp+edx],byte 0xdf
  32.    @@:
  33.     add  [esp+edx],byte 0x20
  34.    
  35.     dec  edx
  36.     jns  .loop
  37.     pop  ecx
  38.     pop  edx
  39.     ret
  40.    
  41. incecx2:
  42.     push edx
  43.     push ecx
  44.    
  45.     mov  edx,2
  46.   .loop:
  47.    
  48.     cmp  byte [esp+edx],0xeb
  49.     jbe  @f
  50.     mov  [esp+edx],byte 0xeb
  51.    @@:
  52.     add  [esp+edx],byte 0x14
  53.    
  54.     dec  edx
  55.     jns  .loop
  56.     pop  ecx
  57.     pop  edx
  58.     ret
  59.  
  60. drawbuttonframes:
  61.  
  62.         push  esi
  63.         push  edi
  64.         push  eax
  65.         push  ebx
  66.         push  ecx
  67.         push  edx
  68.  
  69.         shr   eax,16
  70.         shr   ebx,16
  71.         mov   edx,[0x3010]
  72.  
  73.         add   eax,[edx-twdw]
  74.         add   ebx,[edx-twdw+4]
  75.         mov   cx,ax
  76.         mov   dx,bx
  77.         shl   eax,16
  78.         shl   ebx,16
  79.         mov   ax,cx
  80.         mov   bx,dx
  81.         add   ax,word [esp+12]
  82.         mov   esi,ebx
  83.         mov   edi,0
  84.         mov   ecx,[esp+0]
  85.         call  incecx
  86.         call  [draw_line]
  87.  
  88.         movzx edx,word [esp+8]
  89.         add   ebx,edx
  90.         shl   edx,16
  91.         add   ebx,edx
  92.         mov   ecx,[esp+0]
  93.         call  dececx
  94.         call  [draw_line]
  95.  
  96.         mov   ebx,esi
  97.         push  edx
  98.         mov   edx,eax
  99.         shr   edx,16
  100.         mov   ax,dx
  101.         mov   edx,ebx
  102.         shr   edx,16
  103.         mov   bx,dx
  104.         mov   dx,[esp+8+4]
  105.         add   bx,dx
  106.         pop   edx
  107.         mov   edi,0
  108.         mov   ecx,[esp+0]
  109.         call  incecx
  110.         call  [draw_line]
  111.  
  112.         mov   esi,edx
  113.         mov   dx,[esp+12]
  114.         add   ax,dx
  115.         shl   edx,16
  116.         add   eax,edx
  117.         add   ebx,1*65536
  118.         mov   edx,esi
  119.         mov   ecx,[esp+0]
  120.         call  dececx
  121.         call  [draw_line]
  122.  
  123.         pop   edx
  124.         pop   ecx
  125.         pop   ebx
  126.         pop   eax
  127.         pop   edi
  128.         pop   esi
  129.  
  130.         ret
  131.  
  132. button_dececx:
  133.  
  134.         cmp   [buttontype],dword 1
  135.         jne   .finish
  136. ;        je    bdece
  137. ;        ret
  138. ;      bdece:
  139.         push  eax
  140.         mov   eax,0x01
  141.         cmp   edi,20
  142.         jg    @f
  143.         mov   eax,0x02
  144.       @@:
  145.         test  ecx,0xff
  146.         jz    @f
  147.         sub   ecx,eax
  148.       @@:
  149.         shl   eax,8
  150.         test  ecx,0xff00
  151.         jz    @f
  152.         sub   ecx,eax
  153.       @@:
  154.         shl   eax,8
  155.         test  ecx,0xff0000
  156.         jz    @f
  157.         sub   ecx,eax
  158.       @@:
  159.         pop    eax
  160.       .finish:
  161.         ret
  162.  
  163.  
  164. sys_button:
  165.  
  166.         test  ecx,0x80000000
  167.         jnz   remove_button
  168.  
  169.         push  esi
  170.         push  edi
  171.         push  eax
  172.         push  ebx
  173.         push  ecx
  174.         push  edx
  175.  
  176.         or    ax,ax
  177.         jle   noaddbutt
  178.         or    bx,bx
  179.         jle   noaddbutt
  180.  
  181.         test  ecx,0x40000000
  182.         jnz   button_no_draw
  183.  
  184.         pushad                       ; button body
  185.         push  ebx
  186.         shr   eax,16
  187.         shr   ebx,16
  188.         mov   edx,[0x3010]
  189.         mov   esi,[edx-twdw]
  190.         mov   edi,[edx-twdw+4]
  191.         add   eax,esi
  192.         add   ebx,edi
  193.         mov   cx,ax
  194.         mov   dx,bx
  195.         shl   eax,16
  196.         shl   ebx,16
  197.         mov   ax,cx
  198.         mov   bx,dx
  199.         movzx ecx,word [4+32+esp+12]
  200.         add   eax,ecx
  201.         mov   ecx,[4+32+esp+0]
  202.         cmp   [buttontype],dword 0
  203.         je    @f
  204.         call  incecx2
  205.        @@:
  206.         movzx edi,word [esp]
  207.  
  208.         pop   edx
  209.         and   edx, 0xFFFF
  210.  
  211.      .newline:
  212.         call  button_dececx
  213.         push  edi
  214.         xor   edi, edi
  215.         call  [draw_line]
  216.         pop   edi
  217.         add   ebx,1*65536+1   ; [ y start | y end ]
  218.         dec   edx
  219.         jnz   .newline
  220.         popad
  221.  
  222.         call  drawbuttonframes
  223.  
  224.       button_no_draw:
  225.  
  226.         and   ecx,0xffff
  227.  
  228.         mov   edi,[0x3010]
  229.         sub   edi,twdw
  230.  
  231.         mov   edi,[0xfe88]
  232.         movzx eax,word [edi]
  233.         cmp   eax,max_buttons
  234.         jge   noaddbutt
  235.         inc   eax
  236.         mov   [edi],ax
  237.  
  238.         shl   eax,4
  239.         add   eax,edi
  240.  
  241.         mov   bx,[0x3000]
  242.         mov   [eax],bx
  243.  
  244.         add   eax,2         ; save button id number
  245.         mov   ebx,[esp+4]
  246.         mov   [eax],bx      ; bits 0-15
  247.         shr   ebx,16
  248.         mov   [eax-2+0xc],bx; bits 16-31
  249.         add   eax,2         ; x start
  250.         mov   bx,[esp+12+2]
  251.         mov   [eax],bx
  252.         add   eax,2         ; x size
  253.         mov   bx,[esp+12+0]
  254.         mov   [eax],bx
  255.         add   eax,2         ; y start
  256.         mov   bx,[esp+8+2]
  257.         mov   [eax],bx
  258.         add   eax,2         ; y size
  259.         mov   bx,[esp+8+0]
  260.         mov   [eax],bx
  261.  
  262.      noaddbutt:
  263.  
  264.         pop   edx
  265.         pop   ecx
  266.         pop   ebx
  267.         pop   eax
  268.         pop   edi
  269.         pop   esi
  270.  
  271.         ret
  272.  
  273.  
  274. remove_button:
  275.  
  276.     and  ecx,0x7fffffff
  277.  
  278.   rnewba2:
  279.  
  280.     mov   edi,[0xfe88]
  281.     mov   eax,edi
  282.     movzx ebx,word [edi]
  283.     inc   bx
  284.  
  285.   rnewba:
  286.  
  287.     dec   bx
  288.     jz    rnmba
  289.  
  290.     add   eax,0x10
  291.  
  292.     mov   dx,[0x3000]
  293.     cmp   dx,[eax]
  294.     jnz   rnewba
  295.  
  296.     cmp   cx,[eax+2]
  297.     jnz   rnewba
  298.  
  299.     pushad
  300.     mov   ecx,ebx
  301.     inc   ecx
  302.     shl   ecx,4
  303.     mov   ebx,eax
  304.     add   eax,0x10
  305.     call  memmove
  306.     dec   dword [edi]
  307.     popad
  308.  
  309.     jmp   rnewba2
  310.  
  311.   rnmba:
  312.  
  313.     ret
  314.  
  315. find_pressed_button_frames:
  316.  
  317.         pushad
  318.  
  319.         movzx ebx,word [eax+0]
  320.         shl   ebx,5
  321.         add   ebx,window_data
  322.         movzx ecx,word [ebx+0]     ; window x start
  323.         movzx edx,word [eax+4]     ; button x start
  324.         add   ecx,edx
  325.         push  ecx
  326.  
  327.         mov   dx,[eax+6]     ; button x size
  328.         add   cx,dx
  329.         mov   esi,ecx
  330.         inc   esi
  331.         mov   cx,[ebx+4]     ; window y start
  332.         mov   dx,[eax+8]     ; button y start
  333.         add   ecx,edx
  334.         mov   ebx,ecx
  335.         mov   dx,[eax+10]    ; button y size
  336.         add   dx,cx
  337.         inc   dx
  338.  
  339.         pop   eax
  340.  
  341.         ; eax x beginning
  342.         ; ebx y beginning
  343.         ; esi x end
  344.         ; edx y end
  345.         ; ecx color
  346.  
  347.         mov   [pressed_button_eax],eax
  348.         mov   [pressed_button_ebx],ebx
  349.         mov   [pressed_button_ecx],ecx
  350.         mov   [pressed_button_edx],edx
  351.         mov   [pressed_button_esi],esi
  352.  
  353.         popad
  354.         ret
  355.  
  356. uglobal
  357.   pressed_button_eax  dd  0
  358.   pressed_button_ebx  dd  0
  359.   pressed_button_ecx  dd  0
  360.   pressed_button_edx  dd  0
  361.   pressed_button_esi  dd  0
  362. endg
  363.  
  364. ; negative button image
  365.  
  366. negativebutton:
  367.         ; If requested, do not display button
  368.         ; boarder on press.
  369.         test  ebx,0x20000000
  370.         jz    draw_negative_button
  371.         ret
  372.       draw_negative_button:
  373.  
  374.         pushad
  375.  
  376.         mov   eax,[pressed_button_eax]
  377.         mov   ebx,[pressed_button_ebx]
  378.         mov   ecx,[pressed_button_ecx]
  379.         mov   edx,[pressed_button_edx]
  380.         mov   esi,[pressed_button_esi]
  381.         mov   ecx,0x01000000
  382.  
  383.         dec   edx
  384.         push  edx
  385.         inc   edx
  386.         dec   esi
  387.         push  esi
  388.         inc   esi
  389.  
  390.         push  eax
  391.         push  ebx
  392.         push  ecx
  393.         push  edx
  394.         push  edi
  395.  
  396.         call  [disable_mouse]
  397.  
  398.       bdbnewline:
  399.         mov   edi,1    ; force
  400.         cmp   eax,[esp+16]
  401.         jz    bneg
  402.         cmp   eax,[esp+20]
  403.         jz    bneg
  404.         cmp   ebx,[esp+12]
  405.         jz    bneg
  406.         cmp   ebx,[esp+24]
  407.         jnz   nbneg
  408. ;        jz    bneg
  409. ;        jmp   nbneg
  410.  
  411.       bneg:
  412.  
  413.         ;;;call  [disable_mouse]
  414.         call  [putpixel]
  415.  
  416.       nbneg:
  417.  
  418.         inc   eax
  419.         cmp   eax,esi
  420.         jnz   bdbnewline
  421.         mov   eax,[esp+16]
  422.         inc   ebx
  423.         cmp   ebx,edx
  424.         jnz   bdbnewline
  425.  
  426.         add   esp,28
  427.  
  428.         popad
  429.  
  430.         ret
  431.  
  432. ; check buttons
  433.  
  434.  
  435. ; 0000 word process number
  436. ; 0002 word button id number : bits 0-15
  437. ; 0004 word x start
  438. ; 0006 word x size
  439. ; 0008 word y start
  440. ; 000A word y size
  441. ; 000C word button id number : bits 16-31
  442. ;
  443. ; button table in 0x10 increments
  444. ;
  445. ; first at 0x10
  446.  
  447.  
  448. checkbuttons:
  449.  
  450.     cmp   [0xfb40],byte 0    ; mouse buttons pressed
  451.     jnz   @f
  452.     ret
  453.   @@:
  454.  
  455.     pushad
  456.  
  457.     xor    esi, esi
  458.     mov    edi, [0xfe88]
  459.     movzx  edx, word [edi]
  460.     test   edx, edx
  461.     jne    @f
  462.     popad
  463.     ret
  464.  
  465.   @@:
  466.  
  467.     push  esi
  468.     inc   edx
  469.     push  edx
  470.  
  471.   buttonnewcheck:
  472.  
  473.     pop   edx
  474.     pop   esi
  475.     inc   esi
  476.     cmp   edx,esi
  477.     jge   bch
  478.  
  479.     popad                 ; no button pressed
  480.     ret
  481.  
  482.   bch:
  483.  
  484.     push  esi
  485.     push  edx
  486.     mov   eax,esi
  487.     shl   eax,4
  488.     add   eax,edi
  489.  
  490. ;......................start 1/2 : modified by vhanla .............................
  491.     mov   [buttonid],eax
  492. ;......................end   1/2 : modified by vhanla .............................
  493.  
  494.     ; check that button is at top of windowing stack
  495.  
  496.     movzx ebx,word [eax]
  497.     movzx ecx,word [0xC000 + ebx * 2]
  498.     cmp   ecx,[0x3004]
  499.     jne   buttonnewcheck
  500.  
  501.     ; check that button start is inside window x/y end
  502.  
  503.     movzx ebx,word [eax+0]
  504.     shl   ebx,5
  505.  
  506.         test    [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED
  507.         jnz     buttonnewcheck
  508.  
  509. ;    add   ebx,window_data
  510. ;    mov   ecx,[window_data+ebx+8]          ; window end X
  511.     movzx edx,word [eax+4]     ; button start X
  512.     cmp   edx, [window_data+ebx+8] ;ecx
  513.     jge   buttonnewcheck
  514.  
  515. ;    mov   ecx,[window_data+ebx+12]         ; window end Y
  516.     movzx edx, word [eax+8]    ; button start Y
  517.     cmp   edx, [window_data+ebx+12] ;ecx
  518.     jge   buttonnewcheck
  519.  
  520.     ; check coordinates
  521.                                ; mouse x >= button x ?
  522.     movzx ebx,word [eax+0]
  523.     shl   ebx,5
  524.     add   ebx,window_data
  525.     movzx ecx,word [ebx+0]     ; window x start
  526.     movzx edx,word [eax+4]     ; button x start
  527.     add   edx,ecx
  528.     mov   cx,[0xfb0a]
  529.     cmp   edx,ecx
  530.     jg    buttonnewcheck
  531.  
  532.     movzx ebx,word [eax+6]     ; button x size
  533.     add   edx,ebx
  534.     cmp   ecx,edx
  535.     jg    buttonnewcheck
  536.  
  537.                                ; mouse y >= button y ?
  538.     movzx ebx,word [eax+0]
  539.     shl   ebx,5
  540.     add   ebx,window_data
  541.     movzx ecx,word [ebx+4]     ; window y start
  542.     movzx edx,word [eax+8]     ; button y start
  543.     add   edx,ecx
  544.     mov   cx,[0xfb0c]
  545.     cmp   edx,ecx
  546.     jg    buttonnewcheck
  547.  
  548.     movzx ebx,word [eax+10]    ; button y size
  549.     add   edx,ebx
  550.     cmp   ecx,edx
  551.     jg    buttonnewcheck
  552.  
  553.     ; mouse on button
  554.  
  555.     pop   edx
  556.     pop   esi
  557.  
  558.     mov   bx,[eax+0xc]     ; button id : bits 16-31
  559.     shl   ebx,16
  560.     mov   bx,[eax+2]       ; button id : bits 00-16
  561.     push  ebx
  562.  
  563.     mov   [0xfb44],byte 1  ; no mouse down checks
  564.     call find_pressed_button_frames
  565.     call negativebutton
  566.  
  567.     pushad
  568.   cbwaitmouseup:
  569.  
  570.     call  checkidle
  571.  
  572.     call  [draw_pointer]
  573.  
  574.     pushad
  575.     call  stack_handler
  576.     popad
  577.  
  578.     cmp   [0xfb40],byte 0  ; mouse buttons pressed ?
  579.     jnz   cbwaitmouseup
  580.     popad
  581.  
  582.     call  negativebutton
  583.     mov   [0xfff4],byte 0  ; no mouse background
  584.     mov   [0xfff5],byte 0  ; draw mouse
  585. ;..................................... start 2/2 : modified by vhanla .............................
  586.     ; check coordinates
  587.     jmp afterbuttonid
  588.     buttonid dd 0x0 ;here a will backup the eax value
  589.     afterbuttonid:
  590.  
  591.    pusha
  592.   ; mouse x >= button x ?
  593.    movzx ebx,word [eax+0]
  594.    shl   ebx,5
  595.    add   ebx,window_data
  596.    movzx ecx,word [ebx+0]    ; window x start
  597.    movzx edx,word [eax+4]    ; button x start
  598.    add   edx,ecx
  599.    mov   cx,[0xfb0a]
  600.    cmp   edx,ecx
  601.    jg   no_on_button ;if we release the pointer out of the button area
  602.  
  603.    movzx ebx,word [eax+6]    ; button x size
  604.    add   edx,ebx
  605.    cmp   ecx,edx
  606.    jg   no_on_button
  607.  
  608.         ; mouse y >= button y ?
  609.    movzx ebx,word [eax+0]
  610.    shl   ebx,5
  611.    add   ebx,window_data
  612.    movzx ecx,word [ebx+4]    ; window y start
  613.    movzx edx,word [eax+8]    ; button y start
  614.    add   edx,ecx
  615.    mov   cx,[0xfb0c]
  616.    cmp   edx,ecx
  617.    jg   no_on_button
  618.  
  619.    movzx ebx,word [eax+10]   ; button y size
  620.    add   edx,ebx
  621.    cmp   ecx,edx
  622.    jg   no_on_button
  623.    popa
  624.    mov   [0xf500],byte 1 ; no of buttons in buffer
  625.    pop   ebx
  626.    mov   [0xf501],ebx   ; lets put the button id in buffer
  627.    push  ebx
  628.    pusha
  629.    jmp yes_on_button
  630. no_on_button:
  631.    mov   [0xf500],byte 0 ; no of buttons in buffer
  632. yes_on_button:
  633.    mov   [0xfb44],byte 0 ; mouse down -> do not draw
  634.    popa
  635.    pop ebx
  636.    popa
  637.    ret
  638.  
  639. ;..................................... end 2/2 : modified by vhanla ................................
  640.