Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Mode 13h
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Standard 256-color mode on VGA graphics hardware}} {{multiple issues|{{more citations needed|date=May 2023}} {{original research|date=May 2023}}}} [[File:Birds VGA mode 13h 320x200.png|thumb|320x320px|Simulated image as displayed using VGA mode 13h resolution and color abilities (aspect ratio not corrected).]][[File:VGA palette with black borders.svg|thumb|257px|right|Default VGA 256-color palette]] '''Mode 13h''' is the standard 256-color mode on [[Video Graphics Array|VGA]] [[graphics hardware]] introduced in 1987 with the [[IBM PS/2]]. It has a resolution of {{resx|320x200}} [[pixels]].<ref name="Brown"/> It was used in [[computer games]] and [[art]]/[[animation software]] of the late 1980s and early to mid-1990s.{{citation needed|date=June 2024}} "13h" refers to the number of the mode in the VGA [[BIOS]]. The "h" stands for [[hexadecimal]]. Mode 13h provides [[programmers]] with a linear {{resx|320x200}} 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 (image)|aspect ratio]] of a {{resx|320x200}} [[Display resolution|resolution]] screen for use on a [[Fullscreen (aspect ratio)|4:3]] display, Mode 13h does not have [[Pixel aspect ratio|square pixels]].<ref>Fabien Sanglard, GAME ENGINE BLACK BOOK: WOLFENSTEIN 3D, 2nd edition, Chapter Hardware, page 59, freely available at https://fabiensanglard.net/gebb/index.html</ref> == Technical details == {{original research|section|date=February 2019}} Mode 13h is something of a curiosity, because the VGA is a [[planar (computer graphics)|planar]] device from a [[Hardware store|hardware]] perspective, and not suited to chunky graphics operation. The VGA has 256 [[Kibibyte|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 2<sup>14</sup> (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 [[Multi-Color Graphics Array|MCGA]] set of video modes, has [[List of monochrome and RGB color formats#18-bit RGB|18 bits of color]], 6 per RGB channel. The [[Palette (computing)|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 [[Digital-to-analog converter|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=== 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 == <code>13h</code> refers to the number 19 written in the hexadecimal notation in a format typical of assembly code for Intel processors. In [[C (programming language)|the C programming language]], hexadecimal 13 is written <code>0x13</code>. In [[x86 assembly language]] the video mode is entered by setting the ''AL'' register to 13h, the ''AH'' register to 0, and then calling [[INT 10h|BIOS interrupt 10h]].<ref name="Brown">{{cite web |url=http://www.ctyme.com/intr/rb-0069.htm |title=Ralf Brown's Interrupt List |access-date=2018-08-24 |author-first=Ralf D. |author-last=Brown |author-link=Ralf D. Brown}}</ref> The two 8-bit registers ''AL'' and ''AH'' comprise the 16-bit ''AX'' register. Although 13<sub>[[Hexadecimal|hex]]</sub> is 19 in decimal, in [[QuickBASIC]]'s screen mode numbering scheme it is simply screen mode 13 (not hexadecimal).<ref name="SCREEN_13">{{cite web |url=http://www.qbasicnews.com/qboho/qckadvr.m111213.shtml |title=Microsoft QuickBasic 4.5 Advisor |access-date=2007-07-19 |date=1990 |publisher=[[Microsoft]] |archive-date=2009-01-05 |archive-url=https://web.archive.org/web/20090105235430/http://www.qbasicnews.com/qboho/qckadvr.m111213.shtml |url-status=dead }}</ref> Many QuickBASIC screen modes have numbers which differ from the BIOS modes on which they are based.<ref>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 Card|Hercules graphics mode]], which has no standard BIOS support at all, and for [[Olivetti M24#CGA compatible video card|Olivetti/AT&T extended-CGA graphics modes]].</ref> === Source code examples === Assembly code to enter Mode 13h: <syntaxhighlight lang="asm"> mov ax, 0013h int 10h </syntaxhighlight> As an illustration of mode 13h in a video game source code, [[Wolfenstein 3D]] includes this function in a file named "ID_VL.C". It enters mode 13h by using two assembly instructions (prefixed with <code>asm</code>) embedded in the C source code.<ref>https://github.com/id-Software/wolf3d/blob/master/WOLFSRC/ID_VL.C#L108</ref> This function also executes three other functions. <syntaxhighlight lang="c"> void VL_SetVGAPlaneMode (void) { asm mov ax,0x13 asm int 0x10 VL_DePlaneVGA (); VGAMAPMASK(15); VL_SetLineWidth (40); } </syntaxhighlight> ''[[Wolfenstein 3D]] source code (circa 1992) which calls the BIOS to change to mode 13h.'' == References == {{reflist}} == External links == *[https://web.archive.org/web/20140702154140/http://www.brackeen.com/vga/index.html David Brackeen's 256-Color VGA Programming in C] *[https://web.archive.org/web/20080125222522/https://atrevida.comprenica.com/atrtut07.html Introduction to VGA ... Mode 13h] *[http://asm.inightmare.org/index.php?tutorial=1&location=11 Assembler for Dummies: Mode 13h] *[https://archive.org/details/ps-2-hardware-interface-technical-reference-ocr/PS2HardwareInterfaceTechnicalReference-OCR/page/n7/mode/2up IBM PS 2 Hardware Interface Technical Reference] [[Category:Computer display standards]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Citation needed
(
edit
)
Template:Cite web
(
edit
)
Template:Multiple issues
(
edit
)
Template:Original research
(
edit
)
Template:Reflist
(
edit
)
Template:Resx
(
edit
)
Template:Short description
(
edit
)