home *** CD-ROM | disk | FTP | other *** search
/ Top Ten Mega Games 2 / TOP_TEN_Mega_Games_2.iso / SW / QPEG / DRVSRC / VESA.ASM < prev   
Assembly Source File  |  1994-05-01  |  4KB  |  112 lines

  1. ;
  2. ; QPEG video driver
  3. ; for VESA compatible graphics cards
  4. ;
  5. ; 15-Oct-93:  1st release
  6. ; 04-Nov-93:  several bugs fixed
  7. ; 01-May-94:  added properties part
  8. ;
  9.  
  10.         .286
  11. Code    Segment Para 'Code'
  12.         Assume  cs:Code
  13.         Org 100h
  14.  
  15. Procs   dw      Bank,Init,Exit,Props
  16.         dw      0,0,0,0
  17.  
  18. Bank:   test    cs:VesaMode,0ffh
  19.         jz      SkipIt          ; don't do bank switching if no VESA mode
  20.         pusha
  21.         push    es
  22.         push    ds
  23.         mul     cs:VesaGranularity
  24.         mov     dx,ax
  25.         push    dx
  26.         xor     bx,bx           ; window A
  27.         mov     ax,4f05h
  28.         int     10h
  29.         pop     dx
  30.         mov     bx,1            ; window B
  31.         mov     ax,4f05h
  32.         int     10h
  33.         pop     ds
  34.         pop     es
  35.         popa
  36. SkipIt: retf
  37.  
  38. VesaGranularity db 0    ; granularity of video bank address
  39. VesaMode        db 0    ; 0 = not a VESA mode (i.e. no bank switching)
  40.  
  41. Init:   mov     cs:VesaMode,0
  42.         cmp     ax,4f02h
  43.         jne     Ready           ; skip everything if no VESA mode
  44.         mov     cs:VesaMode,1
  45.         push    cx
  46.         mov     dx,cs
  47.         mov     es,dx
  48.         xor     di,di           ; es:di - VESA info table
  49.         mov     cx,bx           ; mode number
  50.         mov     ax,4f01h        ; get VESA mode info
  51.         int     10h
  52.         cmp     ax,004fh
  53.         jne     Fail
  54.  
  55.         mov     cl,Byte Ptr cs:[00h]
  56.         and     cl,10001b
  57.         cmp     cl,10001b
  58.         je      Supp
  59. Fail:   xor     cx,cx           ; Mode not supported
  60.         pop     ax
  61.         jmp     Short Ready
  62. Supp:   mov     cx,cs:[04h]     ; VESA page granularity (in Kb)
  63.         mov     al,1
  64.         test    cx,cx
  65.         je      Gran64
  66.         mov     ax,64
  67.         div     cl
  68. Gran64: mov     cs:VesaGranularity,al
  69.  
  70.         pop     ax              ; default = minimum bytes per line
  71.         mov     cx,cs:[10h]     ; VESA bytes per line
  72.         cmp     cx,ax
  73.         jae     Ready
  74.         add     cx,cx           ; double if too small
  75. Ready:  retf
  76.  
  77. Exit:   retf
  78.  
  79. ; Properties Part (called after Init)
  80. ; -> ax,bx: Mode numbers (as for int10h and Init)
  81. ; <- VESA-like mode information at cs:[00h]
  82. ;      00h: bit 0 and 4 set if mode is supported
  83. ;      12h: (word) width (pixels per line)
  84. ;      14h: (word) heigth (lines per screen)
  85. ;      19h: bits per pixel
  86. ; The following are only valid for hicolor and truecolor modes:
  87. ;      1fh: bits per red component, 5 (hicolor) or 8 (truecolor)
  88. ;      20h: bit offset of red component, 0 (hi/true RGB) or 16 (true BGR)
  89. ;      21h: bits per green component, 5/6 (hicolor) or 8 (truecolor)
  90. ;      22h: bit offset of green component, 5 (hi) or 8 (true)
  91. ;      23h: bits per blue component, 5 (hicolor) or 8 (truecolor)
  92. ;      24h: bit offset of blue component, 10/11 (hi), 0 (true BGR) or 16 (true RGB)
  93. ;      25h: bits per Rsvd component, 0/1 (hicolor/true) or 8 (true 32bit)
  94. ;      26h: bit offset of Rsvd component, 24 (true 32bit) or 0 (else)
  95. ; QPEG uses 25h to distinguish between 24bit and 32bit truecolor.
  96.  
  97. Props:  mov     Byte Ptr cs:[00h],0
  98.         test    cs:VesaMode,0ffh
  99.         jz      Ready2          ; skip everything if no VESA mode
  100.         mov     dx,cs
  101.         mov     es,dx
  102.         xor     di,di           ; es:di - VESA info table
  103.         mov     cx,bx           ; mode number
  104.         mov     ax,4f01h        ; get VESA mode info
  105.         int     10h
  106. Ready2: retf
  107.  
  108. Code    Ends
  109.         End Procs
  110.  
  111. ; End of source.
  112.