Subversion Repositories Kolibri OS

Rev

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

  1. $Revision: 527 $
  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[BgrDataWidth]
  210.         mov   ebx,dword[BgrDataHeight]
  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.  
  224.         cmp   [BgrDrawMode],dword 1     ; tiled background
  225.         jne   no_vesa12_tiled_bgr
  226.  
  227.         push  edx
  228.  
  229.         xor   edx,edx
  230.         div   dword [BgrDataWidth]
  231.  
  232.         push  edx
  233.         mov   eax,ebx
  234.         xor   edx,edx
  235.         div   dword [BgrDataHeight]
  236.         mov   ebx,edx
  237.         pop   eax
  238.  
  239.         pop   edx
  240.  
  241.       no_vesa12_tiled_bgr:
  242.  
  243.         cmp   [BgrDrawMode],dword 2     ; stretched background
  244.         jne   no_vesa12_stretched_bgr
  245.  
  246.         push  edx
  247.  
  248.         mul   dword [BgrDataWidth]
  249.         mov   ecx,[ScreenWidth]
  250.         inc   ecx
  251.         div   ecx
  252.  
  253.         push  eax
  254.         mov   eax,ebx
  255.         mul   dword [BgrDataHeight]
  256.         mov   ecx,[ScreenHeight]
  257.         inc   ecx
  258.         div   ecx
  259.         mov   ebx,eax
  260.         pop   eax
  261.  
  262.         pop   edx
  263.  
  264.       no_vesa12_stretched_bgr:
  265.  
  266.  
  267.         mov   esi,ebx
  268.         imul  esi, dword [BgrDataWidth]
  269.         add   esi,eax
  270.         lea   esi,[esi*3]
  271.         add   esi,[img_background]   ;IMG_BACKGROUND
  272.         pop   ebx
  273.         pop   eax
  274.  
  275.       v12di4:
  276.  
  277.         mov   cl,[esi+2]
  278.         shl   ecx,16
  279.         mov   cx,[esi]
  280.         pusha
  281.         mov   esi,eax
  282.         mov   edi,ebx
  283.         mov   eax,[ScreenWidth]
  284.         add   eax,1
  285.         mul   ebx
  286.         cmp   [eax+esi+WinMapAddress],byte 1
  287.         jnz   v12nbgp
  288.         mov   eax,[BytesPerScanLine]
  289.         mov   ebx,edi
  290.         mul   ebx
  291.         add   eax,esi
  292.         add   eax,esi
  293.         add   eax,esi
  294.         cmp   [ScreenBPP],byte 24
  295.         jz    v12bgl3
  296.         add   eax,esi
  297.  
  298.       v12bgl3:
  299.  
  300.         push ebx
  301.         push eax
  302.  
  303.         sub  eax,[LFBAddress]
  304.  
  305.         shr  eax,16
  306.         call set_bank
  307.         pop  eax
  308.         and  eax,65535
  309.         add  eax,VGABasePtr
  310.         pop  ebx
  311.  
  312.         mov   [eax],cx
  313.         add   eax,2
  314.         shr   ecx,16
  315.         mov   [eax],cl
  316.         sti
  317.  
  318.       v12nbgp:
  319.  
  320.         popa
  321.         add   esi,3
  322.         inc   eax
  323.         cmp   eax,[draw_data+32+RECT.right]
  324.         jg    v12nodp31
  325.         jmp   v12dp3
  326.  
  327.       v12nodp31:
  328.  
  329.         mov   eax,[draw_data+32+RECT.left]
  330.         inc   ebx
  331.         cmp   ebx,[draw_data+32+RECT.bottom]
  332.         jg    v12dp4
  333.         jmp   v12dp3
  334.  
  335.       v12dp4:
  336.  
  337.         pop   edx
  338.         pop   ecx
  339.         pop   ebx
  340.         pop   eax
  341.         ret
  342.  
  343.  
  344. vesa12_drawbar:
  345.  
  346.     call  [disable_mouse]
  347.  
  348. ;;    mov  [novesachecksum],dword 0
  349.     sub  edx,ebx
  350.     sub  ecx,eax
  351.     push esi
  352.     push edi
  353.     push eax
  354.     push ebx
  355.     push ecx
  356.     push edx
  357.     mov  ecx,[TASK_BASE]
  358.     add  eax,[ecx-twdw+WDATA.box.left]
  359.     add  ebx,[ecx-twdw+WDATA.box.top]
  360.     push eax
  361.     mov  eax,ebx         ; y
  362.     mov  ebx,[BytesPerScanLine]
  363.     mul  ebx
  364.     pop  ecx
  365.     add  eax,ecx         ; x
  366.     add  eax,ecx
  367.     add  eax,ecx
  368.     cmp  [ScreenBPP],byte 24     ; 24 or 32 bpp ? - x start
  369.     jz   dbpi2412
  370.     add  eax,ecx
  371.  
  372.   dbpi2412:
  373.  
  374.     add  eax,[LFBAddress]
  375.     mov  edi,eax
  376.  
  377.     ; x size
  378.  
  379.     mov  eax,[esp+4] ; [esp+6]
  380.     mov  ecx,eax
  381.     add  ecx,eax
  382.     add  ecx,eax
  383.     cmp  [ScreenBPP],byte 24     ; 24 or 32 bpp ? - x size
  384.     jz   dbpi24312
  385.     add  ecx,eax
  386.  
  387.   dbpi24312:
  388.  
  389.     mov  ebx,[esp+0]
  390.  
  391.     ; check limits ?
  392.  
  393.     push eax
  394.     push ecx
  395.     mov  eax,[TASK_BASE]
  396.     mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.left]
  397.     cmp  ecx,0
  398.     jnz  dbcblimitlset12
  399.     mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.top]
  400.     cmp  ecx,0
  401.     jnz  dbcblimitlset12
  402.     mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.right]
  403.     cmp  ecx,[ScreenWidth]
  404.     jnz  dbcblimitlset12
  405.     mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.bottom]
  406.     cmp  ecx,[ScreenHeight]
  407.     jnz  dbcblimitlset12
  408.     pop  ecx
  409.     pop  eax
  410.     push dword 0
  411.     jmp  dbcblimitlno12
  412.  
  413.   dbcblimitlset12:
  414.  
  415.     pop  ecx
  416.     pop  eax
  417.     push dword 1
  418.  
  419.   dbcblimitlno12:
  420.  
  421.     cmp  [ScreenBPP],byte 24     ; 24 or 32 bpp ?
  422.     jz   dbpi24bit12
  423.     jmp  dbpi32bit12
  424.  
  425.  
  426. ; DRAWBAR 24 BBP
  427.  
  428.  
  429. dbpi24bit12:
  430.  
  431.     push eax
  432.     push ebx
  433.     push edx
  434.     mov  eax,ecx
  435.     mov  ebx,3
  436.     div  ebx
  437.     mov  ecx,eax
  438.     pop  edx
  439.     pop  ebx
  440.     pop  eax
  441.     cld
  442.  
  443.   dbnewpi12:
  444.  
  445.     push ebx
  446.     push edi
  447.     push ecx
  448.  
  449.       xor  edx,edx
  450.       mov  eax,edi
  451.       sub  eax,[LFBAddress]
  452.       mov  ebx,3
  453.       div  ebx
  454.       add  eax,WinMapAddress
  455.       mov   ebx,[CURRENT_TASK]
  456.       cld
  457.  
  458.       dbnp2412:
  459.  
  460.         mov  dl,[eax]
  461.         push eax
  462.         push ecx
  463.         cmp  dl,bl
  464.         jnz  dbimp24no12
  465.         cmp  [esp+5*4],dword 0
  466.         jz   dbimp24yes12
  467. ;        call dbcplimit
  468. ;        jnz  dbimp24no12
  469.  
  470.      dbimp24yes12:
  471.  
  472.         push edi
  473.         mov  eax,edi
  474.         sub  eax,[LFBAddress]
  475.         shr  eax,16
  476.         call set_bank
  477.         and  edi,0xffff
  478.         add  edi,VGABasePtr
  479.         mov  eax,[esp+8+3*4+16+4+4]
  480.         stosw
  481.         shr  eax,16
  482.         stosb
  483.         sti
  484.         pop  edi
  485.         add  edi,3
  486.         pop  ecx
  487.         pop  eax
  488.         inc  eax
  489.         loop dbnp2412
  490.         jmp  dbnp24d12
  491.  
  492.       dbimp24no12:
  493.  
  494.         pop  ecx
  495.         pop  eax
  496.         cld
  497.         add  edi,3
  498.         inc  eax
  499.         loop dbnp2412
  500.  
  501.       dbnp24d12:
  502.  
  503.         mov  eax,[esp+3*4+16+4]
  504.         test eax,0x80000000
  505.         jz   nodbgl2412
  506.         cmp  al,0
  507.         jz   nodbgl2412
  508.         dec  eax
  509.         mov  [esp+3*4+16+4],eax
  510.  
  511.       nodbgl2412:
  512.  
  513.     pop  ecx
  514.     pop  edi
  515.     pop  ebx
  516.     add  edi,[BytesPerScanLine]
  517.     dec  ebx
  518.     jz   dbnonewpi12
  519.     jmp  dbnewpi12
  520.  
  521.   dbnonewpi12:
  522.  
  523.     add  esp,7*4
  524.  
  525.     ret
  526.  
  527.  
  528. ; DRAWBAR 32 BBP
  529.  
  530.  
  531.   dbpi32bit12:
  532.  
  533.     cld
  534.     shr  ecx,2
  535.  
  536.    dbnewpi3212:
  537.  
  538.     push ebx
  539.     push edi
  540.     push ecx
  541.  
  542.       mov  eax,edi
  543.       sub  eax,[LFBAddress]
  544.       shr  eax,2
  545.       add  eax,WinMapAddress
  546.       mov   ebx,[CURRENT_TASK]
  547.       cld
  548.  
  549.       dbnp3212:
  550.  
  551.         mov  dl,[eax]
  552.         push eax
  553.         push ecx
  554.         cmp  dl,bl
  555.         jnz  dbimp32no12
  556.         cmp  [esp+5*4],dword 0
  557.         jz   dbimp32yes12
  558. ;        call dbcplimit
  559. ;        jnz  dbimp32no12
  560.  
  561.       dbimp32yes12:
  562.  
  563.         push edi
  564.         mov  eax,edi
  565.         sub  eax,[LFBAddress]
  566.         shr  eax,16
  567.         call set_bank
  568.         and  edi,0xffff
  569.         add  edi,VGABasePtr
  570.         mov  eax,[esp+8+3*4+16+4+4]
  571.         stosw
  572.         shr  eax,16
  573.         stosb
  574.         sti
  575.         pop  edi
  576.         add  edi,4
  577.         inc  ebp
  578.         pop  ecx
  579.         pop  eax
  580.         inc  eax
  581.         loop dbnp3212
  582.         jmp  dbnp32d12
  583.  
  584.       dbimp32no12:
  585.  
  586.         pop  ecx
  587.         pop  eax
  588.         inc  eax
  589.         add  edi,4
  590.         inc  ebp
  591.         loop dbnp3212
  592.  
  593.       dbnp32d12:
  594.  
  595.         mov  eax,[esp+12+16+4]
  596.         test eax,0x80000000
  597.         jz   nodbgl3212
  598.         cmp  al,0
  599.         jz   nodbgl3212
  600.         dec  eax
  601.         mov  [esp+12+16+4],eax
  602.  
  603.       nodbgl3212:
  604.  
  605.     pop  ecx
  606.     pop  edi
  607.     pop  ebx
  608.     add  edi,[BytesPerScanLine]
  609.     dec  ebx
  610.     jz   nodbnewpi3212
  611.     jmp  dbnewpi3212
  612.  
  613.   nodbnewpi3212:
  614.  
  615.     add  esp,7*4
  616.     ret
  617.  
  618.  
  619. Vesa12_putpixel24:
  620.  
  621.         mov  edi,eax ; x
  622.         mov  eax,ebx ; y
  623.         lea  edi,[edi+edi*2]
  624.         mov  ebx,[BytesPerScanLine]
  625.         mul  ebx
  626.         add  edi,eax
  627.         mov  eax,edi
  628.         shr  eax,16
  629.         call set_bank
  630.         and  edi,65535
  631.         add  edi,VGABasePtr
  632.         mov  eax,[esp+28]
  633.         stosw
  634.         shr  eax,16
  635.         mov  [edi],al
  636.         sti
  637.         ret
  638.  
  639.  
  640.  
  641. Vesa12_putpixel32:
  642.  
  643.         mov  edi,eax ; x
  644.         mov  eax,ebx ; y
  645.         shl  edi,2
  646.         mov  ebx,[BytesPerScanLine]
  647.         mul  ebx
  648.         add  edi,eax
  649.         mov  eax,edi
  650.         shr  eax,16
  651.         call set_bank
  652.         and  edi,65535
  653.         add  edi,VGABasePtr
  654.         mov  ecx,[esp+28]
  655.         mov  [edi],ecx
  656.         sti
  657.         ret
  658.  
  659.  
  660. Vesa12_getpixel24:
  661.  
  662.         mov  edi,eax ; x
  663.         mov  eax,ebx ; y
  664.         lea  edi,[edi+edi*2]
  665.         mov  ebx,[BytesPerScanLine]
  666.         mul  ebx
  667.         add  edi,eax
  668.         mov  eax,edi
  669.         shr  eax,16
  670.         call set_bank
  671.         and  edi,65535
  672.         add  edi,VGABasePtr
  673.         mov  ecx,[edi]
  674.         and  ecx,255*256*256+255*256+255
  675.         sti
  676.         ret
  677.  
  678.  
  679. Vesa12_getpixel32:
  680.  
  681.         mov  edi,eax ; x
  682.         mov  eax,ebx ; y
  683.         shl  edi,2
  684.         mov  ebx,[BytesPerScanLine]
  685.         xor  edx,edx
  686.         mul  ebx
  687.         add  edi,eax
  688.         mov  eax,edi
  689.         shr  eax,16
  690.         call set_bank
  691.         and  edi,65535
  692.         add  edi,VGABasePtr
  693.         mov  ecx,[edi]
  694.         and  ecx,255*256*256+255*256+255
  695.         sti
  696.  
  697.         ret
  698.  
  699.  
  700.  
  701. vesa12_putimage:
  702. ; ebx = pointer to image
  703. ; ecx = size [x|y]
  704. ; edx = coordinates [x|y]
  705. ; ebp = pointer to 'get' function
  706. ; esi = pointer to 'init' function
  707. ; edi = parameter for 'get' function
  708.  
  709. ;    mov  ebx,image
  710. ;    mov  ecx,320*65536+240
  711. ;    mov  edx,20*65536+20
  712.  
  713.     call  [disable_mouse]
  714.  
  715.     mov   [novesachecksum],dword 0
  716.     push  esi
  717.     push  edi
  718.     push  eax
  719.     push  ebx
  720.     push  ecx
  721.     push  edx
  722.     movzx eax,word [esp+2]
  723.     movzx ebx,word [esp+0]
  724.     mov   ecx,[TASK_BASE]
  725.     add   eax,[ecx-twdw+WDATA.box.left]
  726.     add   ebx,[ecx-twdw+WDATA.box.top]
  727.     push  eax
  728.     mov   eax,ebx         ; y
  729.     mul   dword [BytesPerScanLine]
  730.     pop   ecx
  731.     add   eax,ecx         ; x
  732.     add   eax,ecx
  733.     add   eax,ecx
  734.     cmp  [ScreenBPP],byte 24     ; 24 or 32 bpp ? - x start
  735.     jz   pi2412
  736.     add  eax,ecx
  737.  
  738.   pi2412:
  739.  
  740.     add  eax,[LFBAddress]
  741.     mov  edi,eax
  742.  
  743.     ; x size
  744.  
  745.     movzx ecx,word [esp+6]
  746.  
  747.     mov   esi,[esp+8]
  748.     movzx ebx,word [esp+4]
  749.  
  750.     ; check limits while draw ?
  751.  
  752.     push  ecx
  753.     mov  eax,[TASK_BASE]
  754.     cmp  dword [eax+draw_data-CURRENT_TASK+RECT.left], 0
  755.     jnz  dbcblimitlset212
  756.     cmp  dword [eax+draw_data-CURRENT_TASK+RECT.top], 0
  757.     jnz  dbcblimitlset212
  758.     mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.right]
  759.     cmp  ecx,[ScreenWidth]
  760.     jnz  dbcblimitlset212
  761.     mov  ecx,[eax+draw_data-CURRENT_TASK+RECT.bottom]
  762.     cmp  ecx,[ScreenHeight]
  763.     jnz  dbcblimitlset212
  764.     pop  ecx
  765.     push 0
  766.     jmp  dbcblimitlno212
  767.  
  768.   dbcblimitlset212:
  769.  
  770.     pop  ecx
  771.     push 1
  772.  
  773.   dbcblimitlno212:
  774.  
  775.     cmp  [ScreenBPP],byte 24     ; 24 or 32 bpp ?
  776.     jnz  pi32bit12
  777.  
  778.   pi24bit12:
  779.  
  780.   newpi12:
  781.  
  782.     push edi
  783.     push ecx
  784.     push ebx
  785.  
  786.       mov  edx,edi
  787.       sub  edx,[LFBAddress]
  788.       mov  ebx,3
  789.       div  ebx
  790.       add  edx,WinMapAddress
  791.       mov  ebx,[CURRENT_TASK]
  792.       mov  bh,[esp+4*3]
  793.  
  794.       np2412:
  795.  
  796.         cmp  bl,[edx]
  797.         jnz  imp24no12
  798. ;        mov  eax,[esi]
  799.         push    dword [esp+4*3+20]
  800.         call    ebp
  801. ;        cmp  bh,0
  802. ;        jz   imp24yes12
  803. ;        call dbcplimit
  804. ;        jnz  imp24no12
  805.  
  806.      imp24yes12:
  807.  
  808.         push edi
  809.         push eax
  810.         mov  eax,edi
  811.         sub  eax,[LFBAddress]
  812.         shr  eax,16
  813.         call set_bank
  814.         pop  eax
  815.         and  edi,0xffff
  816.         add  edi,VGABasePtr
  817.         mov  [edi],ax
  818.         shr  eax,16
  819.         mov  [edi+2],al
  820.         pop  edi
  821.  
  822.      imp24no12:
  823.  
  824.         inc  edx
  825. ;        add  esi,3
  826.         add  edi,3
  827.         dec  ecx
  828.         jnz  np2412
  829.  
  830.       np24d12:
  831.  
  832.      pop  ebx
  833.      pop  ecx
  834.      pop  edi
  835.  
  836.     add  edi,[BytesPerScanLine]
  837.     add  esi,[esp+32]
  838.     dec  ebx
  839.     jnz  newpi12
  840.  
  841.   nonewpi12:
  842.  
  843.         pop     eax edx ecx ebx eax edi esi
  844.         xor     eax, eax
  845.         ret
  846.  
  847.  
  848.   pi32bit12:
  849.  
  850.    newpi3212:
  851.  
  852.     push edi
  853.     push ecx
  854.     push ebx
  855.  
  856.       mov  edx,edi
  857.       sub  edx,[LFBAddress]
  858.       shr  edx,2
  859.       add  edx,WinMapAddress
  860.       mov   ebx,[CURRENT_TASK]
  861.       mov   bh,[esp+4*3]
  862.  
  863.       np3212:
  864.  
  865.         cmp  bl,[edx]
  866.         jnz  imp32no12
  867. ;        mov  eax,[esi]
  868.         push    dword [esp+4*3+20]
  869.         call    ebp
  870. ;        cmp  bh,0
  871. ;        jz   imp32yes12
  872. ;        call dbcplimit
  873. ;        jnz  imp32no12
  874.  
  875.       imp32yes12:
  876.  
  877.         push edi
  878.         push eax
  879.         mov  eax,edi
  880.         sub  eax,[LFBAddress]
  881.         shr  eax,16
  882.         call set_bank
  883.         pop  eax
  884.         and  edi,0xffff
  885.         mov  [edi+VGABasePtr],eax
  886.         pop  edi
  887.  
  888.       imp32no12:
  889.  
  890.         inc  edx
  891. ;        add  esi,3
  892.         add  edi,4
  893.         dec  ecx
  894.         jnz  np3212
  895.  
  896.       np32d12:
  897.  
  898.      pop  ebx
  899.      pop  ecx
  900.      pop  edi
  901.  
  902.     add   edi,[BytesPerScanLine]
  903.     dec   ebx
  904.     jnz   newpi3212
  905.  
  906.   nonewpi3212:
  907.  
  908.         pop     eax edx ecx ebx eax edi esi
  909.         xor     eax, eax
  910.         ret
  911.  
  912.  
  913. vesa12_read_screen_pixel:
  914.  
  915.      and   eax,0x3FFFFF
  916.      cmp   [ScreenBPP],byte 24      ; 24 or 32 bpp ?
  917.      jz    v12rsp24
  918.      mov   edi,eax
  919.      shl   edi,2
  920.      mov   eax,edi
  921.      shr   eax,16
  922.      call  set_bank
  923.      and   edi,65535
  924.      add   edi,VGABasePtr
  925.      mov   eax,[edi]
  926.      and   eax,0x00ffffff
  927.      ret
  928.   v12rsp24:
  929.  
  930.      imul  eax,3
  931.      mov   edi,eax
  932.      shr   eax,16
  933.      call  set_bank
  934.      and   edi,65535
  935.      add   edi,VGABasePtr
  936.      mov   eax,[edi]
  937.      and   eax,0x00ffffff
  938.      ret
  939.  
  940.  
  941.