home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 163 / VESA.ZIP / VESA.TXT
Text File  |  1990-12-11  |  41KB  |  984 lines

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