home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer 9 / 1995-08_Disc_9.iso / vesa / everex / vesa.doc < prev    next >
Text File  |  1990-01-11  |  40KB  |  861 lines

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