Subversion Repositories Kolibri OS

Rev

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