1vga_setmode(3) Svgalib User Manual vga_setmode(3)
2
3
4
6 vga_setmode - sets a video mode
7
9 #include <vga.h>
10
11 int vga_setmode(int mode);
12
13
15 vga_setmode(int mode) selects the video mode given and clears the
16 screen (if it was a graphics mode). Basically this should be the first
17 action of your application after calling vga_init(3) and finding out
18 which mode to use. Prior to exiting your application should call
19 vga_setmode(TEXT).
20
21 vga_setmode() returns 0 on success and -1 if this mode is not avail‐
22 able.
23
24 From svgalib-1.4.1, if mode is -1 then vga_setmode() returns the cur‐
25 rent svgalib version, in BCD format, so svgalib 1.4.1 returns 0x1410.
26
27 mode should be one of the following, predefined values, or generally a
28 value in range 1 <= mode <= vga_lastmodenumber() where vga_modeinfo(3)
29 returned details about this mode. Instead of trying to set the mode,
30 vga_hasmode(3) determines if the mode would actually be supported. It
31 is also possible to use the numeric values given below though this is
32 discouraged. They are commonly used as values for the
33 SVGALIB_DEFAULT_MODE environment variable to set the vga_getdefault‐
34 mode(3).
35
36 Here are the predefined values for mode.
37
38 Text mode
39 TEXT(0) restores textmode and falls back to ordinary text console han‐
40 dling. All other calls switch to a graphics mode. You should set this
41 mode prior to exiting an svgalib application.
42
43 VGA compatible graphics modes
44 In general, for all modes following, the first number is the amount of
45 x pixels, the second the amount of y pixels, the third the number of
46 colors, with shortcuts 32K, 64K, 16M, 16M4 for 32768, 65536, and
47 1677721. Those with 2 or more than 256 colors use fixed color mappings
48 (either black and white or some RGB true/high color) the others make
49 use of a color lookup table.
50
51 Memory layout for the VGA modes is weird. Too weird to be explained
52 here, but you can check the usual VGA literature. vga_setmodeX(3) has
53 a short explanation which is valid for all 256 color modes.
54
55 G320x200x16(1), G640x200x16(2), G640x350x16(3), G640x480x16(4),
56 G320x200x256(5), G320x240x256(6), G320x400x256(7), G360x480x256(8), and
57 G640x480x2(9)
58
59
60 Basic SVGA modes
61 These use linear 256 color memory layouts similar to G320x200x256.
62
63 G640x480x256(10), G800x600x256(11), G1024x768x256(12), and
64 G1280x1024x256(13)
65
66
67 High color SVGA modes
68 These also use linear memory layouts, but for 32K & 64K each pixel
69 occupies two bytes and three for 16M. For 32K, each 16 bit word is
70 divided into 555 bit portions refering to 5 bit red, green, blue part.
71 The most significant bit is ignored by the card. For 64K the division
72 is 565 allowing to specify green in a little bit more detail (Human
73 eyes are more sensitive to green. People joke this is because our
74 ancestors lived in trees where light was filtered through green
75 leaves).
76
77 For the 16M modes, from low to high addresses the 3 bytes are named BGR
78 and specify the blue, green, red parts of the pixel value.
79
80 G320x200x32K(14), G320x200x64K(15), G320x200x16M(16), G640x480x32K(17),
81 G640x480x64K(18), G640x480x16M(19), G800x600x32K(20), G800x600x64K(21),
82 G800x600x16M(22), G1024x768x32K(23), G1024x768x64K(24),
83 G1024x768x16M(25), G1280x1024x32K(26), G1280x1024x64K(27), and
84 G1280x1024x16M(28)
85
86
87 High resolutions with less color numbers.
88 Memory layout is probably one nibble per pixel, two pixels per byte in
89 a linear fashion where the most significant nibble is the left most
90 pixel.
91
92 G800x600x16(29), G1024x768x16(30), and G1280x1024x16(31)
93
94
95 Hercules emulation mode
96 Again check out the ordinary VGA literature for the memory layout.
97
98 G720x348x2(32)
99
100
101 32-bit per pixel modes
102 These are similar to 16M but each pixel uses four bytes. The first
103 three are similar to 16M but the fourth is left empty and ignored by
104 the VGA card (you can store own status there).
105
106 This eases pixel address calculations on the screen and drawing opera‐
107 tions. However, 1/3 more data has to be moved to the screen. Experi‐
108 ments show that usually the higher memory bandwidth used outweighs the
109 effects of the simplified algorithms by far.
110
111 G320x200x16M32(33), G640x480x16M32(34), G800x600x16M32(35),
112 G1024x768x16M32(36), and G1280x1024x16M32(37)
113
114
115 Some more resolutions
116 It should by now be clear how the modes will look.
117
118 G1152x864x16(38), G1152x864x256(39), G1152x864x32K(40),
119 G1152x864x64K(41), G1152x864x16M(42), G1152x864x16M32(43),
120 G1600x1200x16(44), G1600x1200x256(45), G1600x1200x32K(46),
121 G1600x1200x64K(47), G1600x1200x16M(48), and G1600x1200x16M32(49)
122
123
124 The vgatest(6) produces a list of supported modes for your hardware,
125 prints some info on the modes and allows you to try each of them.
126
128 svgalib(7), vgagl(7), libvga.config(5), vgatest(6), vga_hasmode(3),
129 vga_init(3), vga_modeinfo(3), vga_getcurrentmode(3), vga_getdefault‐
130 mode(3), vga_lastmodenumber(3), vga_getmodename(3), vga_getmodenum‐
131 ber(3)
132
134 This manual page was edited by Michael Weller <eowmob@exp-math.uni-
135 essen.de>. The exact source of the referenced function as well as of
136 the original documentation is unknown.
137
138 It is very likely that both are at least to some extent are due to Harm
139 Hanemaayer <H.Hanemaayer@inter.nl.net>.
140
141 Occasionally this might be wrong. I hereby asked to be excused by the
142 original author and will happily accept any additions or corrections to
143 this first version of the svgalib manual.
144
145
146
147Svgalib 1.4.1 28 Jul 1999 vga_setmode(3)