Subversion Repositories Kolibri OS

Rev

Rev 2317 | Go to most recent revision | 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.         cmp     eax,10
  472.         jae     @f
  473.         mov     eax,10
  474. @@:
  475. .no_size:
  476.         mov     sb_run_size,eax
  477. ;*********************************
  478.         cmp     word sb_delta,1
  479.         je      .@@_3
  480.         mov     eax,sb_work_size
  481.         sub     eax,sb_run_size
  482.         mov     ebx,sb_max_area
  483.         cmp     ebx,sb_cur_area
  484.         ja      @f
  485.         xor     eax,eax
  486.         jmp     .@@_1
  487. @@:
  488.         sub     ebx,sb_cur_area
  489.         imul    eax,sb_position
  490.         xor     edx,edx
  491.         div     ebx
  492. .@@_1:
  493.         mov     sb_position2,eax
  494.         xor     edx,edx
  495.         mov     dx,sb_size_y
  496.         sub     edx,sb_btn_high
  497.         sub     edx,sb_btn_high
  498.         sub     edx,sb_run_size
  499.         cmp     sb_position2,edx
  500.         jbe     .@@_3
  501.         mov     sb_position2,edx
  502. .@@_3:
  503. ;*********************************     
  504.         mov     ebx,sb_start_x
  505.         shl     ebx,16
  506.         inc     ebx
  507.         mov     ecx,sb_size_y
  508.         mov     edx,sb_line_col
  509.         mov     eax,13
  510.         cmp     dword sb_all_redraw,0
  511.         je      @f
  512.         int     0x40    ; left extreme line
  513. @@:
  514.         push    ebx
  515.         ror     ebx,16
  516.         add     bx,sb_size_x
  517.         rol     ebx,16
  518.         cmp     dword sb_all_redraw,0
  519.         je      @f
  520.         int     0x40    ; right extreme line
  521. @@:
  522.         pop     ebx
  523.  
  524.         push    ecx
  525.        
  526.         add     ebx,1 shl 16
  527.         mov     bx,sb_size_x
  528.         dec     ebx    
  529.         mov     cx,1
  530.         cmp     dword sb_all_redraw,0
  531.         je      @f
  532.         int     0x40    ; top button - extreme line
  533. @@:
  534.         push    ecx
  535.         add     ecx,1 shl 16
  536.         add     ecx,sb_btn_high
  537.         sub     ecx,2
  538.         mov     edx,sb_frnt_col
  539.         cmp     dword sb_all_redraw,0
  540.         je      .no_draw_top_button
  541.         int     0x40    ; top button filling
  542. ;-----------------------------------------------------------------------------
  543. ; scrollbar type 2
  544.         cmp     word sb_type,2
  545.         jne     .no_type2
  546. ;*********************************
  547. draw_up_arrow_vertical_type2
  548. ;*********************************
  549.         jmp     .no_draw_top_button
  550. .no_type2:
  551. ;*********************************
  552. draw_up_arrow_vertical
  553. ;*********************************
  554. .no_draw_top_button:
  555.         pop     ecx
  556.        
  557.         ror     ecx,16
  558.         add     ecx,sb_btn_high  ;14 shl 16
  559.         rol     ecx,16
  560.         mov     edx,sb_line_col
  561.         cmp     dword sb_all_redraw,0
  562.         je      @f
  563.         mcall   13      ;  top button - bottom line
  564. @@:
  565.         pop     ecx
  566. ;*********************************
  567.         ror     ecx,16 
  568.         add     ecx,sb_btn_high  ;15 shl 16
  569.         inc     ecx
  570.         rol     ecx,16
  571.         sub     ecx,sb_btn_high  ;30
  572.         sub     ecx,sb_btn_high
  573.         push    ecx
  574.         mov     cx,0
  575.         add     ecx,sb_position2
  576.         dec     cx
  577.         mov     eax,13
  578.         test    cx,0x8000
  579.         jnz     @f
  580.         mov     edx,sb_bckg_col
  581.         int     0x40    ; top interval
  582. @@:
  583. ;*********************************
  584.         shr     ecx,16
  585.         add     ecx,sb_position2
  586.         dec     ecx
  587.         shl     ecx,16
  588.         inc     ecx
  589.         mov     edx,sb_line_col
  590.         int     0x40    ; runner - top extreme line
  591.        
  592.         add     ecx,1 shl 16
  593.         mov     cx,0
  594.         add     ecx,sb_run_size
  595.         mov     sb_r_size_x,ebx
  596.         mov     sb_r_size_y,ecx
  597.         sub     ecx,2
  598.         mov     edx,sb_frnt_col
  599.         int     0x40    ; runner filling
  600. ;-----------------------------------------------------------------------------
  601. ; scrollbar type 2
  602.         cmp     word sb_type,2
  603.         je      @f
  604. ;*********************************
  605. draw_runner_center_vertical
  606. ;*********************************
  607. @@:
  608. ;-----------------------------------------------------------------------------
  609. ; scrollbar type 1 - stylish frame
  610.         cmp     word sb_type,1
  611.         jne     @f
  612.         push    eax ebx ecx edx
  613.         movzx   eax,word sb_start_x
  614.         xor     ebx,ebx
  615.         add     bx,sb_r_start_y
  616.         dec     ebx
  617.         movzx   ecx,word sb_size_x
  618.         mov     edx,sb_run_size
  619.         dec     edx
  620.         ; drawing a stylish frame on the slider
  621.         stdcall draw_edge,eax,ebx,ecx,edx,sb_bckg_col,sb_frnt_col,sb_line_col
  622.         pop     edx ecx ebx eax
  623. @@:
  624. ;-----------------------------------------------------------------------------
  625.         shr     ecx,16
  626.         add     ecx,sb_run_size
  627.         sub     ecx,2
  628.         shl     ecx,16  
  629.         inc     ecx
  630.         mov     edx,sb_line_col
  631.         int     0x40    ; runner - bottom extreme line
  632.        
  633.         add     ecx,1 shl 16
  634.         mov     cx,sb_start_y
  635.         add     cx,sb_size_y
  636.         sub     ecx,sb_btn_high
  637.         dec     ecx
  638.         mov     eax,ecx
  639.         shr     eax,16
  640.         sub     cx,ax
  641.         test    cx,0x8000
  642.         jnz     @f
  643.         mov     edx,sb_bckg_col
  644.         mov     eax,13
  645.         int     0x40    ; bottom interval
  646. @@:    
  647.         pop     ecx    
  648. ;*********************************     
  649.         mov     ax,cx
  650.         shr     ecx,16
  651.         add     cx,ax
  652.         sub     ecx,2
  653.         shl     ecx,16
  654.         inc     ecx
  655.         mov     edx,sb_line_col
  656.         mov     eax,13
  657.         cmp     dword sb_all_redraw,0
  658.         je      @f
  659.         int     0x40    ; bottom button - top line
  660. @@:
  661.         push    ecx
  662.         add     ecx,1 shl 16
  663.         add     cx,sb_btn_high
  664.         sub     ecx,2
  665.         mov     edx,sb_frnt_col
  666.         cmp     dword sb_all_redraw,0
  667.         je      .no_draw_bottom_button
  668.         int     0x40    ; bottom button filling
  669. ;-----------------------------------------------------------------------------
  670. ; scrollbar type 2
  671.         cmp     word sb_type,2
  672.         jne     .no_type2_1
  673. ;*********************************
  674. draw_down_arrow_vertical_type2
  675. ;*********************************
  676.         jmp     .no_draw_bottom_button
  677. .no_type2_1:
  678. ;*********************************
  679. draw_down_arrow_vertical
  680. ;*********************************
  681. .no_draw_bottom_button:
  682.         pop     ecx
  683.        
  684.         ror     ecx,16
  685.         add     ecx,sb_btn_high
  686.         rol     ecx,16
  687.        
  688.         mov     edx,sb_line_col
  689.         mov     cx,1
  690.         cmp     dword sb_all_redraw,0
  691.         je      @f
  692.         mcall   13      ; bottom button - extreme line
  693. ;-----------------------------------------------------------------------------
  694. ; scrollbar type 1 - stylish frame
  695.         cmp     word sb_type,1
  696.         jne     @f
  697.         movzx   eax,word sb_start_x
  698.         movzx   ebx,word sb_start_y
  699.         movzx   ecx,word sb_size_x
  700.         ; drawing a stylish frame on the top button
  701.         stdcall draw_edge,eax,ebx,ecx,sb_btn_high,\
  702.                 sb_bckg_col,sb_frnt_col,sb_line_col
  703.         add     bx,sb_size_y
  704.         sub     ebx,sb_btn_high
  705.         dec     ebx
  706.         ; drawing a stylish frame on the bottom  button
  707.         stdcall draw_edge,eax,ebx,ecx,sb_btn_high,\
  708.                 sb_bckg_col,sb_frnt_col,sb_line_col
  709. @@:
  710. ;-----------------------------------------------------------------------------
  711.         popa
  712.         ret
  713. ;*****************************************************************************
  714. ;*****************************************************************************
  715. ; mouse event
  716. ;*****************************************************************************
  717. ;*****************************************************************************
  718. .mouse:
  719.         pusha
  720.         mov     edi,dword [esp+36]
  721.         mcall   37,1
  722.         mov     sb_m_pos,eax
  723.         cmp     dword sb_m_pos_2,0
  724.         jne     @f
  725.        
  726.         mov     sb_m_pos_2,eax 
  727. @@:
  728.         mcall   37,2
  729.         mov     sb_m_keys,eax  
  730.  
  731.         cmp     sb_m_keys,eax
  732.         je      @f
  733.        
  734.         mov     sb_m_keys,eax
  735.         mov     sb_delta,dword 0
  736.         mov     eax,sb_m_pos
  737.         mov     sb_m_pos_2,eax
  738.         jmp     .continue_2
  739. @@:
  740.         cmp     dword sb_m_keys,0
  741.         jne      @f
  742.         mov     eax,sb_m_pos
  743.         mov     sb_m_pos_2,eax
  744.         jmp     .correct_1      ;.exit_sb      
  745. @@:
  746.         mov     sb_delta,word 1
  747.  
  748. .continue_2:
  749.         mov     eax,sb_m_pos
  750.         test    eax,0x80000000
  751.         jnz     .exit_sb
  752.        
  753.         test    eax,0x8000
  754.         jnz     .exit_sb
  755.        
  756.         mov     ebx,eax
  757.         shr     ebx,16  ; x position
  758.         shl     eax,16
  759.         shr     eax,16  ; y position
  760.  
  761.         mov     cx,sb_start_y
  762.         cmp     ax,cx
  763.         jb      .exit_sb
  764.        
  765.         cmp     word sb_delta2,0
  766.         je      @f
  767.         push    ecx
  768.         add     cx,sb_btn_high
  769.         cmp     ax,cx
  770.         pop     ecx
  771.         jb      .exit_sb
  772.        
  773. @@:
  774.         add     cx,sb_size_y
  775.         cmp     ax,cx
  776.         ja      .exit_sb
  777.  
  778.         cmp     word sb_delta2,0
  779.         je      @f
  780.         sub     cx,sb_btn_high
  781.         cmp     ax,cx
  782.         ja      .exit_sb
  783.        
  784. @@:
  785.         cmp     word sb_delta2,1
  786.         je      @f
  787.        
  788.         cmp     dword sb_m_keys,0
  789.         je      .exit_sb
  790.        
  791.         mov     cx,sb_start_x
  792.         cmp     bx,cx
  793.         jb      .exit_sb
  794.        
  795.         add     cx,sb_size_x
  796.         cmp     bx,cx
  797.         ja      .exit_sb
  798.  
  799.         mov     cx,sb_r_start_y
  800.         cmp     ax,cx
  801.         jb      .no_runner
  802.        
  803.         add     cx,sb_r_size_y
  804.         cmp     ax,cx
  805.         ja      .no_runner
  806.  
  807.         mov     sb_delta2,word 1       
  808. @@:
  809.         push    eax
  810.         mov     ax,sb_m_pos
  811.         cmp     ax,sb_m_pos_2
  812.         je      .correct       
  813.        
  814.         shl     eax,16
  815.         shr     eax,16
  816.         mov     ebx,sb_m_pos_2
  817.         shl     ebx,16
  818.         shr     ebx,16
  819.         cmp     eax,ebx
  820.         jb      .sub
  821.        
  822.         sub     eax,ebx
  823.         mov     ebx,eax
  824.         add     sb_position2,ebx
  825.         xor     eax,eax
  826.         mov     ax,sb_size_y
  827.         sub     eax,sb_btn_high
  828.         sub     eax,sb_btn_high
  829.         sub     eax,sb_run_size
  830.         cmp     sb_position2,eax
  831.         jbe     @f
  832.        
  833.         mov     sb_position2,eax
  834. @@:
  835.         mov     eax,sb_m_pos
  836.         mov     sb_m_pos_2,eax
  837.         pop     eax
  838.         call    .draw_1
  839.         jmp     .no_runner_1
  840.        
  841. .correct:
  842.         pop     eax
  843.         jmp     .exit_sb
  844. .correct_1:
  845.         mov     sb_delta,dword 0
  846.         jmp     .exit_sb
  847.  
  848. .sub:
  849.         sub     ebx,eax
  850.         sub     sb_position2,ebx
  851.         test    sb_position2,dword 0x80000000
  852.         jz      @f
  853.        
  854.         mov     sb_position2,dword 0
  855. @@:
  856.         mov     eax,sb_m_pos
  857.         mov     sb_m_pos_2,eax
  858.         pop     eax
  859.         call    .draw_1
  860.         jmp     .no_runner_1
  861.  
  862. ;*****************************************************************************
  863. .no_runner:
  864.         mov     sb_delta,dword 0
  865. .no_runner_1:
  866.         xor     ecx,ecx
  867.         mov     cx,sb_start_y
  868.         add     cx,sb_btn_high  ;15
  869.         cmp     word sb_delta,1
  870.         je      .scroll_sb
  871.        
  872.         cmp     ax,cx
  873.         ja      .scroll_sb
  874.        
  875.         cmp     dword sb_m_keys,0
  876.         je      .exit_sb
  877.        
  878.         mov     eax,sb_ar_offset
  879.         cmp     sb_position,eax  ;dword 0
  880.         jbe     @f
  881.        
  882.         sub     sb_position,eax
  883.         jmp     .all_sb
  884. @@:
  885.         xor     eax,eax
  886.         mov     sb_position,eax ;dword 0
  887.         mov     sb_position2,eax ;dword 0
  888.         jmp     .all_sb
  889. ;*****************************************************************************
  890. .scroll_sb:
  891.         add     cx,sb_size_y
  892.         sub     cx,sb_btn_high
  893.         sub     cx,sb_btn_high
  894.         cmp     word sb_delta,1
  895.         je      @f
  896.        
  897.         cmp     ax,cx
  898.         ja      .down_sb
  899.        
  900. @@:
  901.         mov     ebx,sb_btn_high ;16  ;15
  902.         add     bx,sb_start_y
  903.         sub     cx,bx
  904.         sub     ax,bx
  905.        
  906. .scroll_sb_1:  
  907.         mov     ebx,sb_run_size
  908. ;***************************************************************************** 
  909.         cmp     word sb_delta,1
  910.         je      .continue
  911.        
  912. @@:
  913.         mov     edx,eax
  914.         push    ebx
  915.         shr     ebx,1
  916.         sub     edx,ebx
  917.         pop     ebx
  918.         mov     sb_position2,edx
  919.         test    sb_position2,dword 0x80000000
  920.         jz      .test_1
  921.        
  922.         mov     sb_position2,dword 0
  923.         jmp     .continue
  924.        
  925. .test_1:
  926.         xor     edx,edx
  927.         mov     dx,sb_size_y
  928.         sub     edx,sb_btn_high
  929.         sub     edx,sb_btn_high
  930.         sub     edx,sb_run_size
  931.         cmp     sb_position2,edx
  932.         jbe     .continue
  933.        
  934.         mov     sb_position2,edx
  935.  
  936. .continue:     
  937.         mov     eax,sb_position2
  938.         sub     ecx,ebx
  939. .continue_1:
  940. ;*****************************************************************************  
  941.         mov     ebx,eax
  942.  
  943.         mov     eax,sb_max_area
  944.         cmp     eax,sb_cur_area
  945.         ja      @f
  946.  
  947.         xor     eax,eax
  948.         inc     eax
  949.         mov     sb_position2,eax
  950.         jmp     .all_sb
  951. @@:
  952.         sub     eax,sb_cur_area
  953.         inc     eax
  954.         shl     eax,10
  955.         xor     edx,edx
  956.         div     ecx
  957.         shl     edx,1
  958.         cmp     edx,ecx
  959.         jb      @f
  960.        
  961.         inc     eax
  962.        
  963. @@:
  964.         imul    eax,ebx
  965.         shr     eax,10
  966.        
  967.         cmp     sb_position,eax
  968.         je      .exit_sb
  969.        
  970.         cmp     eax,0
  971.         ja      @f
  972.        
  973.         xor     eax,eax
  974.        
  975. @@:
  976. .store_position:
  977.         mov     sb_position,eax
  978. .all_sb:
  979.         mov     sb_redraw,dword 1
  980.         call    .draw_1
  981.         mov     eax,sb_m_pos
  982.         mov     sb_m_pos_2,eax
  983.         jmp     .exit_sb
  984. ;*****************************************************************************
  985. .down_sb:
  986.         cmp     dword sb_m_keys,0
  987.         je      .exit_sb
  988.        
  989.         mov     eax,sb_max_area
  990.         mov     ebx,sb_ar_offset
  991.         sub     eax,sb_cur_area
  992.         push    eax
  993.         sub     eax,ebx
  994.         cmp     sb_position,eax
  995.         pop     eax
  996.         jae     @f
  997.        
  998.         add     sb_position,ebx
  999.         jmp     .all_sb
  1000. @@:
  1001.         mov     sb_position,eax
  1002.         xor     eax,eax
  1003.         mov     ax,sb_size_y
  1004.         sub     eax,sb_btn_high
  1005.         sub     eax,sb_btn_high
  1006.         sub     eax,sb_run_size
  1007.         mov     sb_position2,eax
  1008.         jmp     .all_sb
  1009. .exit_sb:      
  1010. scroll_bar_exit
  1011. }
  1012.  
  1013. ;*****************************************************************************
  1014. ;*****************************************************************************
  1015. ;*****************************************************************************
  1016. ;*****************************************************************************
  1017. ;*****************************************************************************
  1018. macro use_scroll_bar_horizontal
  1019. {
  1020. scroll_bar_horizontal:
  1021. .draw:
  1022.         pusha
  1023.         mov     edi,dword [esp+36]
  1024.         mov     sb_delta,word 0
  1025.         call    .draw_1
  1026.         mov     sb_all_redraw,dword 0
  1027. scroll_bar_exit
  1028. .draw_1:
  1029.         pusha
  1030. ;*********************************
  1031.         xor     eax,eax
  1032.         mov     ax,sb_size_x    ;sb_size_y
  1033.         mov     edx,sb_btn_high
  1034.         shl     edx,1
  1035.         sub     eax,edx
  1036.         mov     sb_work_size,eax
  1037. ;*********************************
  1038.         mov     eax,sb_work_size        ;sb_max_area
  1039.         mov     ebx,sb_max_area
  1040.         cmp     ebx,sb_cur_area
  1041.         ja      @f
  1042.  
  1043.         jmp     .no_size
  1044.  
  1045. @@:
  1046.         imul    eax,sb_cur_area
  1047.         xor     edx,edx
  1048.         div     ebx
  1049.         cmp     eax,10
  1050.         jae     @f
  1051.         mov     eax,10
  1052. @@:
  1053. .no_size:
  1054.         mov     sb_run_size,eax
  1055. ;*********************************
  1056.         cmp     word sb_delta,1
  1057.         je      .@@_3
  1058.         mov     eax,sb_work_size
  1059.         sub     eax,sb_run_size
  1060.         mov     ebx,sb_max_area
  1061.         cmp     ebx,sb_cur_area
  1062.         ja      @f
  1063.         xor     eax,eax
  1064.         jmp     .@@_1
  1065. @@:
  1066.         sub     ebx,sb_cur_area
  1067.         imul    eax,sb_position
  1068.         xor     edx,edx
  1069.         div     ebx
  1070. .@@_1:
  1071.         mov     sb_position2,eax
  1072.         xor     edx,edx
  1073.         mov     dx,sb_size_x
  1074.         sub     edx,sb_btn_high
  1075.         sub     edx,sb_btn_high
  1076.         sub     edx,sb_run_size
  1077.         cmp     sb_position2,edx
  1078.         jbe     .@@_3
  1079.         mov     sb_position2,edx
  1080. .@@_3:
  1081. ;*********************************     
  1082.         mov     ebx,sb_size_x
  1083.         mov     ecx,sb_start_y
  1084.         shl     ecx,16
  1085.         inc     ecx    
  1086.         mov     edx,sb_line_col
  1087.         mov     eax,13
  1088.         cmp     dword sb_all_redraw,0
  1089.         je      @f
  1090.         int     0x40    ; top extreme line
  1091. @@:
  1092.         push    ecx
  1093.         ror     ecx,16
  1094.         add     cx,sb_size_y
  1095.         rol     ecx,16
  1096.         cmp     dword sb_all_redraw,0
  1097.         je      @f
  1098.         int     0x40    ; bottom extreme line
  1099. @@:
  1100.         pop     ecx
  1101.  
  1102.         push    ebx
  1103.        
  1104.         add     ecx,1 shl 16
  1105.         mov     cx,sb_size_y
  1106.         dec     ecx    
  1107.         mov     bx,1
  1108.         cmp     dword sb_all_redraw,0
  1109.         je      @f
  1110.         int     0x40    ; left button - extreme line
  1111. @@:
  1112.         push    ebx
  1113.         add     ebx,1 shl 16
  1114.         add     ebx,sb_btn_high
  1115.         sub     ebx,2
  1116.         mov     edx,sb_frnt_col
  1117.         cmp     dword sb_all_redraw,0
  1118.         je      .no_draw_top_button
  1119.         int     0x40    ; left  button filling
  1120. ;-----------------------------------------------------------------------------
  1121. ; scrollbar type 2
  1122.         cmp     word sb_type,2
  1123.         jne     .no_type2
  1124. ;*********************************
  1125. draw_up_arrow_horizontal_type2
  1126. ;*********************************
  1127.         jmp     .no_draw_top_button
  1128. .no_type2:
  1129. ;*********************************     
  1130. draw_up_arrow_horizontal
  1131. ;*********************************
  1132. .no_draw_top_button:
  1133.         pop     ebx
  1134.        
  1135.         ror     ebx,16
  1136.         add     ebx,sb_btn_high  ;14 shl 16
  1137.         rol     ebx,16
  1138.         mov     edx,sb_line_col
  1139.         cmp     dword sb_all_redraw,0
  1140.         je      @f
  1141.         mcall   13      ;  left  button - right line
  1142. @@:
  1143.         pop     ebx
  1144. ;*********************************
  1145.         ror     ebx,16 
  1146.         add     ebx,sb_btn_high  ;15 shl 16
  1147.         inc     ebx
  1148.         rol     ebx,16
  1149.         sub     ebx,sb_btn_high  ;30
  1150.         sub     ebx,sb_btn_high
  1151.         push    ebx
  1152.         mov     bx,0
  1153.         add     ebx,sb_position2
  1154.         dec     bx
  1155.         mov     eax,13
  1156.         test    bx,0x8000
  1157.         jnz     @f
  1158.         mov     edx,sb_bckg_col
  1159.         int     0x40    ; left interval
  1160. @@:
  1161. ;*********************************
  1162.         shr     ebx,16
  1163.         add     ebx,sb_position2
  1164.         dec     ebx
  1165.         shl     ebx,16
  1166.         inc     ebx
  1167.         mov     edx,sb_line_col
  1168.         int     0x40    ; runner - left extreme line
  1169.        
  1170.         add     ebx,1 shl 16
  1171.         mov     bx,0
  1172.         add     ebx,sb_run_size
  1173.         mov     sb_r_size_x,ebx
  1174.         mov     sb_r_size_y,ecx
  1175.         sub     ebx,2
  1176.         mov     edx,sb_frnt_col
  1177.         int     0x40    ; runner filling
  1178. ;-----------------------------------------------------------------------------
  1179. ; scrollbar type 2
  1180.         cmp     word sb_type,2
  1181.         je      @f
  1182. ;*********************************
  1183. draw_runner_center_horizontal
  1184. ;*********************************
  1185. @@:    
  1186. ;-----------------------------------------------------------------------------
  1187. ; scrollbar type 1 - stylish frame
  1188.         cmp     word sb_type,1
  1189.         jne     @f
  1190.         push    eax ebx ecx edx
  1191.         xor     eax,eax
  1192.         add     ax,sb_r_start_x
  1193.         dec     eax
  1194.         movzx   ebx,word sb_start_y
  1195.         mov     ecx,sb_run_size
  1196.         dec     ecx
  1197.         movzx   edx,word sb_size_y
  1198.         ; drawing a stylish frame on the slider
  1199.         stdcall draw_edge,eax,ebx,ecx,edx,\
  1200.                 sb_bckg_col,sb_frnt_col,sb_line_col
  1201.         pop     edx ecx ebx eax
  1202. @@:
  1203. ;-----------------------------------------------------------------------------
  1204.         shr     ebx,16
  1205.         add     ebx,sb_run_size
  1206.         sub     ebx,2
  1207.         shl     ebx,16  
  1208.         inc     ebx
  1209.         mov     edx,sb_line_col
  1210.         int     0x40    ; runner - bottom extreme line
  1211.        
  1212.         add     ebx,1 shl 16
  1213.         mov     bx,sb_start_x
  1214.         add     bx,sb_size_x
  1215.         sub     ebx,sb_btn_high
  1216.         dec     ebx
  1217.         mov     eax,ebx
  1218.         shr     eax,16
  1219.         sub     bx,ax
  1220.         test    bx,0x8000
  1221.         jnz     @f
  1222.         mov     edx,sb_bckg_col
  1223.         mov     eax,13
  1224.         int     0x40    ; bottom interval
  1225. @@:
  1226.         pop     ebx    
  1227. ;*********************************     
  1228.         mov     ax,bx
  1229.         shr     ebx,16
  1230.         add     bx,ax
  1231.         sub     ebx,2
  1232.         shl     ebx,16
  1233.         inc     ebx
  1234.         mov     edx,sb_line_col
  1235.         mov     eax,13
  1236.         cmp     dword sb_all_redraw,0
  1237.         je      @f
  1238.         int     0x40    ; bottom button - top line
  1239. @@:
  1240.         push    ebx
  1241.         add     ebx,1 shl 16
  1242.         add     bx,sb_btn_high
  1243.         sub     ebx,2
  1244.         mov     edx,sb_frnt_col
  1245.         cmp     dword sb_all_redraw,0
  1246.         je      .no_draw_bottom_button
  1247.         int     0x40    ; bottom button filling
  1248. ;-----------------------------------------------------------------------------
  1249. ; scrollbar type 2
  1250.         cmp     word sb_type,2
  1251.         jne     .no_type2_1
  1252. ;*********************************
  1253. draw_down_arrow_horizontal_type2
  1254. ;*********************************
  1255.         jmp     .no_draw_bottom_button
  1256. .no_type2_1:
  1257. ;*********************************
  1258. draw_down_arrow_horizontal
  1259. ;*********************************
  1260. .no_draw_bottom_button:
  1261.         pop     ebx
  1262.        
  1263.         ror     ebx,16
  1264.         add     ebx,sb_btn_high  ;14 shl 16
  1265.         rol     ebx,16
  1266.        
  1267.         mov     edx,sb_line_col
  1268.         mov     bx,1
  1269.         cmp     dword sb_all_redraw,0
  1270.         je      @f
  1271.         mcall   13      ; bottom button - extreme line
  1272. ;-----------------------------------------------------------------------------
  1273. ; scrollbar type 1 - stylish frame
  1274.         cmp     word sb_type,1
  1275.         jne     @f
  1276.         ; drawing a stylish frame on the left button
  1277.         movzx   eax,word sb_start_x
  1278.         movzx   ebx,word sb_start_y
  1279.         movzx   edx,word sb_size_y
  1280.         stdcall draw_edge,eax,ebx,sb_btn_high,edx,\
  1281.                 sb_bckg_col,sb_frnt_col,sb_line_col
  1282.        
  1283.         movzx   eax,word sb_start_x
  1284.         add     ax,sb_size_x
  1285.         sub     eax,sb_btn_high
  1286.         dec     eax
  1287.         ; drawing a stylish frame on the right button
  1288.         stdcall draw_edge,eax,ebx,sb_btn_high,edx,\
  1289.                 sb_bckg_col,sb_frnt_col,sb_line_col
  1290. @@:
  1291. ;-----------------------------------------------------------------------------
  1292.         popa
  1293.         ret
  1294. ;*****************************************************************************
  1295. ; mouse event
  1296. ;*****************************************************************************
  1297. .mouse:
  1298.         pusha
  1299.         mov      edi,dword [esp+36]
  1300.         mcall   37,1
  1301.         mov     sb_m_pos,eax
  1302.         cmp     dword sb_m_pos_2,0
  1303.         jne     @f
  1304.        
  1305.         mov     sb_m_pos_2,eax 
  1306. @@:
  1307.         mcall   37,2
  1308.         mov     sb_m_keys,eax  
  1309.  
  1310.         cmp     sb_m_keys,eax
  1311.         je      @f
  1312.        
  1313.         mov     sb_m_keys,eax
  1314.  
  1315.         mov     sb_delta,dword 0
  1316.        
  1317.         mov     eax,sb_m_pos
  1318.         mov     sb_m_pos_2,eax
  1319.         jmp     .continue_2
  1320.        
  1321. @@:
  1322.         cmp     dword sb_m_keys,0
  1323.         jne      @f
  1324.         mov     eax,sb_m_pos
  1325.         mov     sb_m_pos_2,eax
  1326.         jmp     .correct_1      ;.exit_sb
  1327. @@:
  1328.         mov     sb_delta,word 1
  1329.  
  1330. .continue_2:
  1331.         mov     eax,sb_m_pos
  1332.         test    eax,0x80000000
  1333.         jnz     .exit_sb
  1334.        
  1335.         test    eax,0x8000
  1336.         jnz     .exit_sb
  1337.        
  1338.         mov     ebx,eax
  1339.         shr     eax,16  ; x position
  1340.         shl     ebx,16
  1341.         shr     ebx,16  ; y position
  1342.  
  1343.         mov     cx,sb_start_x   ;y
  1344.         cmp     ax,cx
  1345.         jb      .exit_sb
  1346.        
  1347.         cmp     word sb_delta2,0
  1348.         je      @f
  1349.         push    ecx
  1350.         add     cx,sb_btn_high
  1351.         cmp     ax,cx
  1352.         pop     ecx
  1353.         jb      .exit_sb
  1354.        
  1355. @@:
  1356.         add     cx,sb_size_x    ;y
  1357.         cmp     ax,cx
  1358.         ja      .exit_sb
  1359.  
  1360.         cmp     word sb_delta2,0
  1361.         je      @f
  1362.         sub     cx,sb_btn_high
  1363.         cmp     ax,cx
  1364.         ja      .exit_sb
  1365.        
  1366. @@:
  1367.         cmp     word sb_delta2,1
  1368.         je      @f
  1369.        
  1370.         cmp     dword sb_m_keys,0
  1371.         je      .exit_sb
  1372.        
  1373.         mov     cx,sb_start_y   ;x
  1374.         cmp     bx,cx
  1375.         jb      .exit_sb
  1376.        
  1377.         add     cx,sb_size_y    ;x
  1378.         cmp     bx,cx
  1379.         ja      .exit_sb
  1380.        
  1381.         mov     cx,sb_r_start_x
  1382.         cmp     ax,cx
  1383.         jb      .no_runner
  1384.        
  1385.         add     cx,sb_r_size_x
  1386.         cmp     ax,cx
  1387.         ja      .no_runner
  1388.  
  1389.         mov     sb_delta2,word 1
  1390. @@:
  1391.         push    eax
  1392.         mov     eax,sb_m_pos
  1393.         mov     ebx,sb_m_pos_2
  1394.         shr     eax,16
  1395.         shr     ebx,16
  1396.         cmp     eax,ebx
  1397.         je      .correct       
  1398.        
  1399. ;       shl     eax,16
  1400. ;       shr     eax,16
  1401. ;       mov     ebx,sb_m_pos_2
  1402. ;       shl     ebx,16
  1403. ;       shr     ebx,16
  1404. ;       cmp     eax,ebx
  1405.         jb      .sub
  1406.        
  1407.         sub     eax,ebx
  1408.         mov     ebx,eax
  1409.         add     sb_position2,ebx
  1410.         xor     eax,eax
  1411.         mov     ax,sb_size_x    ;y
  1412.         sub     eax,sb_btn_high
  1413.         sub     eax,sb_btn_high
  1414.         sub     eax,sb_run_size
  1415.         cmp     sb_position2,eax
  1416.         jbe     @f
  1417.        
  1418.         mov     sb_position2,eax
  1419. @@:
  1420.         mov     eax,sb_m_pos
  1421.         mov     sb_m_pos_2,eax
  1422.         pop     eax
  1423.         call    .draw_1
  1424.         jmp     .no_runner_1
  1425.        
  1426. .correct:
  1427.         pop     eax
  1428.         jmp     .exit_sb
  1429. .correct_1:
  1430.         mov     sb_delta,dword 0
  1431.         jmp     .exit_sb
  1432.  
  1433. .sub:
  1434.         sub     ebx,eax
  1435.         sub     sb_position2,ebx
  1436.         test    sb_position2,dword 0x80000000
  1437.         jz      @f
  1438.        
  1439.         mov     sb_position2,dword 0
  1440. @@:
  1441.         mov     eax,sb_m_pos
  1442.         mov     sb_m_pos_2,eax
  1443.         pop     eax
  1444.         call    .draw_1
  1445.         jmp     .no_runner_1
  1446.  
  1447. ;*****************************************************************************
  1448. .no_runner:
  1449.         mov     sb_delta,dword 0
  1450. .no_runner_1:
  1451.         xor     ecx,ecx
  1452.         mov     cx,sb_start_x   ;y
  1453.         add     cx,sb_btn_high  ;15
  1454.         cmp     word sb_delta,1
  1455.         je      .scroll_sb
  1456.        
  1457.         cmp     ax,cx
  1458.         ja      .scroll_sb
  1459.        
  1460.         cmp     dword sb_m_keys,0
  1461.         je      .exit_sb
  1462.        
  1463.         mov     eax,sb_ar_offset
  1464.         cmp     sb_position,eax  ;dword 0
  1465.         jbe     @f
  1466.        
  1467.         sub     sb_position,eax
  1468.         jmp     .all_sb
  1469. @@:
  1470.         xor     eax,eax
  1471.         mov     sb_position,eax ;dword 0
  1472.         mov     sb_position2,eax  ;dword 0
  1473.         jmp     .all_sb
  1474. ;*****************************************************************************
  1475. .scroll_sb:
  1476.         add     cx,sb_size_x    ;y
  1477.         sub     cx,sb_btn_high
  1478.         sub     cx,sb_btn_high
  1479.         cmp     word sb_delta,1
  1480.         je      @f
  1481.        
  1482.         cmp     ax,cx
  1483.         ja      .down_sb
  1484.        
  1485. @@:
  1486.         mov     ebx,sb_btn_high ;16  ;15
  1487.         add     bx,sb_start_x   ;y
  1488.         sub     cx,bx
  1489.         sub     ax,bx
  1490.        
  1491. .scroll_sb_1:  
  1492.         mov     ebx,sb_run_size
  1493. ;***************************************************************************** 
  1494.         cmp     word sb_delta,1
  1495.         je      .continue
  1496.        
  1497. @@:
  1498.         mov     edx,eax
  1499.  
  1500.         push    ebx
  1501.         shr     ebx,1
  1502.         sub     edx,ebx
  1503.         pop     ebx
  1504.         mov     sb_position2,edx
  1505.         test    sb_position2,dword 0x80000000
  1506.         jz       .test_1
  1507.        
  1508.         mov     sb_position2,dword 0
  1509.         jmp     .continue
  1510.        
  1511. .test_1:
  1512.         xor     edx,edx
  1513.         mov     dx,sb_size_x     ;y
  1514.         sub     edx,sb_btn_high
  1515.         sub     edx,sb_btn_high
  1516.         sub     edx,sb_run_size
  1517.         cmp     sb_position2,edx
  1518.         jbe     .continue
  1519.        
  1520.         mov     sb_position2,edx
  1521.  
  1522. .continue:     
  1523.         mov     eax,sb_position2
  1524.         sub     ecx,ebx
  1525. .continue_1:
  1526. ;*****************************************************************************  
  1527.         mov     ebx,eax
  1528.  
  1529.         mov     eax,sb_max_area
  1530.         cmp     eax,sb_cur_area
  1531.         ja      @f
  1532.  
  1533.         xor     eax,eax
  1534.         inc     eax
  1535.         mov     sb_position2,eax
  1536.         jmp     .all_sb
  1537. @@:
  1538.         sub     eax,sb_cur_area
  1539.         inc     eax
  1540.         shl     eax,10
  1541.         xor     edx,edx
  1542.         div     ecx
  1543.         shl     edx,1
  1544.         cmp     edx,ecx
  1545.         jb      @f
  1546.        
  1547.         inc     eax
  1548.        
  1549. @@:
  1550.         imul  eax,ebx
  1551.         shr     eax,10
  1552.        
  1553.         cmp     sb_position,eax
  1554.         je      .exit_sb
  1555.        
  1556.         cmp     eax,0
  1557.         ja      @f
  1558.        
  1559.         xor     eax,eax
  1560.        
  1561. @@:
  1562. .store_position:
  1563.         mov     sb_position,eax
  1564. .all_sb:
  1565.         mov     sb_redraw,dword 1
  1566.         call    .draw_1
  1567.         mov     eax,sb_m_pos
  1568.         mov     sb_m_pos_2,eax
  1569.         jmp     .exit_sb
  1570. ;*****************************************************************************
  1571. .down_sb:
  1572.         cmp     dword sb_m_keys,0
  1573.         je      .exit_sb
  1574.        
  1575.         mov     eax,sb_max_area
  1576.         mov     ebx,sb_ar_offset
  1577.         sub     eax,sb_cur_area
  1578.         push    eax
  1579.         sub     eax,ebx
  1580.         cmp     sb_position,eax
  1581.         pop     eax
  1582.         jae     @f
  1583.        
  1584.         add     sb_position,ebx
  1585.         jmp     .all_sb
  1586. @@:
  1587.         mov     sb_position,eax
  1588.         xor     eax,eax
  1589.         mov     ax,sb_size_x
  1590.         sub     eax,sb_btn_high
  1591.         sub     eax,sb_btn_high
  1592.         sub     eax,sb_run_size
  1593.         mov     sb_position2,eax
  1594.         jmp     .all_sb
  1595. ;*****************************************************************************
  1596. .exit_sb:
  1597. scroll_bar_exit
  1598. }
  1599.