Subversion Repositories Kolibri OS

Rev

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

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