Subversion Repositories Kolibri OS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2007. 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: 928 $
  19.  
  20.  
  21. TRIDENT       equ 0
  22. S3_VIDEO      equ 0
  23. INTEL_VIDEO   equ 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, byte [bank_rw]
  67.            je .retsb
  68.  
  69.            mov byte [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, byte [bank_rw]
  88.            je .retsb
  89.  
  90.            mov byte [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, byte [bank_rw]
  176.            je .retsb
  177.  
  178.            mov byte [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, byte [bank_rw]
  210.            je .retsb
  211.  
  212.            mov byte [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  [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.         mov   edi,0 ;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.         mov   ebx, [_display_data]
  331.         add   ebx, esi
  332.         cmp   [eax+ebx],byte 1
  333.         jnz   v12nbgp
  334.         mov   eax,[BytesPerScanLine]
  335.         mov   ebx,edi
  336.         mul   ebx
  337.         add   eax, esi
  338.         lea   eax, [VGABasePtr+eax+esi*2]
  339.         cmp   byte [ScreenBPP], 24
  340.         jz    v12bgl3
  341.         add   eax,esi
  342.  
  343.       v12bgl3:
  344.  
  345.         push ebx
  346.         push eax
  347.  
  348.         sub  eax,VGABasePtr
  349.  
  350.         shr  eax,16
  351.         call set_bank
  352.         pop  eax
  353.         and  eax,65535
  354.         add  eax,VGABasePtr
  355.         pop  ebx
  356.  
  357.         mov   [eax],cx
  358.         add   eax,2
  359.         shr   ecx,16
  360.         mov   [eax],cl
  361.         sti
  362.  
  363.       v12nbgp:
  364.  
  365.         popa
  366.         add   esi,3
  367.         inc   eax
  368.         cmp   eax,[draw_data+32+RECT.right]
  369.         jg    v12nodp31
  370.         jmp   v12dp3
  371.  
  372.       v12nodp31:
  373.  
  374.         mov   eax,[draw_data+32+RECT.left]
  375.         inc   ebx
  376.         cmp   ebx,[draw_data+32+RECT.bottom]
  377.         jg    v12dp4
  378.         jmp   v12dp3
  379.  
  380.       v12dp4:
  381.  
  382.         pop   edx
  383.         pop   ecx
  384.         pop   ebx
  385.         pop   eax
  386.         ret
  387.  
  388.  
  389. vesa12_drawbar:
  390.  
  391.     call  [disable_mouse]
  392.  
  393. ;;    mov  [novesachecksum],dword 0
  394.     sub  edx,ebx
  395.     sub  ecx,eax
  396.     push esi
  397.     push edi
  398.     push eax
  399.     push ebx
  400.     push ecx
  401.     push edx
  402.     mov  ecx,[TASK_BASE]
  403.     add  eax,[ecx-twdw+WDATA.box.left]
  404.     add  ebx,[ecx-twdw+WDATA.box.top]
  405.     push eax
  406.     mov  eax,ebx         ; y
  407.     mov  ebx,[BytesPerScanLine]
  408.     mul  ebx
  409.     pop  ecx
  410.     add  eax,ecx         ; x
  411.     add  eax,ecx
  412.     add  eax,ecx
  413.     cmp  byte [ScreenBPP], 24     ; 24 or 32 bpp ? - x start
  414.     jz   dbpi2412
  415.     add  eax,ecx
  416.  
  417.   dbpi2412:
  418.  
  419.     add  eax,VGABasePtr
  420.     mov  edi,eax
  421.  
  422.     ; x size
  423.  
  424.     mov  eax,[esp+4] ; [esp+6]
  425.     mov  ecx,eax
  426.     add  ecx,eax
  427.     add  ecx,eax
  428.     cmp  byte [ScreenBPP], 24     ; 24 or 32 bpp ? - x size
  429.     jz   dbpi24312
  430.     add  ecx,eax
  431.  
  432.   dbpi24312:
  433.  
  434.     mov  ebx,[esp+0]
  435.  
  436.     ; check limits ?
  437.  
  438.     push eax
  439.     push ecx
  440.     mov  eax,[TASK_BASE]
  441.     mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.left]
  442.     cmp  ecx,0
  443.     jnz  dbcblimitlset12
  444.     mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.top]
  445.     cmp  ecx,0
  446.     jnz  dbcblimitlset12
  447.     mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.right]
  448.     cmp  ecx,[Screen_Max_X]
  449.     jnz  dbcblimitlset12
  450.     mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.bottom]
  451.     cmp  ecx,[Screen_Max_Y]
  452.     jnz  dbcblimitlset12
  453.     pop  ecx
  454.     pop  eax
  455.     push dword 0
  456.     jmp  dbcblimitlno12
  457.  
  458.   dbcblimitlset12:
  459.  
  460.     pop  ecx
  461.     pop  eax
  462.     push dword 1
  463.  
  464.   dbcblimitlno12:
  465.  
  466.     cmp  byte [ScreenBPP], 24     ; 24 or 32 bpp ?
  467.     jz   dbpi24bit12
  468.     jmp  dbpi32bit12
  469.  
  470.  
  471. ; DRAWBAR 24 BBP
  472.  
  473.  
  474. dbpi24bit12:
  475.  
  476.     push eax
  477.     push ebx
  478.     push edx
  479.     mov  eax,ecx
  480.     mov  ebx,3
  481.     div  ebx
  482.     mov  ecx,eax
  483.     pop  edx
  484.     pop  ebx
  485.     pop  eax
  486.     cld
  487.  
  488.   dbnewpi12:
  489.  
  490.     push ebx
  491.     push edi
  492.     push ecx
  493.  
  494.       xor  edx,edx
  495.       mov  eax,edi
  496.       sub  eax,VGABasePtr
  497.       mov  ebx,3
  498.       div  ebx
  499.       add  eax, [_display_data]
  500.       mov   ebx,[CURRENT_TASK]
  501.       cld
  502.  
  503.       dbnp2412:
  504.  
  505.         mov  dl,[eax]
  506.         push eax
  507.         push ecx
  508.         cmp  dl,bl
  509.         jnz  dbimp24no12
  510.         cmp  [esp+5*4],dword 0
  511.         jz   dbimp24yes12
  512. ;        call dbcplimit
  513. ;        jnz  dbimp24no12
  514.  
  515.      dbimp24yes12:
  516.  
  517.         push edi
  518.         mov  eax,edi
  519.         sub  eax,VGABasePtr
  520.         shr  eax,16
  521.         call set_bank
  522.         and  edi,0xffff
  523.         add  edi,VGABasePtr
  524.         mov  eax,[esp+8+3*4+16+4+4]
  525.         stosw
  526.         shr  eax,16
  527.         stosb
  528.         sti
  529.         pop  edi
  530.         add  edi,3
  531.         pop  ecx
  532.         pop  eax
  533.         inc  eax
  534.         loop dbnp2412
  535.         jmp  dbnp24d12
  536.  
  537.       dbimp24no12:
  538.  
  539.         pop  ecx
  540.         pop  eax
  541.         cld
  542.         add  edi,3
  543.         inc  eax
  544.         loop dbnp2412
  545.  
  546.       dbnp24d12:
  547.  
  548.         mov  eax,[esp+3*4+16+4]
  549.         test eax,0x80000000
  550.         jz   nodbgl2412
  551.         cmp  al,0
  552.         jz   nodbgl2412
  553.         dec  eax
  554.         mov  [esp+3*4+16+4],eax
  555.  
  556.       nodbgl2412:
  557.  
  558.     pop  ecx
  559.     pop  edi
  560.     pop  ebx
  561.     add  edi,[BytesPerScanLine]
  562.     dec  ebx
  563.     jz   dbnonewpi12
  564.     jmp  dbnewpi12
  565.  
  566.   dbnonewpi12:
  567.  
  568.     add  esp,7*4
  569.  
  570.     ret
  571.  
  572.  
  573. ; DRAWBAR 32 BBP
  574.  
  575.  
  576.   dbpi32bit12:
  577.  
  578.     cld
  579.     shr  ecx,2
  580.  
  581.    dbnewpi3212:
  582.  
  583.     push ebx
  584.     push edi
  585.     push ecx
  586.  
  587.       mov  eax,edi
  588.       sub  eax,VGABasePtr
  589.       shr  eax,2
  590.       add  eax, [_display_data]
  591.       mov   ebx,[CURRENT_TASK]
  592.       cld
  593.  
  594.       dbnp3212:
  595.  
  596.         mov  dl,[eax]
  597.         push eax
  598.         push ecx
  599.         cmp  dl,bl
  600.         jnz  dbimp32no12
  601.         cmp  [esp+5*4],dword 0
  602.         jz   dbimp32yes12
  603. ;        call dbcplimit
  604. ;        jnz  dbimp32no12
  605.  
  606.       dbimp32yes12:
  607.  
  608.         push edi
  609.         mov  eax,edi
  610.         sub  eax,VGABasePtr
  611.         shr  eax,16
  612.         call set_bank
  613.         and  edi,0xffff
  614.         add  edi,VGABasePtr
  615.         mov  eax,[esp+8+3*4+16+4+4]
  616.         stosw
  617.         shr  eax,16
  618.         stosb
  619.         sti
  620.         pop  edi
  621.         add  edi,4
  622.         inc  ebp
  623.         pop  ecx
  624.         pop  eax
  625.         inc  eax
  626.         loop dbnp3212
  627.         jmp  dbnp32d12
  628.  
  629.       dbimp32no12:
  630.  
  631.         pop  ecx
  632.         pop  eax
  633.         inc  eax
  634.         add  edi,4
  635.         inc  ebp
  636.         loop dbnp3212
  637.  
  638.       dbnp32d12:
  639.  
  640.         mov  eax,[esp+12+16+4]
  641.         test eax,0x80000000
  642.         jz   nodbgl3212
  643.         cmp  al,0
  644.         jz   nodbgl3212
  645.         dec  eax
  646.         mov  [esp+12+16+4],eax
  647.  
  648.       nodbgl3212:
  649.  
  650.     pop  ecx
  651.     pop  edi
  652.     pop  ebx
  653.     add  edi,[BytesPerScanLine]
  654.     dec  ebx
  655.     jz   nodbnewpi3212
  656.     jmp  dbnewpi3212
  657.  
  658.   nodbnewpi3212:
  659.  
  660.     add  esp,7*4
  661.     ret
  662.  
  663.  
  664. Vesa12_putpixel24:
  665.  
  666.         mov  edi,eax ; x
  667.         mov  eax,ebx ; y
  668.         lea  edi,[edi+edi*2]
  669.         mov  ebx,[BytesPerScanLine]
  670.         mul  ebx
  671.         add  edi,eax
  672.         mov  eax,edi
  673.         shr  eax,16
  674.         call set_bank
  675.         and  edi,65535
  676.         add  edi,VGABasePtr
  677.         mov  eax,[esp+28]
  678.         stosw
  679.         shr  eax,16
  680.         mov  [edi],al
  681.         sti
  682.         ret
  683.  
  684.  
  685.  
  686. Vesa12_putpixel32:
  687.  
  688.         mov  edi,eax ; x
  689.         mov  eax,ebx ; y
  690.         shl  edi,2
  691.         mov  ebx,[BytesPerScanLine]
  692.         mul  ebx
  693.         add  edi,eax
  694.         mov  eax,edi
  695.         shr  eax,16
  696.         call set_bank
  697.         and  edi,65535
  698.         add  edi,VGABasePtr
  699.         mov  ecx,[esp+28]
  700.         mov  [edi],ecx
  701.         sti
  702.         ret
  703.  
  704.  
  705. Vesa12_getpixel24:
  706.  
  707.         mov  edi,eax ; x
  708.         mov  eax,ebx ; y
  709.         lea  edi,[edi+edi*2]
  710.         mov  ebx,[BytesPerScanLine]
  711.         mul  ebx
  712.         add  edi,eax
  713.         mov  eax,edi
  714.         shr  eax,16
  715.         call set_bank
  716.         and  edi,65535
  717.         add  edi,VGABasePtr
  718.         mov  ecx,[edi]
  719.         and  ecx,255*256*256+255*256+255
  720.         sti
  721.         ret
  722.  
  723.  
  724. Vesa12_getpixel32:
  725.  
  726.         mov  edi,eax ; x
  727.         mov  eax,ebx ; y
  728.         shl  edi,2
  729.         mov  ebx,[BytesPerScanLine]
  730.         xor  edx,edx
  731.         mul  ebx
  732.         add  edi,eax
  733.         mov  eax,edi
  734.         shr  eax,16
  735.         call set_bank
  736.         and  edi,65535
  737.         add  edi,VGABasePtr
  738.         mov  ecx,[edi]
  739.         and  ecx,255*256*256+255*256+255
  740.         sti
  741.  
  742.         ret
  743.  
  744.  
  745.  
  746. vesa12_putimage:
  747. ; ebx = pointer to image
  748. ; ecx = size [x|y]
  749. ; edx = coordinates [x|y]
  750. ; ebp = pointer to 'get' function
  751. ; esi = pointer to 'init' function
  752. ; edi = parameter for 'get' function
  753.  
  754. ;    mov  ebx,image
  755. ;    mov  ecx,320*65536+240
  756. ;    mov  edx,20*65536+20
  757.  
  758.     call  [disable_mouse]
  759.  
  760.     mov   [novesachecksum],dword 0
  761.     push  esi
  762.     push  edi
  763.     push  eax
  764.     push  ebx
  765.     push  ecx
  766.     push  edx
  767.     movzx eax,word [esp+2]
  768.     movzx ebx,word [esp+0]
  769.     mov   ecx,[TASK_BASE]
  770.     add   eax,[ecx-twdw+WDATA.box.left]
  771.     add   ebx,[ecx-twdw+WDATA.box.top]
  772.     push  eax
  773.     mov   eax,ebx         ; y
  774.     mul   dword [BytesPerScanLine]
  775.     pop   ecx
  776.     add   eax,ecx         ; x
  777.     add   eax,ecx
  778.     add   eax,ecx
  779.     cmp  byte [ScreenBPP], 24     ; 24 or 32 bpp ? - x start
  780.     jz   pi2412
  781.     add  eax,ecx
  782.  
  783.   pi2412:
  784.  
  785.     add  eax,VGABasePtr
  786.     mov  edi,eax
  787.  
  788.     ; x size
  789.  
  790.     movzx ecx,word [esp+6]
  791.  
  792.     mov   esi,[esp+8]
  793.     movzx ebx,word [esp+4]
  794.  
  795.     ; check limits while draw ?
  796.  
  797.     push  ecx
  798.     mov  eax,[TASK_BASE]
  799.     cmp  dword [eax+draw_data-CURRENT_TASK+RECT.left], 0
  800.     jnz  dbcblimitlset212
  801.     cmp  dword [eax+draw_data-CURRENT_TASK+RECT.top], 0
  802.     jnz  dbcblimitlset212
  803.     mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.right]
  804.     cmp  ecx,[Screen_Max_X]
  805.     jnz  dbcblimitlset212
  806.     mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.bottom]
  807.     cmp  ecx,[Screen_Max_Y]
  808.     jnz  dbcblimitlset212
  809.     pop  ecx
  810.     push 0
  811.     jmp  dbcblimitlno212
  812.  
  813.   dbcblimitlset212:
  814.  
  815.     pop  ecx
  816.     push 1
  817.  
  818.   dbcblimitlno212:
  819.  
  820.     cmp  byte [ScreenBPP], 24     ; 24 or 32 bpp ?
  821.     jnz  pi32bit12
  822.  
  823.   pi24bit12:
  824.  
  825.   newpi12:
  826.  
  827.     push edi
  828.     push ecx
  829.     push ebx
  830.  
  831.       mov  edx,edi
  832.       sub  edx,VGABasePtr
  833.       mov  ebx,3
  834.       div  ebx
  835.       add  edx,[_display_data]
  836.       mov  ebx,[CURRENT_TASK]
  837.       mov  bh,[esp+4*3]
  838.  
  839.       np2412:
  840.  
  841.         cmp  bl,[edx]
  842.         jnz  imp24no12
  843. ;        mov  eax,[esi]
  844.         push    dword [esp+4*3+20]
  845.         call    ebp
  846. ;        cmp  bh,0
  847. ;        jz   imp24yes12
  848. ;        call dbcplimit
  849. ;        jnz  imp24no12
  850.  
  851.      imp24yes12:
  852.  
  853.         push edi
  854.         push eax
  855.         mov  eax,edi
  856.         sub  eax,VGABasePtr
  857.         shr  eax,16
  858.         call set_bank
  859.         pop  eax
  860.         and  edi,0xffff
  861.         add  edi,VGABasePtr
  862.         mov  [edi],ax
  863.         shr  eax,16
  864.         mov  [edi+2],al
  865.         pop  edi
  866.  
  867.      imp24no12:
  868.  
  869.         inc  edx
  870. ;        add  esi,3
  871.         add  edi,3
  872.         dec  ecx
  873.         jnz  np2412
  874.  
  875.       np24d12:
  876.  
  877.      pop  ebx
  878.      pop  ecx
  879.      pop  edi
  880.  
  881.     add  edi,[BytesPerScanLine]
  882.     add  esi,[esp+32]
  883.     cmp  ebp,putimage_get1bpp
  884.     jz   .correct
  885.     cmp  ebp,putimage_get4bpp
  886.     jnz  @f
  887. .correct:
  888.     mov  eax,[esp+20]
  889.     mov  byte[eax],80h
  890. @@:
  891.     dec  ebx
  892.     jnz  newpi12
  893.  
  894.   nonewpi12:
  895.  
  896.         pop     eax edx ecx ebx eax edi esi
  897.         xor     eax, eax
  898.         ret
  899.  
  900.  
  901.   pi32bit12:
  902.  
  903.    newpi3212:
  904.  
  905.     push edi
  906.     push ecx
  907.     push ebx
  908.  
  909.       mov  edx,edi
  910.       sub  edx,VGABasePtr
  911.       shr  edx,2
  912.       add  edx, [_display_data]
  913.       mov   ebx,[CURRENT_TASK]
  914.       mov   bh,[esp+4*3]
  915.  
  916.       np3212:
  917.  
  918.         cmp  bl,[edx]
  919.         jnz  imp32no12
  920. ;        mov  eax,[esi]
  921.         push    dword [esp+4*3+20]
  922.         call    ebp
  923. ;        cmp  bh,0
  924. ;        jz   imp32yes12
  925. ;        call dbcplimit
  926. ;        jnz  imp32no12
  927.  
  928.       imp32yes12:
  929.  
  930.         push edi
  931.         push eax
  932.         mov  eax,edi
  933.         sub  eax,VGABasePtr
  934.         shr  eax,16
  935.         call set_bank
  936.         pop  eax
  937.         and  edi,0xffff
  938.         mov  [edi+VGABasePtr],eax
  939.         pop  edi
  940.  
  941.       imp32no12:
  942.  
  943.         inc  edx
  944. ;        add  esi,3
  945.         add  edi,4
  946.         dec  ecx
  947.         jnz  np3212
  948.  
  949.       np32d12:
  950.  
  951.      pop  ebx
  952.      pop  ecx
  953.      pop  edi
  954.  
  955.     add   edi,[BytesPerScanLine]
  956.     cmp   ebp,putimage_get1bpp
  957.     jz    .correct
  958.     cmp   ebp,putimage_get4bpp
  959.     jnz   @f
  960. .correct:
  961.     mov   eax,[esp+20]
  962.     mov   byte[eax],80h
  963. @@:
  964.     dec   ebx
  965.     jnz   newpi3212
  966.  
  967.   nonewpi3212:
  968.  
  969.         pop     eax edx ecx ebx eax edi esi
  970.         xor     eax, eax
  971.         ret
  972.  
  973.  
  974. vesa12_read_screen_pixel:
  975.  
  976.      and   eax,0x3FFFFF
  977.      cmp   byte [ScreenBPP], 24      ; 24 or 32 bpp ?
  978.      jz    v12rsp24
  979.      mov   edi,eax
  980.      shl   edi,2
  981.      mov   eax,edi
  982.      shr   eax,16
  983.      call  set_bank
  984.      and   edi,65535
  985.      add   edi,VGABasePtr
  986.      mov   eax,[edi]
  987.      and   eax,0x00ffffff
  988.      ret
  989.   v12rsp24:
  990.  
  991.      imul  eax,3
  992.      mov   edi,eax
  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.  
  1001.  
  1002.