Mode 13h

From Wikipedia, the free encyclopedia

VGA 256 color palette
VGA 256 color palette

Mode 13h is the IBM VGA BIOS mode number for a specific standard 256 color mode on IBM's VGA graphics hardware. It features a resolution of 320×200 pixels[1] and was used extensively in computer games and art/animation software of the late 1980s and early- to mid-1990s. Mode 13h provides a straightforward manner of access (nicknamed chunky graphics) to video memory at the expense of some useful features the VGA hardware was capable of providing. Due to the aspect ratio of a 320×200 resolution screen, Mode 13h does not have square pixels.

Contents

[edit] Technical layout

Mode 13h is something of a curiosity, because the VGA is a planar device from a hardware perspective, and somewhat unsuited for chunky graphics operation. It was made possible by a hardware trick. In order to understand how Mode 13h was possible, one must consider the VGA's memory layout:

The VGA's 256K of video memory is not directly available to the programmer and is accessed via a 64KB 'window' in the PC's real mode address space. The Video RAM is actually a bank of 4 planes, 64KB each. By manipulating the VGA's control registers the programmer can decide how some or all of these 4 planes will be affected by each write or read operation. In 256 color mode each plane represents a pixel. For example, on the first line of the screen pixels 0, 4, 8, 12 etc. are all contained in memory plane 0, while pixels 1, 5, 9, 13 etc. are contained in memory plane 1 and so on. A single byte written to the 64K window therefore can address up to 4 pixels at once. The programmer through a combination of the 64K window available, and the selection of any of the four planes (an effective extra two bits of address space) allows the manipulation of the total 256K video memory.

Mode 13h, however, allows the programmer to access the VGA in "chunky" fashion, where every byte represents a single pixel. This is made possible because in Mode 13h the hardware uses the last two bits of the address to select the plane to write to. The upshot is that the programmer has a simple access model; the downside is that three quarters of the video memory is now inaccessible. A simple bank switching method could have made the remaining memory available, and indeed bank switching was made available on Super VGAs to access the larger VRAMs these devices sported.

Although never documented by IBM, an alternative planar 256 color mode is available by "unchaining" the video ram; video modes created using this technique are collectively called Mode X.

[edit] Notation

The "h" in Mode 13h stands for "hexadecimal"; it is actually VGA mode 19 in decimal. In x86 assembly language the mode is entered when AL is 13h, AH is 0 and INT 10h is executed.[1] However, the "h" is sometimes dropped for languages that don't support that method of notation; for example, it is known as screen mode 13 in QuickBasic and its spinoffs.[2] In C, it is written 0x13.

[edit] References

  1. ^ a b Ralf Brown. Ralf Brown's Interrupt List. Retrieved on 2007-07-15.
  2. ^ Microsoft QuickBasic 4.5 Advisor. Microsoft (1990). Retrieved on 2007-07-19.

[edit] External links

Languages