Subversion Repositories Kolibri OS

Rev

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

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