Subversion Repositories Kolibri OS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                        ;;
  3. ;;  VESA20.INC                                            ;;
  4. ;;                                                        ;;
  5. ;;  Vesa 2.0 functions for MenuetOS                       ;;
  6. ;;                                                        ;;
  7. ;;  Copyright 2002 Ville Turjanmaa                        ;;
  8. ;;  Alexey, kgaz@crosswindws.net                          ;;
  9. ;;  - Voodoo compatible graphics                          ;;
  10. ;;  Juan M. Caravaca                                      ;;
  11. ;;  - Graphics optimimizations eg. drawline               ;;
  12. ;;                                                        ;;
  13. ;;  See file COPYING for details                          ;;
  14. ;;                                                        ;;
  15. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  16.  
  17. ; If you're planning to write your own video driver I suggest
  18. ; you replace the VESA12.INC file and see those instructions.
  19.  
  20. ScreenWidth             equ     0xfe00
  21. ScreenHeight            equ     0xfe04
  22. BytesPerScanLine        equ     0xfe08
  23. LFBAddress              equ     0xfe80
  24. ScreenBPP               equ     0xfbf1
  25. WinMapAddress           equ     0x460000
  26.  
  27.  
  28.  
  29. ;*************************************************
  30. ; getpixel
  31. ;
  32. ; in:
  33. ; eax = x coordinate
  34. ; ebx = y coordinate
  35. ;
  36. ; ret:
  37. ; ecx = 00 RR GG BB
  38.  
  39. getpixel:
  40.         push    eax ebx edx edi
  41.         call    dword [0xe024]
  42.         pop     edi edx ebx eax
  43.         ret
  44.  
  45. Vesa20_getpixel24:
  46.         ; eax = x
  47.         ; ebx = y
  48.         imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
  49.         lea     edi, [eax+eax*2] ; edi = x*3
  50.         add     edi, ebx         ; edi = x*3+(y*y multiplier)
  51.         add     edi, [LFBAddress]    ; ebx = where pixel is in memory
  52.         mov     ecx, [edi]
  53.         and     ecx, 0xffffff
  54.         ret
  55.  
  56.  
  57. Vesa20_getpixel32:
  58.         imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
  59.         lea     edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
  60.         add     edi, [LFBAddress]    ; ebx = where pixel is in memory
  61.         mov     ecx, [edi]
  62.         and     ecx, 0xffffff
  63.         ret
  64.  
  65. ;*************************************************
  66.  
  67. virtual at esp
  68.  putimg:
  69.    .real_sx        dd ?
  70.    .real_sy        dd ?
  71.    .image_sx       dd ?
  72.    .image_sy       dd ?
  73.    .image_cx       dd ?
  74.    .image_cy       dd ?
  75.    .pti            dd ?
  76.    .abs_cx         dd ?
  77.    .abs_cy         dd ?
  78.    .line_increment dd ?
  79.    .source_bpp     dd ?
  80.    .winmap_newline dd ?
  81.    .screen_newline dd ?
  82.    .stack_data = 4*13
  83. end virtual
  84.  
  85. align 4
  86. ; ebx = pointer
  87. ; ecx = size [x|y]
  88. ; edx = coordinates [x|y]
  89. vesa20_putimage:
  90.         pushad
  91.         call    [disable_mouse]
  92.  
  93.         sub     esp, putimg.stack_data
  94.  
  95.         mov     [putimg.source_bpp], 3
  96. ;        test    ebx, 0x80000000
  97. ;        jz      @f
  98. ;        inc     [putimg.source_bpp]
  99. ;      @@:
  100. ;        and     ebx, 0x7FFFFFFF
  101.  
  102.         ; save pointer to image
  103.         mov     [putimg.pti], ebx
  104.  
  105.         ; unpack the size
  106.         mov     eax, ecx
  107.         and     ecx, 0xFFFF
  108.         shr     eax, 16
  109.         mov     [putimg.image_sx], eax
  110.         mov     [putimg.image_sy], ecx
  111.  
  112.         ; unpack the coordinates
  113.         mov     eax, edx
  114.         and     edx, 0xFFFF
  115.         shr     eax, 16
  116.         mov     [putimg.image_cx], eax
  117.         mov     [putimg.image_cy], edx
  118.  
  119.         ; calculate absolute (i.e. screen) coordinates
  120.         mov     eax, [0x3010]
  121.         mov     ebx, [eax-twdw + 0]
  122.         add     ebx, [putimg.image_cx]
  123.         mov     [putimg.abs_cx], ebx
  124.         mov     ebx, [eax-twdw + 4]
  125.         add     ebx, [putimg.image_cy]
  126.         mov     [putimg.abs_cy], ebx
  127.  
  128.         ; real_sx = MIN(wnd_sx-image_cx, image_sx);
  129.         mov     ebx, [eax-twdw + 8] ; ebx = wnd_sx
  130.         sub     ebx, [putimg.image_cx]
  131.         ja      @f
  132.         add     esp, putimg.stack_data
  133.         popad
  134.         ret
  135.       @@:
  136.         cmp     ebx, [putimg.image_sx]
  137.         jbe     .end_x
  138.         mov     ebx, [putimg.image_sx]
  139.         dec     ebx
  140.       .end_x:
  141.         inc     ebx
  142.         mov     [putimg.real_sx], ebx
  143.  
  144.         ; init real_sy
  145.         mov     ebx, [eax-twdw + 12] ; ebx = wnd_sy
  146.         sub     ebx, [putimg.image_cy]
  147.         ja      @f
  148.         add     esp, putimg.stack_data
  149.         popad
  150.         ret
  151.       @@:
  152.         cmp     ebx, [putimg.image_sy]
  153.         jbe     .end_y
  154.         mov     ebx, [putimg.image_sy]
  155.         dec     ebx
  156.       .end_y:
  157.         inc     ebx
  158.         mov     [putimg.real_sy], ebx
  159.  
  160.         ; line increment
  161.         mov     eax, [putimg.image_sx]
  162.         sub     eax, [putimg.real_sx]
  163. ;;        imul    eax, [putimg.source_bpp]
  164.         lea     eax, [eax + eax * 2]
  165.         mov     [putimg.line_increment], eax
  166.  
  167.         ; winmap new line increment
  168.         mov     eax, [ScreenWidth]
  169.         inc     eax
  170.         sub     eax, [putimg.real_sx]
  171.         mov     [putimg.winmap_newline], eax
  172.  
  173.         ; screen new line increment
  174.         mov     eax, [BytesPerScanLine]
  175.         mov     ecx, [putimg.real_sx]
  176.         movzx   ebx, byte [ScreenBPP]
  177.         shr     ebx, 3
  178.         imul    ecx, ebx
  179.         sub     eax, ecx
  180.         mov     [putimg.screen_newline], eax
  181.  
  182.         ; pointer to image
  183.         mov     ecx, [putimg.pti]
  184.  
  185.         ; pointer to screen
  186.         mov     edx, [putimg.abs_cy]
  187.         imul    edx, [BytesPerScanLine]
  188.         mov     eax, [putimg.abs_cx]
  189.         movzx   ebx, byte [ScreenBPP]
  190.         shr     ebx, 3
  191.         imul    eax, ebx
  192.         add     edx, eax
  193.         add     edx, [LFBAddress]
  194.  
  195.         ; pointer to pixel map
  196.         mov     eax, [putimg.abs_cy]
  197.         imul    eax, [ScreenWidth]
  198.         add     eax, [putimg.abs_cy]
  199.         add     eax, [putimg.abs_cx]
  200.         add     eax, WinMapAddress
  201.         xchg    eax, ebp
  202.  
  203.         ; get process number
  204.         mov     eax, [0x3010]
  205.         mov     bl, [eax+0xE]
  206.  
  207.         cmp     byte [ScreenBPP], 32
  208.         je      put_image_end_32
  209.  
  210. ;put_image_end_24:
  211.         ;cli ; !!!!!!!!!!!!!!!!!!!!!!
  212.         mov     edi, [putimg.real_sy]
  213.         align   4
  214.       .new_line:
  215.         mov     esi, [putimg.real_sx]
  216.  
  217. ;        push    ebp edx
  218.         align   4
  219.           .new_x:
  220.  
  221.                 cmp     [ebp], bl
  222.                 jne     .skip
  223.                 mov     eax, [ecx]        ; ecx = RRBBGGRR
  224.                 mov     [edx], ax
  225.                 shr     eax, 16
  226.                 mov     [edx+2], al
  227.               .skip:
  228.  
  229.             add     ecx, 3 ;[putimg.source_bpp]
  230.             add     edx, 3
  231.             inc     ebp
  232.  
  233.             dec     esi
  234.             jnz     .new_x
  235. ;        pop     edx ebp
  236.  
  237.         add     ecx, [putimg.line_increment]
  238.         add     edx, [putimg.screen_newline] ;[BytesPerScanLine]
  239.         add     ebp, [putimg.winmap_newline] ;[ScreenWidth]
  240.         ;inc     ebp
  241.  
  242.         dec     edi
  243.         jnz     .new_line
  244.    .finish:
  245.         add     esp, putimg.stack_data
  246.         popad
  247.         ;sti ; !!!!!!!!!!!!!!!!!!!!!
  248. ret
  249.  
  250. put_image_end_32:
  251.         mov     edi, [putimg.real_sy]
  252.         align   4
  253.       .new_line:
  254.         mov     esi, [putimg.real_sx]
  255.  
  256. ;        push    ebp edx
  257.         align   4
  258.           .new_x:
  259.  
  260.                 cmp     [ebp], bl
  261.                 jne     .skip
  262.                 mov     eax, [ecx]        ; ecx = RRBBGGRR
  263.                 mov     [edx], eax
  264.               .skip:
  265.  
  266.             add     ecx, [putimg.source_bpp]
  267.             add     edx, 4
  268.             inc     ebp
  269.  
  270.             dec     esi
  271.             jnz     .new_x
  272. ;        pop     edx ebp
  273.  
  274.         add     ecx, [putimg.line_increment]
  275.         add     edx, [putimg.screen_newline] ;[BytesPerScanLine]
  276.         add     ebp, [putimg.winmap_newline] ;[ScreenWidth]
  277.         ;inc     ebp
  278.  
  279.         dec     edi
  280.         jnz     .new_line
  281.    .finish:
  282.         add     esp, putimg.stack_data
  283.         popad
  284. ret
  285.  
  286.  
  287. ;*************************************************
  288. align 4
  289. __sys_putpixel:
  290.  
  291. ; eax = x coordinate
  292. ; ebx = y coordinate
  293. ; ecx = ?? RR GG BB    ; 0x01000000 negation
  294. ; edi = 0x00000001 force
  295.  
  296. ;;;        mov  [novesachecksum], dword 0
  297.  
  298.         pushad
  299.         test  edi,1                 ; force ?
  300.         jnz   .forced
  301.       ; not forced:
  302.         push  ecx               ; save 24th bit in case negative pixel wanted
  303.         call  checkpixel
  304.         test  ecx,ecx
  305.         pop   ecx
  306.         jnz   .exit
  307.       .forced:
  308.         cmp   [ScreenWidth], eax
  309.         jb    .exit
  310.         cmp   [ScreenHeight], ebx
  311.         jb    .exit
  312.       .ok:
  313.         ; check if negation
  314.         test  ecx,0x01000000
  315.         jz    .noneg
  316.         call  getpixel
  317.         not   ecx
  318.         mov   [esp+32-8],ecx
  319.       .noneg:
  320.         ; OK to set pixel
  321.         call  dword [0xe020]        ; call the real put_pixel function
  322.       .exit:
  323.         popad
  324.  
  325.         ret
  326.  
  327. align 4
  328. Vesa20_putpixel24:
  329.  
  330.         ; eax = x
  331.         ; ebx = y
  332.  
  333.         imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
  334.         lea     edi, [eax+eax*2]  ; edi = x*3
  335.         mov     eax, [esp+32-8+4]
  336.         add     edi, [LFBAddress]
  337.         add     edi, ebx          ; ebx = where to put pixel in memory
  338.         mov     [edi], ax
  339.         shr     eax, 16
  340.         mov     [edi+2], al
  341.  
  342.         ret
  343.  
  344.  
  345. align 4
  346. Vesa20_putpixel32:
  347.  
  348.         ; eax = x
  349.         ; ebx = y
  350.  
  351.         imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
  352.         lea     edi, [ebx+eax*4]  ; edi = x*4+(y*y multiplier)
  353.         mov     eax, [esp+32-8+4] ; eax = color
  354.         add     edi, [LFBAddress]     ; ebx = where to put pixel in memory
  355.         mov     [edi], eax
  356.  
  357.         ret
  358.  
  359.  
  360. ;*************************************************
  361.  
  362. ;align 4
  363. calculate_edi:
  364.         mov     edi, ebx
  365.         imul    edi, [ScreenWidth]
  366.         add     edi, ebx
  367.         add     edi, eax
  368. ret
  369.  
  370. ;*************************************************
  371.  
  372. ; DRAWLINE
  373.  
  374. align 4
  375. __sys_draw_line:
  376. ;     inc   [mouse_pause]
  377.         call    [disable_mouse]
  378.  
  379. ; draw a line
  380. ; eax = HIWORD = x1
  381. ;       LOWORD = x2
  382. ; ebx = HIWORD = y1
  383. ;       LOWORD = y2
  384. ; ecx = color
  385. ; edi = force ?
  386.         pusha
  387.  
  388. dl_x1 equ esp+20
  389. dl_y1 equ esp+16
  390. dl_x2 equ esp+12
  391. dl_y2 equ esp+8
  392. dl_dx equ esp+4
  393. dl_dy equ esp+0
  394.  
  395.         xor     edx, edx      ; clear edx
  396.         xor     esi, esi      ; unpack arguments
  397.         xor     ebp, ebp
  398.         mov     si, ax        ; esi = x2
  399.         mov     bp, bx        ; ebp = y2
  400.         shr     eax, 16       ; eax = x1
  401.         shr     ebx, 16       ; ebx = y1
  402.  
  403.         push    eax           ; save x1
  404.         push    ebx           ; save y1
  405.         push    esi           ; save x2
  406.         push    ebp           ; save y2
  407.  
  408.         ; checking x-axis...
  409.         sub     esi, eax      ; esi = x2-x1
  410.         push    esi           ; save y2-y1
  411.         jl      .x2lx1        ; is x2 less than x1 ?
  412.         jg      .no_vline     ; x1 > x2 ?
  413.         mov     edx, ebp      ; else (if x1=x2)
  414.         call    vline
  415.         push    edx    ; necessary to rightly restore stack frame at .exit
  416.         jmp     .exit
  417. .x2lx1:
  418.         neg     esi            ; get esi absolute value
  419. .no_vline:
  420.  
  421.         ; checking y-axis...
  422.         sub     ebp, ebx       ; ebp = y2-y1
  423.         push    ebp            ; save y2-y1
  424.         jl      .y2ly1         ; is y2 less than y1 ?
  425.         jg      .no_hline      ; y1 > y2 ?
  426.         mov     edx, [dl_x2]   ; else (if y1=y2)
  427.         call    hline
  428.         jmp     .exit
  429. .y2ly1:
  430.         neg     ebp            ; get ebp absolute value
  431. .no_hline:
  432.  
  433.  
  434.         cmp     ebp, esi
  435.         jle     .x_rules       ; |y2-y1| < |x2-x1|  ?
  436.  
  437.         cmp     [dl_y2], ebx   ; make sure y1 is at the begining
  438.         jge     .no_reverse1
  439.  
  440.         neg     dword [dl_dx]
  441.         mov     edx, [dl_x2]
  442.         mov     [dl_x2], eax
  443.         mov     [dl_x1], edx
  444.         mov     edx, [dl_y2]
  445.         mov     [dl_y2], ebx
  446.         mov     [dl_y1], edx
  447.  
  448. .no_reverse1:
  449.  
  450.         mov     eax, [dl_dx]
  451.         cdq                    ; extend eax sing to edx
  452.         shl     eax, 16        ; using 16bit fix-point maths
  453.         idiv    ebp            ; eax = ((x2-x1)*65536)/(y2-y1)
  454.         mov     edx, ebp       ; edx = counter (number of pixels to draw)
  455.         mov     ebp, 1 *65536  ; <<16   ; ebp = dy = 1.0
  456.         mov     esi, eax       ; esi = dx
  457.  
  458.         jmp     .y_rules
  459. .x_rules:
  460.  
  461.         cmp     [dl_x2], eax    ; make sure x1 is at the begining
  462.         jge     .no_reverse2
  463.  
  464.         neg     dword [dl_dy]
  465.         mov     edx, [dl_x2]
  466.         mov     [dl_x2], eax
  467.         mov     [dl_x1], edx
  468.         mov     edx, [dl_y2]
  469.         mov     [dl_y2], ebx
  470.         mov     [dl_y1], edx
  471.  
  472. .no_reverse2:
  473.  
  474.         xor     edx, edx
  475.         mov     eax, [dl_dy]
  476.         cdq                    ; extend eax sing to edx
  477.         shl     eax, 16        ; using 16bit fix-point maths
  478.         idiv    esi            ; eax = ((y2-y1)*65536)/(x2-x1)
  479.         mov     edx, esi       ; edx = counter (number of pixels to draw)
  480.         mov     esi, 1 *65536  ;<< 16   ; esi = dx = 1.0
  481.         mov     ebp, eax       ; ebp = dy
  482.  
  483. .y_rules:
  484.  
  485.         mov     eax, [dl_x1]
  486.         mov     ebx, [dl_y1]
  487.         shl     eax, 16
  488.         shl     ebx, 16
  489.  
  490. align 4
  491.  
  492. .draw:
  493.         push    eax ebx
  494.         shr     eax, 16
  495.         shr     ebx, 16
  496.         call    [putpixel]
  497.         pop     ebx eax
  498.  
  499.         add     ebx, ebp        ; y = y+dy
  500.         add     eax, esi        ; x = x+dx
  501.  
  502.         dec     edx
  503.         jnz     .draw
  504.  
  505.         ; force last drawn pixel to be at (x2,y2)
  506.         mov     eax, [dl_x2]
  507.         mov     ebx, [dl_y2]
  508.         call    [putpixel]
  509. .exit:
  510.         add     esp, 6*4
  511.         popa
  512. ;     dec   [mouse_pause]
  513.      call   [draw_pointer]
  514. ret
  515.  
  516.  
  517. hline:
  518. ; draw an horizontal line
  519. ; eax = x1
  520. ; edx = x2
  521. ; ebx = y
  522. ; ecx = color
  523. ; edi = force ?
  524.         push    eax edx
  525.  
  526.         cmp     edx, eax      ; make sure x2 is above x1
  527.         jge     @f
  528.         xchg    eax, edx
  529.         align   4
  530.    @@:
  531.         call    [putpixel]
  532.         inc     eax
  533.         cmp     eax, edx
  534.         jle     @b
  535.  
  536.         pop     edx eax
  537. ret
  538.  
  539.  
  540. vline:
  541. ; draw a vertical line
  542. ; eax = x
  543. ; ebx = y1
  544. ; edx = y2
  545. ; ecx = color
  546. ; edi = force ?
  547.         push    ebx edx
  548.  
  549.         cmp     edx, ebx      ; make sure y2 is above y1
  550.         jge     @f
  551.         xchg    ebx, edx
  552.         align   4
  553.    @@:
  554.         call    [putpixel]
  555.         inc     ebx
  556.         cmp     ebx, edx
  557.         jle     @b
  558.  
  559.         pop     edx ebx
  560. ret
  561.  
  562.  
  563. ;*************************************************
  564.  
  565.  
  566. virtual at esp
  567.       drbar:
  568.         .bar_sx       dd ?
  569.         .bar_sy       dd ?
  570.         .bar_cx       dd ?
  571.         .bar_cy       dd ?
  572.         .abs_cx       dd ?
  573.         .abs_cy       dd ?
  574.         .real_sx      dd ?
  575.         .real_sy      dd ?
  576.         .color        dd ?
  577.         .line_inc_scr dd ?
  578.         .line_inc_map dd ?
  579.         .stack_data = 4*11
  580. end virtual
  581.  
  582. align 4
  583. ; eax   cx
  584. ; ebx   cy
  585. ; ecx   xe
  586. ; edx   ye
  587. ; edi   color
  588. vesa20_drawbar:
  589.        
  590.         pushad
  591.         call    [disable_mouse]
  592.  
  593.         sub     esp, drbar.stack_data
  594.  
  595.         mov     [drbar.color], edi
  596.  
  597.         sub     edx, ebx
  598.         jle     .exit          ;// mike.dld, 2005-01-29
  599.         sub     ecx, eax
  600.         jle     .exit          ;// mike.dld, 2005-01-29
  601.         mov     [drbar.bar_sy], edx
  602.         mov     [drbar.bar_sx], ecx
  603.  
  604.         mov     [drbar.bar_cx], eax
  605.         mov     [drbar.bar_cy], ebx
  606.  
  607.         mov     edi, [0x3010]
  608.         add     eax, [edi-twdw + 0] ; win_cx
  609.         add     ebx, [edi-twdw + 4] ; win_cy
  610.         mov     [drbar.abs_cx], eax
  611.         mov     [drbar.abs_cy], ebx
  612.  
  613.         ; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
  614.         mov     ebx, [edi-twdw + 8] ; ebx = wnd_sx
  615.         sub     ebx, [drbar.bar_cx]
  616.         ja      @f
  617.   .exit:                       ;// mike.dld, 2005-01-29
  618.         add     esp, drbar.stack_data
  619.         popad
  620.         xor     eax, eax
  621.         inc     eax
  622.        
  623.         ret
  624.       @@:
  625.         cmp     ebx, [drbar.bar_sx]
  626.         jbe     .end_x
  627.         mov     ebx, [drbar.bar_sx]
  628.       .end_x:
  629.         mov     [drbar.real_sx], ebx
  630.  
  631.         ; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
  632.         mov     ebx, [edi-twdw + 12] ; ebx = wnd_sy
  633.         sub     ebx, [drbar.bar_cy]
  634.         ja      @f
  635.         add     esp, drbar.stack_data
  636.         popad
  637.         xor     eax, eax
  638.         inc     eax
  639.        
  640.         ret
  641.       @@:
  642.         cmp     ebx, [drbar.bar_sy]
  643.         jbe     .end_y
  644.         mov     ebx, [drbar.bar_sy]
  645.       .end_y:
  646.         mov     [drbar.real_sy], ebx
  647.  
  648.         ; line_inc_map
  649.         mov     eax, [ScreenWidth]
  650.         sub     eax, [drbar.real_sx]
  651.         inc     eax
  652.         mov     [drbar.line_inc_map], eax
  653.  
  654.         ; line_inc_scr
  655.         mov     eax, [drbar.real_sx]
  656.         movzx   ebx, byte [ScreenBPP]
  657.         shr     ebx, 3
  658.         imul    eax, ebx
  659.         neg     eax
  660.         add     eax, [BytesPerScanLine]
  661.         mov     [drbar.line_inc_scr], eax
  662.  
  663.         ; pointer to screen
  664.         mov     edx, [drbar.abs_cy]
  665.         imul    edx, [BytesPerScanLine]
  666.         mov     eax, [drbar.abs_cx]
  667. ;        movzx   ebx, byte [ScreenBPP]
  668. ;        shr     ebx, 3
  669.         imul    eax, ebx
  670.         add     edx, eax
  671.         add     edx, [LFBAddress]
  672.  
  673.         ; pointer to pixel map
  674.         mov     eax, [drbar.abs_cy]
  675.         imul    eax, [ScreenWidth]
  676.         add     eax, [drbar.abs_cy]
  677.         add     eax, [drbar.abs_cx]
  678.         add     eax, WinMapAddress
  679.         xchg    eax, ebp
  680.  
  681.         ; get process number
  682.         mov     eax, [0x3010]
  683.         mov     bl, [eax+0xE]
  684.  
  685.         cmp     byte [ScreenBPP], 24
  686.         jne     draw_bar_end_32
  687. draw_bar_end_24:
  688.         ;cli ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  689.         mov     eax, [drbar.color]    ;; BBGGRR00
  690.         mov     bh, al                ;; bh  = BB
  691.         shr     eax, 8                ;; eax = RRGG
  692. ; eax - color high   RRGG
  693. ; bl - process num
  694. ; bh - color low    BB
  695. ; ecx - temp
  696. ; edx - pointer to screen
  697. ; esi - counter
  698. ; edi - counter
  699.  
  700.         mov     esi, [drbar.real_sy]
  701.         align   4
  702.      .new_y:
  703.         mov     edi, [drbar.real_sx]
  704.         align   4
  705.      .new_x:
  706.  
  707.         cmp     byte [ebp], bl
  708.         jne     .skip
  709.         mov     [edx], bh
  710.         mov     [edx + 1], ax
  711.       .skip:
  712.  
  713.         ; add pixel
  714.         add     edx, 3
  715.         inc     ebp
  716.  
  717.         dec     edi
  718.         jnz     .new_x
  719.  
  720.         ; add line
  721.         add     edx, [drbar.line_inc_scr]
  722.         add     ebp, [drbar.line_inc_map]
  723.  
  724.     ; <Ivan 15.10.04> drawing gradient bars
  725.         test    eax, 0x00800000
  726.         jz      @f
  727.         test    bh, bh
  728.         jz      @f
  729.         dec     bh
  730.       @@:
  731.     ; </Ivan 15.10.04>
  732.  
  733.         dec     esi
  734.         jnz     .new_y
  735.  
  736.         add     esp, drbar.stack_data
  737.         popad
  738.         xor     eax, eax
  739.         ;sti ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  740. ret
  741.  
  742. draw_bar_end_32:
  743.         mov     eax, [drbar.color]    ;; BBGGRR00
  744.  
  745.         mov     esi, [drbar.real_sy]
  746.         align   4
  747.      .new_y:
  748.         mov     edi, [drbar.real_sx]
  749.         align   4
  750.      .new_x:
  751.  
  752.         cmp     byte [ebp], bl
  753.         jne     .skip
  754.         mov     [edx], eax
  755.       .skip:
  756.  
  757.         ; add pixel
  758.         add     edx, 4
  759.         inc     ebp
  760.  
  761.         dec     edi
  762.         jnz     .new_x
  763.  
  764.         ; add line
  765.         add     edx, [drbar.line_inc_scr]
  766.         add     ebp, [drbar.line_inc_map]
  767.  
  768.     ; <Ivan 15.10.04> drawing gradient bars
  769.         test    eax, 0x80000000
  770.         jz      @f
  771.         test    al, al
  772.         jz      @f
  773.         dec     al
  774.       @@:
  775.     ; </Ivan 15.10.04>
  776.  
  777.         dec     esi
  778.         jnz     .new_y
  779.  
  780.         add     esp, drbar.stack_data
  781.         popad
  782.         xor     eax, eax
  783.  
  784. ret
  785.  
  786.  
  787. ;voodoodbcplimit:
  788.  
  789. ; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
  790.  
  791.  
  792. ;     pusha
  793.  
  794. ;     xor edx,edx
  795. ;     mov eax,ebp
  796. ;     mov ebx,[ScreenWidth] ; Screen_X_size
  797. ;     inc ebx   ; +1
  798. ;     sub eax,WinMapAddress ; -AddrBuffer
  799. ;     div ebx ;
  800. ;     mov ebx,eax ; ebx:=Y
  801. ;     mov eax,edx ; eax:=X
  802. ;     call cplimit
  803.  
  804. ;     test ecx,ecx
  805. ;     jne  dbcpl12
  806. ;     popa
  807. ;     clc
  808. ;     ret
  809. ;   dbcpl12:
  810. ;     popa
  811. ;     stc
  812. ;     ret
  813.  
  814.  
  815.  
  816.  
  817. ;dbcplimit:
  818.  
  819. ;        pusha
  820.  
  821. ;        xor  edx,edx
  822. ;        mov  ebx,[ScreenWidth]
  823. ;        inc  ebx
  824. ;        sub  eax,WinMapAddress
  825. ;        div  ebx
  826. ;        mov  ebx,eax
  827. ;        mov  eax,edx
  828. ;        call cplimit
  829.  
  830. ;        test ecx,ecx
  831. ;        jne  dbcpl1
  832. ;        popa
  833. ;        clc
  834. ;        ret
  835. ;     dbcpl1:
  836. ;        popa
  837. ;        stc
  838. ;        ret
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845. ;--------------vbe voodoo ------------------------------------------------
  846. vesa20_drawbackground_tiled:
  847.  
  848.      call [disable_mouse]
  849.  
  850.      push ebp
  851.      push eax
  852.      push ebx
  853.      push ecx
  854.      push edx
  855.  
  856.      mov edx,dword [WinMapAddress-8] ; B
  857.      add edx,dword [WinMapAddress-8] ; +B
  858.      add edx,dword [WinMapAddress-8] ; +B
  859.      push edx
  860.  
  861.      mov ebp,[draw_data+32+0] ; x start:=(x+Xwin)
  862.      mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
  863.  
  864.      mov eax,[BytesPerScanLine]
  865.      mul ebx
  866.      xchg ebp, eax  ; BytesPerScanLine*(Ywin+y)
  867.      add ebp, eax   ; +X
  868.      add ebp, eax   ; +X
  869.      add ebp, eax   ; +X
  870.  
  871.      cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
  872.      jz @f
  873.      add ebp,eax ; +X
  874.    @@:
  875.      add ebp,[LFBAddress]  ; +LFB
  876.  
  877.      ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
  878.  
  879.      call calculate_edi
  880.  
  881.  
  882.    dp3:                             ; MAIN LOOP
  883.  
  884.      cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1)
  885. ;     je  ybgp
  886. ;
  887. ;     jmp nbgp
  888. ;
  889. ;   ybgp:
  890.      jne nbgp
  891.  
  892.      push eax
  893.      push ebx
  894.  
  895.      mov ecx,dword [WinMapAddress-8]    ; B
  896.      xor edx,edx                   ; edx:=0
  897.      div ecx                       ; Xstart/B
  898.  
  899.      ; eax=Int(qn) edx:=Rem
  900.  
  901.      lea esi,[edx+edx*2]           ; esi:=edx*3
  902.  
  903.      mov ecx,dword [WinMapAddress-4]    ; ecx:=H
  904.      mov eax,[esp+0]               ; eax:=Ystart
  905.      xor edx,edx                   ;
  906.      div ecx                       ; Ystart/H
  907.  
  908.      mov eax,edx                   ; eax:=Rem
  909.      xor edx,edx                   ;
  910.      mov ebx,[esp+8]               ; ebx:=B*3
  911.      mul ebx                       ;
  912.      add esi,eax                   ;
  913.      mov eax,[esi+0x300000]
  914.      and eax,0xffffff
  915.  
  916.      xchg edi, ebp
  917.      stosw
  918.      shr eax,16
  919.      stosb
  920.      xchg ebp, edi                 ; ebp+=3
  921.      cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
  922.      jz @f
  923.      inc ebp ; +1
  924.    @@:
  925.  
  926.      pop ebx
  927.      pop eax
  928.  
  929.      jmp hook1
  930.  
  931.    nbgp:
  932.      add ebp,3                     ; +3
  933.      cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
  934.      jz  @f
  935.      inc ebp ; +1
  936.    @@:
  937.  
  938.    hook1:
  939.  
  940.      inc edi                       ; ptrBuffer++
  941.      add esi,3                     ; ptrImage+=3
  942.      inc eax
  943.      cmp eax,[draw_data+32+8]         ; X > xend?
  944. ;     jg nodp3
  945. ;     jmp dp3
  946. ;
  947. ;   nodp3:
  948.      jle dp3
  949.  
  950.      mov ebp,[draw_data+32+0]
  951.  
  952.      inc ebx
  953.  
  954.      mov  eax,[BytesPerScanLine]
  955.      mul  ebx
  956.      xchg ebp, eax                 ; BytesPerScanLine*(Ywin+y)
  957.      add  ebp, eax                 ; +X
  958.      add  ebp, eax                 ; +X=X*2
  959.      add  ebp, eax                 ; +X=X*3
  960.      cmp  [ScreenBPP],byte 24      ; 24 or 32 bpp ? - x size
  961.      jz   @f
  962.      add  ebp,eax                  ; +X=X*4
  963.    @@:
  964.      add ebp,[LFBAddress]          ; +LFB
  965.  
  966.      ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
  967.  
  968.      call calculate_edi
  969.  
  970.      cmp ebx,[draw_data+32+12]
  971. ;     jg  dp4
  972. ;
  973. ;     jmp dp3
  974. ;
  975. ;   dp4:
  976.      jle dp3
  977.  
  978.      add esp,4
  979.  
  980.      pop edx
  981.      pop ecx
  982.      pop ebx
  983.      pop eax
  984.      pop ebp
  985.  
  986.      ret
  987.  
  988. ; ----------
  989.  
  990.  
  991. vesa20_drawbackground_stretch:
  992.  
  993.      call  [disable_mouse]
  994.  
  995.      push ebp
  996.      push eax
  997.      push ebx
  998.      push ecx
  999.      push edx
  1000.  
  1001.      mov edx,dword [WinMapAddress-8] ; B
  1002.      add edx,dword [WinMapAddress-8] ; +B
  1003.      add edx,dword [WinMapAddress-8] ; +B
  1004.      push edx
  1005.  
  1006.      mov ebp,[draw_data+32+0] ; x start:=(x+Xwin)
  1007.      mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
  1008.  
  1009.      mov eax,[BytesPerScanLine]
  1010.      mul ebx
  1011.      xchg ebp, eax  ; BytesPerScanLine*(Ywin+y)
  1012.      add ebp, eax   ; +X
  1013.      add ebp, eax   ; +X
  1014.      add ebp, eax   ; +X
  1015.  
  1016.      cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
  1017.      jz  @f
  1018.      add ebp,eax ; +X
  1019.    @@:
  1020.      add ebp,[LFBAddress] ; +LFB
  1021.  
  1022.      ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
  1023.  
  1024.      call calculate_edi
  1025.  
  1026.  
  1027.    sdp3:                            ; MAIN LOOP
  1028.  
  1029.      cmp [edi+WinMapAddress],byte 1     ; ptrBuffer^<>byte(1)
  1030.      jne snbgp
  1031.  
  1032.      push eax
  1033.      push ebx
  1034.  
  1035.      mov   eax,dword [WinMapAddress-8]
  1036.      imul  eax, [esp+4]      ;4
  1037.      xor   edx,edx
  1038.      mov   ebx,[ScreenWidth]
  1039.      div   ebx
  1040.      lea   esi,[eax+eax*2]
  1041.      mov   eax,dword [WinMapAddress-4]
  1042.      imul  eax, [esp+0]      ;0
  1043.      xor   edx,edx
  1044.      mov   ebx,[ScreenHeight]
  1045.      div   ebx
  1046.      imul  eax, [esp+8]      ;8
  1047.      add   esi,eax
  1048.  
  1049.      mov   eax,[esi+0x300000]
  1050.      and   eax,0xffffff
  1051.  
  1052.      xchg edi, ebp
  1053.      stosw
  1054.      shr eax,16
  1055.      stosb
  1056.      xchg ebp, edi                 ; ebp+=3
  1057.      cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
  1058.      jz  @f
  1059.      inc ebp ; +1
  1060.    @@:
  1061.  
  1062.      pop ebx
  1063.      pop eax
  1064.  
  1065.      jmp shook1
  1066.  
  1067.    snbgp:
  1068.      add  ebp,3                     ; +3
  1069.      cmp [ScreenBPP],byte 24        ; 24 or 32 bpp ? - x size
  1070.      jz  @f
  1071.      inc ebp ; +1
  1072.    @@:
  1073.  
  1074.    shook1:
  1075.  
  1076.      inc edi                       ; ptrBuffer++
  1077.      add esi,3                     ; ptrImage+=3
  1078.      inc eax
  1079.      cmp eax,[draw_data+32+8]         ; X > xend?
  1080.      jle sdp3
  1081.  
  1082.      mov ebp,[draw_data+32+0]
  1083.  
  1084.      inc ebx
  1085.  
  1086.      mov  eax,[BytesPerScanLine]
  1087.      mul  ebx
  1088.      xchg ebp, eax                 ; BytesPerScanLine*(Ywin+y)
  1089.      add  ebp, eax                 ; +X
  1090.      add  ebp, eax                 ; +X=X*2
  1091.      add  ebp, eax                 ; +X=X*3
  1092.      cmp  [ScreenBPP],byte 24      ; 24 or 32 bpp ? - x size
  1093.      jz   @f
  1094.      add  ebp,eax                  ; +X=X*4
  1095.    @@:
  1096.      add ebp,[LFBAddress]          ; +LFB
  1097.  
  1098.      ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
  1099.  
  1100.      call calculate_edi
  1101.  
  1102.      cmp ebx,[draw_data+32+12]
  1103.      jle sdp3
  1104.  
  1105.      add esp,4
  1106.  
  1107.      pop edx
  1108.      pop ecx
  1109.      pop ebx
  1110.      pop eax
  1111.      pop ebp
  1112.  
  1113.      ret
  1114.