Specifications.
[pintos-anon] / specs / freevga / vga / graphreg.htm
1 <HTML>
2 <HEAD>
3    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
4    <META NAME="Author" CONTENT="Joshua Neal">
5    <META NAME="Description" CONTENT="Pure VGA/SVGA hardware programming (registers, identification, and other low-level stuff.)">
6    <META NAME="KeyWords" CONTENT="VGA SVGA hardware video programming">
7    <TITLE>VGA/SVGA Video Programming--Graphics Registers</TITLE>
8 </HEAD>
9 <BODY>
10
11 <CENTER><A HREF="../home.htm">Home</A> <A HREF="vga.htm#register">Back</A>&nbsp;
12 <HR WIDTH="100%"><B>Hardware Level VGA and SVGA Video Programming Information
13 Page</B></CENTER>
14
15 <CENTER>Graphics Registers&nbsp;
16 <HR WIDTH="100%"></CENTER>
17
18
19 <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The Graphics Registers are
20 accessed via a pair of registers, the Graphics Address Register and the
21 Graphics Data Register. See the <A HREF="vgareg.htm">Accessing the VGA
22 Registers</A> section for more details. The Address Register is located
23 at port 3CEh and the Data Register is located at port 3CFh.
24 <UL>
25 <LI>
26 Index 00h -- Set/Reset Register</LI>
27
28 <LI>
29 Index 01h -- Enable Set/Reset Register</LI>
30
31 <LI>
32 Index 02h -- Color Compare Register</LI>
33
34 <LI>
35 Index 03h -- Data Rotate Register</LI>
36
37 <LI>
38 Index 04h -- Read Map Select Register</LI>
39
40 <LI>
41 Index 05h -- <I>Graphics Mode Register</I></LI>
42
43 <LI>
44 Index 06h -- <I>Miscellaneous Graphics Register</I></LI>
45
46 <LI>
47 Index 07h -- Color Don't Care Register</LI>
48
49 <LI>
50 Index 08h -- Bit Mask Register</LI>
51 </UL>
52 &nbsp;
53 <TABLE BORDER WIDTH="600" CELLPADING="2" >
54 <CAPTION ALIGN=TOP><A NAME="00"></A><B>Set/Reset Register (Index 00h)</B></CAPTION>
55
56 <TR ALIGN=CENTER VALIGN=CENTER>
57 <TD WIDTH="75">7</TD>
58
59 <TD WIDTH="75">6</TD>
60
61 <TD WIDTH="75">5</TD>
62
63 <TD WIDTH="75">4</TD>
64
65 <TD WIDTH="75">3</TD>
66
67 <TD WIDTH="75">2</TD>
68
69 <TD WIDTH="75">1</TD>
70
71 <TD WIDTH="75">0</TD>
72 </TR>
73
74 <TR ALIGN=CENTER VALIGN=CENTER>
75 <TD WIDTH="75"></TD>
76
77 <TD WIDTH="75"></TD>
78
79 <TD WIDTH="75"></TD>
80
81 <TD WIDTH="75"></TD>
82
83 <TD COLSPAN="4" WIDTH="300">Set/Reset</TD>
84 </TR>
85 </TABLE>
86 &nbsp;
87 <UL>
88 <LI>
89 <B>Set/Reset</B></LI>
90
91 <BR>Bits 3-0 of this field represent planes 3-0 of the VGA display memory.
92 This field is used by Write Mode 0 and Write Mode 3 (See the <A HREF="#05">Write
93 Mode</A> field.) In Write Mode 0, if the corresponding bit in the <A HREF="#01">Enable
94 Set/Reset</A> field is set, and in Write Mode 3 regardless of the <A HREF="#01">Enable
95 Set/Reset</A> field, the value of the bit in this field is expanded to
96 8 bits and substituted for the data of the respective plane and passed
97 to the next stage in the graphics pipeline, which for Write Mode 0 is the
98 <A HREF="#03">Logical Operation</A> unit and for Write Mode 3 is the <A HREF="#08">Bit
99 Mask</A> unit.</UL>
100 &nbsp;
101 <TABLE BORDER WIDTH="600" CELLPADING="2" >
102 <CAPTION ALIGN=TOP><A NAME="01"></A><B>Enable Set/Reset Register (Index
103 01h)</B></CAPTION>
104
105 <TR ALIGN=CENTER VALIGN=CENTER>
106 <TD WIDTH="75">7</TD>
107
108 <TD WIDTH="75">6</TD>
109
110 <TD WIDTH="75">5</TD>
111
112 <TD WIDTH="75">4</TD>
113
114 <TD WIDTH="75">3</TD>
115
116 <TD WIDTH="75">2</TD>
117
118 <TD WIDTH="75">1</TD>
119
120 <TD WIDTH="75">0</TD>
121 </TR>
122
123 <TR ALIGN=CENTER VALIGN=CENTER>
124 <TD WIDTH="75"></TD>
125
126 <TD WIDTH="75"></TD>
127
128 <TD WIDTH="75"></TD>
129
130 <TD WIDTH="75"></TD>
131
132 <TD COLSPAN="4" WIDTH="300">Enable Set/Reset</TD>
133 </TR>
134 </TABLE>
135 &nbsp;
136 <UL>
137 <LI>
138 <B>Enable Set/Reset</B></LI>
139
140 <BR>Bits 3-0 of this field represent planes 3-0 of the VGA display memory.
141 This field is used in Write Mode 0 (See the <A HREF="#05">Write Mode</A>
142 field) to select whether data for each plane is derived from host data
143 or from expansion of the respective bit in the <A HREF="#00">Set/Reset</A>
144 field.</UL>
145 &nbsp;
146 <TABLE BORDER WIDTH="600" CELLPADING="2" >
147 <CAPTION ALIGN=TOP><A NAME="02"></A><B>Color Compare Register (Index 02h)</B></CAPTION>
148
149 <TR ALIGN=CENTER VALIGN=CENTER>
150 <TD WIDTH="75">7</TD>
151
152 <TD WIDTH="75">6</TD>
153
154 <TD WIDTH="75">5</TD>
155
156 <TD WIDTH="75">4</TD>
157
158 <TD WIDTH="75">3</TD>
159
160 <TD WIDTH="75">2</TD>
161
162 <TD WIDTH="75">1</TD>
163
164 <TD WIDTH="75">0</TD>
165 </TR>
166
167 <TR ALIGN=CENTER VALIGN=CENTER>
168 <TD WIDTH="75"></TD>
169
170 <TD WIDTH="75"></TD>
171
172 <TD WIDTH="75"></TD>
173
174 <TD WIDTH="75"></TD>
175
176 <TD COLSPAN="4" WIDTH="300">Color Compare</TD>
177 </TR>
178 </TABLE>
179 &nbsp;
180 <UL>
181 <LI>
182 <B>Color Compare</B></LI>
183
184 <BR>Bits 3-0 of this field represent planes 3-0 of the VGA display memory.
185 This field holds a reference color that is used by Read Mode 1 (See the
186 <A HREF="#05">Read Mode</A> field.) Read Mode 1 returns the result of the
187 comparison between this value and a location of display memory, modified
188 by the <A HREF="#07">Color Don't Care</A> field.</UL>
189 &nbsp;
190 <TABLE BORDER WIDTH="600" CELLPADING="2" >
191 <CAPTION ALIGN=TOP><A NAME="03"></A><B>Data Rotate Register (Index 03h)</B></CAPTION>
192
193 <TR ALIGN=CENTER VALIGN=CENTER>
194 <TD WIDTH="75">7</TD>
195
196 <TD WIDTH="75">6</TD>
197
198 <TD WIDTH="75">5</TD>
199
200 <TD WIDTH="75">4</TD>
201
202 <TD WIDTH="75">3</TD>
203
204 <TD WIDTH="75">2</TD>
205
206 <TD WIDTH="75">1</TD>
207
208 <TD WIDTH="75">0</TD>
209 </TR>
210
211 <TR ALIGN=CENTER VALIGN=CENTER>
212 <TD WIDTH="75"></TD>
213
214 <TD WIDTH="75"></TD>
215
216 <TD WIDTH="75"></TD>
217
218 <TD COLSPAN="2" WIDTH="150">Logical Operation</TD>
219
220 <TD COLSPAN="3" WIDTH="225">Rotate Count</TD>
221 </TR>
222 </TABLE>
223 &nbsp;
224 <UL>
225 <LI>
226 <B>Logical Operation</B></LI>
227
228 <BR>This field is used in Write Mode 0 and Write Mode 2 (See the <A HREF="#05">Write
229 Mode</A> field.) The logical operation stage of the graphics pipeline is
230 32 bits wide (1 byte * 4 planes) and performs the operations on its inputs
231 from the previous stage in the graphics pipeline and the latch register.
232 The latch register remains unchanged and the result is passed on to the
233 next stage in the pipeline. The results based on the value of this field
234 are:
235 <UL>
236 <LI>
237 00b - Result is input from previous stage unmodified.</LI>
238
239 <LI>
240 01b - Result is input from previous stage logical ANDed with latch register.</LI>
241
242 <LI>
243 10b - Result is input from previous stage logical ORed with latch register.</LI>
244
245 <LI>
246 11b - Result is input from previous stage logical XORed with latch register.</LI>
247 </UL>
248
249 <LI>
250 <B>Rotate Count</B></LI>
251
252 <BR>This field is used in Write Mode 0 and Write Mode 3 (See the <A HREF="#05">Write
253 Mode</A> field.) In these modes, the host data is rotated to the right
254 by the value specified by the value of this field. A rotation operation
255 consists of moving bits 7-1 right one position to bits 6-0, simultaneously
256 wrapping bit 0 around to bit 7, and is repeated the number of times specified
257 by this field.</UL>
258 &nbsp;
259 <TABLE BORDER WIDTH="600" CELLPADING="2" >
260 <CAPTION ALIGN=TOP><A NAME="04"></A><B>Read Map Select Register (Index
261 04h)</B></CAPTION>
262
263 <TR ALIGN=CENTER VALIGN=CENTER>
264 <TD WIDTH="75">7</TD>
265
266 <TD WIDTH="75">6</TD>
267
268 <TD WIDTH="75">5</TD>
269
270 <TD WIDTH="75">4</TD>
271
272 <TD WIDTH="75">3</TD>
273
274 <TD WIDTH="75">2</TD>
275
276 <TD WIDTH="75">1</TD>
277
278 <TD WIDTH="75">0</TD>
279 </TR>
280
281 <TR ALIGN=CENTER VALIGN=CENTER>
282 <TD WIDTH="75"></TD>
283
284 <TD WIDTH="75"></TD>
285
286 <TD WIDTH="75"></TD>
287
288 <TD WIDTH="75"></TD>
289
290 <TD WIDTH="75"></TD>
291
292 <TD WIDTH="75"></TD>
293
294 <TD COLSPAN="2" WIDTH="150">Read Map Select</TD>
295 </TR>
296 </TABLE>
297 &nbsp;
298 <UL>
299 <LI>
300 <B>Read Map Select</B></LI>
301
302 <BR>This value of this field is used in Read Mode 0 (see the <A HREF="#05">Read
303 Mode</A> field) to specify the display memory plane to transfer data from.
304 Due to the arrangement of video memory, this field must be modified four
305 times to read one or more pixels values in the planar video modes.</UL>
306 &nbsp;
307 <TABLE BORDER WIDTH="600" CELLPADING="2" >
308 <CAPTION><A NAME="05"></A><B>Graphics Mode Register (Index 05h)</B></CAPTION>
309
310 <TR ALIGN=CENTER VALIGN=CENTER>
311 <TD WIDTH="75">7</TD>
312
313 <TD WIDTH="75">6</TD>
314
315 <TD WIDTH="75">5</TD>
316
317 <TD WIDTH="75">4</TD>
318
319 <TD WIDTH="75">3</TD>
320
321 <TD WIDTH="75">2</TD>
322
323 <TD WIDTH="75">1</TD>
324
325 <TD WIDTH="75">0</TD>
326 </TR>
327
328 <TR ALIGN=CENTER VALIGN=CENTER>
329 <TD WIDTH="75"></TD>
330
331 <TD WIDTH="75">Shift256</TD>
332
333 <TD>Shift Reg.</TD>
334
335 <TD WIDTH="75">Host O/E</TD>
336
337 <TD WIDTH="75">Read Mode</TD>
338
339 <TD WIDTH="75"></TD>
340
341 <TD COLSPAN="2" WIDTH="150">Write Mode</TD>
342 </TR>
343 </TABLE>
344 &nbsp;
345 <UL>
346 <LI>
347 <B>Shift256 -- 256-Color Shift Mode<BR>
348 </B>"<I>When set to 0, this bit allows bit 5 to control the loading of
349 the shift registers. When set to 1, this bit causes the shift registers
350 to be loaded in a manner that supports the 256-color mode.</I>"</LI>
351
352 <BR><B>Shift Reg. -- Shift Register Interleave Mode<BR>
353 </B>"<I>When set to 1, this bit directs the shift registers in the graphics
354 controller to format the serial data stream with even-numbered bits from
355 both maps on even-numbered maps, and odd-numbered bits from both maps on
356 the odd-numbered maps. This bit is used for modes 4 and 5.</I>"
357 <BR><B>Host O/E -- Host Odd/Even Memory Read Addressing Enable<BR>
358 </B>"<I>When set to 1, this bit selects the odd/even addressing mode used
359 by the IBM Color/Graphics Monitor Adapter. Normally, the value here follows
360 the value of Memory Mode register bit 2 in the sequencer.</I>"
361 <LI>
362 <B>Read Mode</B></LI>
363
364 <BR>This field selects between two read modes, simply known as Read Mode
365 0, and Read Mode 1, based upon the value of this field:
366 <UL>
367 <LI>
368 0b -- Read Mode 0: In this mode, a byte from one of the four planes is
369 returned on read operations. The plane from which the data is returned
370 is determined by the value of the <A HREF="#04">Read Map Select</A> field.</LI>
371 </UL>
372
373 <LI>
374 1b -- Read Mode 1: In this mode, a comparison is made between display memory
375 and a reference color defined by the <A HREF="#02">Color Compare</A> field.
376 Bit planes not set in the <A HREF="#07">Color Don't Care</A> field then
377 the corresponding color plane is not considered in the comparison. Each
378 bit in the returned result represents one comparison between the reference
379 color, with the bit being set if the comparison is true.</LI>
380
381 <LI>
382 <B>Write Mode</B></LI>
383
384 <BR>This field selects between four write modes, simply known as Write
385 Modes 0-3, based upon the value of this field:
386 <UL>
387 <LI>
388 00b -- Write Mode 0: In this mode, the host data is first rotated as per
389 the <A HREF="#03">Rotate Count</A> field, then the <A HREF="#01">Enable
390 Set/Reset</A> mechanism selects data from this or the <A HREF="#00">Set/Reset</A>
391 field. Then the selected <A HREF="#03">Logical Operation</A> is performed
392 on the resulting data and the data in the latch register. Then the <A HREF="#08">Bit
393 Mask</A> field is used to select which bits come from the resulting data
394 and which come from the latch register. Finally, only the bit planes enabled
395 by the <A HREF="seqreg.htm#02">Memory Plane Write Enable</A> field are
396 written to memory.</LI>
397
398 <LI>
399 01b -- Write Mode 1: In this mode, data is transferred directly from the
400 32 bit latch register to display memory, affected only by the <A HREF="seqreg.htm#02">Memory
401 Plane Write Enable</A> field. The host data is not used in this mode.</LI>
402
403 <LI>
404 10b -- Write Mode 2: In this mode, the bits 3-0 of the host data are replicated
405 across all 8 bits of their respective planes. Then the selected <A HREF="#03">Logical
406 Operation</A> is performed on the resulting data and the data in the latch
407 register. Then the <A HREF="#08">Bit Mask</A> field is used to select which
408 bits come from the resulting data and which come from the latch register.
409 Finally, only the bit planes enabled by the <A HREF="seqreg.htm#02">Memory
410 Plane Write Enable</A> field are written to memory.</LI>
411
412 <LI>
413 11b -- Write Mode 3: In this mode, the data in the <A HREF="#00">Set/Reset</A>
414 field is used as if the <A HREF="#01">Enable Set/Reset</A> field were set
415 to 1111b. Then the host data is first rotated as per the <A HREF="#03">Rotate
416 Count</A> field, then logical ANDed with the value of the <A HREF="#08">Bit
417 Mask</A> field. The resulting value is used on the data obtained from the
418 Set/Reset field in the same way that the <A HREF="#08">Bit Mask</A> field
419 would ordinarily be used. to select which bits come from the expansion
420 of the <A HREF="#00">Set/Reset</A> field and which come from the latch
421 register. Finally, only the bit planes enabled by the <A HREF="seqreg.htm#02">Memory
422 Plane Write Enable</A> field are written to memory.</LI>
423 </UL>
424 </UL>
425 &nbsp;
426 <TABLE BORDER WIDTH="600" CELLPADING="2" >
427 <CAPTION ALIGN=TOP><A NAME="06"></A><B>Miscellaneous Graphics Register
428 (Index 06h)</B></CAPTION>
429
430 <TR ALIGN=CENTER VALIGN=CENTER>
431 <TD WIDTH="75">7</TD>
432
433 <TD WIDTH="75">6</TD>
434
435 <TD WIDTH="75">5</TD>
436
437 <TD WIDTH="75">4</TD>
438
439 <TD WIDTH="75">3</TD>
440
441 <TD WIDTH="75">2</TD>
442
443 <TD WIDTH="75">1</TD>
444
445 <TD WIDTH="75">0</TD>
446 </TR>
447
448 <TR ALIGN=CENTER VALIGN=CENTER>
449 <TD WIDTH="75"></TD>
450
451 <TD WIDTH="75"></TD>
452
453 <TD WIDTH="75"></TD>
454
455 <TD WIDTH="75"></TD>
456
457 <TD COLSPAN="2" WIDTH="150">Memory Map Select</TD>
458
459 <TD WIDTH="75">Chain O/E</TD>
460
461 <TD WIDTH="75">Alpha Dis.</TD>
462 </TR>
463 </TABLE>
464 &nbsp;
465 <UL>
466 <LI>
467 <B>Memory Map Select<BR>
468 </B>This field specifies the range of host memory addresses that is decoded
469 by the VGA hardware and mapped into display memory accesses.&nbsp; The
470 values of this field and their corresponding host memory ranges are:</LI>
471
472 <UL>
473 <LI>
474 00b -- A0000h-BFFFFh (128K region)</LI>
475
476 <LI>
477 01b -- A0000h-AFFFFh (64K region)</LI>
478
479 <LI>
480 10b -- B0000h-B7FFFh (32K region)</LI>
481
482 <LI>
483 11b -- B8000h-BFFFFh (32K region)</LI>
484 </UL>
485 <B>Chain O/E -- Chain Odd/Even Enable<BR>
486 </B>"<I>When set to 1, this bit directs the system address bit, A0, to
487 be replaced by a higher-order bit. The odd map is then selected when A0
488 is 1, and the even map when A0 is 0.</I>"
489 <BR><B>Alpha Dis. -- Alphanumeric Mode Disable<BR>
490 </B>"<I>This bit controls alphanumeric mode addressing. When set to 1,
491 this bit selects graphics modes, which also disables the character generator
492 latches."</I></UL>
493 &nbsp;
494 <TABLE BORDER WIDTH="600" CELLPADING="2" >
495 <CAPTION ALIGN=TOP><A NAME="07"></A><B>Color Don't Care Register (Index
496 07h)</B></CAPTION>
497
498 <TR ALIGN=CENTER VALIGN=CENTER>
499 <TD WIDTH="75">7</TD>
500
501 <TD WIDTH="75">6</TD>
502
503 <TD WIDTH="75">5</TD>
504
505 <TD WIDTH="75">4</TD>
506
507 <TD WIDTH="75">3</TD>
508
509 <TD WIDTH="75">2</TD>
510
511 <TD WIDTH="75">1</TD>
512
513 <TD WIDTH="75">0</TD>
514 </TR>
515
516 <TR ALIGN=CENTER VALIGN=CENTER>
517 <TD WIDTH="75"></TD>
518
519 <TD WIDTH="75"></TD>
520
521 <TD WIDTH="75"></TD>
522
523 <TD WIDTH="75"></TD>
524
525 <TD COLSPAN="4" WIDTH="300">Color Don't Care</TD>
526 </TR>
527 </TABLE>
528 &nbsp;
529 <UL>
530 <LI>
531 <B>Color Don't Care</B></LI>
532
533 <BR>Bits 3-0 of this field represent planes 3-0 of the VGA display memory.
534 This field selects the planes that are used in the comparisons made by
535 Read Mode 1 (See the <A HREF="#05">Read Mode</A> field.) Read Mode 1 returns
536 the result of the comparison between the value of the <A HREF="#02">Color
537 Compare</A> field and a location of display memory. If a bit in this field
538 is set, then the corresponding display plane is considered in the comparison.
539 If it is not set, then that plane is ignored for the results of the comparison.</UL>
540 &nbsp;
541 <TABLE BORDER WIDTH="600" CELLPADING="2" >
542 <CAPTION ALIGN=TOP><A NAME="08"></A><B>Bit Mask Register (Index 08h)</B></CAPTION>
543
544 <TR ALIGN=CENTER VALIGN=CENTER>
545 <TD WIDTH="75">7</TD>
546
547 <TD WIDTH="75">6</TD>
548
549 <TD WIDTH="75">5</TD>
550
551 <TD WIDTH="75">4</TD>
552
553 <TD WIDTH="75">3</TD>
554
555 <TD WIDTH="75">2</TD>
556
557 <TD WIDTH="75">1</TD>
558
559 <TD WIDTH="75">0</TD>
560 </TR>
561
562 <TR ALIGN=CENTER VALIGN=CENTER>
563 <TD COLSPAN="8" WIDTH="600">Bit Mask</TD>
564 </TR>
565 </TABLE>
566 &nbsp;
567 <UL>
568 <LI>
569 <B>Bit Mask</B></LI>
570
571 <BR>This field is used in Write Modes 0, 2, and 3 (See the <A HREF="#05">Write
572 Mode</A> field.) It it is applied to one byte of data in all four display
573 planes. If a bit is set, then the value of corresponding bit from the previous
574 stage in the graphics pipeline is selected; otherwise the value of the
575 corresponding bit in the latch register is used instead. In Write Mode
576 3, the incoming data byte, after being rotated is logical ANDed with this
577 byte and the resulting value is used in the same way this field would normally
578 be used by itself.</UL>
579 Notice: All trademarks used or referred to on this page are the property
580 of their respective owners.
581 <BR>All pages are Copyright &copy; 1997, 1998, J. D. Neal, except where
582 noted. Permission for utilization and distribution is subject to the terms
583 of the <A HREF="license.htm">FreeVGA Project Copyright License</A>.
584 </BODY>
585 </HTML>