Jump to content

Mode 13h

From Wikipedia, the free encyclopedia
Simulated image as displayed using VGA mode 13h resolution and color abilities (aspect ratio not corrected).
Default VGA 256-color palette

Mode 13h is the standard 256-color mode on VGA graphics hardware introduced in 1987 with the IBM PS/2. It has a resolution of 320 × 200 pixels.[1] It was used in computer games and art/animation software of the late 1980s and early to mid-1990s.[citation needed] "13h" refers to the number of the mode in the VGA BIOS. The "h" stands for hexadecimal.

Mode 13h provides programmers with a linear 320 × 200 block of video memory, where each byte represents one pixel. This allows ease of programming at the expense of access to other useful features of the VGA hardware.

Given the aspect ratio of a 320 × 200 resolution screen for use on a 4:3 display, Mode 13h does not have square pixels.[2]

Technical details

[edit]

Mode 13h is something of a curiosity, because the VGA is a planar device from a hardware perspective, and not suited to chunky graphics operation. The VGA has 256 KiB of video memory consisting of 4 banks of 64 KiB, known as planes (or 'maps' in IBM's documentation). Planar memory arrangement splits the pixels horizontally into groups of four. For any given byte in the PC's 64 KiB video memory aperture, four pixels can be accessed on screen by selecting the required plane(s). This is more complicated for the programmer, but allows access to all of the available video memory and other benefits (see Mode X).

Mode 13h, however, allows the programmer to access the VGA in "chunky" (linear) fashion, where each consecutive address in the aperture represents a consecutive pixel on screen. Planes need not be manipulated to select the correct pixels to modify or read. This is achieved using the VGA 'Chain 4' setting in which the lowest two bits of the 16 bit aperture address are used to select the plane to write to/read from. The upshot is that the programmer has a simple access model; the downside is that now only 214 (16 KiB) of the video plane's address space are accessible (the other 2 bits being used to select planes) so only a total of 64 KiB is addressable (4 × 16 KiB). The upper 48 KiB of each plane remains unused in this mode.

Unlike SVGA and higher color depths, Mode 13h, part of the MCGA set of video modes, has 18 bits of color, 6 per RGB channel. The color palette data is not stored in memory per se, but rather modified, read and written to by low level I/O port calls, to the DAC registers.

The palette data was often copied from the low level ports one at a time to a spot in memory after the screen data so the colors could be saved along with the pixels they belonged to. A mode 13h screen capture is merely 64,000 bytes of values from 0 to 255, each an index of a color from a known palette of multiple colors. If the color palette is jumbled or totally wrong, a green leaf will appear blue, or any other possible color, depending on what that particular color was set for, which particular one out of 256.

Due to the way chunks of memory are allocated in such an environment, the bytes in segment 0xA000 from offset 64000 to 64768, can be written to with no negative effects. This lets the programmer save the additional bytes, 256 (colors) × 3 (color channels) = 768 bytes, at the end of the screen capture file. These have to be read back out again and written to the color port for them to change, when an image containing a footer of color info gets loaded. A method used with this was to have a global palette, and match the colors from an old color palette, to a new color palette. This meant changing the index of each pixel, where it would point to a near perfect match of one color from old to new color set. This also had drawbacks, as sometimes there were not enough gradients, and artifacts and such would appear.

It is not essential to set the graphics mode through the BIOS; it is possible to switch graphics mode in 32-bit protected mode, if a little more complicated. It involves writing size data to the VGA controller.

Variants

[edit]

An alternative planar 256-color mode is available by disabling Chain 4 mode (unchaining). Video modes created using this technique are collectively called Mode X, though the original use of that term was for a VGA mode which also had square pixels. While these modes (along with very many other possible VGA modes) were not specifically documented by IBM, the VGA hardware functions and features used to implement them were documented at least as early as 1988, in the PS/2 Hardware Interface Technical Reference.

Notation

[edit]

In x86 assembly language the mode is entered when AL is 13h, AH is 0 and BIOS 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.[3] QuickBASIC has its own screen mode numbering scheme, and many QuickBASIC screen modes have numbers which differ from the BIOS modes on which they are based.[4] In C, hexadecimal 13 is written 0x13.

References

[edit]
  1. ^ a b Brown, Ralf D. "Ralf Brown's Interrupt List". Retrieved 2018-08-24.
  2. ^ Fabien Sanglard, GAME ENGINE BLACK BOOK: WOLFENSTEIN 3D, 2nd edition, Chapter Hardware, page 59, freely available at https://fabiensanglard.net/gebb/index.html
  3. ^ "Microsoft QuickBasic 4.5 Advisor". Microsoft. 1990. Archived from the original on 2009-01-05. Retrieved 2007-07-19.
  4. ^ A major example is QuickBASIC screen mode 0, which covers all of the BIOS text modes 00h..03h. Also, QuickBASIC screen modes 1 and 2 correspond to the CGA BIOS modes 04h through 06h. Further note that QuickBASIC has modes for the Hercules graphics mode, which has no standard BIOS support at all, and for Olivetti/AT&T extended-CGA graphics modes.
[edit]
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy