Subversion Repositories Kolibri OS

Rev

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

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