home *** CD-ROM | disk | FTP | other *** search
/ 20th Century Video Alman…Century in Depth - Sports / ALMANAC_03.iso / vesa / everex / vesa05.txt < prev    next >
Text File  |  1990-01-11  |  39KB  |  1,049 lines

  1. VESA Super VGA Standard VS891101
  2.  
  3. Video Electronics Standards Association
  4. 1330 South Bascom Avenue, Suite D
  5. San Jose, CA 95128-4502
  6. Phone: (408) 971-7525
  7. Fax: (408) 286-8988
  8.  
  9.  
  10.  
  11.  
  12.  
  13. SUPER VGA BIOS EXTENSION
  14. Standard # VS891101
  15. November 14, 1989
  16.  
  17.  
  18.  
  19.  
  20. OBJECTIVE
  21.  
  22. To standardize a common software interface to Super VGA video
  23. adapters in order to provide simplified software application
  24. access to advanced VGA products.
  25.  
  26.  
  27. SUMMARY
  28.  
  29. The standard provides a set of functions which an application
  30. program can use to a) obtain information about the
  31. capabilities and characteristics of a specific Super VGA
  32. implementation and b) to control the operation of such
  33. hardware in terms of video mode initialization and video
  34. memory access. The functions are provided as an extension to
  35. the VGA BIOS video services, accessed through interrupt 10.
  36.  
  37.  
  38.  
  39.  
  40. Contents
  41.  
  42.  
  43. 1.    Introduction
  44.  
  45. 2.    Goals and Objectives
  46.     2.1    Video environment information
  47.     2.2    Programming support
  48.     2.3    Compatibility
  49.     2.4    Scope of standard
  50.  
  51. 3.    Standard VGA BIOS
  52.  
  53. 4.    Super VGA Mode Numbers
  54.  
  55. 5.    CPU Video Memory Windows
  56.     5.1    Hardware design considerations
  57.         5.1.1    Limited to 64k/128k of CPU address
  58.             space
  59.         5.1.2    Crossing CPU video memory window
  60.             boundaries
  61.         5.1.3    Operating on data from different areas
  62.         5.1.4    Combining data from two different
  63.             windows
  64.     5.2    Different types of hardware windows
  65.         5.2.1    Single window systems
  66.         5.2.2    Dual window systems
  67.  
  68. 6.    Extended VGA BIOS
  69.     6.1    Status information
  70.     6.2    00h - Return Super VGA information
  71.     6.3    01h - Return Super VGA mode information
  72.     6.4    02h - Set Super VGA mode
  73.     6.5    03h - Return Super VGA mode
  74.     6.6    04h - Save/restore Super VGA video state
  75.     6.7    06h - Super VGA video memory window control
  76.  
  77. 7.    Application Example
  78.  
  79.  
  80.  
  81. 1.    Introduction
  82.  
  83.  
  84. This document contains a specification for a standardized
  85. interface to extended VGA video modes and functions. The
  86. specification consists of mechanisms for supporting standard
  87. extended video modes and functions that have been approved by
  88. the main VESA committee and non-standard video modes that an
  89. individual VGA supplier may choose to add, in a uniform manner
  90. that application software can utilize without having to
  91. understand the intricate details of the particular VGA
  92. hardware.
  93.  
  94. The primary topics of this specification are definitions of
  95. extended VGA video modes and the functions necessary for
  96. application software to understand the characteristics of the
  97. video mode and manipulate the extended memory associated with
  98. the video modes.
  99.  
  100. Readers of this document should already be familiar with
  101. programming VGAs at the hardware level and Intel iAPX real
  102. mode assembly language. Readers who are unfamiliar with
  103. programming the VGA should first read one of the many VGA
  104. programming tutorials before attempting to understand these
  105. extensions to the standard VGA.
  106.  
  107.  
  108. 2.    Goals and Objectives
  109.  
  110.  
  111. The IBM VGA(1) has become a de-facto standard in the PC graphics
  112. world. A multitude of different VGA offerings exist in the
  113. marketplace, each one providing BIOS or register compatibility
  114. with the IBM VGA. More and more of these VGA compatible
  115. products implements various supersets of the VGA standard.
  116. These extensions range from higher resolutions and more colors
  117. to improved performance and even some graphics processing
  118. capabilities. Intense competition has dramatically improved
  119. the price/performance ratio, to the benefit of the end user.
  120.  
  121. However, several serious problems face a software developer
  122. who intends to take advantage of these "Super VGA"(2)
  123. environments. Because there is no standard hardware
  124. implementation, the developer is faced with widely disparate
  125. Super VGA hardware architectures. Lacking a common software
  126. interface, designing applications for these environments is
  127. costly and technically difficult. Except for applications
  128. supported by OEM-specific display drivers, very few software
  129. packages can take advantage of the power and capabilities of
  130. Super VGA products.
  131.  
  132. The purpose of the VESA VGA BIOS Extension is to remedy this
  133. situation. Being a common software interface to Super VGA
  134. graphics products, the primary objective is to enable
  135. application and system software to adapt to and exploit the
  136. wide range of features available in these VGA extensions.
  137.  
  138. Specifically, the VESA BIOS Extension attempts to address the
  139. following two main issues: a) Return information about the
  140. video environment to the application and b) Assist the
  141. application in initializing and programming the hardware.
  142.  
  143.  
  144. 2.1    Video environment information
  145.  
  146. Today, an application has no standard mechanism to determine
  147. what Super VGA hardware it is running on. Only by knowing OEM-
  148. specific features can an application determine the presence of
  149. a particular video board. This often involves reading and
  150. testing registers located at I/O addresses unique to each OEM.
  151. By not knowing what hardware an application is running on,
  152. few, if any, of the extended features of the underlying
  153. hardware can be used.
  154.  
  155. The VESA BIOS Extension provides several functions to return
  156. information about the video environment. These functions
  157. return system level information as well as video mode specific
  158. details. Function 00h returns general system level
  159. information, including an OEM identification string. The
  160. function also returns a pointer to the supported video modes.
  161. Function 01h may be used by the application to obtain
  162. information about each supported video mode. Function 03h
  163. returns the current video mode.
  164.  
  165.  
  166. 2.2    Programming support
  167.  
  168. Due to the fact that different Super VGA products have
  169. different hardware implementations, application software has
  170. great difficulty in adapting to each environment. However,
  171. since each is based on the VGA hardware architecture,
  172. differences are most common in video mode initialization and
  173. memory mapping. The rest of the architecture is usually kept
  174. intact, including I/O mapped registers, video buffer location
  175. in the CPU address space, DAC location and function, etc.
  176.  
  177. The VESA BIOS Extension provides several functions to
  178. interface to the different Super VGA hardware implementations.
  179. The most important of these is Function 02h, Set Super VGA
  180. video mode. This function isolates the application from the
  181. tedious and complicated task of setting up a video mode.
  182. Function 05h provides an interface to the underlying memory
  183. mapping hardware. Function 04h enables an application to save
  184. and restore a Super VGA state without knowing anything of the
  185. specific implementation.
  186.  
  187.  
  188. 2.3    Compatibility
  189.  
  190. A primary design objective of the VESA BIOS Extension is to
  191. preserve maximum compatibility to the standard VGA
  192. environment. In no way should the BIOS extensions compromise
  193. compatibility or performance. Another but related concern is
  194. to minimize the changes necessary to an existing VGA BIOS.
  195. RAM- as well as ROM-based implementations of the BIOS
  196. extension should be possible.
  197.  
  198.  
  199. 2.4    Scope of standard
  200.  
  201. The purpose of the VESA BIOS Extension is to provide support
  202. for extended VGA environments. Thus, the underlying hardware
  203. architecture is assumed to be a VGA. Graphics software that
  204. drives a Super VGA board, will perform its graphics output in
  205. generally the same way it drives a standard VGA, ie. writing
  206. directly to a VGA style frame buffer, manipulating graphics
  207. controller registers, directly programming the palette etc. No
  208. significant graphics processing will be done in hardware. For
  209. this reason, the VESA BIOS Extension does not provide any
  210. graphics output functions, such as BitBlt, line or circle
  211. drawing, etc.
  212.  
  213. An important constraint of the functionalities that can be
  214. placed into the VESA BIOS Extension, is that ROM-space is
  215. severely limited in certain existing BIOS implementations.
  216.  
  217. Outside the scope of this VESA BIOS Extension is handling of
  218. different monitors and monitor timings. Such items are dealt
  219. with in other VESA fora. The purpose of the VESA BIOS
  220. Extension is to provide a standardized software interface to
  221. Super VGA graphics modes, independent of monitor and monitor
  222. timing issues.
  223.  
  224.  
  225. 3.    Standard VGA BIOS
  226.  
  227.  
  228. A primary design goal with the VESA BIOS Extension is to
  229. minimize the effects on the standard VGA BIOS. Standard VGA
  230. BIOS functions should need to be modified as little as
  231. possible. This is important since ROM- as well as RAM-based
  232. versions of the extension may be implemented.
  233.  
  234. However, two standard VGA BIOS functions are affected by the
  235. VESA extension. These are Function 00h (Set video mode) and
  236. Function 0Fh (Read current video state). VESA-aware
  237. applications will not set the video mode using VGA BIOS
  238. function 00h. Nor will such applications use VGA BIOS function
  239. 0Fh. VESA BIOS functions 02h (Set Super VGA mode) and 03h (Get
  240. Super VGA mode) will be used instead.
  241.  
  242. However, VESA-unaware applications (such as old Pop-Up
  243. programs and other TSRs, or the CLS command of MS-DOS), might
  244. use VGA BIOS function 0Fh to get the present video mode. Later
  245. it may call VGA BIOS function 00h to restore/reinitialize the
  246. old video mode.
  247.  
  248. To make such applications work, VESA recommends that whatever
  249. value returned by VGA BIOS function 0Fh (it is up to the OEM
  250. to define this number), it can be used to reinitialize the
  251. video mode through VGA BIOS function 00h. Thus, the BIOS
  252. should keep track of the last Super VGA mode in effect.
  253.  
  254. It is recommended, but not mandatory, to support output
  255. functions (such as TTY-output, scroll, set pixel, etc.) in
  256. Super VGA modes. If the BIOS extension doesn't support such
  257. output functions, bit D2 (Output functions supported) of the
  258. ModeAttributes field (returned by VESA BIOS function 01h)
  259. should be cleared.
  260.  
  261.  
  262. 4.    Super VGA mode numbers
  263.  
  264.  
  265. Standard VGA mode numbers are 7 bits wide and presently ranges
  266. from 00h to 13h. OEMs have defined extended video modes in the
  267. range 14h to 7Fh. Values in the range 80h to FFh cannot be
  268. used, since VGA BIOS function 00h (Set video mode) interprets
  269. bit 7 as a flag to clear/not clear video memory.
  270.  
  271. Due to the limitations of 7 bit mode numbers, VESA video mode
  272. numbers are 15 bits wide. To initialize a Super VGA mode, its
  273. number is passed in the BX register to VESA BIOS function 02h
  274. (Set Super VGA mode).
  275.  
  276. The format of VESA mode numbers is as follows:
  277.             
  278.     D0-D8=    Mode number
  279.         If D8 == 0, this is not a VESA defined mode
  280.         If D8 == 1, this is a VESA defined mode
  281.     D9-D14= Reserved by VESA for future expansion (= 0)
  282.     D15=    Reserved (= 0)
  283.  
  284. Thus, VESA mode numbers begin at 100h. This mode numbering
  285. scheme implements standard VGA mode numbers as well as OEM-
  286. defined mode numbers as subsets of the VESA mode number. That
  287. means that regular VGA modes may be initialized through VESA
  288. BIOS function 02h (Set Super VGA mode), simply by placing the
  289. mode number in BL and clearing the upper byte (BH). OEM-
  290. defined video modes may be initialized in the same way.
  291.  
  292. To date, VESA has defined a 7-bit video mode number, 6Ah, for
  293. the 800x600, 16-color, 4-plane graphics mode. The
  294. corresponding 15-bit mode number for this mode is 102h.
  295.  
  296. The following VESA mode numbers have been defined:
  297.  
  298.  
  299. 15-bit    7-bit    Resolution    Colors
  300. mode    mode
  301. number    number            
  302. ---------------------------------------
  303.  
  304. 100h    -    640x400     256
  305. 101h    -    640x480     256
  306.  
  307. 102h    6Ah    800x600     16
  308. 103h    -    800x600     256
  309.  
  310. 104h    -    1024x768    16
  311. 105h    -    1024x768    256
  312.  
  313. 106h    -    1280x1024    16
  314. 107h    -    1280x1024    256
  315.  
  316.  
  317.  
  318. 5.    CPU Video Memory Windows
  319.  
  320.  
  321. A standard VGA sub-system provides 256k bytes of memory and a
  322. corresponding mechanism to address this memory. Super VGAs and
  323. their extended modes require more than the standard 256k bytes
  324. of memory but also require that the address space for this
  325. memory be restricted to the standard address space for
  326. compatibility reasons. CPU video memory windows provide a
  327. means of accessing this extended VGA memory within the
  328. standard CPU address space.
  329.  
  330. This chapter describes how several hardware implementations of
  331. CPU video memory windows operate, their impact on application
  332. software design, and relates them to the software model
  333. presented by the VESA VGA BIOS extensions.
  334.  
  335. The VESA CPU video memory windows functions have been designed
  336. to put the performance insensitive, non-standard hardware
  337. functions into the BIOS while putting the performance
  338. sensitive, standard hardware functions into the application.
  339. This provides portability among VGA systems together with the
  340. performance that comes from accessing the hardware directly.
  341. In particular, the VESA BIOS is responsible for mapping video
  342. memory into the CPU address space while the application is
  343. responsible for performing the actual memory read and write
  344. operations.
  345.  
  346. This combination software and hardware interface is
  347. accomplished by informing the application of the parameters
  348. that control the hardware mechanism of mapping the video
  349. memory into the CPU address space and then letting the
  350. application control the mapping within those parameters.
  351.  
  352.  
  353. 5.1    Hardware design considerations
  354.  
  355. 5.1.1    Limited to 64k/128k of CPU address space
  356.  
  357. The first consideration in implementing extended video memory
  358. is to give access to the memory to application software.
  359.  
  360. The standard VGA CPU address space for 16 color graphics modes
  361. is typically at segment A000h for 64k. This gives access to
  362. the 256k bytes of a standard VGA, i.e. 64k per plane. Access
  363. to the extended video memory is accomplished by mapping
  364. portions of the video memory into the standard VGA CPU address
  365. space.
  366.  
  367. Every super VGA hardware implementation provides a mechanism
  368. for software to specify the offset from the start of video
  369. memory which is to be mapped to the start of the CPU address
  370. space. Providing both read and write access to the mapped
  371. memory provides a necessary level of hardware support for an
  372. application to manipulate the extended video memory.
  373.  
  374.  
  375. 5.1.2    Crossing CPU video memory window boundaries
  376.  
  377. The organization of most software algorithms which perform
  378. video operations consists of a pair of nested loops: an outer
  379. loop over rows or scan lines and an inner loop across the row
  380. or scan line. The latter is the proverbial inner loop, which
  381. is the bottle neck to high performance software.
  382.  
  383. If a target rectangle is large enough, or poorly located, part
  384. of the required memory may be within the video memory mapped
  385. into the CPU address space and part of it may not be
  386. addressable by the CPU without changing the mapping. It is
  387. desirable that the test for re-mapping the video memory is
  388. located outside of the inner loop.
  389.  
  390. This is typically accomplished by selecting the mapping offset
  391. of the start of video memory to the start of the CPU address
  392. space so that at least one entire row or scan line can be
  393. processed without changing the video memory mapping.    There
  394. are currently no super VGAs that allow this offset to be
  395. specified on a byte boundary and there is a wide range among
  396. super VGAs in the ability to position a desired video memory
  397. location at the start of the CPU address space.
  398.  
  399. The number of bytes between the closest two bytes in video
  400. memory that can be placed on any single CPU address is defined
  401. as the granularity of the window mapping function. Some super
  402. VGA systems allow any 4k video memory boundary to be mapped to
  403. the start of the CPU address space, while other super VGA
  404. systems allow any 64k video memory boundary to be mapped to
  405. the start of the CPU address space. These two example systems
  406. would have granularities of 4k and 64k, respectively This
  407. concept is very similar to the bytes that can be accessed with
  408. a 16 bit pointer in an Intel CPU before a segment register
  409. must be changed (the granularity of the segment register or
  410. mapping, here is 16 bytes).
  411.  
  412. Note that if the granularity is equal to the length of the CPU
  413. address space, i.e. the least significant address bit of the
  414. hardware mapping function is more significant than the most
  415. significant bit of the CPU address, then the inner loop will
  416. have to contain the test for crossing the end or beginning of
  417. the CPU address space. This is because if the length of the
  418. CPU address space (which is the granularity in this case) is
  419. not evenly divisible by the length of a scan line, then the
  420. scan line at the end of the CPU address will be in two
  421. different video memory which cannot be mapped into the CPU
  422. address space simultaneously.
  423.  
  424.  
  425. 5.1.3    Operating on data from different areas
  426.  
  427. It is sometimes required or convenient to move or combine data
  428. from two different areas of video memory. One example of this
  429. is storing menus in the video memory beyond the displayed
  430. memory because there is hardware support in all VGAs for
  431. transferring 32 bits of video data with an 8 bit CPU read and
  432. write. Two separately mappable CPU video memory windows must
  433. be used if the distance between the source and destination is
  434. larger than the size of the CPU video memory window.
  435.  
  436.  
  437. 5.1.4    Combining data from two different windows
  438.  
  439. The above example of moving data from one CPU video memory
  440. window to another CPU video memory only required read access
  441. to one window and only required write access to the other
  442. window. Sometimes it is convenient to have read access to both
  443. windows and write access to one window. An example of this
  444. would be a raster operation where the resulting destination is
  445. the source data logically combined with the original
  446. destination data.
  447.  
  448.  
  449. 5.2    Different types of hardware windows
  450.  
  451. Different hardware implementations of CPU video memory windows
  452. can be supported by the VESA BIOS extension. The information
  453. necessary for an application to understand the type of
  454. hardware implementation is provided by the BIOS to the
  455. application. There are three basic types of hardware windowing
  456. implementations and they are described below.
  457.  
  458. The types of windowing schemes described below do not include
  459. differences in granularity.
  460.  
  461. Also note that is possible for a VGA to use a CPU address
  462. space of 128k starting at segment A000h.
  463.  
  464.  
  465. 5.2.1    Single window systems
  466.  
  467. Some hardware implementations only provide a single window.
  468. This single window will be readable as well as writable.
  469. However, this causes a significant performance degradation
  470. when moving data in video memory a distance that is larger
  471. than the CPU address space.
  472.  
  473.  
  474. 5.2.2    Dual window systems
  475.  
  476. Many super VGAs provide two windows to facilitate moving data
  477. within video memory. There are two separate methods of
  478. providing two windows.
  479.  
  480.  
  481. 5.2.2.1    Overlapping windows
  482.  
  483. Some hardware implementations distinguish window A and window
  484. B by determining if the CPU is attempting to do a memory read
  485. or a memory write operation. When the two windows are
  486. distinguished by whether the CPU is trying to read or write
  487. they can, and usually do, share the same CPU address space.
  488. However, one window will be read only and the other will be
  489. write only.
  490.  
  491.  
  492. 5.2.2.2    Non-overlapping windows
  493.  
  494. Another mechanism used by two window systems to distinguish
  495. window A and window B is by looking at the CPU address within
  496. the total VGA CPU address space. When the two windows are
  497. distinguished by the CPU address within the VGA CPU address
  498. space the windows cannot share the same address space, but
  499. they can each be both read and written.
  500.  
  501.  
  502.  
  503. 6.    Extended VGA BIOS
  504.  
  505.  
  506. Several new BIOS calls have been defined to support Super VGA
  507. modes. For maximum compatibility with the standard VGA BIOS,
  508. these calls are grouped under one function number. This number
  509. is passed in the AH register to the int 10h handler.
  510.  
  511. The designated Super VGA extended function number is 4Fh. This
  512. function number is presently unused in most, if not all, VGA
  513. BIOS implementations. A standard VGA BIOS performs no action
  514. when function call 4F is made.
  515.  
  516.  
  517.  
  518. 6.1    Status information
  519.  
  520. Every function returns status information in the AX register.
  521. The format of the status word is as follows:
  522.  
  523.     AL ==    4Fh:    Function is supported
  524.     AL !=    4Fh:    Function is not supported
  525.     AH ==    00h:    Function call successful
  526.     AH ==    01h:    Function call failed
  527.  
  528. Software should treat a non-zero value in the AH register as a
  529. general failure condition. In later versions of the VESA BIOS
  530. Extension new error codes might be defined.
  531.  
  532.  
  533.  
  534. 6.2    Function 00h - Return Super VGA information
  535.  
  536. The purpose of this function is to provide information to the
  537. calling program about the general capabilities of the Super
  538. VGA environment. The function fills an information block
  539. structure at the address specified by the caller. The
  540. information block size is 256 bytes.
  541.  
  542.     Input:    AH= 4Fh Super VGA support
  543.         AL= 00h Return Super VGA information
  544.         ES:DI=    Pointer to buffer
  545.  
  546.     Output: AX=    Status
  547.         All other registers are preserved
  548.  
  549.  
  550. The information block has the following structure:
  551.                             
  552. VgaInfoBlock struc
  553.     VESASignature    db    'VESA'    ; 4 signature bytes
  554.     VESAVersion    dw    ?    ; VESA version number
  555.     OEMStringPtr    dd    ?    ; Pointer to OEM string
  556.     Capabilities    db    4 dup (?) ; Capabilities of
  557.                     ; the video environment
  558.     VideoModePtr    dd    ?    ; Pointer to supported Super 
  559.                     ; VGA modes
  560. VgaInfoBlock ends
  561.  
  562.  
  563. The VESASignature field contains the characters 'VESA' if this
  564. is a valid block.
  565.  
  566. The VESAVersion field specifies which VESA standard the Super
  567. VGA BIOS conforms to. The higher byte would specify the major
  568. version number. The lower byte would specify the minor version
  569. number. The initial VESA version number is 1.0. Applications
  570. written to use the features of a specific version of the VESA
  571. BIOS Extension, is guaranteed to work in later versions. The
  572. VESA BIOS Extension will be fully upwards compatible.
  573.  
  574. The OEMStringPtr is a far pointer to a null terminated OEM-
  575. defined string. The string may used to identify the video
  576. chip, video board, memory configuration etc., to hardware
  577. specific display drivers. There are no restrictions on the
  578. format of the string.
  579.  
  580. The Capabilities field describes what general features are
  581. supported in the video environment. The bits are defined as
  582. follows:
  583.  
  584.     D0-31= Reserved
  585.  
  586. The VideoModePtr points to a list of supported Super VGA
  587. (VESA-defined as well as OEM-specific) mode numbers. Each mode
  588. number occupies one word (16 bits). The list of mode numbers
  589. is terminated by a -1 (0FFFFh). Please refer to chapter 2 for
  590. a description of VESA mode numbers. The pointer could point
  591. into either ROM or RAM, depending on the specific
  592. implementation. Either the list would be a static string
  593. stored in ROM, or the list would be generated at run-time in
  594. the information block (see above) in RAM.
  595.  
  596.  
  597.  
  598. 6.3    Function 01h - Return Super VGA mode information
  599.  
  600. This function returns information about a specific Super VGA
  601. video mode. The function fills a mode information block
  602. structure at the address specified by the caller. The mode
  603. information block size is maximum 256 bytes.
  604.  
  605. Some information provided by this function is implicitly
  606. defined by the VESA mode number. However, some Super VGA
  607. implementations might support other video modes than those
  608. defined by VESA. To provide access to these modes, this
  609. function also returns various other information about the
  610. mode.
  611.  
  612.     Input:    AH= 4Fh Super VGA support
  613.         AL= 01h Return Super VGA mode information
  614.         CX=    Super VGA video mode
  615.         ES:DI=    Pointer to buffer
  616.  
  617.     Output: AX=    Status
  618.         All other registers are preserved
  619.  
  620.  
  621. The mode information block has the following structure:
  622.  
  623. ModeInfoBlock    struc
  624.  
  625. ; mandatory information (allways provided)
  626. ModeAttributes         dw    ?    ; mode attributes
  627. WinAAttributes         db    ?    ; window A attributes
  628. WinBAttributes         db    ?    ; window B attributes
  629. WinGranularity         dw    ?    ; window granularity
  630. WinSize            dw    ?    ; window size
  631. WinASegment        dw    ?    ; window A start segment
  632. WinBSegment        dw    ?    ; window B start segment
  633. WinFuncPtr        dd    ?    ; pointer to window function
  634. BytesPerScanLine    dw    ?    ; bytes per scan line
  635.  
  636. ; optional information (provided if bit D1 of ModeAttributes is set)
  637. XResolution        dw    ?    ; horizontal resolution
  638. YResolution        dw    ?    ; vertical resolution
  639. XCharSize        db    ?    ; character cell width
  640. YCharSize        db    ?    ; character cell height
  641. NumberOfPlanes         db    ?    ; number of memory planes
  642. BitsPerPixel        db    ?    ; bits per pixel
  643. NumberOfBanks        db    ?    ; number of banks
  644. MemoryModel        db    ?    ; memory model type
  645. BankSize        db    ?    ; bank size in kb
  646.  
  647. ModeInfoBlock    ends
  648.  
  649.  
  650.  
  651. The ModeAttributes field describes certain important
  652. characteristics of the video mode. Bit D0 specifies whether
  653. this mode can be initialized in the present video
  654. configuration. This bit can be used to block access to a video
  655. mode if it requires a certain monitor type, and that this
  656. monitor is presently not connected. Bit D1 specifies whether
  657. extended mode information is available. Video modes defined by
  658. VESA will have certain known characteristics, like resolution,
  659. number of planes, pixel format etc. Due to the severe space
  660. constraint for ROM based implementations of the VESA BIOS
  661. Extension, this information need not to be given for VESA-
  662. defined video modes. Bit D2 indicates whether the BIOS have
  663. support for output functions like TTY output, scroll, pixel
  664. output etc. in this mode (it is recommended, but not
  665. mandatory, that the BIOS have support for all output functions).
  666.  
  667. The field is defined as follows:
  668.  
  669.     D0= Mode supported in hardware
  670.         0= Mode not supported in hardware
  671.         1= Mode supported in hardware
  672.     D1= Extended information available
  673.         0= Extended mode information not available
  674.         1= Extended mode information available
  675.     D2= Output functions supported by BIOS
  676.         0= Output functions not supported by BIOS
  677.         1= Output functions supported by BIOS
  678.     D3= Monochrome/color mode (see note below)
  679.         0= Monochrome mode
  680.         1= Color mode
  681.     D4= Mode type
  682.         0= Text mode
  683.         1= Graphics mode
  684.     D5-D15= Reserved
  685.  
  686. Note:    Monochrome modes have their CRTC address at 3B4h.
  687. Color modes have their CRTC address at 3D4h. Monochrome modes
  688. have attributes in which only bit 3 (video) and bit 4
  689. (intensity) of the attribute controller output are
  690. significant. Therefore, monochrome text modes have attributes
  691. of off, video, high intensity, blink, etc. Monochrome graphics
  692. modes are two plane graphics modes and have attributes of off,
  693. video, high intensity, and blink. Extended two color modes
  694. that have their CRTC address at 3D4h, are color modes with one
  695. bit per pixel and one plane. The standard VGA modes, 06h and
  696. 11h would be classified as color modes, while the standard VGA
  697. modes 07h and 0fh would be classified as monochrome modes.
  698.  
  699. The BytesPerScanline field specifies how many bytes each
  700. logical scanline consists of. The logical scanline could be
  701. equal to or larger than the displayed scanline.
  702.  
  703. The WinAAttributes and WinBAttributes describe the
  704. characteristics of the CPU windowing scheme such as whether
  705. the windows exist and are read/writeable, as follows:
  706.  
  707.     D0= Window supported
  708.         0= Window is not supported
  709.         1= Window is supported
  710.     D1= Window readable
  711.         0= Window is not readable
  712.         1= Window is readable
  713.     D2= Window writable
  714.         0= Window is not writeable
  715.         1= Window is writeable
  716.     D3-D7= Reserved
  717.  
  718. WinGranularity specifies the smallest boundary, in KB, on
  719. which the window can be placed in the video memory.
  720.  
  721. WinSize specifies the size of the window in KB.
  722.  
  723. WinASegment and WinBSegment address specify the segment
  724. addresses where the windows are located in the CPU address
  725. space.
  726.  
  727. WinFuncAddr specifies the address of the CPU video memory
  728. windowing function. The windowing function can be invoked
  729. either through VESA BIOS function 05h, or by calling the
  730. function directly. A direct call will provide faster access to
  731. the hardware paging registers than using Int 10h, and is
  732. intended to be used by high performance applications.
  733.  
  734. The XResolution and YResolution specify the width and height
  735. of the video mode. In graphics modes, this resolution is in
  736. units of pixels. In text modes this resolution is in units of
  737. characters. Note that text mode resolutions, in units of
  738. pixels, can be obtained by multiplying XResolution and
  739. YResolution by the cell width and height, if the extended
  740. information is present.
  741.  
  742. The XCharCellSize and YCharCellSize specify the size of the
  743. character cell in pixels.
  744.  
  745. The NumberOfPlanes field specifies the number of memory planes
  746. available to software in that mode. For standard 16-color VGA
  747. graphics, this would be set to 4. For standard packed pixel
  748. modes, the field would be set to 1.
  749.  
  750. The BitsPerPixel field specifies the number of bits that
  751. define the color of one pixel. 16-color and 256-color graphics
  752. modes would specify 4 and 8 respectively. Non-standard memory
  753. organizations can be specified using this field and the
  754. NumberOfPlanes field. For example, a 16-color packed pixel
  755. mode would be described as having 1 plane and 4 bits per
  756. pixel.
  757.  
  758. The MemoryModel field specifies the general type of memory
  759. organization used in this mode. The following models have been
  760. defined:
  761.  
  762.     00h=        Text mode
  763.     01h=        CGA graphics
  764.     02h=        Hercules graphics
  765.     03h=        4-plane planar
  766.     04h=        Packed pixel
  767.     05h=        Non-chain 4, 256 color
  768.     06h-0fh=    Reserved, to be defined by VESA
  769.     10h-ffh=    To be defined by OEM
  770.  
  771. NumberOfBanks. This is the number of banks in which the scan
  772. lines are grouped. The remainder from dividing the scan line
  773. number by the number of banks is the bank that contains the
  774. scan line and the quotient is the scan line number within the
  775. bank. For example, CGA graphics modes have two banks and
  776. Hercules graphics mode has four banks. For modes that don't
  777. have scanline banks (such as VGA modes 0Dh-13h), this field
  778. should be set to 1.
  779.  
  780. The BankSize field specifies the size of a bank (group of scan
  781. lines) in units of 1 KB. For CGA and Hercules graphics modes
  782. this is 8, as each bank is 8192 bytes in length. For modes
  783. that don't have scanline banks (such as VGA modes 0Dh-13h),
  784. this field should be set to 0.
  785.  
  786. MapFuncAddr specifies the address of the Mapping function. The
  787. mapping function can be invoked either through VESA BIOS
  788. Function 06h, or by calling the function directly. A direct
  789. call will provide a faster memory mapping than using Int 10h,
  790. and is intended to be used by high performance applications.
  791.  
  792.  
  793. 6.4    Function 02h - Set Super VGA video mode
  794.  
  795. This function initializes a Super VGA video mode. The BX
  796. register contains the Super VGA mode to set. The format of
  797. VESA mode numbers is described in chapter 2. If the mode
  798. cannot be set, the BIOS should leave the video environment
  799. unchanged and return a failure error code.
  800.  
  801.     Input:    AH= 4Fh Super VGA support
  802.         AL= 02h Set Super VGA video mode
  803.         BX=    Video mode
  804.             D0-D14= Video mode
  805.             D15= Clear memory flag
  806.                 0= Clear video memory
  807.                 1= Don't clear video memory
  808.  
  809.     Output: AX=    Status
  810.         All other registers are preserved
  811.  
  812.  
  813.  
  814.  
  815. 6.5    Function 03h - Return current video mode
  816.  
  817. This function returns the current video mode in BX. The format
  818. of VESA video mode numbers is described in chapter 2 of this
  819. document.
  820.  
  821.     Input:    AH= 4Fh Super VGA support
  822.         AL= 03h Return current video mode
  823.  
  824.     Output: AX=    Status
  825.         BX=    Current video mode
  826.         All other registers are preserved
  827.  
  828. Notes:
  829.  
  830. In a standard VGA BIOS, function 0Fh (Read current video
  831. state) returns the current video mode in the AL register. In
  832. D7 of AL, it also returns the status of the memory clear bit
  833. (D7 of 40:87). This bit is set if the mode was set without
  834. clearing memory. In this Super VGA function, the memory clear
  835. bit will not be returned in BX since the purpose of the
  836. function is to return the video mode only. If an application
  837. wants to obtain the memory clear bit, it should call VGA BIOS
  838. function Fh.
  839.  
  840.  
  841.  
  842.  
  843. 6.6    Function 04h - Save/Restore Super VGA video state
  844. These functions provide a mechanism to save and restore the
  845. Super VGA video state. The functions are a superset of the
  846. three subfunctions under standard VGA BIOS function 1Ch
  847. (Save/restore video state). The complete Super VGA video state
  848. (except video memory) should be saveable/restorable by setting
  849. the requested states mask (in the CX register) to 000Fh.
  850.  
  851.     Input:    AH= 4Fh Super VGA support
  852.         AL= 04h Save/Restore Super VGA video state
  853.         DL= 00h Return save/restore state buffer size
  854.         CX=    Requested states
  855.                 D0= Save/restore video hardware state
  856.                 D1= Save/restore video BIOS data state
  857.                 D2= Save/restore video DAC state
  858.                 D3= Save/restore Super VGA state
  859.  
  860.     Output: AX=    Status
  861.         BX=    Number of 64-byte blocks to hold the state buffer
  862.         All other registers are preserved
  863.  
  864.  
  865.     Input:    AX= 4Fh Super VGA support
  866.         AL= 04h Save/Restore Super VGA video state
  867.         DL= 01h Save Super VGA video state
  868.         CX=    Requested states (see above)
  869.         ES:BX=    Pointer to buffer
  870.  
  871.     Output: AX=    Status
  872.         All other registers are preserved
  873.  
  874.  
  875.     Input:    AH= 4Fh Super VGA support
  876.         AL= 04h Save/Restore Super VGA video state
  877.         DL= 02h Restore Super VGA video state
  878.         CX=    Requested states (see above)
  879.         ES:BX=    Pointer to buffer
  880.  
  881.     Output: AX=    Status
  882.         All other registers are preserved
  883.  
  884.  
  885. Notes:
  886.  
  887. Due to the goal of complete compatibility with the VGA
  888. environment, the standard VGA BIOS function 1Ch (Save/Restore
  889. VGA state) has not been extended to save the Super VGA video
  890. state. VGA BIOS compatibility requires that function 1Ch
  891. returns a specific buffer size with specific contents, in
  892. which there is no room for the Super VGA state.
  893.  
  894.  
  895.  
  896.  
  897. 6.7    Function 05h - CPU Video Memory Window Control
  898.  
  899. This function sets or gets the position of the specified
  900. window in the video memory. The function allows direct access
  901. to the hardware paging registers. To use this function
  902. properly, the software should use VESA BIOS Function 01h
  903. (Return Super VGA mode information) to determine the size,
  904. location and granularity of the windows.
  905.  
  906.     Input:    AH= 4Fh Super VGA support
  907.         AL= 05h Super VGA video memory window control
  908.         BH= 00h Select super VGA video memory window
  909.         BL=    Window number
  910.                 0= Window A
  911.                 1= Window B
  912.         DX=    Window position in video memory 
  913.                 (in window granularity units)
  914.  
  915.     Output: AX=    Status
  916.         See notes below
  917.  
  918.  
  919.     Input:    AH= 4Fh Super VGA support
  920.         AL= 05h Super VGA video memory window control
  921.         BH= 01h Return super VGA video memory window
  922.         BL=    Window number
  923.                 0= Window A
  924.                 1= Window B
  925.  
  926.     Output: AX=    Status
  927.         DX=    Window position in video memory 
  928.                 (in window granularity units)
  929.         See notes below
  930.  
  931.  
  932. Notes:
  933.  
  934. This function is also directly accessible through a far call
  935. from the application. The address of the BIOS function may be
  936. obtained by using VESA BIOS Function 01h, return Super VGA
  937. mode information. A field in the ModeInfoBlock contains the
  938. address of this function. Note that this function may be
  939. different among video modes in a particular BIOS
  940. implementation so the function pointer should be obtained
  941. after each set mode.
  942.  
  943. In the far call version, no status information is returned to
  944. the application. Also, in the far call version, the AX and DX
  945. registers will be destroyed. Therefore if AX and/or DX must be
  946. preserved, the application must do so prior to making the far
  947. call.
  948.  
  949. The application must load the input arguments in BH, BL, and
  950. DX (for set window) but does not need to load either AH or AL
  951. in order to use the far call version of this function.
  952.  
  953.  
  954.  
  955.  
  956.  
  957. 7.    Application example
  958.  
  959.  
  960. The following sequence illustrates how an application would
  961. interface to the VESA BIOS Extension. The hypothetical
  962. application is VESA-aware and calls the VESA BIOS functions.
  963. However, the application is not limited to supporting just
  964. VESA-defined video modes. Thus, it will inquire what video
  965. modes are available, before setting up the video mode.
  966.  
  967. 1)    The application would first allocate a 256 byte
  968. buffer. This buffer will be used by the VESA BIOS to return
  969. information about the video environment. Some applications
  970. will statically allocate this buffer, others will use system
  971. calls to temporarily obtain buffer space.
  972.  
  973. 2)    The application would then call VESA BIOS function 00h
  974. (Return Super VGA information). If the AX register does not
  975. contain 004Fh on return from the function call, the
  976. application can determine that the VESA BIOS Extension is not
  977. present and handle such situation.
  978.  
  979.     If no error code is passed in AX, the function call
  980. was successful. The buffer has been filled by the VESA BIOS
  981. Extension with various information. The application can verify
  982. that indeed this is a valid VESA block by identifying the
  983. characters 'VESA' in the beginning of the block. The
  984. application can inspect the VESAVersion field to determine
  985. whether the VESA BIOS Extension has sufficient functionality.
  986. The application may use the OEMStringPtr to locate OEM-
  987. specific information.
  988.  
  989.     Finally, the application can obtain a list of the
  990. supported Super VGA modes, by using the VideoModePtr. This
  991. field points to a list of the video modes supported by the
  992. video environment.
  993.  
  994. 3)    The application would then create a new buffer and
  995. call the VESA BIOS function 01h (Return Super VGA mode
  996. information), to obtain information about the supported video
  997. modes. Using the VideoModePtr, obtained in step 2 above, the
  998. application would call this function with a new mode number
  999. until a suitable video mode is found. If no appropriate video
  1000. mode is found, its up to the application to handle this
  1001. situation.
  1002.  
  1003.     The Return Super VGA mode information function fills a
  1004. buffer specified by the application with information
  1005. describing the features of the video mode. The data block
  1006. contains all the information an application needs to take
  1007. advantage of the video mode.
  1008.  
  1009.     The application would examine the ModeAttributes
  1010. field. To verify that the mode indeed is supported, the
  1011. application would inspect bits D0. If D0 is cleared, then the
  1012. mode is not supported by the hardware. This might happen if a
  1013. specific mode requires a certain type of monitor, but that
  1014. monitor is not present.
  1015.  
  1016. 4)    After the application has selected a video mode, the
  1017. next step is to initialize the mode. However, the application
  1018. might first want to save the present video mode. When the
  1019. application exits, this mode would be restored. To obtain the
  1020. present video mode, the VESA BIOS function 03h (Get Super VGA
  1021. mode), would be used. If a non-VESA (standard VGA or OEM-
  1022. specific) mode is in effect, only the lower byte in the mode
  1023. number is filled. The upper byte is cleared.
  1024.  
  1025. 5)    To initialize the video mode, the application would
  1026. use VESA BIOS function 02h (Set Super VGA mode). The
  1027. application has from this point on full access to the VGA
  1028. hardware and video memory.
  1029.  
  1030. 6)    When the application is about to terminate, it would
  1031. restore the prior video mode. The prior video, obtained in
  1032. step 4) above could be either a standard VGA mode, OEM-
  1033. specific mode, or VESA-supported mode. It would reinitialize
  1034. the video mode by calling VESA BIOS function 02h (Set Super
  1035. VGA mode). The application would then exit.
  1036.  
  1037.  
  1038.  
  1039. Footnotes:
  1040.  
  1041. 1 IBM and VGA are trademarks of International Business
  1042. Machines Corporation.
  1043. 2 The term "Super VGA" is used in this document as a term for
  1044. video graphics products implementing a superset of the
  1045. standard IBM VGA display adapter.
  1046. 1 Mandatory information
  1047. 2 Information provided only if bit D1 of Mode Attributes is
  1048. set
  1049.