Subversion Repositories Kolibri OS

Rev

Rev 9941 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2023. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;  VESA20.INC                                                  ;;
  7. ;;                                                              ;;
  8. ;;  Vesa 2.0 functions for MenuetOS                             ;;
  9. ;;                                                              ;;
  10. ;;  Copyright 2002 Ville Turjanmaa                              ;;
  11. ;;  Alexey, kgaz@crosswindws.net                                ;;
  12. ;;  - Voodoo compatible graphics                                ;;
  13. ;;  Juan M. Caravaca                                            ;;
  14. ;;  - Graphics optimimizations eg. drawline                     ;;
  15. ;;                                                              ;;
  16. ;;  See file COPYING for details                                ;;
  17. ;;                                                              ;;
  18. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  19.  
  20. $Revision: 9948 $
  21.  
  22. uglobal
  23. align 4
  24.         bgr_cur_line    rd MAX_SCREEN_WIDTH
  25.         bgr_next_line   rd MAX_SCREEN_WIDTH
  26. endg
  27.  
  28. iglobal
  29. align 4
  30.         overlapping_of_points_ptr       dd overlapping_of_points
  31. endg
  32.  
  33.  
  34. ;-----------------------------------------------------------------------------
  35. ; eax = x
  36. ; ebx = y
  37.  
  38. align 4
  39. Vesa20_getpixel16:
  40.  
  41.         ; check for hardware cursor
  42.         cmp     [_display.select_cursor], select_cursor
  43.         jne     .no_mouseunder
  44.  
  45.         ; check mouse area for putpixel
  46.         test    ecx, 0x04000000         ; don't load to mouseunder area
  47.         jnz     .no_mouseunder
  48.         call    [_display.check_m_pixel]
  49.         test    ecx, ecx                ; 0xff000000
  50.         jnz     @f
  51.  
  52.   .no_mouseunder:
  53. ;        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
  54.         mov     ebx, [BPSLine_calc_area + ebx*4]
  55.         lea     edi, [eax*2]            ; edi = x*2
  56.         add     edi, ebx                ; edi = x*2+(y*y multiplier)
  57.  
  58.         movzx   ecx, word[LFB_BASE + edi]
  59.         shl     ecx, 3
  60.         ror     ecx, 8
  61.         shl     cx, 2
  62.         ror     ecx, 8
  63.         shl     cl, 3
  64.         rol     ecx, 16
  65.   @@:
  66.         and     ecx, 0x00ffffff
  67.         ret
  68.  
  69. ;-----------------------------------------------------------------------------
  70. ; eax = x
  71. ; ebx = y
  72.  
  73. align 4
  74. Vesa20_getpixel24:
  75.  
  76.         ; check for hardware cursor
  77.         cmp     [_display.select_cursor], select_cursor
  78.         jne     .no_mouseunder
  79.  
  80.         ; check mouse area for putpixel
  81.         test    ecx, 0x04000000         ; don't load to mouseunder area
  82.         jnz     .no_mouseunder
  83.         call    [_display.check_m_pixel]
  84.         test    ecx, ecx                ; 0xff000000
  85.         jnz     @f
  86.  
  87.   .no_mouseunder:
  88. ;        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
  89.         mov     ebx, [BPSLine_calc_area + ebx*4]
  90.         lea     edi, [eax + eax*2]        ; edi = x*3
  91.         add     edi, ebx                ; edi = x*3+(y*y multiplier)
  92.  
  93.         mov     ecx, [LFB_BASE + edi]
  94.   @@:
  95.         and     ecx, 0x00ffffff
  96.         ret
  97.  
  98. ;-----------------------------------------------------------------------------
  99. ; eax = x
  100. ; ebx = y
  101.  
  102. align 4
  103. Vesa20_getpixel32:
  104.  
  105.         ; check for hardware cursor
  106.         cmp     [_display.select_cursor], select_cursor
  107.         jne     .no_mouseunder
  108.  
  109.         ; check mouse area for putpixel
  110.         test    ecx, 0x04000000         ; don't load to mouseunder area
  111.         jnz     .no_mouseunder
  112.         call    [_display.check_m_pixel]
  113.         test    ecx, ecx                ; 0xff000000
  114.         jnz     @f
  115.  
  116.   .no_mouseunder:
  117. ;        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
  118.         mov     ebx, [BPSLine_calc_area + ebx*4]
  119.         lea     edi, [ebx + eax*4]        ; edi = x*4+(y*y multiplier)
  120.  
  121.         mov     ecx, [LFB_BASE + edi]
  122.   @@:
  123.         and     ecx, 0x00ffffff
  124.         ret
  125.  
  126. ;-----------------------------------------------------------------------------
  127. ; ebx = pointer
  128. ; ecx = size [x|y]
  129. ; edx = coordinates [x|y]
  130. ; ebp = pointer to 'get' function
  131. ; esi = pointer to 'init' function
  132. ; edi = parameter for 'get' function
  133.  
  134. align 16
  135. vesa20_putimage:
  136.  
  137. virtual at esp
  138.  putimg:
  139.    .real_sx        dd ?
  140.    .real_sy        dd ?
  141.    .image_sx       dd ?
  142.    .image_sy       dd ?
  143.    .image_cx       dd ?
  144.    .image_cy       dd ?
  145.    .pti            dd ?
  146.    .abs_cx         dd ?
  147.    .abs_cy         dd ?
  148.    .line_increment dd ?
  149.    .winmap_newline dd ?
  150.    .screen_newline dd ?
  151.    .real_sx_and_abs_cx dd ?
  152.    .real_sy_and_abs_cy dd ?
  153.    .stack_data = 4*14
  154.    .edi         dd      ?
  155.    .esi         dd      ?
  156.    .ebp         dd      ?
  157.    .esp         dd      ?
  158.    .ebx         dd      ?
  159.    .edx         dd      ?
  160.    .ecx         dd      ?
  161.    .eax         dd      ?
  162.    .ret_addr    dd      ?
  163.    .arg_0       dd      ?
  164. end virtual
  165.  
  166.         pushad
  167.         sub     esp, putimg.stack_data
  168. ; save pointer to image
  169.         mov     [putimg.pti], ebx
  170. ; unpack the size
  171.         mov     eax, ecx
  172.         and     ecx, 0xFFFF
  173.         shr     eax, 16
  174.         mov     [putimg.image_sx], eax
  175.         mov     [putimg.image_sy], ecx
  176. ; unpack the coordinates
  177.         mov     eax, edx
  178.         and     edx, 0xFFFF
  179.         shr     eax, 16
  180.         mov     [putimg.image_cx], eax
  181.         mov     [putimg.image_cy], edx
  182. ; calculate absolute (i.e. screen) coordinates
  183.         mov     eax, [current_slot]
  184.         mov     eax, [eax + APPDATA.window]
  185.         mov     ebx, [eax + WDATA.box.left]
  186.         add     ebx, [putimg.image_cx]
  187.         mov     [putimg.abs_cx], ebx
  188.         mov     ebx, [eax + WDATA.box.top]
  189.         add     ebx, [putimg.image_cy]
  190.         mov     [putimg.abs_cy], ebx
  191. ; real_sx = MIN(wnd_sx-image_cx, image_sx);
  192.         mov     ebx, [eax + WDATA.box.width]       ; ebx = wnd_sx
  193.         inc     ebx                                     ; WDATA.box.width is one pixel less than real window x-size
  194.         sub     ebx, [putimg.image_cx]
  195.         ja      @f
  196.         add     esp, putimg.stack_data
  197.         popad
  198.         ret
  199.  
  200.   @@:
  201.         cmp     ebx, [putimg.image_sx]
  202.         jbe     .end_x
  203.         mov     ebx, [putimg.image_sx]
  204.   .end_x:
  205.         mov     [putimg.real_sx], ebx
  206. ; init real_sy
  207.         mov     ebx, [eax + WDATA.box.height]      ; ebx = wnd_sy
  208.         inc     ebx
  209.         sub     ebx, [putimg.image_cy]
  210.         ja      @f
  211.         add     esp, putimg.stack_data
  212.         popad
  213.         ret
  214.  
  215.   @@:
  216.         cmp     ebx, [putimg.image_sy]
  217.         jbe     .end_y
  218.         mov     ebx, [putimg.image_sy]
  219.   .end_y:
  220.         mov     [putimg.real_sy], ebx
  221. ; line increment
  222.         mov     eax, [putimg.image_sx]
  223.         mov     ecx, [putimg.real_sx]
  224.         sub     eax, ecx
  225. ;;     imul    eax, [putimg.source_bpp]
  226. ;     lea     eax, [eax + eax * 2]
  227.         call    esi
  228.         add     eax, [putimg.arg_0]
  229.         mov     [putimg.line_increment], eax
  230. ; winmap new line increment
  231.         mov     eax, [_display.width]
  232.         sub     eax, [putimg.real_sx]
  233.         mov     [putimg.winmap_newline], eax
  234. ; screen new line increment
  235.         mov     eax, [_display.lfb_pitch]
  236.         mov     ebx, [_display.bytes_per_pixel]
  237.         imul    ecx, ebx
  238.         sub     eax, ecx
  239.         mov     [putimg.screen_newline], eax
  240. ; pointer to image
  241.         mov     esi, [putimg.pti]
  242. ; pointer to screen
  243.         mov     edx, [putimg.abs_cy]
  244. ;        imul    edx, [BytesPerScanLine]
  245.         mov     edx, [BPSLine_calc_area + edx*4]
  246.         mov     eax, [putimg.abs_cx]
  247.         imul    eax, ebx
  248.         add     edx, eax
  249. ; pointer to pixel map
  250.         mov     eax, [putimg.abs_cy]
  251. ;        imul    eax, [Screen_Max_X]
  252. ;        add     eax, [putimg.abs_cy]
  253.         mov     eax, [d_width_calc_area + eax*4]
  254.  
  255.         add     eax, [putimg.abs_cx]
  256.         add     eax, [_display.win_map]
  257.         xchg    eax, ebp
  258.  
  259.         mov     ecx, [putimg.real_sx]
  260.         add     ecx, [putimg.abs_cx]
  261.         mov     [putimg.real_sx_and_abs_cx], ecx
  262.         mov     ecx, [putimg.real_sy]
  263.         add     ecx, [putimg.abs_cy]
  264.         mov     [putimg.real_sy_and_abs_cy], ecx
  265.  
  266. ; get process number
  267.         mov     ebx, [current_slot_idx]
  268.  
  269.         cmp     byte [_display.bits_per_pixel], 16
  270.         je      put_image_end_16
  271.         cmp     byte [_display.bits_per_pixel], 24
  272.         je      put_image_end_24
  273.         cmp     byte [_display.bits_per_pixel], 32
  274.         je      put_image_end_32
  275.  
  276. ;------------------------------------------------------------------------------
  277.  
  278. put_image_end_16:
  279.  
  280.         mov     edi, [putimg.real_sy]
  281.  
  282. ; check for hardware cursor
  283.         mov     ecx, [_display.select_cursor]
  284.         cmp     ecx, select_cursor
  285.         je      put_image_end_16_new
  286.  
  287.   .new_line:
  288.         mov     ecx, [putimg.real_sx]
  289.   .new_x:
  290.         push    [putimg.edi]
  291.         mov     eax, [putimg.ebp + 4]
  292.         call    eax
  293.         cmp     [ebp], bl
  294.         jne     .skip
  295. ; convert to 16 bpp and store to LFB
  296.         and     eax, 00000000111110001111110011111000b
  297.         shr     ah, 2
  298.         shr     ax, 3
  299.         ror     eax, 8
  300.         add     al, ah
  301.         rol     eax, 8
  302.         mov     [LFB_BASE + edx], ax
  303.   .skip:
  304.         add     edx, 2
  305.         inc     ebp
  306.         dec     ecx
  307.         jnz     .new_x
  308.  
  309.         add     esi, [putimg.line_increment]
  310.         add     edx, [putimg.screen_newline]
  311.         add     ebp, [putimg.winmap_newline]
  312.  
  313.         cmp     [putimg.ebp], putimage_get1bpp
  314.         jz      .correct
  315.         cmp     [putimg.ebp], putimage_get2bpp
  316.         jz      .correct
  317.         cmp     [putimg.ebp], putimage_get4bpp
  318.         jnz     @f
  319.   .correct:
  320.         mov     eax, [putimg.edi]
  321.         mov     byte [eax], 80h
  322.   @@:
  323.         dec     edi
  324.         jnz     .new_line
  325.   .finish:
  326.         add     esp, putimg.stack_data
  327.         popad
  328.         ret
  329.  
  330. ;------------------------------------------------------------------------------
  331.  
  332. align 4
  333. put_image_end_16_new:
  334.  
  335.   .new_line:
  336.         mov     ecx, [putimg.real_sx]
  337.  
  338.   .new_x:
  339.         push    [putimg.edi]
  340.         mov     eax, [putimg.ebp + 4]
  341.         call    eax
  342.  
  343.         cmp     [ebp], bl
  344.         jne     .skip
  345.  
  346.         push    ecx
  347.   .sh:
  348.         neg     ecx
  349.         add     ecx, [putimg.real_sx_and_abs_cx + 4]
  350.  
  351. ; check for X
  352.         cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
  353.         jae     .no_mouse_area
  354.  
  355.         sub     cx, [X_UNDER_subtraction_CUR_hot_x]
  356.         jb      .no_mouse_area
  357.  
  358.         shl     ecx, 16
  359.         add     ecx, [putimg.real_sy_and_abs_cy + 4]
  360.         sub     ecx, edi
  361.  
  362. ; check for Y
  363.         cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
  364.         jae     .no_mouse_area
  365.  
  366.         sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
  367.         jb      .no_mouse_area
  368.  
  369. ; check mouse area for putpixel
  370.         call    check_mouse_area_for_putpixel_new.1
  371.         cmp     ecx, -1                 ; SHIT HAPPENS?
  372.         jne     .no_mouse_area
  373.  
  374.         mov     ecx, [esp]
  375.         jmp     .sh
  376.  
  377.   .no_mouse_area:
  378.         pop     ecx
  379. ; convert to 16 bpp and store to LFB
  380.         and     eax, 00000000111110001111110011111000b
  381.         shr     ah, 2
  382.         shr     ax, 3
  383.         ror     eax, 8
  384.         add     al, ah
  385.         rol     eax, 8
  386.         mov     [LFB_BASE+edx], ax
  387.  
  388.   .skip:
  389.         add     edx, 2
  390.         inc     ebp
  391.         dec     ecx
  392.         jnz     .new_x
  393.  
  394.         add     esi, [putimg.line_increment]
  395.         add     edx, [putimg.screen_newline]
  396.         add     ebp, [putimg.winmap_newline]
  397.  
  398.         cmp     [putimg.ebp], putimage_get1bpp
  399.         jz      .correct
  400.         cmp     [putimg.ebp], putimage_get2bpp
  401.         jz      .correct
  402.         cmp     [putimg.ebp], putimage_get4bpp
  403.         jnz     @f
  404.  
  405.   .correct:
  406.         mov     eax, [putimg.edi]
  407.         mov     byte [eax], 80h
  408.  
  409.   @@:
  410.         dec     edi
  411.         jnz     .new_line
  412.         jmp     put_image_end_16.finish
  413.  
  414. ;------------------------------------------------------------------------------
  415.  
  416. align 4
  417. put_image_end_24:
  418.  
  419.         mov     edi, [putimg.real_sy]
  420.  
  421. ; check for hardware cursor
  422.         mov     ecx, [_display.select_cursor]
  423.         cmp     ecx, select_cursor
  424.         je      put_image_end_24_new
  425.  
  426.   .new_line:
  427.         mov     ecx, [putimg.real_sx]
  428.   .new_x:
  429.         push    [putimg.edi]
  430.         mov     eax, [putimg.ebp + 4]
  431.         call    eax
  432.         cmp     [ebp], bl
  433.         jne     .skip
  434.  
  435. ; store to LFB
  436.         mov     [LFB_BASE + edx], ax
  437.         shr     eax, 16
  438.         mov     [LFB_BASE + edx + 2], al
  439.  
  440.   .skip:
  441.         add     edx, 3
  442.         inc     ebp
  443.         dec     ecx
  444.         jnz     .new_x
  445.  
  446.         add     esi, [putimg.line_increment]
  447.         add     edx, [putimg.screen_newline]
  448.         add     ebp, [putimg.winmap_newline]
  449.  
  450.         cmp     [putimg.ebp], putimage_get1bpp
  451.         jz      .correct
  452.         cmp     [putimg.ebp], putimage_get2bpp
  453.         jz      .correct
  454.         cmp     [putimg.ebp], putimage_get4bpp
  455.         jnz     @f
  456.   .correct:
  457.         mov     eax, [putimg.edi]
  458.         mov     byte [eax], 80h
  459.   @@:
  460.         dec     edi
  461.         jnz     .new_line
  462.   .finish:
  463.         add     esp, putimg.stack_data
  464.         popad
  465.         ret
  466.  
  467. ;------------------------------------------------------------------------------
  468.  
  469. align 4
  470. put_image_end_24_new:
  471.  
  472.   .new_line:
  473.         mov     ecx, [putimg.real_sx]
  474.  
  475.   .new_x:
  476.         push    [putimg.edi]
  477.         mov     eax, [putimg.ebp + 4]
  478.         call    eax
  479.         cmp     [ebp], bl
  480.         jne     .skip
  481.  
  482.         push    ecx
  483.   .sh:
  484.         neg     ecx
  485.         add     ecx, [putimg.real_sx_and_abs_cx + 4]
  486.  
  487. ; check for X
  488.         cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
  489.         jae     .no_mouse_area
  490.  
  491.         sub     cx, [X_UNDER_subtraction_CUR_hot_x]
  492.         jb      .no_mouse_area
  493.  
  494.         shl     ecx, 16
  495.  
  496.         add     ecx, [putimg.real_sy_and_abs_cy + 4]
  497.         sub     ecx, edi
  498.  
  499. ; check for Y
  500.         cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
  501.         jae     .no_mouse_area
  502.  
  503.         sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
  504.         jb      .no_mouse_area
  505.  
  506. ; check mouse area for putpixel
  507.         call    check_mouse_area_for_putpixel_new.1
  508.         cmp     ecx, -1         ; SHIT HAPPENS?
  509.         jne     .no_mouse_area
  510.  
  511.         mov     ecx, [esp]
  512.         jmp     .sh
  513.  
  514.   .no_mouse_area:
  515.         pop     ecx
  516.  
  517. ; store to LFB
  518.         mov     [LFB_BASE + edx], ax
  519.         shr     eax, 16
  520.         mov     [LFB_BASE + edx + 2], al
  521.  
  522.   .skip:
  523.         add     edx, 3
  524.         inc     ebp
  525.         dec     ecx
  526.         jnz     .new_x
  527.  
  528.         add     esi, [putimg.line_increment]
  529.         add     edx, [putimg.screen_newline]
  530.         add     ebp, [putimg.winmap_newline]
  531.  
  532.         cmp     [putimg.ebp], putimage_get1bpp
  533.         jz      .correct
  534.         cmp     [putimg.ebp], putimage_get2bpp
  535.         jz      .correct
  536.         cmp     [putimg.ebp], putimage_get4bpp
  537.         jnz     @f
  538.  
  539.   .correct:
  540.         mov     eax, [putimg.edi]
  541.         mov     byte [eax], 80h
  542.  
  543.   @@:
  544.         dec     edi
  545.         jnz     .new_line
  546.         jmp     put_image_end_24.finish
  547.  
  548. ;------------------------------------------------------------------------------
  549.  
  550. align 4
  551. put_image_end_32:
  552.  
  553.         mov     edi, [putimg.real_sy]
  554.  
  555. ; check for hardware cursor
  556.         mov     ecx, [_display.select_cursor]
  557.         cmp     ecx, select_cursor
  558.         je      put_image_end_32_new
  559.  
  560.   .new_line:
  561.         mov     ecx, [putimg.real_sx]
  562.  
  563.   .new_x:
  564.         push    [putimg.edi]
  565.         mov     eax, [putimg.ebp + 4]
  566.         call    eax
  567.         cmp     [ebp], bl
  568.         jne     .skip
  569.  
  570. ; store to LFB
  571.         mov     [LFB_BASE + edx], eax
  572.  
  573.   .skip:
  574.         add     edx, 4
  575.         inc     ebp
  576.         dec     ecx
  577.         jnz     .new_x
  578.  
  579.         add     esi, [putimg.line_increment]
  580.         add     edx, [putimg.screen_newline]
  581.         add     ebp, [putimg.winmap_newline]
  582.  
  583.         cmp     [putimg.ebp], putimage_get1bpp
  584.         jz      .correct
  585.         cmp     [putimg.ebp], putimage_get2bpp
  586.         jz      .correct
  587.         cmp     [putimg.ebp], putimage_get4bpp
  588.         jnz     @f
  589.  
  590.   .correct:
  591.         mov     eax, [putimg.edi]
  592.         mov     byte [eax], 80h
  593.  
  594.   @@:
  595.         dec     edi
  596.         jnz     .new_line
  597.  
  598.   .finish:
  599.         add     esp, putimg.stack_data
  600.         popad
  601.         cmp     [SCR_MODE], 0x12
  602.         jne     @f
  603.         call    VGA__putimage
  604.   @@:
  605.         mov     [EGA_counter], 1
  606.         ret
  607.  
  608. ;------------------------------------------------------------------------------
  609.  
  610. align 4
  611. put_image_end_32_new:
  612.  
  613.   .new_line:
  614.         mov     ecx, [putimg.real_sx]
  615.  
  616.   .new_x:
  617.         push    [putimg.edi]
  618.         mov     eax, [putimg.ebp + 4]
  619.         call    eax
  620.         cmp     [ebp], bl
  621.         jne     .skip
  622.  
  623.         push    ecx
  624.  
  625.   .sh:
  626.         neg     ecx
  627.         add     ecx, [putimg.real_sx_and_abs_cx + 4]
  628.  
  629. ; check for X
  630.         cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
  631.         jae     .no_mouse_area
  632.         sub     cx, [X_UNDER_subtraction_CUR_hot_x]
  633.         jb      .no_mouse_area
  634.         shl     ecx, 16
  635.  
  636.         add     ecx, [putimg.real_sy_and_abs_cy + 4]
  637.         sub     ecx, edi
  638.  
  639. ; check for Y
  640.         cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
  641.         jae     .no_mouse_area
  642.         sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
  643.         jb      .no_mouse_area
  644.  
  645. ; check mouse area for putpixel
  646.         call    check_mouse_area_for_putpixel_new.1
  647.         cmp     ecx, -1         ; SHIT HAPPENS?
  648.         jne     .no_mouse_area
  649.  
  650.         mov     ecx, [esp]
  651.         jmp     .sh
  652.  
  653.   .no_mouse_area:
  654.         pop     ecx
  655.  
  656. ; store to LFB
  657.         mov     [LFB_BASE+edx], eax
  658.  
  659.   .skip:
  660.         add     edx, 4
  661.         inc     ebp
  662.         dec     ecx
  663.         jnz     .new_x
  664.  
  665.         add     esi, [putimg.line_increment]
  666.         add     edx, [putimg.screen_newline]
  667.         add     ebp, [putimg.winmap_newline]
  668.  
  669.         cmp     [putimg.ebp], putimage_get1bpp
  670.         jz      .correct
  671.         cmp     [putimg.ebp], putimage_get2bpp
  672.         jz      .correct
  673.         cmp     [putimg.ebp], putimage_get4bpp
  674.         jnz     @f
  675.  
  676.   .correct:
  677.         mov     eax, [putimg.edi]
  678.         mov     byte [eax], 80h
  679.  
  680.   @@:
  681.         dec     edi
  682.         jnz     .new_line
  683.         jmp     put_image_end_32.finish
  684.  
  685. ;------------------------------------------------------------------------------
  686. ; eax = x coordinate
  687. ; ebx = y coordinate
  688. ; ecx = xx RR GG BB
  689. ; xx flags:
  690. ; 0x01000000 color inversion
  691. ; 0x02000000 used for draw_rectangle without top line (for drawwindow_III and drawwindow_IV)
  692. ; edi = 0x00000001 force
  693.  
  694. align 4
  695. __sys_putpixel:
  696.  
  697.         pushad
  698.         cmp     eax, [_display.width]
  699.         jae     .exit
  700.         cmp     ebx, [_display.height]
  701.         jae     .exit
  702.         test    edi, 1          ; force ?
  703.         jnz     .forced
  704.  
  705. ; not forced
  706.         mov     edx, [d_width_calc_area + ebx*4]
  707.         add     edx, [_display.win_map]
  708.         movzx   edx, byte [eax+edx]
  709.         cmp     edx, [current_slot_idx]
  710.         jne     .exit
  711.  
  712.   .forced:
  713. ; check for color inversion
  714.         test    ecx, 0x01000000
  715.         jz      .no_inv
  716.  
  717.         push    eax ebx edx edi
  718.         call    [GETPIXEL]
  719.         pop     edi edx ebx eax
  720.  
  721.         not     ecx
  722.         rol     ecx, 8
  723.         mov     cl, [esp + 32-8+3]
  724.         ror     ecx, 8
  725.         mov     [esp + 32-8], ecx
  726.   .no_inv:
  727.         call    [PUTPIXEL]      ; call the real put_pixel function
  728.   .exit:
  729.         popad
  730.         ret
  731.  
  732. ;-----------------------------------------------------------------------------
  733. ; eax = x
  734. ; ebx = y
  735.  
  736. align 4
  737. Vesa20_putpixel16_new:
  738.  
  739.         mov     ecx, eax
  740.         shl     ecx, 16
  741.         mov     cx, bx
  742.  
  743. ;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
  744.         mov     ebx, [BPSLine_calc_area + ebx*4]
  745.         lea     edi, [eax*2]; edi = x*2
  746.         mov     eax, [esp + 32-8+4]
  747.  
  748. ; check for hardware cursor
  749.         cmp     [_display.select_cursor], select_cursor
  750.         jne     @f
  751. ; check mouse area for putpixel
  752.         test    eax, 0x04000000
  753.         jnz     @f
  754.  
  755. ; check for Y
  756.         cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
  757.         jae     @f
  758.         sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
  759.         jb      @f
  760.         rol     ecx, 16
  761.  
  762. ; check for X
  763.         cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
  764.         jae     @f
  765.         sub     cx, [X_UNDER_subtraction_CUR_hot_x]
  766.         jb      @f
  767.         ror     ecx, 16
  768.  
  769.         call    check_mouse_area_for_putpixel_new.1
  770.   @@:
  771. ; store to LFB
  772.         and     eax, 00000000111110001111110011111000b
  773.         shr     ah, 2
  774.         shr     ax, 3
  775.         ror     eax, 8
  776.         add     al, ah
  777.         rol     eax, 8
  778.  
  779.         mov     [LFB_BASE + ebx + edi], ax
  780.         ret
  781.  
  782. ;-----------------------------------------------------------------------------
  783. ; eax = x
  784. ; ebx = y
  785.  
  786. align 4
  787. Vesa20_putpixel24_new:
  788.  
  789.         mov     ecx, eax
  790.         shl     ecx, 16
  791.         mov     cx, bx
  792.  
  793. ;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
  794.         mov     ebx, [BPSLine_calc_area+ebx*4]
  795.         lea     edi, [eax + eax*2]; edi = x*3
  796.         mov     eax, [esp + 32-8+4]
  797.  
  798. ; check for hardware cursor
  799.         cmp     [_display.select_cursor], select_cursor
  800.         jne     @f
  801. ; check mouse area for putpixel
  802.         test    eax, 0x04000000
  803.         jnz     @f
  804.  
  805. ; check for Y
  806.         cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
  807.         jae     @f
  808.         sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
  809.         jb      @f
  810.         rol     ecx, 16
  811.  
  812. ; check for X
  813.         cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
  814.         jae     @f
  815.         sub     cx, [X_UNDER_subtraction_CUR_hot_x]
  816.         jb      @f
  817.         ror     ecx, 16
  818.  
  819.         call    check_mouse_area_for_putpixel_new.1
  820.   @@:
  821. ; store to LFB
  822.         mov     [LFB_BASE + ebx + edi], ax
  823.         shr     eax, 16
  824.         mov     [LFB_BASE + ebx + edi + 2], al
  825.         ret
  826.  
  827. ;-----------------------------------------------------------------------------
  828. ; eax = x
  829. ; ebx = y
  830.  
  831. align 4
  832. Vesa20_putpixel32_new:
  833.  
  834.         mov     ecx, eax
  835.         shl     ecx, 16
  836.         mov     cx, bx
  837.  
  838. ;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
  839.         mov     ebx, [BPSLine_calc_area+ebx*4]
  840.         lea     edi, [ebx + eax*4]        ; edi = x*4+(y*y multiplier)
  841.         mov     eax, [esp + 32-8+4]       ; eax = color
  842.  
  843. ; check for hardware cursor
  844.         cmp     [_display.select_cursor], select_cursor
  845.         jne     @f
  846. ; check mouse area for putpixel
  847.         test    eax, 0x04000000
  848.         jnz     @f
  849.  
  850. ; check for Y
  851.         cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
  852.         jae     @f
  853.         sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
  854.         jb      @f
  855.         rol     ecx, 16
  856.  
  857. ; check for X
  858.         cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
  859.         jae     @f
  860.         sub     cx, [X_UNDER_subtraction_CUR_hot_x]
  861.         jb      @f
  862.         ror     ecx, 16
  863.  
  864.         call    check_mouse_area_for_putpixel_new.1
  865.   @@:
  866.         and     eax, 0x00ffffff
  867. ; store to LFB
  868.         mov     [LFB_BASE + edi], eax
  869.         ret
  870.  
  871. ;-----------------------------------------------------------------------------
  872.  
  873. align 4
  874. calculate_edi:
  875. ;        mov     edi, ebx
  876. ;        imul    edi, [Screen_Max_X]
  877. ;        add     edi, ebx
  878.         mov     edi, [d_width_calc_area + ebx*4]
  879.         add     edi, eax
  880.         ret
  881.  
  882.  
  883. ;-----------------------------------------------------------------------------
  884. ; DRAWLINE
  885. ;-----------------------------------------------------------------------------
  886. ; eax = x1 shl 16 + x2
  887. ; ebx = y1 shl 16 + y2
  888. ; ecx = color
  889. ; edi = force ?
  890.  
  891. align 4
  892. __sys_draw_line:
  893.  
  894. dl_x1 equ esp+20
  895. dl_y1 equ esp+16
  896. dl_x2 equ esp+12
  897. dl_y2 equ esp+8
  898. dl_dx equ esp+4
  899. dl_dy equ esp+0
  900.  
  901.         pusha
  902.  
  903.         xor     edx, edx        ; clear edx
  904.         xor     esi, esi        ; unpack arguments
  905.         xor     ebp, ebp
  906.         mov     si, ax          ; esi = x2
  907.         mov     bp, bx          ; ebp = y2
  908.         shr     eax, 16         ; eax = x1
  909.         shr     ebx, 16         ; ebx = y1
  910.         push    eax             ; save x1
  911.         push    ebx             ; save y1
  912.         push    esi             ; save x2
  913.         push    ebp             ; save y2
  914. ; checking x-axis...
  915.         sub     esi, eax        ; esi = x2-x1
  916.         push    esi             ; save y2-y1
  917.         jl      .x2lx1          ; is x2 less than x1 ?
  918.         jg      .no_vline       ; x1 > x2 ?
  919.         mov     edx, ebp        ; else (if x1=x2)
  920.         call    vline
  921.         push    edx             ; necessary to rightly restore stack frame at .exit
  922.         jmp     .exit
  923.  
  924.   .x2lx1:
  925.         neg     esi             ; get esi absolute value
  926.  
  927.   .no_vline:
  928. ; checking y-axis...
  929.         sub     ebp, ebx        ; ebp = y2-y1
  930.         push    ebp             ; save y2-y1
  931.         jl      .y2ly1          ; is y2 less than y1 ?
  932.         jg      .no_hline       ; y1 > y2 ?
  933.         mov     edx, [dl_x2]    ; else (if y1=y2)
  934.         call    hline
  935.         jmp     .exit
  936.  
  937.   .y2ly1:
  938.         neg     ebp             ; get ebp absolute value
  939.  
  940.   .no_hline:
  941.         cmp     ebp, esi
  942.         jle     .x_rules        ; |y2-y1| < |x2-x1|  ?
  943.         cmp     [dl_y2], ebx    ; make sure y1 is at the begining
  944.         jge     .no_reverse1
  945.         neg     dword [dl_dx]
  946.         mov     edx, [dl_x2]
  947.         mov     [dl_x2], eax
  948.         mov     [dl_x1], edx
  949.         mov     edx, [dl_y2]
  950.         mov     [dl_y2], ebx
  951.         mov     [dl_y1], edx
  952.  
  953.   .no_reverse1:
  954.         mov     eax, [dl_dx]
  955.         cdq                     ; extend eax sing to edx
  956.         shl     eax, 16         ; using 16bit fix-point maths
  957.         idiv    ebp             ; eax = ((x2-x1)*65536)/(y2-y1)
  958.  
  959. ; correction for the remainder of the division
  960.         shl     edx, 1
  961.         cmp     ebp, edx
  962.         jb      @f
  963.         inc     eax
  964.   @@:
  965.         mov     edx, ebp        ; edx = counter (number of pixels to draw)
  966.         mov     ebp, 1 shl 16   ; ebp = dy = 1.0
  967.         mov     esi, eax        ; esi = dx
  968.         jmp     .y_rules
  969.   .x_rules:
  970.         cmp     [dl_x2], eax    ; make sure x1 is at the begining
  971.         jge     .no_reverse2
  972.         neg     dword [dl_dy]
  973.         mov     edx, [dl_x2]
  974.         mov     [dl_x2], eax
  975.         mov     [dl_x1], edx
  976.         mov     edx, [dl_y2]
  977.         mov     [dl_y2], ebx
  978.         mov     [dl_y1], edx
  979.   .no_reverse2:
  980.         xor     edx, edx
  981.         mov     eax, [dl_dy]
  982.         cdq                     ; extend eax sing to edx
  983.         shl     eax, 16         ; using 16bit fix-point maths
  984.         idiv    esi             ; eax = ((y2-y1)*65536)/(x2-x1)
  985. ; correction for the remainder of the division
  986.         shl     edx, 1
  987.         cmp     esi, edx
  988.         jb      @f
  989.         inc     eax
  990.   @@:
  991.         mov     edx, esi        ; edx = counter (number of pixels to draw)
  992.         mov     esi, 1 shl 16   ; esi = dx = 1.0
  993.         mov     ebp, eax        ; ebp = dy
  994.  
  995.   .y_rules:
  996.         mov     eax, [dl_x1]
  997.         mov     ebx, [dl_y1]
  998.         shl     eax, 16
  999.         shl     ebx, 16
  1000.  
  1001.         and     ecx, 0xFBFFFFFF ; negate 0x04000000 save to mouseunder area
  1002.   .draw:
  1003.         push    eax ebx
  1004.  
  1005. ; correction for the remainder of the division
  1006.         test    ah, 0x80
  1007.         jz      @f
  1008.         add     eax, 1 shl 16
  1009.   @@:
  1010.         shr     eax, 16
  1011. ; correction for the remainder of the division
  1012.         test    bh, 0x80
  1013.         jz      @f
  1014.         add     ebx, 1 shl 16
  1015.   @@:
  1016.         shr     ebx, 16
  1017. ;        and     ecx, 0xFBFFFFFF  ; negate 0x04000000 save to mouseunder area
  1018. ;        call    [putpixel]
  1019.         call    __sys_putpixel
  1020.         pop     ebx eax
  1021.         add     ebx, ebp     ; y = y+dy
  1022.         add     eax, esi     ; x = x+dx
  1023.         dec     edx
  1024.         jnz     .draw
  1025. ; force last drawn pixel to be at (x2,y2)
  1026.         mov     eax, [dl_x2]
  1027.         mov     ebx, [dl_y2]
  1028. ;        and     ecx, 0xFBFFFFFF ;n egate 0x04000000 save to mouseunder area
  1029. ;        call    [putpixel]
  1030.         call    __sys_putpixel
  1031.  
  1032.   .exit:
  1033.         add     esp, 6*4
  1034.         popa
  1035. ;        call    [draw_pointer]
  1036.         ret
  1037.  
  1038. ;------------------------------------------------------------------------------
  1039. ; draw an horizontal line
  1040. ; eax = x1
  1041. ; edx = x2
  1042. ; ebx = y
  1043. ; ecx = color
  1044. ; edi = force ?
  1045.  
  1046. align 4
  1047. hline:
  1048.  
  1049.         push    eax edx
  1050.         cmp     edx, eax   ; make sure x2 is above x1
  1051.         jge     @f
  1052.         xchg    eax, edx
  1053.   @@:
  1054.         and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
  1055.   @@:
  1056. ;        call    [putpixel]
  1057.         call    __sys_putpixel
  1058.         inc     eax
  1059.         cmp     eax, edx
  1060.         jle     @b
  1061.         pop     edx eax
  1062.         ret
  1063.  
  1064. ;------------------------------------------------------------------------------
  1065. ; draw a vertical line
  1066. ; eax = x
  1067. ; ebx = y1
  1068. ; edx = y2
  1069. ; ecx = color
  1070. ; edi = force ?
  1071.  
  1072. align 4
  1073. vline:
  1074.  
  1075.         push    ebx edx
  1076.         cmp     edx, ebx   ; make sure y2 is above y1
  1077.         jge     @f
  1078.         xchg    ebx, edx
  1079.   @@:
  1080.         and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
  1081.   @@:
  1082. ;        call    [putpixel]
  1083.         call    __sys_putpixel
  1084.         inc     ebx
  1085.         cmp     ebx, edx
  1086.         jle     @b
  1087.         pop     edx ebx
  1088.         ret
  1089.  
  1090. ;------------------------------------------------------------------------------
  1091. ; eax   cx
  1092. ; ebx   cy
  1093. ; ecx   xe
  1094. ; edx   ye
  1095. ; edi   color
  1096.  
  1097. align 4
  1098. vesa20_drawbar:
  1099.  
  1100. virtual at esp
  1101. drbar:
  1102.      .bar_sx       dd ?
  1103.      .bar_sy       dd ?
  1104.      .bar_cx       dd ?
  1105.      .bar_cy       dd ?
  1106.      .abs_cx       dd ?
  1107.      .abs_cy       dd ?
  1108.      .real_sx      dd ?
  1109.      .real_sy      dd ?
  1110.      .color        dd ?
  1111.      .line_inc_scr dd ?
  1112.      .line_inc_map dd ?
  1113.      .real_sx_and_abs_cx dd ?
  1114.      .real_sy_and_abs_cy dd ?
  1115.      .stack_data = 4*13
  1116. end virtual
  1117.  
  1118.         pushad
  1119.         sub     esp, drbar.stack_data
  1120.         mov     [drbar.color], edi
  1121.         sub     edx, ebx
  1122.         jle     .exit
  1123.         sub     ecx, eax
  1124.         jle     .exit
  1125.         mov     [drbar.bar_sy], edx
  1126.         mov     [drbar.bar_sx], ecx
  1127.         mov     [drbar.bar_cx], eax
  1128.         mov     [drbar.bar_cy], ebx
  1129.         mov     edi, [current_slot]
  1130.         mov     edi, [edi + APPDATA.window]
  1131.         add     eax, [edi + WDATA.box.left]        ; win_cx
  1132.         add     ebx, [edi + WDATA.box.top]         ; win_cy
  1133.         mov     [drbar.abs_cx], eax
  1134.         mov     [drbar.abs_cy], ebx
  1135. ; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
  1136.         mov     ebx, [edi + WDATA.box.width]       ; ebx = wnd_sx
  1137.         inc     ebx                                     ; WDATA.box.width is one pixel less than real window x-size
  1138.         sub     ebx, [drbar.bar_cx]
  1139.         ja      @f
  1140.   .exit:
  1141.         add     esp, drbar.stack_data
  1142.         popad
  1143.         xor     eax, eax
  1144.         inc     eax
  1145.         ret
  1146.   @@:
  1147.         cmp     ebx, [drbar.bar_sx]
  1148.         jbe     .end_x
  1149.         mov     ebx, [drbar.bar_sx]
  1150.   .end_x:
  1151.         mov     [drbar.real_sx], ebx
  1152. ; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
  1153.         mov     ebx, [edi + WDATA.box.height]      ; ebx = wnd_sy
  1154.         inc     ebx
  1155.         sub     ebx, [drbar.bar_cy]
  1156.         ja      @f
  1157.         add     esp, drbar.stack_data
  1158.         popad
  1159.         xor     eax, eax
  1160.         inc     eax
  1161.         ret
  1162.   @@:
  1163.         cmp     ebx, [drbar.bar_sy]
  1164.         jbe     .end_y
  1165.         mov     ebx, [drbar.bar_sy]
  1166.   .end_y:
  1167.         mov     [drbar.real_sy], ebx
  1168. ; line_inc_map
  1169.         mov     eax, [_display.width]
  1170.         sub     eax, [drbar.real_sx]
  1171.         mov     [drbar.line_inc_map], eax
  1172. ; line_inc_scr
  1173.         mov     eax, [drbar.real_sx]
  1174.         mov     ebx, [_display.bytes_per_pixel]
  1175.         imul    eax, ebx
  1176.         neg     eax
  1177.         add     eax, [_display.lfb_pitch]
  1178.         mov     [drbar.line_inc_scr], eax
  1179. ; pointer to screen
  1180.         mov     edx, [drbar.abs_cy]
  1181. ;        imul    edx, [BytesPerScanLine]
  1182.         mov     edx, [BPSLine_calc_area+edx*4]
  1183.         mov     eax, [drbar.abs_cx]
  1184.         imul    eax, ebx
  1185.         add     edx, eax
  1186. ; pointer to pixel map
  1187.         mov     eax, [drbar.abs_cy]
  1188. ;        imul    eax, [Screen_Max_X]
  1189. ;        add     eax, [drbar.abs_cy]
  1190.         mov     eax, [d_width_calc_area + eax*4]
  1191.  
  1192.         add     eax, [drbar.abs_cx]
  1193.         add     eax, [_display.win_map]
  1194.         xchg    eax, ebp
  1195.  
  1196.         mov     ebx, [drbar.real_sx]
  1197.         add     ebx, [drbar.abs_cx]
  1198.         mov     [drbar.real_sx_and_abs_cx], ebx
  1199.         mov     ebx, [drbar.real_sy]
  1200.         add     ebx, [drbar.abs_cy]
  1201.         mov     [drbar.real_sy_and_abs_cy], ebx
  1202.  
  1203.         add     edx, LFB_BASE
  1204.  
  1205. ; get process number
  1206.         mov     ebx, [current_slot_idx]  ; bl - process num
  1207.         mov     esi, [drbar.real_sy]
  1208.         mov     eax, [drbar.color] ; BBGGRR00
  1209.         rol     eax, 8
  1210.         mov     bh, al  ; 0x80 drawing gradient bars
  1211.         ror     eax, 8
  1212.  
  1213.         cmp     byte [_display.bits_per_pixel], 16
  1214.         je      draw_bar_end_16
  1215.         cmp     byte [_display.bits_per_pixel], 24
  1216.         je      draw_bar_end_24
  1217.         cmp     byte [_display.bits_per_pixel], 32
  1218.         je      draw_bar_end_32
  1219.  
  1220. ;--------------------------------------
  1221. ; eax - color high   RRGGBB
  1222. ; bl - process num
  1223. ; ecx - temp
  1224. ; edx - pointer to screen
  1225. ; esi - counter
  1226. ; edi - counter
  1227.  
  1228. align 4
  1229. draw_bar_end_24:
  1230.  
  1231. ; check for hardware cursor
  1232.         mov     ecx, [_display.select_cursor]
  1233.         cmp     ecx, select_cursor
  1234.         je      draw_bar_end_24_new
  1235.  
  1236.   .new_y:
  1237.         mov     edi, [drbar.real_sx]
  1238.   .new_x:
  1239.         cmp     byte [ebp], bl
  1240.         jne     .skip
  1241.  
  1242. ; store to LFB
  1243.         mov     [edx], ax
  1244.         shr     eax, 16
  1245.         mov     [edx + 2], al
  1246.   .skip:
  1247. ; add pixel
  1248.         add     edx, 3
  1249.         inc     ebp
  1250.         dec     edi
  1251.         jnz     .new_x
  1252. ; add line
  1253.         add     edx, [drbar.line_inc_scr]
  1254.         add     ebp, [drbar.line_inc_map]
  1255. ; drawing gradient bars
  1256.         test    bh, 0x80
  1257.         jz      @f
  1258.         test    al, al
  1259.         jz      @f
  1260.         dec     al
  1261.   @@:
  1262.         dec     esi
  1263.         jnz     .new_y
  1264.   .end:
  1265.         add     esp, drbar.stack_data
  1266.         popad
  1267.         xor     eax, eax
  1268.         ret
  1269.  
  1270. ;------------------------------------------------------------------------------
  1271.  
  1272. align 4
  1273. draw_bar_end_24_new:
  1274.  
  1275.   .new_y:
  1276.         mov     edi, [drbar.real_sx]
  1277.   .new_x:
  1278.         cmp     byte [ebp], bl
  1279.         jne     .skip
  1280.  
  1281.         mov     ecx, [drbar.real_sy_and_abs_cy]
  1282.         sub     ecx, esi
  1283.  
  1284. ; check for Y
  1285.         cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
  1286.         jae     .no_mouse_area
  1287.         sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
  1288.         jb      .no_mouse_area
  1289.         rol     ecx, 16
  1290.         add     ecx, [drbar.real_sx_and_abs_cx]
  1291.         sub     ecx, edi
  1292.  
  1293. ; check for X
  1294.         cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
  1295.         jae     .no_mouse_area
  1296.         sub     cx, [X_UNDER_subtraction_CUR_hot_x]
  1297.         jb      .no_mouse_area
  1298.         ror     ecx, 16
  1299.  
  1300. ; check mouse area for putpixel
  1301.         push    eax
  1302.         call    check_mouse_area_for_putpixel_new.1
  1303.         mov     [edx], ax
  1304.         shr     eax, 16
  1305.         mov     [edx + 2], al
  1306.         pop     eax
  1307.         jmp     .skip
  1308.  
  1309.   .no_mouse_area:
  1310. ; store to LFB
  1311.         mov     [edx], ax
  1312.         ror     eax, 16
  1313.         mov     [edx + 2], al
  1314.         rol     eax, 16
  1315.   .skip:
  1316.  
  1317. ; add pixel
  1318.         add     edx, 3
  1319.         inc     ebp
  1320.         dec     edi
  1321.         jnz     .new_x
  1322.  
  1323. ; add line
  1324.         add     edx, [drbar.line_inc_scr]
  1325.         add     ebp, [drbar.line_inc_map]
  1326.  
  1327. ; drawing gradient bars
  1328.         test    bh, 0x80
  1329.         jz      @f
  1330.         test    al, al
  1331.         jz      @f
  1332.         dec     al
  1333.   @@:
  1334.         dec     esi
  1335.         jnz     .new_y
  1336.         jmp     draw_bar_end_24.end
  1337.  
  1338. ;------------------------------------------------------------------------------
  1339. ; eax - color high   RRGGBB
  1340. ; bl - process num
  1341. ; ecx - temp
  1342. ; edx - pointer to screen
  1343. ; esi - counter
  1344. ; edi - counter
  1345.  
  1346. draw_bar_end_32:
  1347.  
  1348. ; check for hardware cursor
  1349.         mov     ecx, [_display.select_cursor]
  1350.         cmp     ecx, select_cursor
  1351.         je      draw_bar_end_32_new
  1352.  
  1353.   .new_y:
  1354.         mov     edi, [drbar.real_sx]
  1355.   .new_x:
  1356.         cmp     byte [ebp], bl
  1357.         jne     .skip
  1358.  
  1359. ; store to LFB
  1360.         mov     [edx], eax
  1361.         mov     eax, [drbar.color]
  1362.   .skip:
  1363.  
  1364. ; add pixel
  1365.         add     edx, 4
  1366.         inc     ebp
  1367.         dec     edi
  1368.         jnz     .new_x
  1369.  
  1370. ; add line
  1371.         add     edx, [drbar.line_inc_scr]
  1372.         add     ebp, [drbar.line_inc_map]
  1373.  
  1374. ; drawing gradient bars
  1375.         test    bh, 0x80
  1376.         jz      @f
  1377.         test    al, al
  1378.         jz      @f
  1379.         dec     al
  1380.   @@:
  1381.         dec     esi
  1382.         jnz     .new_y
  1383.   .end:
  1384.         add     esp, drbar.stack_data
  1385.         popad
  1386.         cmp     [SCR_MODE], 0x12
  1387.         jne     @f
  1388.         call    VGA_draw_bar
  1389.   @@:
  1390.         xor     eax, eax
  1391.         mov     [EGA_counter], 1
  1392.         ret
  1393.  
  1394. ;------------------------------------------------------------------------------
  1395.  
  1396. align 4
  1397. draw_bar_end_32_new:
  1398.  
  1399.   .new_y:
  1400.         mov     edi, [drbar.real_sx]
  1401.   .new_x:
  1402.         cmp     byte [ebp], bl
  1403.         jne     .skip
  1404.  
  1405.         mov     ecx, [drbar.real_sy_and_abs_cy]
  1406.         sub     ecx, esi
  1407.  
  1408. ; check for Y
  1409.         cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
  1410.         jae     .no_mouse_area
  1411.         sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
  1412.         jb      .no_mouse_area
  1413.         rol     ecx, 16
  1414.         add     ecx, [drbar.real_sx_and_abs_cx]
  1415.         sub     ecx, edi
  1416.  
  1417. ; check for X
  1418.         cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
  1419.         jae     .no_mouse_area
  1420.         sub     cx, [X_UNDER_subtraction_CUR_hot_x]
  1421.         jb      .no_mouse_area
  1422.         ror     ecx, 16
  1423.  
  1424. ; check mouse area for putpixel
  1425.         push    eax
  1426.         call    check_mouse_area_for_putpixel_new.1
  1427.         mov     [edx], eax
  1428.         pop     eax
  1429.         jmp     .skip
  1430.   .no_mouse_area:
  1431.  
  1432. ; store to LFB
  1433.         mov     [edx], eax
  1434.   .skip:
  1435.  
  1436. ; add pixel
  1437.         add     edx, 4
  1438.         inc     ebp
  1439.         dec     edi
  1440.         jnz     .new_x
  1441.  
  1442. ; add line
  1443.         add     edx, [drbar.line_inc_scr]
  1444.         add     ebp, [drbar.line_inc_map]
  1445.  
  1446. ; drawing gradient bars
  1447.         test    bh, 0x80
  1448.         jz      @f
  1449.         test    al, al
  1450.         jz      @f
  1451.         dec     al
  1452.   @@:
  1453.         dec     esi
  1454.         jnz     .new_y
  1455.         jmp     draw_bar_end_32.end
  1456.  
  1457. ;------------------------------------------------------------------------------
  1458. ; eax - color high   RRGGBB
  1459. ; bl - process num
  1460. ; ecx - temp
  1461. ; edx - pointer to screen
  1462. ; esi - counter
  1463. ; edi - counter
  1464.  
  1465. align 4
  1466. draw_bar_end_16:
  1467.  
  1468. ; check for hardware cursor
  1469.         mov     ecx, [_display.select_cursor]
  1470.         cmp     ecx, select_cursor
  1471.         je      draw_bar_end_16_new
  1472.  
  1473.   .new_y:
  1474.         mov     edi, [drbar.real_sx]
  1475.   .new_x:
  1476.         cmp     byte [ebp], bl
  1477.         jne     .skip
  1478. ; convert to 16 bpp and store to LFB
  1479.         and     eax, 00000000111110001111110011111000b
  1480.         shr     ah, 2
  1481.         shr     ax, 3
  1482.         ror     eax, 8
  1483.         add     al, ah
  1484.         rol     eax, 8
  1485.         mov     [edx], ax
  1486.         mov     eax, [drbar.color]
  1487.   .skip:
  1488.  
  1489. ; add pixel
  1490.         add     edx, 2
  1491.         inc     ebp
  1492.         dec     edi
  1493.         jnz     .new_x
  1494. ; add line
  1495.         add     edx, [drbar.line_inc_scr]
  1496.         add     ebp, [drbar.line_inc_map]
  1497. ; drawing gradient bars
  1498.         test    bh, 0x80
  1499.         jz      @f
  1500.         test    al, al
  1501.         jz      @f
  1502.         dec     al
  1503.   @@:
  1504.         dec     esi
  1505.         jnz     .new_y
  1506.   .end:
  1507.         add     esp, drbar.stack_data
  1508.         popad
  1509.         cmp     [SCR_MODE], 0x12
  1510.         jne     @f
  1511.         call    VGA_draw_bar
  1512.   @@:
  1513.         xor     eax, eax
  1514.         mov     [EGA_counter], 1
  1515.         ret
  1516.  
  1517. ;------------------------------------------------------------------------------
  1518.  
  1519. align 4
  1520. draw_bar_end_16_new:
  1521.  
  1522.   .new_y:
  1523.         mov     edi, [drbar.real_sx]
  1524.   .new_x:
  1525.         cmp     byte [ebp], bl
  1526.         jne     .skip
  1527.  
  1528.         mov     ecx, [drbar.real_sy_and_abs_cy]
  1529.         sub     ecx, esi
  1530.  
  1531. ; check for Y
  1532.         cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
  1533.         jae     .no_mouse_area
  1534.         sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
  1535.         jb      .no_mouse_area
  1536.         rol     ecx, 16
  1537.         add     ecx, [drbar.real_sx_and_abs_cx]
  1538.         sub     ecx, edi
  1539.  
  1540. ; check for X
  1541.         cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
  1542.         jae     .no_mouse_area
  1543.         sub     cx, [X_UNDER_subtraction_CUR_hot_x]
  1544.         jb      .no_mouse_area
  1545.         ror     ecx, 16
  1546.  
  1547. ; check mouse area for putpixel
  1548.         push    eax
  1549.         call    check_mouse_area_for_putpixel_new.1
  1550.         push    eax
  1551.         and     eax, 00000000111110001111110011111000b
  1552.         shr     ah, 2
  1553.         shr     ax, 3
  1554.         ror     eax, 8
  1555.         add     al, ah
  1556.         rol     eax, 8
  1557.         mov     [edx], ax
  1558.         pop     eax
  1559.         pop     eax
  1560.         jmp     .skip
  1561.  
  1562.   .no_mouse_area:
  1563. ; convert to 16 bpp and store to LFB
  1564.         push    eax
  1565.         and     eax, 00000000111110001111110011111000b
  1566.         shr     ah, 2
  1567.         shr     ax, 3
  1568.         ror     eax, 8
  1569.         add     al, ah
  1570.         rol     eax, 8
  1571.         mov     [edx], ax
  1572.         pop     eax
  1573.   .skip:
  1574.  
  1575. ; add pixel
  1576.         add     edx, 2
  1577.         inc     ebp
  1578.         dec     edi
  1579.         jnz     .new_x
  1580.  
  1581. ; add line
  1582.         add     edx, [drbar.line_inc_scr]
  1583.         add     ebp, [drbar.line_inc_map]
  1584.  
  1585. ; drawing gradient bars
  1586.         test    bh, 0x80
  1587.         jz      @f
  1588.         test    al, al
  1589.         jz      @f
  1590.         dec     al
  1591.   @@:
  1592.         dec     esi
  1593.         jnz     .new_y
  1594.         jmp     draw_bar_end_16.end
  1595.  
  1596. ;------------------------------------------------------------------------------
  1597.  
  1598. align 4
  1599. vesa20_drawbackground_tiled:
  1600.  
  1601.         pushad
  1602. ; External loop for all y from start to end
  1603.         mov     ebx, [background_window + WDATA.draw_data.top]    ; y start
  1604.   .dp2:
  1605.         mov     ebp, [background_window + WDATA.draw_data.left]   ; x start
  1606. ; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
  1607. ;    and LFB data (output for our function) [edi]
  1608. ;        mov     eax, [BytesPerScanLine]
  1609. ;        mul     ebx
  1610.         mov     eax, [BPSLine_calc_area+ebx*4]
  1611.         xchg    ebp, eax
  1612.         add     ebp, eax
  1613.         add     ebp, eax
  1614.         cmp     byte [_display.bytes_per_pixel], 2
  1615.         je      @f
  1616.         add     ebp, eax
  1617.         cmp     byte [_display.bytes_per_pixel], 3
  1618.         je      @f
  1619.         add     ebp, eax
  1620.  
  1621.   @@:
  1622.         add     ebp, LFB_BASE
  1623. ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
  1624.         call    calculate_edi
  1625.         xchg    edi, ebp
  1626.         add     ebp, [_display.win_map]
  1627. ; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
  1628. ; 2) Calculate offset in background memory block
  1629.         push    eax
  1630.         xor     edx, edx
  1631.         mov     eax, ebx
  1632.         div     dword [BgrDataHeight]   ; edx := y mod BgrDataHeight
  1633.         pop     eax
  1634.         push    eax
  1635.         mov     ecx, [BgrDataWidth]
  1636.         mov     esi, edx
  1637.         imul    esi, ecx                ; esi := (y mod BgrDataHeight) * BgrDataWidth
  1638.         xor     edx, edx
  1639.         div     ecx             ; edx := x mod BgrDataWidth
  1640.         sub     ecx, edx
  1641.         add     esi, edx        ; esi := (y mod BgrDataHeight)*BgrDataWidth + (x mod BgrDataWidth)
  1642.         pop     eax
  1643.         lea     esi, [esi*3]
  1644.         add     esi, [img_background]
  1645.         xor     edx, edx
  1646.         inc     edx
  1647. ; 3) Loop through redraw rectangle and copy background data
  1648. ; Registers meaning:
  1649. ; eax = x, ebx = y (screen coordinates)
  1650. ; ecx = deltax - number of pixels left in current tile block
  1651. ; edx = 1
  1652. ; esi -> bgr memory, edi -> output
  1653. ; ebp = offset in WinMapAddress
  1654.   .dp3:
  1655.         cmp     [ebp], dl
  1656.         jnz     .next_pix
  1657.  
  1658.         push    eax ecx
  1659.         mov     ecx, eax
  1660.         shl     ecx, 16
  1661.         add     ecx, ebx
  1662.  
  1663.         mov     eax, [esi]
  1664.  
  1665. ; check for hardware cursor
  1666.         cmp     [_display.select_cursor], select_cursor
  1667.         jne     .no_mouseunder
  1668.  
  1669.         and     eax, 0xffffff
  1670. ; check mouse area for putpixel
  1671.         call    [_display.check_mouse]
  1672.   .no_mouseunder:
  1673.  
  1674.         cmp     byte [_display.bits_per_pixel], 16
  1675.         je      .16bpp
  1676. ; store to LFB
  1677.         mov     [edi], ax
  1678.         shr     eax, 16
  1679.         mov     [edi+2], al
  1680.         pop     ecx eax
  1681.         jmp     .next_pix
  1682.  
  1683.   .16bpp:
  1684. ; convert to 16 bpp and store to LFB
  1685.         and     eax, 00000000111110001111110011111000b
  1686.         shr     ah, 2
  1687.         shr     ax, 3
  1688.         ror     eax, 8
  1689.         add     al, ah
  1690.         rol     eax, 8
  1691.         mov     [edi], ax
  1692.         pop     ecx eax
  1693.  
  1694. ; Advance to next pixel
  1695.   .next_pix:
  1696.         add     esi, 3
  1697.         add     edi, [_display.bytes_per_pixel]
  1698.  
  1699.         add     ebp, edx
  1700.         add     eax, edx
  1701.         cmp     eax, [background_window + WDATA.draw_data.right]
  1702.         ja      .dp4
  1703.         sub     ecx, edx
  1704.         jnz     .dp3
  1705.  
  1706. ; next tile block on x-axis
  1707.         mov     ecx, [BgrDataWidth]
  1708.         sub     esi, ecx
  1709.         sub     esi, ecx
  1710.         sub     esi, ecx
  1711.         jmp     .dp3
  1712.  
  1713.   .dp4:
  1714. ; next scan line
  1715.         inc     ebx
  1716.         cmp     ebx, [background_window + WDATA.draw_data.bottom]
  1717.         jbe     .dp2
  1718.         popad
  1719.         mov     [EGA_counter], 1
  1720.         cmp     [SCR_MODE], 0x12
  1721.         jne     @f
  1722.         call    VGA_drawbackground
  1723.   @@:
  1724.         ret
  1725.  
  1726. ;------------------------------------------------------------------------------
  1727.  
  1728. align 4
  1729. vesa20_drawbackground_stretch:
  1730.  
  1731.         pushad
  1732. ; Helper variables
  1733. ; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1)
  1734.         mov     eax, [BgrDataWidth]
  1735.         dec     eax
  1736.         xor     edx, edx
  1737.         div     dword [_display.width]
  1738.         push    eax     ; high
  1739.         xor     eax, eax
  1740.         div     dword [_display.width]
  1741.         push    eax     ; low
  1742.  
  1743. ; the same for height
  1744.         mov     eax, [BgrDataHeight]
  1745.         dec     eax
  1746.         xor     edx, edx
  1747.         div     dword [_display.height]
  1748.         push    eax     ; high
  1749.         xor     eax, eax
  1750.         div     dword [_display.height]
  1751.         push    eax     ; low
  1752.  
  1753. ; External loop for all y from start to end
  1754.         mov     ebx, [background_window + WDATA.draw_data.top]    ; y start
  1755.         mov     ebp, [background_window + WDATA.draw_data.left]   ; x start
  1756. ; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
  1757. ;                       and LFB data (output for our function) [edi]
  1758. ;        mov     eax, [BytesPerScanLine]
  1759. ;        mul     ebx
  1760.         mov     eax, [BPSLine_calc_area+ebx*4]
  1761.         xchg    ebp, eax
  1762.         add     ebp, eax
  1763.         add     ebp, eax
  1764.         cmp     byte [_display.bytes_per_pixel], 2
  1765.         jz      @f
  1766.         add     ebp, eax
  1767.         cmp     byte [_display.bytes_per_pixel], 3
  1768.         jz      @f
  1769.         add     ebp, eax
  1770.   @@:
  1771.  
  1772. ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
  1773.         call    calculate_edi
  1774.         xchg    edi, ebp
  1775.  
  1776. ; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
  1777.         push    ebx
  1778.         push    eax
  1779. ; 2) Calculate offset in background memory block
  1780.         mov     eax, ebx
  1781.         imul    ebx, dword [esp+12]
  1782.         mul     dword [esp+8]
  1783.         add     edx, ebx        ; edx:eax = y * 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
  1784.         mov     esi, edx
  1785.         imul    esi, [BgrDataWidth]
  1786.         push    edx
  1787.         push    eax
  1788.         mov     eax, [esp+8]
  1789.         mul     dword [esp+28]
  1790.         push    eax
  1791.         mov     eax, [esp+12]
  1792.         mul     dword [esp+28]
  1793.         add     [esp], edx
  1794.         pop     edx             ; edx:eax = x * 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
  1795.         add     esi, edx
  1796.         lea     esi, [esi*3]
  1797.         add     esi, [img_background]
  1798.         push    eax
  1799.         push    edx
  1800.         push    esi
  1801.  
  1802. ; 3) Smooth horizontal
  1803.   bgr_resmooth0:
  1804.         mov     ecx, [esp+8]
  1805.         mov     edx, [esp+4]
  1806.         mov     esi, [esp]
  1807.         push    edi
  1808.         mov     edi, bgr_cur_line
  1809.         call    smooth_line
  1810.  
  1811.   bgr_resmooth1:
  1812.         mov     eax, [esp+16+4]
  1813.         inc     eax
  1814.         cmp     eax, [BgrDataHeight]
  1815.         jae     bgr.no2nd
  1816.         mov     ecx, [esp+8+4]
  1817.         mov     edx, [esp+4+4]
  1818.         mov     esi, [esp+4]
  1819.         add     esi, [BgrDataWidth]
  1820.         add     esi, [BgrDataWidth]
  1821.         add     esi, [BgrDataWidth]
  1822.         mov     edi, bgr_next_line
  1823.         call    smooth_line
  1824.  
  1825.   bgr.no2nd:
  1826.         pop     edi
  1827.  
  1828.   sdp3:
  1829.         xor     esi, esi
  1830.         mov     ecx, [esp+12]
  1831.  
  1832. ; 4) Loop through redraw rectangle and copy background data
  1833. ; Registers meaning:
  1834. ; esi = offset in current line, edi -> output
  1835. ; ebp = offset in WinMapAddress
  1836. ; dword [esp] = offset in bgr data
  1837. ; qword [esp+4] = x * 2^32 * (BgrDataWidth-1) / (ScreenWidth-1)
  1838. ; qword [esp+12] = y * 2^32 * (BgrDataHeight-1) / (ScreenHeight-1)
  1839. ; dword [esp+20] = x
  1840. ; dword [esp+24] = y
  1841. ; precalculated constants:
  1842. ; qword [esp+28] = 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
  1843. ; qword [esp+36] = 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
  1844.  
  1845.   sdp3a:
  1846.         mov     eax, [_display.win_map]
  1847.         cmp     [ebp+eax], byte 1
  1848.         jnz     snbgp
  1849.         mov     eax, [bgr_cur_line+esi]
  1850.         test    ecx, ecx
  1851.         jz      .novert
  1852.         mov     ebx, [bgr_next_line+esi]
  1853.         call    [overlapping_of_points_ptr]
  1854.  
  1855.   .novert:
  1856.         push    ecx
  1857. ; check for hardware cursor
  1858.         cmp     [_display.select_cursor], select_cursor
  1859.         jne     .no_mouseunder
  1860.  
  1861.         mov     ecx, [esp+20+4]        ;x
  1862.         shl     ecx, 16
  1863.         add     ecx, [esp+24+4]        ;y
  1864. ; check mouse area for putpixel
  1865.         call    [_display.check_mouse]
  1866.   .no_mouseunder:
  1867.  
  1868.         cmp     [_display.bits_per_pixel], 16
  1869.         jne     .not_16bpp
  1870. ; convert to 16 bpp and store to LFB
  1871.         and     eax, 00000000111110001111110011111000b
  1872.         shr     ah, 2
  1873.         shr     ax, 3
  1874.         ror     eax, 8
  1875.         add     al, ah
  1876.         rol     eax, 8
  1877.         mov     [LFB_BASE+edi], ax
  1878.         pop     ecx
  1879.         jmp     snbgp
  1880.   .not_16bpp:
  1881.  
  1882. ; store to LFB
  1883.         mov     [LFB_BASE+edi], ax
  1884.         shr     eax, 16
  1885.         mov     [LFB_BASE+edi+2], al
  1886.         pop     ecx
  1887.  
  1888.   snbgp:
  1889.         add     edi, [_display.bytes_per_pixel]
  1890.         add     ebp, 1
  1891.         mov     eax, [esp+20]
  1892.         add     eax, 1
  1893.         mov     [esp+20], eax
  1894.         add     esi, 4
  1895.         cmp     eax, [background_window + WDATA.draw_data.right]
  1896.         jbe     sdp3a
  1897.  
  1898.   sdp4:
  1899. ; next y
  1900.         mov     ebx, [esp+24]
  1901.         add     ebx, 1
  1902.         mov     [esp+24], ebx
  1903.         cmp     ebx, [background_window + WDATA.draw_data.bottom]
  1904.         ja      sdpdone
  1905.  
  1906. ; advance edi, ebp to next scan line
  1907.         sub     eax, [background_window + WDATA.draw_data.left]
  1908.         sub     ebp, eax
  1909.         add     ebp, [_display.width]
  1910.         sub     edi, eax
  1911.         sub     edi, eax
  1912.         cmp     byte [_display.bytes_per_pixel], 2
  1913.         jz      @f
  1914.         sub     edi, eax
  1915.         cmp     byte [_display.bytes_per_pixel], 3
  1916.         jz      @f
  1917.         sub     edi, eax
  1918.  
  1919.   @@:
  1920.         add     edi, [_display.lfb_pitch]
  1921. ; restore ecx,edx; advance esi to next background line
  1922.         mov     eax, [esp+28]
  1923.         mov     ebx, [esp+32]
  1924.         add     [esp+12], eax
  1925.         mov     eax, [esp+16]
  1926.         adc     [esp+16], ebx
  1927.         sub     eax, [esp+16]
  1928.         mov     ebx, eax
  1929.         lea     eax, [eax*3]
  1930.         imul    eax, [BgrDataWidth]
  1931.         sub     [esp], eax
  1932.         mov     eax, [background_window + WDATA.draw_data.left]
  1933.         mov     [esp+20], eax
  1934.         test    ebx, ebx
  1935.         jz      sdp3
  1936.         cmp     ebx, -1
  1937.         jnz     bgr_resmooth0
  1938.         push    edi
  1939.         mov     esi, bgr_next_line
  1940.         mov     edi, bgr_cur_line
  1941.         mov     ecx, [_display.width]
  1942.         rep movsd
  1943.         jmp     bgr_resmooth1
  1944.  
  1945.   sdpdone:
  1946.         add     esp, 44
  1947.         popad
  1948.         mov     [EGA_counter], 1
  1949.         cmp     [SCR_MODE], 0x12
  1950.         jne     @f
  1951.         call    VGA_drawbackground
  1952.   @@:
  1953.         ret
  1954.  
  1955. ;--------------------------------------
  1956.  
  1957. align 4
  1958. smooth_line:
  1959.         mov     al, [esi+2]
  1960.         shl     eax, 16
  1961.         mov     ax, [esi]
  1962.         test    ecx, ecx
  1963.         jz      @f
  1964.         mov     ebx, [esi+2]
  1965.         shr     ebx, 8
  1966.         call    [overlapping_of_points_ptr]
  1967.   @@:
  1968.         stosd
  1969.         mov     eax, [esp+20+8]
  1970.         add     eax, 1
  1971.         mov     [esp+20+8], eax
  1972.         cmp     eax, [background_window + WDATA.draw_data.right]
  1973.         ja      @f
  1974.         add     ecx, [esp+36+8]
  1975.         mov     eax, edx
  1976.         adc     edx, [esp+40+8]
  1977.         sub     eax, edx
  1978.         lea     eax, [eax*3]
  1979.         sub     esi, eax
  1980.         jmp     smooth_line
  1981.   @@:
  1982.         mov     eax, [background_window + WDATA.draw_data.left]
  1983.         mov     [esp+20+8], eax
  1984.         ret
  1985.  
  1986. ;------------------------------------------------------------------------------
  1987.  
  1988. align 16
  1989. overlapping_of_points:
  1990. if 0
  1991. ; this version of procedure works, but is slower than next version
  1992.         push    ecx edx
  1993.         mov     edx, eax
  1994.         push    esi
  1995.         shr     ecx, 24
  1996.         mov     esi, ecx
  1997.         mov     ecx, ebx
  1998.         movzx   ebx, dl
  1999.         movzx   eax, cl
  2000.         sub     eax, ebx
  2001.         movzx   ebx, dh
  2002.         imul    eax, esi
  2003.         add     dl, ah
  2004.         movzx   eax, ch
  2005.         sub     eax, ebx
  2006.         imul    eax, esi
  2007.         add     dh, ah
  2008.         ror     ecx, 16
  2009.         ror     edx, 16
  2010.         movzx   eax, cl
  2011.         movzx   ebx, dl
  2012.         sub     eax, ebx
  2013.         imul    eax, esi
  2014.         pop     esi
  2015.         add     dl, ah
  2016.         mov     eax, edx
  2017.         pop     edx
  2018.         ror     eax, 16
  2019.         pop     ecx
  2020.         ret
  2021. else
  2022.         push    ecx edx
  2023.         mov     edx, eax
  2024.         push    esi
  2025.         shr     ecx, 26
  2026.         mov     esi, ecx
  2027.         mov     ecx, ebx
  2028.         shl     esi, 9
  2029.         movzx   ebx, dl
  2030.         movzx   eax, cl
  2031.         sub     eax, ebx
  2032.         movzx   ebx, dh
  2033.         add     dl, [BgrAuxTable + (eax + 0x100) + esi]
  2034.         movzx   eax, ch
  2035.         sub     eax, ebx
  2036.         add     dh, [BgrAuxTable + (eax+0x100) + esi]
  2037.         ror     ecx, 16
  2038.         ror     edx, 16
  2039.         movzx   eax, cl
  2040.         movzx   ebx, dl
  2041.         sub     eax, ebx
  2042.         add     dl, [BgrAuxTable + (eax + 0x100) + esi]
  2043.         pop     esi
  2044.         mov     eax, edx
  2045.         pop     edx
  2046.         ror     eax, 16
  2047.         pop     ecx
  2048.         ret
  2049. end if
  2050.  
  2051.  
  2052. ;------------------------------------------------------------------------------
  2053.  
  2054. align 4
  2055. init_background:
  2056.  
  2057.         mov     edi, BgrAuxTable
  2058.         xor     edx, edx
  2059.  
  2060.   .loop2:
  2061.         mov     eax, edx
  2062.         shl     eax, 8
  2063.         neg     eax
  2064.         mov     ecx, 0x200
  2065.  
  2066.   .loop1:
  2067.         mov     byte [edi], ah
  2068.         inc     edi
  2069.         add     eax, edx
  2070.         loop    .loop1
  2071.         add     dl, 4
  2072.         jnz     .loop2
  2073.         test    byte [cpu_caps + (CAPS_MMX/8)], 1 shl (CAPS_MMX mod 8)
  2074.         jz      @f
  2075.         mov     [overlapping_of_points_ptr], overlapping_of_points_mmx
  2076.   @@:
  2077.         ret
  2078.  
  2079. ;------------------------------------------------------------------------------
  2080.  
  2081. align 16
  2082. overlapping_of_points_mmx:
  2083.  
  2084.         movd    mm0, eax
  2085.         movd    mm4, eax
  2086.         movd    mm1, ebx
  2087.         pxor    mm2, mm2
  2088.         punpcklbw mm0, mm2
  2089.         punpcklbw mm1, mm2
  2090.         psubw   mm1, mm0
  2091.         movd    mm3, ecx
  2092.         psrld   mm3, 24
  2093.         packuswb mm3, mm3
  2094.         packuswb mm3, mm3
  2095.         pmullw  mm1, mm3
  2096.         psrlw   mm1, 8
  2097.         packuswb mm1, mm2
  2098.         paddb   mm4, mm1
  2099.         movd    eax, mm4
  2100.  
  2101.         ret
  2102.  
  2103. ;------------------------------------------------------------------------------
  2104.