Subversion Repositories Kolibri OS

Rev

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