Subversion Repositories Kolibri OS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;  VESA12.INC                                                  ;;
  7. ;;                                                              ;;
  8. ;;  Vesa 1.2 functions for MenuetOS                             ;;
  9. ;;                                                              ;;
  10. ;;  Copyright 2002 Ville Turjanmaa                              ;;
  11. ;;                                                              ;;
  12. ;;  quickcode@mail.ru - bankswitch for S3 cards                 ;;
  13. ;;                                                              ;;
  14. ;;  See file COPYING for details                                ;;
  15. ;;                                                              ;;
  16. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17.  
  18. $Revision: 9679 $
  19.  
  20.  
  21. TRIDENT       = 0
  22. S3_VIDEO      = 0
  23. INTEL_VIDEO   = 0
  24.  
  25. if TRIDENT
  26.   if S3_VIDEO or INTEL_VIDEO
  27.     stop
  28.   end if
  29. end if
  30.  
  31. if S3_VIDEO
  32.   if TRIDENT or INTEL_VIDEO
  33.     stop
  34.   end if
  35. end if
  36.  
  37. if INTEL_VIDEO
  38.   if S3_VIDEO or TRIDENT
  39.     stop
  40.   end if
  41. end if
  42.  
  43.  
  44. ; A complete video driver should include the following types of function
  45. ;
  46. ; Putpixel
  47. ; Getpixel
  48. ;
  49. ; Drawimage
  50. ; Drawbar
  51. ;
  52. ; Drawbackground
  53. ;
  54. ;
  55. ; Modifying the set_bank -function is mostly enough
  56. ; for different Vesa 1.2 setups.
  57.  
  58. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  59. ; set_bank for Trident videocards, work on Trident 9440
  60. ; modified by Mario79
  61.  
  62. if TRIDENT
  63. set_bank:
  64.         pushfd
  65.         cli
  66.         cmp     al, [BANK_RW]
  67.         je      .retsb
  68.  
  69.         mov     [BANK_RW], al
  70.         push    dx
  71.         mov     dx, 3D8h
  72.         out     dx, al
  73.         pop     dx
  74. .retsb:
  75.         popfd
  76.         ret
  77. end if
  78.  
  79. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  80. ; set_bank for S3 videocards, work on S3 ViRGE PCI (325)
  81. ; modified by kmeaw
  82.  
  83. if S3_VIDEO
  84. set_bank:
  85.         pushfd
  86.         cli
  87.         cmp     al, [BANK_RW]
  88.         je      .retsb
  89.  
  90.         mov     [BANK_RW], al
  91.         push    ax
  92.         push    dx
  93.         push    cx
  94.         mov     cl, al
  95.         mov     dx, 0x3D4
  96.         mov     al, 0x38
  97.         out     dx, al    ;CR38 Register Lock 1 ;Note: Traditionally 48h is used to
  98.                           ;unlock and 00h to lock
  99.         inc     dx
  100.         mov     al, 0x48
  101.         out     dx, al    ;3d5 -?
  102.         dec     dx
  103.         mov     al, 0x31
  104.         out     dx, al    ;CR31 Memory Configuration Register
  105. ;0  Enable Base Address Offset (CPUA BASE). Enables bank operation if set, ;disables if clear.
  106. ;4-5  Bit 16-17 of the Display Start Address. For the 801/5,928 see index 51h,
  107. ;for the 864/964 see index 69h.
  108.  
  109.         inc     dx
  110.         in      al, dx
  111.         dec     dx
  112.         mov     ah, al
  113.         mov     al, 0x31
  114.         out     dx, ax
  115.         mov     al, ah
  116.         or      al, 9
  117.         inc     dx
  118.         out     dx, al
  119.         dec     dx
  120.         mov     al, 0x35
  121.         out     dx, al  ;CR35 CRT Register Lock
  122.         inc     dx
  123.         in      al, dx
  124.         dec     dx
  125.         and     al, 0xF0
  126.         mov     ch, cl
  127.         and     ch, 0x0F
  128.         or      ch, al
  129.         mov     al, 0x35
  130.         out     dx, al
  131.         inc     dx
  132.         mov     al, ch
  133.         out     dx, ax
  134.         dec     dx
  135.         mov     al, 0x51 ;Extended System Control 2 Register
  136.         out     dx, al
  137.         inc     dx
  138.         in      al, dx
  139.         dec     dx
  140.         and     al, 0xF3
  141.         shr     cl, 2
  142.         and     cl, 0x0C
  143.         or      cl, al
  144.         mov     al, 0x51
  145.         out     dx, al
  146.         inc     dx
  147.         mov     al, cl
  148.         out     dx, al
  149.         dec     dx
  150.         mov     al, 0x38
  151.         out     dx, al
  152.         inc     dx
  153.         xor     al, al
  154.         out     dx, al
  155.         dec     dx
  156.         pop     cx
  157.         pop     dx
  158.         pop     ax
  159. .retsb:
  160.         popfd
  161.         ret
  162. end if
  163.  
  164. ;Set bank function for Intel 810/815 chipsets
  165. ; *****Modified by Protopopius, Russia.*****
  166. ; ********* http://menuetos.hut.ru **************
  167. ; ************************************************
  168.  
  169. if INTEL_VIDEO
  170.  
  171. set_bank:
  172.         pushfd
  173.         cli
  174.  
  175.         cmp     al, [BANK_RW]
  176.         je      .retsb
  177.  
  178.         mov     [BANK_RW], al
  179.         push    ax
  180.         push    dx
  181.         mov     dx, 3CEh
  182.         mov     ah, al          ; Save value for later use
  183.         mov     al, 10h         ; Index GR10 (Address Mapping)
  184.         out     dx, al          ; Select GR10
  185.         inc     dl
  186.         mov     al, 3           ; Set bits 0 and 1 (Enable linear page mapping)
  187.         out     dx, al          ; Write value
  188.         dec     dl
  189.         mov     al, 11h         ; Index GR11 (Page Selector)
  190.         out     dx, al          ; Select GR11
  191.         inc     dl
  192.         mov     al, ah          ; Write address
  193.         out     dx, al          ; Write the value
  194.         pop     dx
  195.         pop     ax
  196. .retsb:
  197.         popfd
  198.         ret
  199. end if
  200.  
  201. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  202.  
  203. if (TRIDENT or S3_VIDEO or INTEL_VIDEO)
  204. else
  205. set_bank:
  206.         pushfd
  207.         cli
  208.  
  209.         cmp     al, [BANK_RW]
  210.         je      .retsb
  211.  
  212.         mov     [BANK_RW], al
  213.         push    ax
  214.         push    dx
  215.         mov     ah, al
  216.         mov     dx, 0x03D4
  217.         mov     al, 0x39
  218.         out     dx, al
  219.         inc     dl
  220.         mov     al, 0xA5
  221.         out     dx, al
  222.         dec     dl
  223.         mov     al, 6Ah
  224.         out     dx, al
  225.         inc     dl
  226.         mov     al, ah
  227.         out     dx, al
  228.         dec     dl
  229.         mov     al, 0x39
  230.         out     dx, al
  231.         inc     dl
  232.         mov     al, 0x5A
  233.         out     dx, al
  234.         dec     dl
  235.         pop     dx
  236.         pop     ax
  237.  
  238. .retsb:
  239.         popfd
  240.         ret
  241. end if
  242.  
  243. vesa12_drawbackground:
  244.  
  245.         call    [_display.disable_mouse]
  246.  
  247.         push    eax
  248.         push    ebx
  249.         push    ecx
  250.         push    edx
  251.  
  252.         xor     edx, edx
  253.         mov     eax, dword[BgrDataWidth]
  254.         mov     ebx, dword[BgrDataHeight]
  255.         mul     ebx
  256.         mov     ebx, 3
  257.         mul     ebx
  258.         mov     [imax], eax
  259.         mov     eax, [draw_data+32+RECT.left]
  260.         mov     ebx, [draw_data+32+RECT.top]
  261.         xor     edi, edi;no force
  262.  
  263.       v12dp3:
  264.  
  265.         push    eax
  266.         push    ebx
  267.  
  268.         cmp     [BgrDrawMode], dword 1  ; tiled background
  269.         jne     no_vesa12_tiled_bgr
  270.  
  271.         push    edx
  272.  
  273.         xor     edx, edx
  274.         div     dword [BgrDataWidth]
  275.  
  276.         push    edx
  277.         mov     eax, ebx
  278.         xor     edx, edx
  279.         div     dword [BgrDataHeight]
  280.         mov     ebx, edx
  281.         pop     eax
  282.  
  283.         pop     edx
  284.  
  285.       no_vesa12_tiled_bgr:
  286.  
  287.         cmp     [BgrDrawMode], dword 2  ; stretched background
  288.         jne     no_vesa12_stretched_bgr
  289.  
  290.         push    edx
  291.  
  292.         mul     dword [BgrDataWidth]
  293.         mov     ecx, [Screen_Max_X]
  294.         inc     ecx
  295.         div     ecx
  296.  
  297.         push    eax
  298.         mov     eax, ebx
  299.         mul     dword [BgrDataHeight]
  300.         mov     ecx, [Screen_Max_Y]
  301.         inc     ecx
  302.         div     ecx
  303.         mov     ebx, eax
  304.         pop     eax
  305.  
  306.         pop     edx
  307.  
  308.       no_vesa12_stretched_bgr:
  309.  
  310.  
  311.         mov     esi, ebx
  312.         imul    esi, dword [BgrDataWidth]
  313.         add     esi, eax
  314.         lea     esi, [esi*3]
  315.         add     esi, [img_background];IMG_BACKGROUND
  316.         pop     ebx
  317.         pop     eax
  318.  
  319.       v12di4:
  320.  
  321.         mov     cl, [esi+2]
  322.         shl     ecx, 16
  323.         mov     cx, [esi]
  324.         pusha
  325.         mov     esi, eax
  326.         mov     edi, ebx
  327.         mov     eax, [Screen_Max_X]
  328.         add     eax, 1
  329.         mul     ebx
  330.         add     eax, [_WinMapAddress]
  331.         cmp     [eax+esi], byte 1
  332.         jnz     v12nbgp
  333.         mov     eax, [BytesPerScanLine]
  334.         mov     ebx, edi
  335.         mul     ebx
  336.         add     eax, esi
  337.         lea     eax, [VGABasePtr+eax+esi*2]
  338.         cmp     [ScreenBPP], byte 24
  339.         jz      v12bgl3
  340.         add     eax, esi
  341.  
  342.       v12bgl3:
  343.  
  344.         push    ebx
  345.         push    eax
  346.  
  347.         sub     eax, VGABasePtr
  348.  
  349.         shr     eax, 16
  350.         call    set_bank
  351.         pop     eax
  352.         and     eax, 65535
  353.         add     eax, VGABasePtr
  354.         pop     ebx
  355.  
  356.         mov     [eax], cx
  357.         add     eax, 2
  358.         shr     ecx, 16
  359.         mov     [eax], cl
  360.         sti
  361.  
  362.       v12nbgp:
  363.  
  364.         popa
  365.         add     esi, 3
  366.         inc     eax
  367.         cmp     eax, [draw_data+32+RECT.right]
  368.         jg      v12nodp31
  369.         jmp     v12dp3
  370.  
  371.       v12nodp31:
  372.  
  373.         mov     eax, [draw_data+32+RECT.left]
  374.         inc     ebx
  375.         cmp     ebx, [draw_data+32+RECT.bottom]
  376.         jg      v12dp4
  377.         jmp     v12dp3
  378.  
  379.       v12dp4:
  380.  
  381.         pop     edx
  382.         pop     ecx
  383.         pop     ebx
  384.         pop     eax
  385.         ret
  386.  
  387.  
  388. vesa12_drawbar:
  389.  
  390.         call    [_display.disable_mouse]
  391.  
  392. ;;    mov  [novesachecksum],dword 0
  393.         sub     edx, ebx
  394.         sub     ecx, eax
  395.         push    esi
  396.         push    edi
  397.         push    eax
  398.         push    ebx
  399.         push    ecx
  400.         push    edx
  401.         ;mov     ecx, [TASK_BASE]
  402.         ;add     eax, [ecx-twdw+WDATA.box.left]
  403.         ;add     ebx, [ecx-twdw+WDATA.box.top]
  404.         mov     ecx, [current_slot_idx]
  405.         shl     ecx, 5
  406.         add     eax, [ecx + window_data + WDATA.box.left]
  407.         add     ebx, [ecx + window_data + WDATA.box.top]
  408.         push    eax
  409.         mov     eax, ebx ; y
  410.         mov     ebx, [BytesPerScanLine]
  411.         mul     ebx
  412.         pop     ecx
  413.         add     eax, ecx ; x
  414.         add     eax, ecx
  415.         add     eax, ecx
  416.         cmp     [ScreenBPP], byte 24; 24 or 32 bpp ? - x start
  417.         jz      dbpi2412
  418.         add     eax, ecx
  419.  
  420.   dbpi2412:
  421.  
  422.         add     eax, VGABasePtr
  423.         mov     edi, eax
  424.  
  425.     ; x size
  426.  
  427.         mov     eax, [esp+4]; [esp+6]
  428.         mov     ecx, eax
  429.         add     ecx, eax
  430.         add     ecx, eax
  431.         cmp     [ScreenBPP], byte 24; 24 or 32 bpp ? - x size
  432.         jz      dbpi24312
  433.         add     ecx, eax
  434.  
  435.   dbpi24312:
  436.  
  437.         mov     ebx, [esp+0]
  438.  
  439.     ; check limits ?
  440.  
  441.         push    eax
  442.         push    ecx
  443.         mov     eax, [TASK_BASE]
  444.         mov     ecx, [eax+draw_data-CURRENT_TASK+RECT.left]
  445.         cmp     ecx, 0
  446.         jnz     dbcblimitlset12
  447.         mov     ecx, [eax+draw_data-CURRENT_TASK+RECT.top]
  448.         cmp     ecx, 0
  449.         jnz     dbcblimitlset12
  450.         mov     ecx, [eax+draw_data-CURRENT_TASK+RECT.right]
  451.         cmp     ecx, [Screen_Max_X]
  452.         jnz     dbcblimitlset12
  453.         mov     ecx, [eax+draw_data-CURRENT_TASK+RECT.bottom]
  454.         cmp     ecx, [Screen_Max_Y]
  455.         jnz     dbcblimitlset12
  456.         pop     ecx
  457.         pop     eax
  458.         push    dword 0
  459.         jmp     dbcblimitlno12
  460.  
  461.   dbcblimitlset12:
  462.  
  463.         pop     ecx
  464.         pop     eax
  465.         push    dword 1
  466.  
  467.   dbcblimitlno12:
  468.  
  469.         cmp     [ScreenBPP], byte 24; 24 or 32 bpp ?
  470.         jz      dbpi24bit12
  471.         jmp     dbpi32bit12
  472.  
  473.  
  474. ; DRAWBAR 24 BBP
  475.  
  476.  
  477. dbpi24bit12:
  478.  
  479.         push    eax
  480.         push    ebx
  481.         push    edx
  482.         mov     eax, ecx
  483.         mov     ebx, 3
  484.         div     ebx
  485.         mov     ecx, eax
  486.         pop     edx
  487.         pop     ebx
  488.         pop     eax
  489.         cld
  490.  
  491.   dbnewpi12:
  492.  
  493.         push    ebx
  494.         push    edi
  495.         push    ecx
  496.  
  497.         xor     edx, edx
  498.         mov     eax, edi
  499.         sub     eax, VGABasePtr
  500.         mov     ebx, 3
  501.         div     ebx
  502.         add     eax, [_WinMapAddress]
  503.         mov     ebx, [CURRENT_TASK]
  504.         cld
  505.  
  506.       dbnp2412:
  507.  
  508.         mov     dl, [eax]
  509.         push    eax
  510.         push    ecx
  511.         cmp     dl, bl
  512.         jnz     dbimp24no12
  513.         cmp     [esp+5*4], dword 0
  514.         jz      dbimp24yes12
  515. ;        call dbcplimit
  516. ;        jnz  dbimp24no12
  517.  
  518.      dbimp24yes12:
  519.  
  520.         push    edi
  521.         mov     eax, edi
  522.         sub     eax, VGABasePtr
  523.         shr     eax, 16
  524.         call    set_bank
  525.         and     edi, 0xffff
  526.         add     edi, VGABasePtr
  527.         mov     eax, [esp+8+3*4+16+4+4]
  528.         stosw
  529.         shr     eax, 16
  530.         stosb
  531.         sti
  532.         pop     edi
  533.         add     edi, 3
  534.         pop     ecx
  535.         pop     eax
  536.         inc     eax
  537.         loop    dbnp2412
  538.         jmp     dbnp24d12
  539.  
  540.       dbimp24no12:
  541.  
  542.         pop     ecx
  543.         pop     eax
  544.         cld
  545.         add     edi, 3
  546.         inc     eax
  547.         loop    dbnp2412
  548.  
  549.       dbnp24d12:
  550.  
  551.         mov     eax, [esp+3*4+16+4]
  552.         test    eax, 0x80000000
  553.         jz      nodbgl2412
  554.         cmp     al, 0
  555.         jz      nodbgl2412
  556.         dec     eax
  557.         mov     [esp+3*4+16+4], eax
  558.  
  559.       nodbgl2412:
  560.  
  561.         pop     ecx
  562.         pop     edi
  563.         pop     ebx
  564.         add     edi, [BytesPerScanLine]
  565.         dec     ebx
  566.         jz      dbnonewpi12
  567.         jmp     dbnewpi12
  568.  
  569.   dbnonewpi12:
  570.  
  571.         add     esp, 7*4
  572.  
  573.         ret
  574.  
  575.  
  576. ; DRAWBAR 32 BBP
  577.  
  578.  
  579.   dbpi32bit12:
  580.  
  581.         cld
  582.         shr     ecx, 2
  583.  
  584.    dbnewpi3212:
  585.  
  586.         push    ebx
  587.         push    edi
  588.         push    ecx
  589.  
  590.         mov     eax, edi
  591.         sub     eax, VGABasePtr
  592.         shr     eax, 2
  593.         add     eax, [_WinMapAddress]
  594.         mov     ebx, [CURRENT_TASK]
  595.         cld
  596.  
  597.       dbnp3212:
  598.  
  599.         mov     dl, [eax]
  600.         push    eax
  601.         push    ecx
  602.         cmp     dl, bl
  603.         jnz     dbimp32no12
  604.         cmp     [esp+5*4], dword 0
  605.         jz      dbimp32yes12
  606. ;        call dbcplimit
  607. ;        jnz  dbimp32no12
  608.  
  609.       dbimp32yes12:
  610.  
  611.         push    edi
  612.         mov     eax, edi
  613.         sub     eax, VGABasePtr
  614.         shr     eax, 16
  615.         call    set_bank
  616.         and     edi, 0xffff
  617.         add     edi, VGABasePtr
  618.         mov     eax, [esp+8+3*4+16+4+4]
  619.         stosw
  620.         shr     eax, 16
  621.         stosb
  622.         sti
  623.         pop     edi
  624.         add     edi, 4
  625.         inc     ebp
  626.         pop     ecx
  627.         pop     eax
  628.         inc     eax
  629.         loop    dbnp3212
  630.         jmp     dbnp32d12
  631.  
  632.       dbimp32no12:
  633.  
  634.         pop     ecx
  635.         pop     eax
  636.         inc     eax
  637.         add     edi, 4
  638.         inc     ebp
  639.         loop    dbnp3212
  640.  
  641.       dbnp32d12:
  642.  
  643.         mov     eax, [esp+12+16+4]
  644.         test    eax, 0x80000000
  645.         jz      nodbgl3212
  646.         cmp     al, 0
  647.         jz      nodbgl3212
  648.         dec     eax
  649.         mov     [esp+12+16+4], eax
  650.  
  651.       nodbgl3212:
  652.  
  653.         pop     ecx
  654.         pop     edi
  655.         pop     ebx
  656.         add     edi, [BytesPerScanLine]
  657.         dec     ebx
  658.         jz      nodbnewpi3212
  659.         jmp     dbnewpi3212
  660.  
  661.   nodbnewpi3212:
  662.  
  663.         add     esp, 7*4
  664.         ret
  665.  
  666.  
  667. Vesa12_putpixel24:
  668.  
  669.         mov     edi, eax; x
  670.         mov     eax, ebx; y
  671.         lea     edi, [edi+edi*2]
  672.         mov     ebx, [BytesPerScanLine]
  673.         mul     ebx
  674.         add     edi, eax
  675.         mov     eax, edi
  676.         shr     eax, 16
  677.         call    set_bank
  678.         and     edi, 65535
  679.         add     edi, VGABasePtr
  680.         mov     eax, [esp+28]
  681.         stosw
  682.         shr     eax, 16
  683.         mov     [edi], al
  684.         sti
  685.         ret
  686.  
  687.  
  688.  
  689. Vesa12_putpixel32:
  690.  
  691.         mov     edi, eax; x
  692.         mov     eax, ebx; y
  693.         shl     edi, 2
  694.         mov     ebx, [BytesPerScanLine]
  695.         mul     ebx
  696.         add     edi, eax
  697.         mov     eax, edi
  698.         shr     eax, 16
  699.         call    set_bank
  700.         and     edi, 65535
  701.         add     edi, VGABasePtr
  702.         mov     ecx, [esp+28]
  703.         mov     [edi], ecx
  704.         sti
  705.         ret
  706.  
  707.  
  708. Vesa12_getpixel24:
  709.  
  710.         mov     edi, eax; x
  711.         mov     eax, ebx; y
  712.         lea     edi, [edi+edi*2]
  713.         mov     ebx, [BytesPerScanLine]
  714.         mul     ebx
  715.         add     edi, eax
  716.         mov     eax, edi
  717.         shr     eax, 16
  718.         call    set_bank
  719.         and     edi, 65535
  720.         add     edi, VGABasePtr
  721.         mov     ecx, [edi]
  722.         and     ecx, 255*256*256+255*256+255
  723.         sti
  724.         ret
  725.  
  726.  
  727. Vesa12_getpixel32:
  728.  
  729.         mov     edi, eax; x
  730.         mov     eax, ebx; y
  731.         shl     edi, 2
  732.         mov     ebx, [BytesPerScanLine]
  733.         xor     edx, edx
  734.         mul     ebx
  735.         add     edi, eax
  736.         mov     eax, edi
  737.         shr     eax, 16
  738.         call    set_bank
  739.         and     edi, 65535
  740.         add     edi, VGABasePtr
  741.         mov     ecx, [edi]
  742.         and     ecx, 255*256*256+255*256+255
  743.         sti
  744.  
  745.         ret
  746.  
  747.  
  748.  
  749. vesa12_putimage:
  750. ; ebx = pointer to image
  751. ; ecx = size [x|y]
  752. ; edx = coordinates [x|y]
  753. ; ebp = pointer to 'get' function
  754. ; esi = pointer to 'init' function
  755. ; edi = parameter for 'get' function
  756.  
  757. ;    mov  ebx,image
  758. ;    mov  ecx,320*65536+240
  759. ;    mov  edx,20*65536+20
  760.  
  761.         call    [_display.disable_mouse]
  762.  
  763.         mov     [novesachecksum], dword 0
  764.         push    esi
  765.         push    edi
  766.         push    eax
  767.         push    ebx
  768.         push    ecx
  769.         push    edx
  770.         movzx   eax, word [esp+2]
  771.         movzx   ebx, word [esp+0]
  772.         ;mov     ecx, [TASK_BASE]
  773.         ;add     eax, [ecx-twdw+WDATA.box.left]
  774.         ;add     ebx, [ecx-twdw+WDATA.box.top]
  775.         mov     ecx, [current_slot_idx]
  776.         shl     ecx, 5
  777.         add     eax, [ecx + window_data + WDATA.box.left]
  778.         add     ebx, [ecx + window_data + WDATA.box.top]
  779.         push    eax
  780.         mov     eax, ebx  ; y
  781.         mul     dword [BytesPerScanLine]
  782.         pop     ecx
  783.         add     eax, ecx  ; x
  784.         add     eax, ecx
  785.         add     eax, ecx
  786.         cmp     [ScreenBPP], byte 24; 24 or 32 bpp ? - x start
  787.         jz      pi2412
  788.         add     eax, ecx
  789.  
  790.   pi2412:
  791.  
  792.         add     eax, VGABasePtr
  793.         mov     edi, eax
  794.  
  795.     ; x size
  796.  
  797.         movzx   ecx, word [esp+6]
  798.  
  799.         mov     esi, [esp+8]
  800.         movzx   ebx, word [esp+4]
  801.  
  802.     ; check limits while draw ?
  803.  
  804.         push    ecx
  805.         mov     eax, [TASK_BASE]
  806.         cmp     dword [eax+draw_data-CURRENT_TASK+RECT.left], 0
  807.         jnz     dbcblimitlset212
  808.         cmp     dword [eax+draw_data-CURRENT_TASK+RECT.top], 0
  809.         jnz     dbcblimitlset212
  810.         mov     ecx, [eax+draw_data-CURRENT_TASK+RECT.right]
  811.         cmp     ecx, [Screen_Max_X]
  812.         jnz     dbcblimitlset212
  813.         mov     ecx, [eax+draw_data-CURRENT_TASK+RECT.bottom]
  814.         cmp     ecx, [Screen_Max_Y]
  815.         jnz     dbcblimitlset212
  816.         pop     ecx
  817.         push    0
  818.         jmp     dbcblimitlno212
  819.  
  820.   dbcblimitlset212:
  821.  
  822.         pop     ecx
  823.         push    1
  824.  
  825.   dbcblimitlno212:
  826.  
  827.         cmp     [ScreenBPP], byte 24; 24 or 32 bpp ?
  828.         jnz     pi32bit12
  829.  
  830.   pi24bit12:
  831.  
  832.   newpi12:
  833.  
  834.         push    edi
  835.         push    ecx
  836.         push    ebx
  837.  
  838.         mov     edx, edi
  839.         sub     edx, VGABasePtr
  840.         mov     ebx, 3
  841.         div     ebx
  842.         add     edx, [_WinMapAddress]
  843.         mov     ebx, [CURRENT_TASK]
  844.         mov     bh, [esp+4*3]
  845.  
  846.       np2412:
  847.  
  848.         cmp     bl, [edx]
  849.         jnz     imp24no12
  850. ;        mov  eax,[esi]
  851.         push    dword [esp+4*3+20]
  852.         call    ebp
  853. ;        cmp  bh,0
  854. ;        jz   imp24yes12
  855. ;        call dbcplimit
  856. ;        jnz  imp24no12
  857.  
  858.      imp24yes12:
  859.  
  860.         push    edi
  861.         push    eax
  862.         mov     eax, edi
  863.         sub     eax, VGABasePtr
  864.         shr     eax, 16
  865.         call    set_bank
  866.         pop     eax
  867.         and     edi, 0xffff
  868.         add     edi, VGABasePtr
  869.         mov     [edi], ax
  870.         shr     eax, 16
  871.         mov     [edi+2], al
  872.         pop     edi
  873.  
  874.      imp24no12:
  875.  
  876.         inc     edx
  877. ;        add  esi,3
  878.         add     edi, 3
  879.         dec     ecx
  880.         jnz     np2412
  881.  
  882.       np24d12:
  883.  
  884.         pop     ebx
  885.         pop     ecx
  886.         pop     edi
  887.  
  888.         add     edi, [BytesPerScanLine]
  889.         add     esi, [esp+32]
  890.         cmp     ebp, putimage_get1bpp
  891.         jz      .correct
  892.         cmp     ebp, putimage_get2bpp
  893.         jz      .correct
  894.         cmp     ebp, putimage_get4bpp
  895.         jnz     @f
  896. .correct:
  897.         mov     eax, [esp+20]
  898.         mov     byte[eax], 80h
  899. @@:
  900.         dec     ebx
  901.         jnz     newpi12
  902.  
  903.   nonewpi12:
  904.  
  905.         pop     eax edx ecx ebx eax edi esi
  906.         xor     eax, eax
  907.         ret
  908.  
  909.  
  910.   pi32bit12:
  911.  
  912.    newpi3212:
  913.  
  914.         push    edi
  915.         push    ecx
  916.         push    ebx
  917.  
  918.         mov     edx, edi
  919.         sub     edx, VGABasePtr
  920.         shr     edx, 2
  921.         add     edx, [_WinMapAddress]
  922.         mov     ebx, [CURRENT_TASK]
  923.         mov     bh, [esp+4*3]
  924.  
  925.       np3212:
  926.  
  927.         cmp     bl, [edx]
  928.         jnz     imp32no12
  929. ;        mov  eax,[esi]
  930.         push    dword [esp+4*3+20]
  931.         call    ebp
  932. ;        cmp  bh,0
  933. ;        jz   imp32yes12
  934. ;        call dbcplimit
  935. ;        jnz  imp32no12
  936.  
  937.       imp32yes12:
  938.  
  939.         push    edi
  940.         push    eax
  941.         mov     eax, edi
  942.         sub     eax, VGABasePtr
  943.         shr     eax, 16
  944.         call    set_bank
  945.         pop     eax
  946.         and     edi, 0xffff
  947.         mov     [edi+VGABasePtr], eax
  948.         pop     edi
  949.  
  950.       imp32no12:
  951.  
  952.         inc     edx
  953. ;        add  esi,3
  954.         add     edi, 4
  955.         dec     ecx
  956.         jnz     np3212
  957.  
  958.       np32d12:
  959.  
  960.         pop     ebx
  961.         pop     ecx
  962.         pop     edi
  963.  
  964.         add     edi, [BytesPerScanLine]
  965.         cmp     ebp, putimage_get1bpp
  966.         jz      .correct
  967.         cmp     ebp, putimage_get2bpp
  968.         jz      .correct
  969.         cmp     ebp, putimage_get4bpp
  970.         jnz     @f
  971. .correct:
  972.         mov     eax, [esp+20]
  973.         mov     byte[eax], 80h
  974. @@:
  975.         dec     ebx
  976.         jnz     newpi3212
  977.  
  978.   nonewpi3212:
  979.  
  980.         pop     eax edx ecx ebx eax edi esi
  981.         xor     eax, eax
  982.         ret
  983.  
  984.  
  985. vesa12_read_screen_pixel:
  986.  
  987.         and     eax, 0x3FFFFF
  988.         cmp     [ScreenBPP], byte 24; 24 or 32 bpp ?
  989.         jz      v12rsp24
  990.         mov     edi, eax
  991.         shl     edi, 2
  992.         mov     eax, edi
  993.         shr     eax, 16
  994.         call    set_bank
  995.         and     edi, 65535
  996.         add     edi, VGABasePtr
  997.         mov     eax, [edi]
  998.         and     eax, 0x00ffffff
  999.         ret
  1000.   v12rsp24:
  1001.  
  1002.         imul    eax, 3
  1003.         mov     edi, eax
  1004.         shr     eax, 16
  1005.         call    set_bank
  1006.         and     edi, 65535
  1007.         add     edi, VGABasePtr
  1008.         mov     eax, [edi]
  1009.         and     eax, 0x00ffffff
  1010.         ret
  1011.  
  1012.  
  1013.