Subversion Repositories Kolibri OS

Rev

Rev 2354 | Blame | Last modification | View Log | Download | RSS feed

  1. ;**************************************************************
  2. ; ScrollBar Macro for Kolibri OS
  3. ; Copyright (c) 2009-2012, Marat Zakiyanov aka Mario79, aka Mario
  4. ; All rights reserved.
  5. ;
  6. ; Redistribution and use in source and binary forms, with or without
  7. ; modification, are permitted provided that the following conditions are met:
  8. ;        * Redistributions of source code must retain the above copyright
  9. ;        notice, this list of conditions and the following disclaimer.
  10. ;        * Redistributions in binary form must reproduce the above copyright
  11. ;        notice, this list of conditions and the following disclaimer in the
  12. ;        documentation and/or other materials provided with the distribution.
  13. ;        * Neither the name of the <organization> nor the
  14. ;        names of its contributors may be used to endorse or promote products
  15. ;        derived from this software without specific prior written permission.
  16. ;
  17. ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
  18. ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. ; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  21. ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. ;*****************************************************************************
  28. ; 15.11.2011 add scroll type 1 by IgorA
  29. ;*****************************************************************************
  30. macro scroll_bar_exit
  31. {
  32. popa
  33. ret 4
  34. }
  35. ;*****************************************************************************
  36. macro draw_up_arrow_vertical
  37. {
  38.         push    ebx
  39.        
  40.         xor     eax,eax
  41.         mov     ax,sb_size_x
  42.         shr     eax,1
  43.         shl     eax,16
  44.         add     ebx,eax
  45.        
  46.         xor     eax,eax
  47.         mov     ax,sb_btn_high
  48.         shr     eax,1
  49.         shl     eax,16
  50.         add     ecx,eax
  51.        
  52.         mov     edx,sb_line_col
  53.         sub     ebx,4 shl 16
  54.         mov     bx,7
  55.         mov     cx,1
  56.         mov     eax,13
  57.         int     0x40
  58.         sub     ecx,1 shl 16
  59.         add     ebx,1 shl 16
  60.         mov     bx,5
  61.         int     0x40
  62.         sub     ecx,1 shl 16
  63.         add     ebx,1 shl 16
  64.         mov     bx,3
  65.         int     0x40
  66.         sub     ecx,1 shl 16
  67.         add     ebx,1 shl 16
  68.         mov     bx,1
  69.         int     0x40
  70.         pop     ebx
  71. }
  72. ;*****************************************************************************
  73. macro draw_up_arrow_vertical_type2
  74. {
  75.         push    ebx
  76.        
  77.         mov     bx,sb_size_x
  78.         shr     bx,1
  79.         add     bx,sb_start_x
  80.  
  81.         mov     cx,sb_btn_high
  82.         shr     cx,1
  83.         add     cx,sb_start_y
  84.        
  85.         mov     ax,bx
  86.         shl     eax,16
  87.         mov     ax,cx
  88.        
  89.         sub     cx,2
  90.        
  91.         shl     ebx,16
  92.         shl     ecx,16
  93.        
  94.         mov     cx,ax
  95.         shr     eax,16
  96.         mov     bx,ax
  97.        
  98.         add     cx,1
  99.         sub     bx,3
  100.  
  101.         mcall   38,,,sb_line_col
  102.  
  103.         add     bx,6
  104.        
  105.         mcall
  106.         pop     ebx
  107. }
  108. ;*****************************************************************************
  109. macro draw_down_arrow_vertical
  110. {
  111.         push    ebx
  112.        
  113.         xor     eax,eax
  114.         mov     ax,sb_size_x
  115.         shr     eax,1
  116.         shl     eax,16
  117.         add     ebx,eax
  118.        
  119.         xor     eax,eax
  120.         mov     ax,sb_btn_high
  121.         shr     eax,1
  122.         shl     eax,16
  123.         add     ecx,eax
  124.        
  125.         mov     edx,sb_line_col
  126.         sub     ebx,4 shl 16
  127.         mov     bx,7
  128.         sub     ecx,2 shl 16
  129.         mov     cx,1
  130.         mov     eax,13
  131.         int     0x40
  132.         add     ecx,1 shl 16
  133.         add     ebx,1 shl 16
  134.         mov     bx,5
  135.         int     0x40
  136.         add     ecx,1 shl 16
  137.         add     ebx,1 shl 16
  138.         mov     bx,3
  139.         int     0x40
  140.         add     ecx,1 shl 16
  141.         add     ebx,1 shl 16
  142.         mov     bx,1
  143.         int     0x40
  144.         pop     ebx
  145. }
  146. ;*****************************************************************************
  147. macro draw_down_arrow_vertical_type2
  148. {
  149.         push    ebx
  150.        
  151.         mov     bx,sb_size_x
  152.         shr     bx,1
  153.         add     bx,sb_start_x
  154.  
  155.         mov     ax,sb_btn_high
  156.         shr     ax,1
  157.         mov     cx,sb_start_y
  158.         add     cx,sb_size_y
  159.         sub     cx,ax
  160.        
  161.         mov     ax,bx
  162.         shl     eax,16
  163.         mov     ax,cx
  164.        
  165.         add     cx,1
  166.        
  167.         shl     ebx,16
  168.         shl     ecx,16
  169.        
  170.         mov     cx,ax
  171.         shr     eax,16
  172.         mov     bx,ax
  173.        
  174.         sub     cx,2
  175.         sub     bx,3
  176.  
  177.         mcall   38,,,sb_line_col
  178.  
  179.         add     bx,6
  180.        
  181.         mcall
  182.         pop     ebx
  183. }
  184. ;*****************************************************************************
  185. macro draw_runner_center_vertical
  186. {
  187.         push    ebx
  188.         push    ecx
  189.        
  190.         xor     eax,eax
  191.         mov     ax,sb_size_x
  192.         shr     eax,1
  193.         shl     eax,16
  194.         add     ebx,eax
  195.        
  196.         mov     edx,sb_run_size
  197.         shr     edx,1
  198.         shl     edx,16
  199.         add     ecx,edx
  200.         mov     edx,sb_line_col
  201.         sub     ecx,8 shl 16
  202.         sub     ebx,5 shl 16
  203.         mov     bx,10
  204.         add     ecx,4 shl 16
  205.         mov     cx,1
  206.         mov     eax,13
  207.         int     0x40
  208.         add     ecx,3 shl 16
  209.         sub     ebx,1 shl 16
  210.         mov     bx,12
  211.         int     0x40
  212.         add     ebx,1 shl 16
  213.         mov     bx,10
  214.         add     ecx,3 shl 16
  215.         int     0x40
  216.         pop     ecx
  217.         pop     ebx
  218. }
  219. ;*****************************************************************************
  220. macro draw_up_arrow_horizontal
  221. {
  222.         push    ecx
  223.        
  224.         xor     eax,eax
  225.         mov     ax,sb_btn_high
  226.         shr     eax,1
  227.         shl     eax,16
  228.         add     ebx,eax
  229.        
  230.         xor     eax,eax
  231.         mov     ax,sb_size_y
  232.         shr     eax,1
  233.         shl     eax,16
  234.         add     ecx,eax
  235.        
  236.         mov     edx,sb_line_col
  237.         sub     ecx,4 shl 16
  238.         mov     cx,7
  239.         mov     bx,1
  240.        
  241.         mov     eax,13
  242.         int     0x40
  243.         sub     ebx,1 shl 16
  244.         add     ecx,1 shl 16
  245.         mov     cx,5
  246.         int     0x40
  247.         sub     ebx,1 shl 16
  248.         add     ecx,1 shl 16
  249.         mov     cx,3
  250.         int     0x40
  251.         sub     ebx,1 shl 16
  252.         add     ecx,1 shl 16
  253.         mov     cx,1
  254.         int     0x40
  255.         pop     ecx
  256. }
  257. ;*****************************************************************************
  258. macro draw_up_arrow_horizontal_type2
  259. {
  260.         push    ebx ecx
  261.        
  262.         mov     bx,sb_btn_high
  263.         shr     bx,1
  264.         add     bx,sb_start_x
  265.  
  266.         mov     cx,sb_size_y
  267.         shr     cx,1
  268.         add     cx,sb_start_y
  269.        
  270.         mov     ax,bx
  271.         shl     eax,16
  272.         mov     ax,cx
  273.        
  274.         sub     bx,2
  275.        
  276.         shl     ebx,16
  277.         shl     ecx,16
  278.        
  279.         mov     cx,ax
  280.         shr     eax,16
  281.         mov     bx,ax
  282.        
  283.         add     bx,1
  284.         sub     cx,3
  285.  
  286.         mcall   38,,,sb_line_col
  287.  
  288.         add     cx,6
  289.        
  290.         mcall
  291.         pop     ecx ebx
  292. }
  293. ;*****************************************************************************
  294. macro draw_down_arrow_horizontal
  295. {
  296.         push    ecx
  297.        
  298.         xor     eax,eax
  299.         mov     ax,sb_btn_high
  300.         shr     eax,1
  301.         shl     eax,16
  302.         add     ebx,eax
  303.        
  304.         xor     eax,eax
  305.         mov     ax,sb_size_y
  306.         shr     eax,1
  307.         shl     eax,16
  308.         add     ecx,eax
  309.        
  310.         mov     edx,sb_line_col
  311.         sub     ecx,4 shl 16
  312.         mov     cx,7
  313.         sub     ebx,2 shl 16
  314.         mov     bx,1
  315.         mov     eax,13
  316.         int     0x40
  317.         add     ebx,1 shl 16
  318.         add     ecx,1 shl 16
  319.         mov     cx,5
  320.         int     0x40
  321.         add     ebx,1 shl 16
  322.         add     ecx,1 shl 16
  323.         mov     cx,3
  324.         int     0x40
  325.         add     ecx,1 shl 16
  326.         add     ebx,1 shl 16
  327.         mov     cx,1
  328.         int     0x40
  329.         pop     ecx
  330. }
  331. ;*****************************************************************************
  332. macro draw_down_arrow_horizontal_type2
  333. {
  334.         push    ebx ecx
  335.        
  336.         mov     ax,sb_btn_high
  337.         shr     ax,1
  338.         mov     bx,sb_start_x
  339.         add     bx,sb_size_x
  340.         sub     bx,ax
  341.        
  342.         mov     cx,sb_size_y
  343.         shr     cx,1
  344.         add     cx,sb_start_y
  345.        
  346.         mov     ax,bx
  347.         shl     eax,16
  348.         mov     ax,cx
  349.        
  350.         add     cx,1
  351.        
  352.         shl     ebx,16
  353.         shl     ecx,16
  354.        
  355.         mov     cx,ax
  356.         shr     eax,16
  357.         mov     bx,ax
  358.        
  359.         sub     cx,2
  360.         sub     bx,3
  361.  
  362.         mcall   38,,,sb_line_col
  363.  
  364.         add     cx,6
  365.        
  366.         mcall
  367.         pop     ecx ebx
  368. }
  369. ;*****************************************************************************
  370. macro draw_runner_center_horizontal
  371. {
  372.         push    ebx
  373.         push    ecx
  374.        
  375.         xor     eax,eax
  376.         mov     ax,sb_size_y
  377.         shr     eax,1
  378.         shl     eax,16
  379.         add     ecx,eax
  380.        
  381.         mov     edx,sb_run_size
  382.         shr     edx,1
  383.         shl     edx,16
  384.         add     ebx,edx
  385.         mov     edx,sb_line_col
  386.         sub     ebx,8 shl 16
  387.         sub     ecx,5 shl 16
  388.         mov     cx,10
  389.         add     ebx,4 shl 16
  390.         mov     bx,1
  391.         mov     eax,13
  392.         int     0x40
  393.         add     ebx,3 shl 16
  394.         sub     ecx,1 shl 16
  395.         mov     cx,12
  396.         int     0x40
  397.         add     ecx,1 shl 16
  398.         mov     cx,10
  399.         add     ebx,3 shl 16
  400.         int     0x40
  401.         pop     ecx
  402.         pop     ebx
  403. }
  404. ;*****************************************************************************
  405. macro use_scroll_bar
  406. {
  407. scroll_bar:
  408. sb_size_x       equ [edi]
  409. sb_start_x      equ [edi+2]
  410. sb_size_y       equ [edi+4]
  411. sb_start_y      equ [edi+6]
  412. sb_btn_high     equ [edi+8]
  413. sb_type         equ [edi+12]
  414. sb_max_area     equ [edi+16]
  415. sb_cur_area     equ [edi+20]
  416. sb_position     equ [edi+24]
  417. sb_bckg_col     equ [edi+28]
  418. sb_frnt_col     equ [edi+32]
  419. sb_line_col     equ [edi+36]
  420. sb_redraw       equ [edi+40]
  421. sb_delta        equ [edi+44]
  422. sb_delta2       equ [edi+46]
  423. sb_r_size_x     equ [edi+48]
  424. sb_r_start_x    equ [edi+50]
  425. sb_r_size_y     equ [edi+52]
  426. sb_r_start_y    equ [edi+54]
  427. sb_m_pos        equ [edi+56]
  428. sb_m_pos_2      equ [edi+60]
  429. sb_m_keys       equ [edi+64]
  430. sb_run_size     equ [edi+68]
  431. sb_position2    equ [edi+72]
  432. sb_work_size    equ [edi+76]
  433. sb_all_redraw   equ [edi+80]
  434. sb_ar_offset    equ [edi+84]
  435. }
  436. ;*****************************************************************************
  437. ;*****************************************************************************
  438. ; draw event
  439. ;*****************************************************************************
  440. ;*****************************************************************************
  441. macro use_scroll_bar_vertical
  442. {
  443. scroll_bar_vertical:
  444. .draw:
  445.         pusha
  446.         mov     edi,dword [esp+36]
  447.         mov     sb_delta,word 0
  448.         call    .draw_1
  449.         mov     sb_all_redraw,dword 0
  450. scroll_bar_exit
  451. .draw_1:
  452.         pusha
  453. ;*********************************
  454.         xor     eax,eax
  455.         mov     ax,sb_size_y
  456.         mov     edx,sb_btn_high
  457.         shl     edx,1
  458.         sub     eax,edx
  459.         mov     sb_work_size,eax
  460. ;*********************************
  461.         mov     eax,sb_work_size
  462.         mov     ebx,sb_max_area
  463.         cmp     ebx,sb_cur_area
  464.         ja      @f
  465.         jmp     .no_size
  466.  
  467. @@:
  468.         imul    eax,sb_cur_area
  469.         xor     edx,edx
  470.         div     ebx
  471.         shl     edx,1
  472.         cmp     edx,ebx
  473.         jb      @f
  474.        
  475.         inc     eax
  476.        
  477. @@:
  478.         cmp     eax,10
  479.         jae     @f
  480.         mov     eax,10
  481. @@:
  482. .no_size:
  483.         mov     sb_run_size,eax
  484. ;*********************************
  485.         cmp     word sb_delta,1
  486.         je      .@@_3
  487.         mov     eax,sb_work_size
  488.         sub     eax,sb_run_size
  489.         mov     ebx,sb_max_area
  490.         cmp     ebx,sb_cur_area
  491.         ja      @f
  492.         xor     eax,eax
  493.         jmp     .@@_1
  494. @@:
  495.         sub     ebx,sb_cur_area
  496.         imul    eax,sb_position
  497.         xor     edx,edx
  498.         div     ebx
  499.         shl     edx,1
  500.         cmp     edx,ebx
  501.         jb      @f
  502.        
  503.         inc     eax
  504.        
  505. @@:
  506. .@@_1:
  507.         mov     sb_position2,eax
  508.         xor     edx,edx
  509.         mov     dx,sb_size_y
  510.         sub     edx,sb_btn_high
  511.         sub     edx,sb_btn_high
  512.         sub     edx,sb_run_size
  513.         cmp     sb_position2,edx
  514.         jbe     .@@_3
  515.         mov     sb_position2,edx
  516. .@@_3:
  517. ;*********************************     
  518.         mov     ebx,sb_start_x
  519.         shl     ebx,16
  520.         inc     ebx
  521.         mov     ecx,sb_size_y
  522.         mov     edx,sb_line_col
  523.         mov     eax,13
  524.         cmp     dword sb_all_redraw,0
  525.         je      @f
  526.         int     0x40    ; left extreme line
  527. @@:
  528.         push    ebx
  529.         ror     ebx,16
  530.         add     bx,sb_size_x
  531.         rol     ebx,16
  532.         cmp     dword sb_all_redraw,0
  533.         je      @f
  534.         int     0x40    ; right extreme line
  535. @@:
  536.         pop     ebx
  537.  
  538.         push    ecx
  539.        
  540.         add     ebx,1 shl 16
  541.         mov     bx,sb_size_x
  542.         dec     ebx    
  543.         mov     cx,1
  544.         cmp     dword sb_all_redraw,0
  545.         je      @f
  546.         int     0x40    ; top button - extreme line
  547. @@:
  548.         push    ecx
  549.         add     ecx,1 shl 16
  550.         add     ecx,sb_btn_high
  551.         sub     ecx,2
  552.         mov     edx,sb_frnt_col
  553.         cmp     dword sb_all_redraw,0
  554.         je      .no_draw_top_button
  555.         int     0x40    ; top button filling
  556. ;-----------------------------------------------------------------------------
  557. ; scrollbar type 2
  558.         cmp     word sb_type,2
  559.         jne     .no_type2
  560. ;*********************************
  561. draw_up_arrow_vertical_type2
  562. ;*********************************
  563.         jmp     .no_draw_top_button
  564. .no_type2:
  565. ;*********************************
  566. draw_up_arrow_vertical
  567. ;*********************************
  568. .no_draw_top_button:
  569.         pop     ecx
  570.        
  571.         ror     ecx,16
  572.         add     ecx,sb_btn_high  ;14 shl 16
  573.         rol     ecx,16
  574.         mov     edx,sb_line_col
  575.         cmp     dword sb_all_redraw,0
  576.         je      @f
  577.         mcall   13      ;  top button - bottom line
  578. @@:
  579.         pop     ecx
  580. ;*********************************
  581.         ror     ecx,16 
  582.         add     ecx,sb_btn_high  ;15 shl 16
  583.         inc     ecx
  584.         rol     ecx,16
  585.         sub     ecx,sb_btn_high  ;30
  586.         sub     ecx,sb_btn_high
  587.         push    ecx
  588.         mov     cx,0
  589.         add     ecx,sb_position2
  590.         dec     cx
  591.         mov     eax,13
  592.         test    cx,0x8000
  593.         jnz     @f
  594.         mov     edx,sb_bckg_col
  595.         int     0x40    ; top interval
  596. @@:
  597. ;*********************************
  598.         shr     ecx,16
  599.         add     ecx,sb_position2
  600.         dec     ecx
  601.         shl     ecx,16
  602.         inc     ecx
  603.         mov     edx,sb_line_col
  604.         int     0x40    ; runner - top extreme line
  605.        
  606.         add     ecx,1 shl 16
  607.         mov     cx,0
  608.         add     ecx,sb_run_size
  609.         mov     sb_r_size_x,ebx
  610.         mov     sb_r_size_y,ecx
  611.         sub     ecx,2
  612.         mov     edx,sb_frnt_col
  613.         int     0x40    ; runner filling
  614. ;-----------------------------------------------------------------------------
  615. ; scrollbar type 2
  616.         cmp     word sb_type,2
  617.         je      @f
  618. ;*********************************
  619. draw_runner_center_vertical
  620. ;*********************************
  621. @@:
  622. ;-----------------------------------------------------------------------------
  623. ; scrollbar type 1 - stylish frame
  624.         cmp     word sb_type,1
  625.         jne     @f
  626.         push    eax ebx ecx edx
  627.         movzx   eax,word sb_start_x
  628.         xor     ebx,ebx
  629.         add     bx,sb_r_start_y
  630.         dec     ebx
  631.         movzx   ecx,word sb_size_x
  632.         mov     edx,sb_run_size
  633.         dec     edx
  634.         ; drawing a stylish frame on the slider
  635.         stdcall draw_edge,eax,ebx,ecx,edx,sb_bckg_col,sb_frnt_col,sb_line_col
  636.         pop     edx ecx ebx eax
  637. @@:
  638. ;-----------------------------------------------------------------------------
  639.         shr     ecx,16
  640.         add     ecx,sb_run_size
  641.         sub     ecx,2
  642.         shl     ecx,16  
  643.         inc     ecx
  644.         mov     edx,sb_line_col
  645.         int     0x40    ; runner - bottom extreme line
  646.        
  647.         add     ecx,1 shl 16
  648.         mov     cx,sb_start_y
  649.         add     cx,sb_size_y
  650.         sub     ecx,sb_btn_high
  651.         dec     ecx
  652.         mov     eax,ecx
  653.         shr     eax,16
  654.         sub     cx,ax
  655.         test    cx,0x8000
  656.         jnz     @f
  657.         mov     edx,sb_bckg_col
  658.         mov     eax,13
  659.         int     0x40    ; bottom interval
  660. @@:    
  661.         pop     ecx    
  662. ;*********************************     
  663.         mov     ax,cx
  664.         shr     ecx,16
  665.         add     cx,ax
  666.         sub     ecx,2
  667.         shl     ecx,16
  668.         inc     ecx
  669.         mov     edx,sb_line_col
  670.         mov     eax,13
  671.         cmp     dword sb_all_redraw,0
  672.         je      @f
  673.         int     0x40    ; bottom button - top line
  674. @@:
  675.         push    ecx
  676.         add     ecx,1 shl 16
  677.         add     cx,sb_btn_high
  678.         sub     ecx,2
  679.         mov     edx,sb_frnt_col
  680.         cmp     dword sb_all_redraw,0
  681.         je      .no_draw_bottom_button
  682.         int     0x40    ; bottom button filling
  683. ;-----------------------------------------------------------------------------
  684. ; scrollbar type 2
  685.         cmp     word sb_type,2
  686.         jne     .no_type2_1
  687. ;*********************************
  688. draw_down_arrow_vertical_type2
  689. ;*********************************
  690.         jmp     .no_draw_bottom_button
  691. .no_type2_1:
  692. ;*********************************
  693. draw_down_arrow_vertical
  694. ;*********************************
  695. .no_draw_bottom_button:
  696.         pop     ecx
  697.        
  698.         ror     ecx,16
  699.         add     ecx,sb_btn_high
  700.         rol     ecx,16
  701.        
  702.         mov     edx,sb_line_col
  703.         mov     cx,1
  704.         cmp     dword sb_all_redraw,0
  705.         je      @f
  706.         mcall   13      ; bottom button - extreme line
  707. ;-----------------------------------------------------------------------------
  708. ; scrollbar type 1 - stylish frame
  709.         cmp     word sb_type,1
  710.         jne     @f
  711.         movzx   eax,word sb_start_x
  712.         movzx   ebx,word sb_start_y
  713.         movzx   ecx,word sb_size_x
  714.         ; drawing a stylish frame on the top button
  715.         stdcall draw_edge,eax,ebx,ecx,sb_btn_high,\
  716.                 sb_bckg_col,sb_frnt_col,sb_line_col
  717.         add     bx,sb_size_y
  718.         sub     ebx,sb_btn_high
  719.         dec     ebx
  720.         ; drawing a stylish frame on the bottom  button
  721.         stdcall draw_edge,eax,ebx,ecx,sb_btn_high,\
  722.                 sb_bckg_col,sb_frnt_col,sb_line_col
  723. @@:
  724. ;-----------------------------------------------------------------------------
  725.         popa
  726.         ret
  727. ;*****************************************************************************
  728. ;*****************************************************************************
  729. ; mouse event
  730. ;*****************************************************************************
  731. ;*****************************************************************************
  732. .mouse:
  733.         pusha
  734.         mov     edi,dword [esp+36]
  735.         mcall   37,1
  736.         mov     sb_m_pos,eax
  737.         cmp     dword sb_m_pos_2,0
  738.         jne     @f
  739.        
  740.         mov     sb_m_pos_2,eax 
  741. @@:
  742.         mcall   37,2
  743.         mov     sb_m_keys,eax  
  744.  
  745.         cmp     sb_m_keys,eax
  746.         je      @f
  747.        
  748.         mov     sb_m_keys,eax
  749.         mov     sb_delta,dword 0
  750.         mov     eax,sb_m_pos
  751.         mov     sb_m_pos_2,eax
  752.         jmp     .continue_2
  753. @@:
  754.         cmp     dword sb_m_keys,0
  755.         jne      @f
  756.         mov     eax,sb_m_pos
  757.         mov     sb_m_pos_2,eax
  758.         jmp     .correct_1      ;.exit_sb      
  759. @@:
  760.         mov     sb_delta,word 1
  761.  
  762. .continue_2:
  763.         mov     eax,sb_m_pos
  764.         test    eax,0x80000000
  765.         jnz     .exit_sb
  766.        
  767.         test    eax,0x8000
  768.         jnz     .exit_sb
  769.        
  770.         mov     ebx,eax
  771.         shr     ebx,16  ; x position
  772.         shl     eax,16
  773.         shr     eax,16  ; y position
  774.  
  775.         mov     cx,sb_start_y
  776.         cmp     ax,cx
  777.         jb      .exit_sb
  778.        
  779.         cmp     word sb_delta2,0
  780.         je      @f
  781.         push    ecx
  782.         add     cx,sb_btn_high
  783.         cmp     ax,cx
  784.         pop     ecx
  785.         jb      .exit_sb
  786.        
  787. @@:
  788.         add     cx,sb_size_y
  789.         cmp     ax,cx
  790.         ja      .exit_sb
  791.  
  792.         cmp     word sb_delta2,0
  793.         je      @f
  794.         sub     cx,sb_btn_high
  795.         cmp     ax,cx
  796.         ja      .exit_sb
  797.        
  798. @@:
  799.         cmp     word sb_delta2,1
  800.         je      @f
  801.        
  802.         cmp     dword sb_m_keys,0
  803.         je      .exit_sb
  804.        
  805.         mov     cx,sb_start_x
  806.         cmp     bx,cx
  807.         jb      .exit_sb
  808.        
  809.         add     cx,sb_size_x
  810.         cmp     bx,cx
  811.         ja      .exit_sb
  812.  
  813.         mov     cx,sb_r_start_y
  814.         cmp     ax,cx
  815.         jb      .no_runner
  816.        
  817.         add     cx,sb_r_size_y
  818.         cmp     ax,cx
  819.         ja      .no_runner
  820.  
  821.         mov     sb_delta2,word 1       
  822. @@:
  823.         push    eax
  824.         mov     ax,sb_m_pos
  825.         cmp     ax,sb_m_pos_2
  826.         je      .correct       
  827.        
  828.         shl     eax,16
  829.         shr     eax,16
  830.         mov     ebx,sb_m_pos_2
  831.         shl     ebx,16
  832.         shr     ebx,16
  833.         cmp     eax,ebx
  834.         jb      .sub
  835.        
  836.         sub     eax,ebx
  837.         mov     ebx,eax
  838.         add     sb_position2,ebx
  839.         xor     eax,eax
  840.         mov     ax,sb_size_y
  841.         sub     eax,sb_btn_high
  842.         sub     eax,sb_btn_high
  843.         sub     eax,sb_run_size
  844.         cmp     sb_position2,eax
  845.         jbe     @f
  846.        
  847.         mov     sb_position2,eax
  848. @@:
  849.         mov     eax,sb_m_pos
  850.         mov     sb_m_pos_2,eax
  851.         pop     eax
  852.         call    .draw_1
  853.         jmp     .no_runner_1
  854.        
  855. .correct:
  856.         pop     eax
  857.         jmp     .exit_sb
  858. .correct_1:
  859.         mov     sb_delta,dword 0
  860.         jmp     .exit_sb
  861.  
  862. .sub:
  863.         sub     ebx,eax
  864.         sub     sb_position2,ebx
  865.         test    sb_position2,dword 0x80000000
  866.         jz      @f
  867.        
  868.         mov     sb_position2,dword 0
  869. @@:
  870.         mov     eax,sb_m_pos
  871.         mov     sb_m_pos_2,eax
  872.         pop     eax
  873.         call    .draw_1
  874.         jmp     .no_runner_1
  875.  
  876. ;*****************************************************************************
  877. .no_runner:
  878.         mov     sb_delta,dword 0
  879. .no_runner_1:
  880.         xor     ecx,ecx
  881.         mov     cx,sb_start_y
  882.         add     cx,sb_btn_high  ;15
  883.         cmp     word sb_delta,1
  884.         je      .scroll_sb
  885.        
  886.         cmp     ax,cx
  887.         ja      .scroll_sb
  888.        
  889.         cmp     dword sb_m_keys,0
  890.         je      .exit_sb
  891.        
  892.         mov     eax,sb_ar_offset
  893.         cmp     sb_position,eax  ;dword 0
  894.         jbe     @f
  895.        
  896.         sub     sb_position,eax
  897.         jmp     .all_sb
  898. @@:
  899.         xor     eax,eax
  900.         mov     sb_position,eax ;dword 0
  901.         mov     sb_position2,eax ;dword 0
  902.         jmp     .all_sb
  903. ;*****************************************************************************
  904. .scroll_sb:
  905.         add     cx,sb_size_y
  906.         sub     cx,sb_btn_high
  907.         sub     cx,sb_btn_high
  908.         cmp     word sb_delta,1
  909.         je      @f
  910.        
  911.         cmp     ax,cx
  912.         ja      .down_sb
  913.        
  914. @@:
  915.         mov     ebx,sb_btn_high ;16  ;15
  916.         add     bx,sb_start_y
  917.         sub     cx,bx
  918.         sub     ax,bx
  919.        
  920. .scroll_sb_1:  
  921.         mov     ebx,sb_run_size
  922. ;***************************************************************************** 
  923.         cmp     word sb_delta,1
  924.         je      .continue
  925.        
  926. @@:
  927.         mov     edx,eax
  928.         push    ebx
  929.         shr     ebx,1
  930.         sub     edx,ebx
  931.         pop     ebx
  932.         mov     sb_position2,edx
  933.         test    sb_position2,dword 0x80000000
  934.         jz      .test_1
  935.        
  936.         mov     sb_position2,dword 0
  937.         jmp     .continue
  938.        
  939. .test_1:
  940.         xor     edx,edx
  941.         mov     dx,sb_size_y
  942.         sub     edx,sb_btn_high
  943.         sub     edx,sb_btn_high
  944.         sub     edx,sb_run_size
  945.         cmp     sb_position2,edx
  946.         jbe     .continue
  947.        
  948.         mov     sb_position2,edx
  949.  
  950. .continue:     
  951.         mov     eax,sb_position2
  952.         sub     ecx,ebx
  953. .continue_1:
  954. ;*****************************************************************************  
  955.         mov     ebx,eax
  956.  
  957.         mov     eax,sb_max_area
  958.         cmp     eax,sb_cur_area
  959.         ja      @f
  960.  
  961.         xor     eax,eax
  962.         inc     eax
  963.         mov     sb_position2,eax
  964.         jmp     .all_sb
  965. @@:
  966.         sub     eax,sb_cur_area
  967.         inc     eax
  968.         shl     eax,10
  969.         xor     edx,edx
  970.         div     ecx
  971.         shl     edx,1
  972.         cmp     edx,ecx
  973.         jb      @f
  974.        
  975.         inc     eax
  976.        
  977. @@:
  978.         imul    eax,ebx
  979.         shr     eax,10
  980.        
  981.         cmp     sb_position,eax
  982.         je      .exit_sb
  983.        
  984.         cmp     eax,0
  985.         ja      @f
  986.        
  987.         xor     eax,eax
  988.        
  989. @@:
  990. .store_position:
  991.         mov     edx,sb_max_area
  992.         sub     edx,sb_cur_area
  993.         cmp     edx,eax
  994.         ja      @f
  995.  
  996.         mov     sb_position,edx
  997.         jmp     .all_sb
  998.  
  999. @@:
  1000.         mov     sb_position,eax
  1001. .all_sb:
  1002.         mov     sb_redraw,dword 1
  1003.         call    .draw_1
  1004.         mov     eax,sb_m_pos
  1005.         mov     sb_m_pos_2,eax
  1006.         jmp     .exit_sb
  1007. ;*****************************************************************************
  1008. .down_sb:
  1009.         cmp     dword sb_m_keys,0
  1010.         je      .exit_sb
  1011.        
  1012.         mov     eax,sb_max_area
  1013.         mov     ebx,sb_ar_offset
  1014.         sub     eax,sb_cur_area
  1015.         push    eax
  1016.         sub     eax,ebx
  1017.         cmp     sb_position,eax
  1018.         pop     eax
  1019.         jae     @f
  1020.        
  1021.         add     sb_position,ebx
  1022.         jmp     .all_sb
  1023. @@:
  1024.         mov     sb_position,eax
  1025.         xor     eax,eax
  1026.         mov     ax,sb_size_y
  1027.         sub     eax,sb_btn_high
  1028.         sub     eax,sb_btn_high
  1029.         sub     eax,sb_run_size
  1030.         mov     sb_position2,eax
  1031.         jmp     .all_sb
  1032. .exit_sb:      
  1033. scroll_bar_exit
  1034. }
  1035.  
  1036. ;*****************************************************************************
  1037. ;*****************************************************************************
  1038. ;*****************************************************************************
  1039. ;*****************************************************************************
  1040. ;*****************************************************************************
  1041. macro use_scroll_bar_horizontal
  1042. {
  1043. scroll_bar_horizontal:
  1044. .draw:
  1045.         pusha
  1046.         mov     edi,dword [esp+36]
  1047.         mov     sb_delta,word 0
  1048.         call    .draw_1
  1049.         mov     sb_all_redraw,dword 0
  1050. scroll_bar_exit
  1051. .draw_1:
  1052.         pusha
  1053. ;*********************************
  1054.         xor     eax,eax
  1055.         mov     ax,sb_size_x    ;sb_size_y
  1056.         mov     edx,sb_btn_high
  1057.         shl     edx,1
  1058.         sub     eax,edx
  1059.         mov     sb_work_size,eax
  1060. ;*********************************
  1061.         mov     eax,sb_work_size        ;sb_max_area
  1062.         mov     ebx,sb_max_area
  1063.         cmp     ebx,sb_cur_area
  1064.         ja      @f
  1065.  
  1066.         jmp     .no_size
  1067.  
  1068. @@:
  1069.         imul    eax,sb_cur_area
  1070.         xor     edx,edx
  1071.         div     ebx
  1072.         shl     edx,1
  1073.         cmp     edx,ebx
  1074.         jb      @f
  1075.        
  1076.         inc     eax
  1077.        
  1078. @@:
  1079.         cmp     eax,10
  1080.         jae     @f
  1081.         mov     eax,10
  1082. @@:
  1083. .no_size:
  1084.         mov     sb_run_size,eax
  1085. ;*********************************
  1086.         cmp     word sb_delta,1
  1087.         je      .@@_3
  1088.         mov     eax,sb_work_size
  1089.         sub     eax,sb_run_size
  1090.         mov     ebx,sb_max_area
  1091.         cmp     ebx,sb_cur_area
  1092.         ja      @f
  1093.         xor     eax,eax
  1094.         jmp     .@@_1
  1095. @@:
  1096.         sub     ebx,sb_cur_area
  1097.         imul    eax,sb_position
  1098.         xor     edx,edx
  1099.         div     ebx
  1100.         shl     edx,1
  1101.         cmp     edx,ebx
  1102.         jb      @f
  1103.        
  1104.         inc     eax
  1105.        
  1106. @@:
  1107. .@@_1:
  1108.         mov     sb_position2,eax
  1109.         xor     edx,edx
  1110.         mov     dx,sb_size_x
  1111.         sub     edx,sb_btn_high
  1112.         sub     edx,sb_btn_high
  1113.         sub     edx,sb_run_size
  1114.         cmp     sb_position2,edx
  1115.         jbe     .@@_3
  1116.         mov     sb_position2,edx
  1117. .@@_3:
  1118. ;*********************************     
  1119.         mov     ebx,sb_size_x
  1120.         mov     ecx,sb_start_y
  1121.         shl     ecx,16
  1122.         inc     ecx    
  1123.         mov     edx,sb_line_col
  1124.         mov     eax,13
  1125.         cmp     dword sb_all_redraw,0
  1126.         je      @f
  1127.         int     0x40    ; top extreme line
  1128. @@:
  1129.         push    ecx
  1130.         ror     ecx,16
  1131.         add     cx,sb_size_y
  1132.         rol     ecx,16
  1133.         cmp     dword sb_all_redraw,0
  1134.         je      @f
  1135.         int     0x40    ; bottom extreme line
  1136. @@:
  1137.         pop     ecx
  1138.  
  1139.         push    ebx
  1140.        
  1141.         add     ecx,1 shl 16
  1142.         mov     cx,sb_size_y
  1143.         dec     ecx    
  1144.         mov     bx,1
  1145.         cmp     dword sb_all_redraw,0
  1146.         je      @f
  1147.         int     0x40    ; left button - extreme line
  1148. @@:
  1149.         push    ebx
  1150.         add     ebx,1 shl 16
  1151.         add     ebx,sb_btn_high
  1152.         sub     ebx,2
  1153.         mov     edx,sb_frnt_col
  1154.         cmp     dword sb_all_redraw,0
  1155.         je      .no_draw_top_button
  1156.         int     0x40    ; left  button filling
  1157. ;-----------------------------------------------------------------------------
  1158. ; scrollbar type 2
  1159.         cmp     word sb_type,2
  1160.         jne     .no_type2
  1161. ;*********************************
  1162. draw_up_arrow_horizontal_type2
  1163. ;*********************************
  1164.         jmp     .no_draw_top_button
  1165. .no_type2:
  1166. ;*********************************     
  1167. draw_up_arrow_horizontal
  1168. ;*********************************
  1169. .no_draw_top_button:
  1170.         pop     ebx
  1171.        
  1172.         ror     ebx,16
  1173.         add     ebx,sb_btn_high  ;14 shl 16
  1174.         rol     ebx,16
  1175.         mov     edx,sb_line_col
  1176.         cmp     dword sb_all_redraw,0
  1177.         je      @f
  1178.         mcall   13      ;  left  button - right line
  1179. @@:
  1180.         pop     ebx
  1181. ;*********************************
  1182.         ror     ebx,16 
  1183.         add     ebx,sb_btn_high  ;15 shl 16
  1184.         inc     ebx
  1185.         rol     ebx,16
  1186.         sub     ebx,sb_btn_high  ;30
  1187.         sub     ebx,sb_btn_high
  1188.         push    ebx
  1189.         mov     bx,0
  1190.         add     ebx,sb_position2
  1191.         dec     bx
  1192.         mov     eax,13
  1193.         test    bx,0x8000
  1194.         jnz     @f
  1195.         mov     edx,sb_bckg_col
  1196.         int     0x40    ; left interval
  1197. @@:
  1198. ;*********************************
  1199.         shr     ebx,16
  1200.         add     ebx,sb_position2
  1201.         dec     ebx
  1202.         shl     ebx,16
  1203.         inc     ebx
  1204.         mov     edx,sb_line_col
  1205.         int     0x40    ; runner - left extreme line
  1206.        
  1207.         add     ebx,1 shl 16
  1208.         mov     bx,0
  1209.         add     ebx,sb_run_size
  1210.         mov     sb_r_size_x,ebx
  1211.         mov     sb_r_size_y,ecx
  1212.         sub     ebx,2
  1213.         mov     edx,sb_frnt_col
  1214.         int     0x40    ; runner filling
  1215. ;-----------------------------------------------------------------------------
  1216. ; scrollbar type 2
  1217.         cmp     word sb_type,2
  1218.         je      @f
  1219. ;*********************************
  1220. draw_runner_center_horizontal
  1221. ;*********************************
  1222. @@:    
  1223. ;-----------------------------------------------------------------------------
  1224. ; scrollbar type 1 - stylish frame
  1225.         cmp     word sb_type,1
  1226.         jne     @f
  1227.         push    eax ebx ecx edx
  1228.         xor     eax,eax
  1229.         add     ax,sb_r_start_x
  1230.         dec     eax
  1231.         movzx   ebx,word sb_start_y
  1232.         mov     ecx,sb_run_size
  1233.         dec     ecx
  1234.         movzx   edx,word sb_size_y
  1235.         ; drawing a stylish frame on the slider
  1236.         stdcall draw_edge,eax,ebx,ecx,edx,\
  1237.                 sb_bckg_col,sb_frnt_col,sb_line_col
  1238.         pop     edx ecx ebx eax
  1239. @@:
  1240. ;-----------------------------------------------------------------------------
  1241.         shr     ebx,16
  1242.         add     ebx,sb_run_size
  1243.         sub     ebx,2
  1244.         shl     ebx,16  
  1245.         inc     ebx
  1246.         mov     edx,sb_line_col
  1247.         int     0x40    ; runner - bottom extreme line
  1248.        
  1249.         add     ebx,1 shl 16
  1250.         mov     bx,sb_start_x
  1251.         add     bx,sb_size_x
  1252.         sub     ebx,sb_btn_high
  1253.         dec     ebx
  1254.         mov     eax,ebx
  1255.         shr     eax,16
  1256.         sub     bx,ax
  1257.         test    bx,0x8000
  1258.         jnz     @f
  1259.         mov     edx,sb_bckg_col
  1260.         mov     eax,13
  1261.         int     0x40    ; bottom interval
  1262. @@:
  1263.         pop     ebx    
  1264. ;*********************************     
  1265.         mov     ax,bx
  1266.         shr     ebx,16
  1267.         add     bx,ax
  1268.         sub     ebx,2
  1269.         shl     ebx,16
  1270.         inc     ebx
  1271.         mov     edx,sb_line_col
  1272.         mov     eax,13
  1273.         cmp     dword sb_all_redraw,0
  1274.         je      @f
  1275.         int     0x40    ; bottom button - top line
  1276. @@:
  1277.         push    ebx
  1278.         add     ebx,1 shl 16
  1279.         add     bx,sb_btn_high
  1280.         sub     ebx,2
  1281.         mov     edx,sb_frnt_col
  1282.         cmp     dword sb_all_redraw,0
  1283.         je      .no_draw_bottom_button
  1284.         int     0x40    ; bottom button filling
  1285. ;-----------------------------------------------------------------------------
  1286. ; scrollbar type 2
  1287.         cmp     word sb_type,2
  1288.         jne     .no_type2_1
  1289. ;*********************************
  1290. draw_down_arrow_horizontal_type2
  1291. ;*********************************
  1292.         jmp     .no_draw_bottom_button
  1293. .no_type2_1:
  1294. ;*********************************
  1295. draw_down_arrow_horizontal
  1296. ;*********************************
  1297. .no_draw_bottom_button:
  1298.         pop     ebx
  1299.        
  1300.         ror     ebx,16
  1301.         add     ebx,sb_btn_high  ;14 shl 16
  1302.         rol     ebx,16
  1303.        
  1304.         mov     edx,sb_line_col
  1305.         mov     bx,1
  1306.         cmp     dword sb_all_redraw,0
  1307.         je      @f
  1308.         mcall   13      ; bottom button - extreme line
  1309. ;-----------------------------------------------------------------------------
  1310. ; scrollbar type 1 - stylish frame
  1311.         cmp     word sb_type,1
  1312.         jne     @f
  1313.         ; drawing a stylish frame on the left button
  1314.         movzx   eax,word sb_start_x
  1315.         movzx   ebx,word sb_start_y
  1316.         movzx   edx,word sb_size_y
  1317.         stdcall draw_edge,eax,ebx,sb_btn_high,edx,\
  1318.                 sb_bckg_col,sb_frnt_col,sb_line_col
  1319.        
  1320.         movzx   eax,word sb_start_x
  1321.         add     ax,sb_size_x
  1322.         sub     eax,sb_btn_high
  1323.         dec     eax
  1324.         ; drawing a stylish frame on the right button
  1325.         stdcall draw_edge,eax,ebx,sb_btn_high,edx,\
  1326.                 sb_bckg_col,sb_frnt_col,sb_line_col
  1327. @@:
  1328. ;-----------------------------------------------------------------------------
  1329.         popa
  1330.         ret
  1331. ;*****************************************************************************
  1332. ; mouse event
  1333. ;*****************************************************************************
  1334. .mouse:
  1335.         pusha
  1336.         mov      edi,dword [esp+36]
  1337.         mcall   37,1
  1338.         mov     sb_m_pos,eax
  1339.         cmp     dword sb_m_pos_2,0
  1340.         jne     @f
  1341.        
  1342.         mov     sb_m_pos_2,eax 
  1343. @@:
  1344.         mcall   37,2
  1345.         mov     sb_m_keys,eax  
  1346.  
  1347.         cmp     sb_m_keys,eax
  1348.         je      @f
  1349.        
  1350.         mov     sb_m_keys,eax
  1351.  
  1352.         mov     sb_delta,dword 0
  1353.        
  1354.         mov     eax,sb_m_pos
  1355.         mov     sb_m_pos_2,eax
  1356.         jmp     .continue_2
  1357.        
  1358. @@:
  1359.         cmp     dword sb_m_keys,0
  1360.         jne      @f
  1361.         mov     eax,sb_m_pos
  1362.         mov     sb_m_pos_2,eax
  1363.         jmp     .correct_1      ;.exit_sb
  1364. @@:
  1365.         mov     sb_delta,word 1
  1366.  
  1367. .continue_2:
  1368.         mov     eax,sb_m_pos
  1369.         test    eax,0x80000000
  1370.         jnz     .exit_sb
  1371.        
  1372.         test    eax,0x8000
  1373.         jnz     .exit_sb
  1374.        
  1375.         mov     ebx,eax
  1376.         shr     eax,16  ; x position
  1377.         shl     ebx,16
  1378.         shr     ebx,16  ; y position
  1379.  
  1380.         mov     cx,sb_start_x   ;y
  1381.         cmp     ax,cx
  1382.         jb      .exit_sb
  1383.        
  1384.         cmp     word sb_delta2,0
  1385.         je      @f
  1386.         push    ecx
  1387.         add     cx,sb_btn_high
  1388.         cmp     ax,cx
  1389.         pop     ecx
  1390.         jb      .exit_sb
  1391.        
  1392. @@:
  1393.         add     cx,sb_size_x    ;y
  1394.         cmp     ax,cx
  1395.         ja      .exit_sb
  1396.  
  1397.         cmp     word sb_delta2,0
  1398.         je      @f
  1399.         sub     cx,sb_btn_high
  1400.         cmp     ax,cx
  1401.         ja      .exit_sb
  1402.        
  1403. @@:
  1404.         cmp     word sb_delta2,1
  1405.         je      @f
  1406.        
  1407.         cmp     dword sb_m_keys,0
  1408.         je      .exit_sb
  1409.        
  1410.         mov     cx,sb_start_y   ;x
  1411.         cmp     bx,cx
  1412.         jb      .exit_sb
  1413.        
  1414.         add     cx,sb_size_y    ;x
  1415.         cmp     bx,cx
  1416.         ja      .exit_sb
  1417.        
  1418.         mov     cx,sb_r_start_x
  1419.         cmp     ax,cx
  1420.         jb      .no_runner
  1421.        
  1422.         add     cx,sb_r_size_x
  1423.         cmp     ax,cx
  1424.         ja      .no_runner
  1425.  
  1426.         mov     sb_delta2,word 1
  1427. @@:
  1428.         push    eax
  1429.         mov     eax,sb_m_pos
  1430.         mov     ebx,sb_m_pos_2
  1431.         shr     eax,16
  1432.         shr     ebx,16
  1433.         cmp     eax,ebx
  1434.         je      .correct       
  1435.        
  1436. ;       shl     eax,16
  1437. ;       shr     eax,16
  1438. ;       mov     ebx,sb_m_pos_2
  1439. ;       shl     ebx,16
  1440. ;       shr     ebx,16
  1441. ;       cmp     eax,ebx
  1442.         jb      .sub
  1443.        
  1444.         sub     eax,ebx
  1445.         mov     ebx,eax
  1446.         add     sb_position2,ebx
  1447.         xor     eax,eax
  1448.         mov     ax,sb_size_x    ;y
  1449.         sub     eax,sb_btn_high
  1450.         sub     eax,sb_btn_high
  1451.         sub     eax,sb_run_size
  1452.         cmp     sb_position2,eax
  1453.         jbe     @f
  1454.        
  1455.         mov     sb_position2,eax
  1456. @@:
  1457.         mov     eax,sb_m_pos
  1458.         mov     sb_m_pos_2,eax
  1459.         pop     eax
  1460.         call    .draw_1
  1461.         jmp     .no_runner_1
  1462.        
  1463. .correct:
  1464.         pop     eax
  1465.         jmp     .exit_sb
  1466. .correct_1:
  1467.         mov     sb_delta,dword 0
  1468.         jmp     .exit_sb
  1469.  
  1470. .sub:
  1471.         sub     ebx,eax
  1472.         sub     sb_position2,ebx
  1473.         test    sb_position2,dword 0x80000000
  1474.         jz      @f
  1475.        
  1476.         mov     sb_position2,dword 0
  1477. @@:
  1478.         mov     eax,sb_m_pos
  1479.         mov     sb_m_pos_2,eax
  1480.         pop     eax
  1481.         call    .draw_1
  1482.         jmp     .no_runner_1
  1483.  
  1484. ;*****************************************************************************
  1485. .no_runner:
  1486.         mov     sb_delta,dword 0
  1487. .no_runner_1:
  1488.         xor     ecx,ecx
  1489.         mov     cx,sb_start_x   ;y
  1490.         add     cx,sb_btn_high  ;15
  1491.         cmp     word sb_delta,1
  1492.         je      .scroll_sb
  1493.        
  1494.         cmp     ax,cx
  1495.         ja      .scroll_sb
  1496.        
  1497.         cmp     dword sb_m_keys,0
  1498.         je      .exit_sb
  1499.        
  1500.         mov     eax,sb_ar_offset
  1501.         cmp     sb_position,eax  ;dword 0
  1502.         jbe     @f
  1503.        
  1504.         sub     sb_position,eax
  1505.         jmp     .all_sb
  1506. @@:
  1507.         xor     eax,eax
  1508.         mov     sb_position,eax ;dword 0
  1509.         mov     sb_position2,eax  ;dword 0
  1510.         jmp     .all_sb
  1511. ;*****************************************************************************
  1512. .scroll_sb:
  1513.         add     cx,sb_size_x    ;y
  1514.         sub     cx,sb_btn_high
  1515.         sub     cx,sb_btn_high
  1516.         cmp     word sb_delta,1
  1517.         je      @f
  1518.        
  1519.         cmp     ax,cx
  1520.         ja      .down_sb
  1521.        
  1522. @@:
  1523.         mov     ebx,sb_btn_high ;16  ;15
  1524.         add     bx,sb_start_x   ;y
  1525.         sub     cx,bx
  1526.         sub     ax,bx
  1527.        
  1528. .scroll_sb_1:  
  1529.         mov     ebx,sb_run_size
  1530. ;***************************************************************************** 
  1531.         cmp     word sb_delta,1
  1532.         je      .continue
  1533.        
  1534. @@:
  1535.         mov     edx,eax
  1536.  
  1537.         push    ebx
  1538.         shr     ebx,1
  1539.         sub     edx,ebx
  1540.         pop     ebx
  1541.         mov     sb_position2,edx
  1542.         test    sb_position2,dword 0x80000000
  1543.         jz       .test_1
  1544.        
  1545.         mov     sb_position2,dword 0
  1546.         jmp     .continue
  1547.        
  1548. .test_1:
  1549.         xor     edx,edx
  1550.         mov     dx,sb_size_x     ;y
  1551.         sub     edx,sb_btn_high
  1552.         sub     edx,sb_btn_high
  1553.         sub     edx,sb_run_size
  1554.         cmp     sb_position2,edx
  1555.         jbe     .continue
  1556.        
  1557.         mov     sb_position2,edx
  1558.  
  1559. .continue:     
  1560.         mov     eax,sb_position2
  1561.         sub     ecx,ebx
  1562. .continue_1:
  1563. ;*****************************************************************************  
  1564.         mov     ebx,eax
  1565.  
  1566.         mov     eax,sb_max_area
  1567.         cmp     eax,sb_cur_area
  1568.         ja      @f
  1569.  
  1570.         xor     eax,eax
  1571.         inc     eax
  1572.         mov     sb_position2,eax
  1573.         jmp     .all_sb
  1574. @@:
  1575.         sub     eax,sb_cur_area
  1576.         inc     eax
  1577.         shl     eax,10
  1578.         xor     edx,edx
  1579.         div     ecx
  1580.         shl     edx,1
  1581.         cmp     edx,ecx
  1582.         jb      @f
  1583.        
  1584.         inc     eax
  1585.        
  1586. @@:
  1587.         imul  eax,ebx
  1588.         shr     eax,10
  1589.        
  1590.         cmp     sb_position,eax
  1591.         je      .exit_sb
  1592.        
  1593.         cmp     eax,0
  1594.         ja      @f
  1595.        
  1596.         xor     eax,eax
  1597.        
  1598. @@:
  1599. .store_position:
  1600.         mov     edx,sb_max_area
  1601.         sub     edx,sb_cur_area
  1602.         cmp     edx,eax
  1603.         ja      @f
  1604.  
  1605.         mov     sb_position,edx
  1606.         jmp     .all_sb
  1607.  
  1608. @@:
  1609.         mov     sb_position,eax
  1610. .all_sb:
  1611.         mov     sb_redraw,dword 1
  1612.         call    .draw_1
  1613.         mov     eax,sb_m_pos
  1614.         mov     sb_m_pos_2,eax
  1615.         jmp     .exit_sb
  1616. ;*****************************************************************************
  1617. .down_sb:
  1618.         cmp     dword sb_m_keys,0
  1619.         je      .exit_sb
  1620.        
  1621.         mov     eax,sb_max_area
  1622.         mov     ebx,sb_ar_offset
  1623.         sub     eax,sb_cur_area
  1624.         push    eax
  1625.         sub     eax,ebx
  1626.         cmp     sb_position,eax
  1627.         pop     eax
  1628.         jae     @f
  1629.        
  1630.         add     sb_position,ebx
  1631.         jmp     .all_sb
  1632. @@:
  1633.         mov     sb_position,eax
  1634.         xor     eax,eax
  1635.         mov     ax,sb_size_x
  1636.         sub     eax,sb_btn_high
  1637.         sub     eax,sb_btn_high
  1638.         sub     eax,sb_run_size
  1639.         mov     sb_position2,eax
  1640.         jmp     .all_sb
  1641. ;*****************************************************************************
  1642. .exit_sb:
  1643. scroll_bar_exit
  1644. }
  1645.