home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / EGA_VGA / XGAINFO.ZIP / XGA-INFO.TXT
Encoding:
Text File  |  1991-01-30  |  21.9 KB  |  421 lines

  1. XGA: A NEW GRAPHICS STANDARD
  2.  
  3. Combine a fast VGA, a graphics coprocessor, and bus mastering, and you
  4. have XGA
  5.  
  6. AUTHOR:  Jake Richter
  7.  
  8.  
  9.  
  10. Three and a half years after introducing both the VGA and 8514/A
  11. graphics standards, IBM has finally unveiled its next-generation PS/2
  12. graphics hardware -- the XGA (Extended Graphics Array).
  13.  
  14. In 1987, the VGA was shipped standard with the newly announced PS/2
  15. systems. Now the XGA is shipped as the default graphics display
  16. platform with IBM's newest PS/2s, the Model 90 XP 486 and the Model 95
  17. XP 486. In the desktop Model 90, the XGA is on the motherboard; in the
  18. Model 95 (a tower unit), it is located on a separate Micro Channel
  19. architecture add-in board. The XGA Display Adapter/A is also available
  20. for other 386- and i486-based PS/2s.
  21.  
  22. IBM's replacement of the VGA with the XGA as a default graphics
  23. platform is remarkable. A couple of years ago, rumors were rampant
  24. about IBM's implementing its 8514/A advanced graphics technology on
  25. PS/2 motherboards. But the 8514/A lacked one major feature that was
  26. necessary for this to occur: backward compatibility. The XGA's full
  27. VGA hardware compatibility eliminates this problem; therefore, it is
  28. suitable for a motherboard implementation.
  29.  
  30. In some ways, the XGA is a merger between the VGA and 8514/A graphics
  31. platforms. The table shows a feature comparison of several mass-market
  32. graphics hardware platforms demonstrating how the XGA has evolved.
  33.  
  34. The XGA Is Born
  35. The XGA was developed in the U.K. at IBM's Hursley Labs, as were the
  36. 8514/A and the niche-oriented Image Adapter/A. Therefore, it is not
  37. surprising that in its design the XGA maintains many of the 8514/A's
  38. features, although it accesses these features in a different fashion.
  39.  
  40. Some of the new features, such as bus mastering, are designed to take
  41. advantage of the Micro Channel architecture bus, which is standard in
  42. most PS/2s. Other features, such as a memory-mapped frame buffer and
  43. hardware cursor, provide greater flexibility over existing designs,
  44. easing the burden for software developers. Another boon to software
  45. developers is that IBM has released full register specifications for
  46. the XGA, unlike its tight-lipped approach to the 8514/A. An Adapter
  47. Interface comes with the XGA to provide backward compatibility for all
  48. those applications that supported the 8514/A via the Adapter
  49. Interface.
  50.  
  51. Multiple Modes
  52. The XGA has three distinct modes: VGA compatibility, 132-column VGA-
  53. compatible text, and extended graphics. The extended-graphics mode is
  54. the most interesting, since it provides higher resolutions and
  55. substantial graphics acceleration.
  56.  
  57. In addition to maintaining full compatibility with the VGA standard it
  58. originally created, IBM learned some lessons from the vast number of
  59. VGA clones out there and implemented a larger data path. The VGA mode,
  60. while still having only an 8-bit internal data path, supports a 32-
  61. bit-wide bus. It also has an internal write cache that allows the chip
  62. to break down and write the bus data without holding up the rest of
  63. the system with unnecessary wait states.
  64.  
  65. According to IBM documents, when the XGA is in VGA mode, it is up to
  66. 90 percent faster than the original VGA under DOS and up to 50 percent
  67. faster under Windows. Except for performance improvements, there is no
  68. change in VGA functionality in this mode.
  69.  
  70. It's important to note, however, that while you can have up to eight
  71. XGAs in one system (the configuration software only supports up to
  72. six), you can only have one VGA active in the system at any one time.
  73. Therefore, if you switch an XGA into VGA mode, you must ensure that no
  74. other VGA is active in the system; otherwise, the system might crash
  75. due to I/O conflicts.
  76.  
  77. Using the 132-column text mode (a VGA extension), you can display and
  78. manipulate 132 characters per line of text on the screen. The
  79. character width is 8 pixels for a virtual horizontal resolution of
  80. 1056. Character height depends on the font used, which means that you
  81. can have text screen resolutions of 132 by 43, 132 by 50, or 132 by 60
  82. pixels.
  83.  
  84. Currently, you can access the 132-column text mode only by manually
  85. manipulating the XGA registers. Ultimately, however, this mode will be
  86. accessible by switching into video mode 14 (hexadecimal). For all
  87. practical purposes, note that the 132-column text mode is a VGA mode
  88. and the same multiple-VGA caveat applies.
  89.  
  90. The extended-graphics mode has many exciting features, such as 65,536
  91. colors (i.e., 1024- by 768-pixel resolution), bus mastering, drawing
  92. acceleration, and the hardware cursor. While some of this mode's
  93. features are available in the other modes, most of the XGA registers
  94. and functions are dedicated for use in the extended-graphics mode.
  95.  
  96. XGA Registers
  97. The XGA design consists of video RAM, a type of dual-ported RAM
  98. designed for use in graphics-display systems; glue logic; and two
  99. custom chips, the graphics coprocessor and the display controller,
  100. which are the core of the XGA. The graphics coprocessor controls VGA
  101. compatibility, drawing functions, and memory management, and the
  102. display controller contains the RAM D/A converter (RAMDAC) with a
  103. color lookup table, the CRT controller, hardware cursor support, and a
  104. VRAM serializer (a device that extracts data from VRAM for display).
  105.  
  106. Access to the XGA is accomplished via two sets of registers: The first
  107. set is mapped into the system's I/O space, while the other set of
  108. registers is mapped into memory. The addresses of these registers
  109. vary, due to the configurability of the XGA. This variable addressing
  110. allows for multiple XGAs in the same system.
  111.  
  112. The I/O registers are mapped in at a hexadecimal I/O address of 21X0,
  113. where X is the instance (or occurrence) of the XGA. According to IBM,
  114. in systems with only one XGA, the instance is typically 6, resulting
  115. in a base hexadecimal I/O address of 2160.
  116.  
  117. The memory-mapped registers occupy 128 bytes of memory in the last
  118. kilobyte of an 8K-byte chunk. This chunk resides on an 8K-byte
  119. boundary anywhere between PC addresses 0C0000h and 0DFFFFh. The
  120. purpose of having an 8K-byte chunk is that the first 7K bytes of the
  121. chunk contains ROM data, but only on an XGA Display Adapter/A. The
  122. motherboard implementation of the XGA does not require its own ROM, as
  123. the main motherboard ROMs contain all the necessary information, such
  124. as XGA initialization code. The XGA instance number determines the
  125. location of the 128 bytes within the 8K-byte chunk.
  126.  
  127. The I/O registers pertain predominantly to the XGA's display
  128. controller. The memory-mapped registers, however, refer primarily to
  129. the graphics coprocessor. The XGA's power-on self test routines set
  130. the base addresses for both registers, and by examining the PS/2 POST
  131. registers for the XGA in question, you can determine the addresses.
  132.  
  133. Many of the memory-mapped registers are 32 bits in size, because the
  134. XGA is designed to fit into a 32-bit environment like that of the
  135. Intel 386 and i486. Also, due to the software support IBM developed
  136. for the XGA, it only works in a 386 or 386-based PS/2 (including
  137. 386SX-based PS/2s). The XGA also offers Motorola format addressing (a
  138. different byte ordering compared to an Intel format), which allows a
  139. Motorola 68000 or similar processor to take advantage of the XGA,
  140. assuming the XGA was ported to such hardware environs.
  141.  
  142. Initialization
  143. Initialization is a necessary step in using any graphics device. In
  144. the case of the XGA, initialization mainly involves setting the XGA
  145. into extended-graphics mode via the operating-mode register. You can
  146. then generate the proper CRT control register data for the desired
  147. resolution. Selectable resolutions are 640 by 480 and 1024 by 768
  148. pixels. But you can only access the 640- by 480-pixel by 65,536-color
  149. and 1024- by 768-pixel by 256-color modes with 1 megabyte of RAM.
  150.  
  151. The 16-bit-per-pixel (65,536-color) resolution provides almost perfect
  152. photo-realistic output. Thus, you can scan or capture a full-color
  153. picture and, using this 65,536-color mode, see an almost exact replica
  154. on your XGA screen. The 16-bit pixel is laid out as 5 bits of red, 6
  155. bits of green, and 5 bits of blue (5-6-5), or in other words, 32
  156. shades of blue, 64 shades of green, and 32 shades of blue -- in each
  157. pixel.
  158.  
  159. This configuration varies from the PC standard TARGA format of 5-5-5
  160. (1 bit is used for overlay) and the i860 format of 6-6-4. According to
  161. a technical contact at IBM, the 5-6-5 approach was used because of
  162. other similar implementations already in place in various IBM
  163. installations.
  164.  
  165. Apparently, the eye is also more sensitive to variations in green than
  166. in red or blue. (The reason for the choice of red, green, and blue is
  167. that these are the three color guns found in all color monitors. The
  168. beams from the three guns combine to display just about any color,
  169. depending on the intensity of each gun.)
  170.  
  171. The Display Controller
  172. You use the display controller during initialization, but it has other
  173. uses as well. Two such uses are the color lookup table and the sprite.
  174. The sprite is a 64- by 64-pixel block that overlays the screen.
  175.  
  176. You use the lookup table to translate the 1-, 2-, 4-, or 8-bit-pixel
  177. value into appropriate RGB values. The pixel value is used as an index
  178. into the lookup table. The resultant RGB values are then converted
  179. from digital levels into analog voltage levels via a built-in DAC.
  180.  
  181. As with the VGA and 8514/A, the XGA's lookup table supports 64 levels
  182. (6 bits) of each primary color, for a total of 262,144 possible color
  183. combinations. Thus, in a 256-color mode, you can choose 256 colors
  184. from this palette of 262,144.
  185.  
  186. Each pixel in the sprite has four possible values: sprite color 0,
  187. sprite color 1, transparent, and complement. Special registers define
  188. the sprite colors, and they let you specify the RGB values for each
  189. color. These RGB values are passed directly to the DAC. Their use
  190. permits applications to fully modify the local color palette without
  191. having to save two entries for the cursor or your having to worry
  192. about the cursor changing color as it goes over various portions of
  193. the display.
  194.  
  195. The transparency setting allows cursors that are smaller than 64 by 64
  196. pixels to be defined. Users who want a cursor that is always visible
  197. against any background can use the complement setting.
  198.  
  199. Task Switching
  200. One of the biggest headaches for systems software developers in
  201. creating a multitasking environment is saving the current state of the
  202. graphics hardware to allow another application to take over the
  203. graphics device. This state save also has to account for the
  204. possibility that the hardware might be in the middle of an operation
  205. or a palette update.
  206.  
  207. The XGA was apparently designed with task switching in mind, because
  208. it has extensive facilities for saving and restoring the state of the
  209. hardware, including interrupted operations.
  210.  
  211. Defining Drawing Space
  212. One of the XGA's features that is unique among current PC graphics
  213. standards is the use of bit maps, which must be defined to perform any
  214. drawing function. These bit maps are linear regions of memory that are
  215. defined with a pixel width, height, and depth (or bits per pixel). As
  216. such, an 8-bit-per-pixel bit map, with a width of 10 and a height of 6
  217. pixels, would require 60 bytes of memory. The last pixel/byte of a
  218. given line of the bit map is directly adjacent in memory to the first
  219. pixel/ byte in the following line.
  220.  
  221. The best feature of these bit maps is that they can exist anywhere in
  222. the system's address and memory space. Thus, if you define a bit map
  223. that resides in your program's data area, the XGA can draw into it or
  224. read from it, saving you the effort of manually copying data to and
  225. from the XGA (i.e., with your system processor).
  226.  
  227. The XGA VRAM is mapped into the system's address space so that when
  228. you want to specify it for a bit-map definition, you just use its
  229. address. The VRAM is usually located in the uppermost addresses of the
  230. 386's 4-gigabyte address space. As a result, there should never be a
  231. memory conflict.
  232.  
  233. Bus-Mastering Pitfalls
  234. When the XGA accesses a bit map, it determines whether the access is
  235. local (VRAM) or remote (system). For remote access, the XGA arbitrates
  236. for the bus and starts accessing system memory. Here is where the
  237. XGA's bus-mastering capability comes into play. There is additional
  238. overhead in the use of system memory for bit maps, beyond that being
  239. used for accessing local VRAM. But there is also the performance
  240. benefit of having the XGA processor manipulate memory while the system
  241. processor is doing something else.
  242.  
  243. This bus mastering has some potential pitfalls. The 386 and i486
  244. processors support virtual memory via an internal page-mapping table.
  245. The page-mapping table allows control applications, such as expanded-
  246. memory managers, DOS extenders, and advanced operating systems, to
  247. create virtual PC addresses 4K bytes (or a page) at a time. So, while
  248. the software application thinks it is writing data to address WWWWW,
  249. the page-mapping table might translate that address to physical
  250. address QQQQQ.
  251.  
  252. In many cases, there is no way for an application to know that the
  253. address it is using is not the physical address. And, to properly bus
  254. master, the XGA requires a physical address; otherwise, it may copy
  255. data to and from an incorrect address, with disastrous results. There
  256. is a possible solution to this dilemma, however, with some control
  257. software environments.
  258.  
  259. If an application has access to the control software's page-mapping
  260. table, it can pass this information to the XGA, which then makes use
  261. of the page-mapping table, and it can do its own virtual-to-physical
  262. address translations. Unfortunately, many control programs and
  263. operating systems do not provide access to the page-mapping table. In
  264. any case, regular DOS applications have the best chance of using bus
  265. mastering, because the first 640K bytes of memory are generally the
  266. least likely to be virtualized.
  267.  
  268. In addition to always having the VRAM mapped into high memory,
  269. software can map the XGA into a 64K-byte bank at either A0000h or
  270. B0000h, the standard PC video-memory addresses. Accessing different
  271. 64K-byte banks in the XGA's VRAM via this approach requires only that
  272. an index value be written into the aperture index register. This
  273. banking mechanism is handy for real-mode applications. Alternatively,
  274. the whole 1-MB chunk of VRAM can be mapped somewhere in the first 16
  275. MB of the system's memory, assuming there is no memory conflict. This
  276. type of mapping is useful only for protected-mode applications.
  277.  
  278. With respect to the bit maps, the XGA has three generic bit maps
  279. available for definition: maps A, B, and C. These maps are referenced
  280. when drawing commands are executed.
  281.  
  282. The drawing commands may require one or more bit maps: source,
  283. destination, and pattern. Source bit maps contain the data you want to
  284. either copy or use as a tile; destination bit maps are those into
  285. which you draw or copy data; and pattern bit maps contain a
  286. monochromatic (1-bit-per-pixel) pattern that you can use as an area
  287. pattern or a pixel-exclusion pattern.
  288.  
  289. The XGA also supports an additional map, referred to as the mask map.
  290. The mask map is a monochromatic bit map that you use to perform
  291. arbitrary clipping (i.e., a method of clipping to nongeometric
  292. shapes). When enabled, each 0 bit in the map indicates a pixel that
  293. should not be modified during a drawing operation, while a 1 bit is a
  294. signal to draw the applicable pixel. If the dimension of the mask map
  295. is smaller than that of the destination map for a given operation,
  296. then the outer edges of the mask map also define a clipping rectangle.
  297.  
  298. The mask map is extremely useful in windowing environments where you
  299. have overlapping windows, because you can draw on underlying windows
  300. without having to manually pre-clip all the objects you're drawing.
  301. Instead, you just define a mask map that permits drawing only in the
  302. exposed area of the desired window. A full-screen 1024- by 768-pixel
  303. mask map occupies only 96K bytes of memory. You can also partially
  304. enable a mask map so that it acts only as a clipping rectangle and
  305. does not perform the arbitrary pixel-by-pixel clip.
  306.  
  307. All four maps are defined via 5-pixel map registers. The first pixel
  308. in the bit map, which is in the upper left corner of a display bit
  309. map, has a coordinate of 0,0. The mask-map origin registers define the
  310. mask-map position over the destination map. All maps are limited to a
  311. height and width of 4096 by 4096 pixels.
  312.  
  313. Drawing with the XGA
  314. Before you can draw anything with the XGA, you must at least define
  315. the destination map for the operation you want to perform. Some
  316. operations also require a source map, such as a BitBlt. A BitBlt is an
  317. operation that copies bits from one place to another. The available
  318. drawing operations on the XGA are lines, short vectors, filled
  319. rectangles, BitBlts, and area fills.
  320.  
  321. Unfortunately, drawing lines is not as simple as just providing an x,y
  322. coordinate pair. The XGA uses a Bresenham line-drawing algorithm, but
  323. you must first calculate the initial Bresenham parameters, a process
  324. that creates a bit of overhead when drawing short lines.
  325. Coincidentally, the method for calculating these parameters is
  326. virtually identical to that used in drawing lines on the 8514/A. A
  327. description of this algorithm for optimized line drawing on computer
  328. displays can be found in Foley and Van Dam's Fundamentals of
  329. Interactive Computer Graphics (Addison-Wesley, 1982).
  330.  
  331. The XGA's short vectors are similar to the 8514/A's short stroke
  332. vectors. These vectors can be up to 15 pixels in length, and they can
  333. point in any direction that is a multiple of 45 degrees (e.g.,
  334. horizontal, vertical, and diagonal). The benefit of the XGA's short
  335. vectors is that the definition for each one consumes only a byte, and
  336. up to 4 bytes can be passed at a time, allowing for a quick data
  337. transfer rate and, therefore, a quick drawing rate.
  338.  
  339. Filled rectangles are quite straightforward. You just specify a width,
  340. height, and position, and off you go. BitBlts are similar to a filled
  341. rectangle except that you have to specify a source map as well as a
  342. destination map. The XGA also has the ability to perform a simple
  343. color-expansion BitBlt, one in which the source is monochromatic and
  344. each 0 bit is converted to one color and each 1 bit to another color.
  345. The destination map can be anything from 1 to 8 bits in depth. Color
  346. expansion is useful for displaying rendered fonts on a high-color-
  347. content screen or bit map.
  348.  
  349. Area fills are a modified rectangle fill in which the XGA graphics
  350. coprocessor uses the pattern map as a guideline for a scan conversion.
  351. This type of fill uses 1-bit flags to toggle the fill state as it
  352. scans each line in the pattern bit map. Initially, for each line, the
  353. fill state is off. On hitting a 1 bit, each subsequent pixel (or bit)
  354. in the pattern map is filled until the next 1 bit is encountered.
  355.  
  356. Lines, short vectors, and filled rectangles can also use a source map
  357. and a pattern map. You can use the pattern map for line patterns and
  358. area patterns, while you can use the source map for tiling a region
  359. (in the case of a filled rectangle) or for providing a color line
  360. pattern for lines and short vectors.
  361.  
  362. All the drawing functions are also affected by four types of drawing
  363. modifiers: drawing colors, mixes, color compare, and the pixel bit
  364. mask. Drawing colors are simple to use. The foreground color specifies
  365. what color you would normally draw in, while the background color
  366. specifies the color you would use in color expansions (for a 0 bit).
  367.  
  368. Mixes, known as raster operations or raster ops on other graphics
  369. platforms, provide a mechanism by which the destination pixel (the one
  370. in the destination map at the current drawing position) and the source
  371. pixel (the foreground color or source map pixel) are mixed. A typical
  372. mix is XOR, the exclusive OR operation, which is used for cursors and
  373. highlights.
  374.  
  375. You can use color compare during normal pixel updates to determine
  376. whether a given pixel should be updated, based on its color. The
  377. destination pixel value (or color) is compared to the destination
  378. color-compare value register by using the compare-operation set in the
  379. destination color-compare condition. Therefore, if the result of the
  380. comparison is TRUE, the pixel is not updated.
  381.  
  382. There are eight compare conditions: always TRUE, always FALSE, greater
  383. than, less than, equal to, not equal to, less than or equal to, and
  384. greater than or equal to. This color comparison can be useful in cases
  385. where you need to protect a range of colors from being updated, such
  386. as background and foreground objects in graphical scenery.
  387.  
  388. The pixel bit mask controls which bits in a pixel can be modified. Its
  389. biggest use is in protecting binary color ranges and planes of color.
  390.  
  391. Why XGA?
  392. From a technical standpoint, the XGA is a very elegant piece of work.
  393. It fixes just about all the problems that the 8514/A has had, except
  394. interlaced displays and simplified line drawing. The added features --
  395. definable bit maps, bus mastering, memory mapping, and state saving --
  396. are well thought out. Software developers who want to get the most out
  397. of the XGA should find them quite useful.
  398.  
  399. In addition, IBM has finally made the right move in providing full
  400. register-level documentation on the XGA. The lack of this type of
  401. documentation hurt the acceptance of the 8514/A. The fact that IBM has
  402. provided it for the XGA should increase the level of support it
  403. receives.
  404.  
  405. Because of its high-powered nature, the XGA will probably not have a
  406. serious effect on Super VGAs or 8514/A clones in the short term. But
  407. it is reasonable to expect XGA clones to be announced before the end
  408. of this year.
  409.  
  410. To obtain further technical information on the XGA, you can call IBM's
  411. technical books group directly at (800) 426-7282.
  412.  
  413.  
  414. ----------------------------------------------------------------------
  415. Jake Richter is the president of Panacea, Inc., a graphics software
  416. development and consulting company located in Londonderry, New
  417. Hampshire. He can be reached on BIX as "jrichter."
  418. ----------------------------------------------------------------------
  419.  
  420.  
  421.