MentOS  0.8.0
The Mentoring Operating System
vga_mode.h
Go to the documentation of this file.
1 
6 #pragma once
7 
9 typedef struct {
10  unsigned char misc;
12  struct {
13  unsigned char reset;
14  unsigned char clocking_mode;
15  unsigned char map_mask;
16  unsigned char character_map_select;
17  unsigned char sequencer_memory_mode;
18  } sc;
20  struct {
21  unsigned char horizontal_total;
22  unsigned char end_horizontal_display;
23  unsigned char start_horizontal_blanking;
24  unsigned char end_horizontal_blanking;
25  unsigned char start_horizontal_retrace;
26  unsigned char end_horizontal_retrace;
27  unsigned char vertical_total;
28  unsigned char overflow;
29  unsigned char preset_row_scan;
30  unsigned char maximum_scan_line;
31  unsigned char cursor_start;
32  unsigned char cursor_end;
33  unsigned char start_address_high;
34  unsigned char start_address_low;
35  unsigned char cursor_location_high;
36  unsigned char cursor_location_low;
37  unsigned char vertical_retrace_start;
38  unsigned char vertical_retrace_end;
39  unsigned char vertical_display_end;
40  unsigned char offset;
41  unsigned char underline_location;
42  unsigned char start_vertical_blanking;
43  unsigned char end_vertical_blanking;
44  unsigned char crtc_mode_control;
45  unsigned char line_compare;
46  } crtc;
48  struct {
49  unsigned char set_reset;
50  unsigned char enable_set_reset;
51  unsigned char color_compare;
52  unsigned char data_rotate;
53  unsigned char read_map;
54  unsigned char graphics_mode;
55  unsigned char misc_graphics;
56  unsigned char color_dont_care;
57  unsigned char bit_mask;
58  } gc;
60  struct {
61  unsigned char internal_palette_registers[16];
62  unsigned char attribute_mode_control;
63  unsigned char overscan_color;
64  unsigned char color_plane_enable;
65  unsigned char horizontal_pixel_panning;
66  unsigned char color_select;
67  } ac;
68 } vga_mode_t;
69 
72  // 3C2h (W): Miscellaneous Output Register
73  // bit 0 If set Color Emulation:
74  // Base Address = 3Dxh else Mono Emulation.
75  // Base Address = 3Bxh.
76  // 1 Enable CPU Access to video memory if set
77  // 2-3 Clock Select:
78  // 00: 25MHz (used for 320/640 pixel wide modes),
79  // 01: 28MHz (used for 360/720 pixel wide modes)
80  // 5 When in Odd/Even modes Select High 64k bank if set
81  // 6 Horizontal Sync Polarity. Negative if set
82  // 7 Vertical Sync Polarity. Negative if set
83  // Bit 6-7 indicates the number of lines on the display:
84  // 1: 400, 2: 350, 3: 480
85  // Note: Set to all zero on a hardware reset.
86  // Note: This register can be read from port 3CCh.
87  .misc = 0x67, // 0110 0011
88  .sc = {
89  .reset = 0x03, // 0000 0011 - Bits 1 and 0 must be 1 to allow the sequencer to operate.
90  .clocking_mode = 0x00, // 0000 0001 - Selects 8 dots per character.
91  .map_mask = 0x03, // 0000 1111 - Write operations affect all the planes.
92  .character_map_select = 0x00, // 0000 0000 - No Character Map Select
93  .sequencer_memory_mode = 0x02, // 0000 0110 - System addresses sequentially access data within a bit map.
94  // Enables the video memory from 64KB to 256KB
95  },
96  .crtc = {
97  .horizontal_total = 0x5F, // 95 (+5) - Number of character clocks per scan line.
98  .end_horizontal_display = 0x4F, //
99  .start_horizontal_blanking = 0x50,
100  .end_horizontal_blanking = 0x82,
101  .start_horizontal_retrace = 0x55,
102  .end_horizontal_retrace = 0x81,
103  .vertical_total = 0xBF,
104  .overflow = 0x1F,
105  .preset_row_scan = 0x00,
106  .maximum_scan_line = 0x4F,
107  .cursor_start = 0x0D,
108  .cursor_end = 0x0E,
109  .start_address_high = 0x00,
110  .start_address_low = 0x00,
111  .cursor_location_high = 0x00,
112  .cursor_location_low = 0x50,
113  .vertical_retrace_start = 0x9C,
114  .vertical_retrace_end = 0x0E,
115  .vertical_display_end = 0x8F,
116  .offset = 0x28,
117  .underline_location = 0x1F,
118  .start_vertical_blanking = 0x96,
119  .end_vertical_blanking = 0xB9,
120  .crtc_mode_control = 0xA3, // 0xA3 1010 0011
121  .line_compare = 0xFF,
122  },
123  .gc = {
124  .set_reset = 0x00,
125  .enable_set_reset = 0x00,
126  .color_compare = 0x00,
127  .data_rotate = 0x00,
128  .read_map = 0x00,
129  .graphics_mode = 0x10,
130  .misc_graphics = 0x0E,
131  .color_dont_care = 0x00,
132  .bit_mask = 0xFF,
133  },
134  .ac = {
135  .internal_palette_registers = {
136  0x00,
137  0x01,
138  0x02,
139  0x03,
140  0x04,
141  0x05,
142  0x14,
143  0x07,
144  0x38,
145  0x39,
146  0x3A,
147  0x3B,
148  0x3C,
149  0x3D,
150  0x3E,
151  0x3F,
152  },
153  .attribute_mode_control = 0x0C,
154  .overscan_color = 0x00,
155  .color_plane_enable = 0x0F,
156  .horizontal_pixel_panning = 0x08,
157  .color_select = 0x00,
158  }
159 };
160 
163  // 3C2h (W): Miscellaneous Output Register
164  // bit 0 If set Color Emulation:
165  // Base Address = 3Dxh else Mono Emulation.
166  // Base Address = 3Bxh.
167  // 1 Enable CPU Access to video memory if set
168  // 2-3 Clock Select:
169  // 00: 25MHz (used for 320/640 pixel wide modes),
170  // 01: 28MHz (used for 360/720 pixel wide modes)
171  // 5 When in Odd/Even modes Select High 64k bank if set
172  // 6 Horizontal Sync Polarity. Negative if set
173  // 7 Vertical Sync Polarity. Negative if set
174  // Bit 6-7 indicates the number of lines on the display:
175  // 1: 400, 2: 350, 3: 480
176  // Note: Set to all zero on a hardware reset.
177  // Note: This register can be read from port 3CCh.
178  .misc = 0x63, // 0110 0011
179  .sc = {
180  .reset = 0x03, // 0000 0011 - Bits 1 and 0 must be 1 to allow the sequencer to operate.
181  .clocking_mode = 0x01, // 0000 0001 - Selects 8 dots per character.
182  .map_mask = 0x0F, // 0000 1111 - Write operations affect all the planes.
183  .character_map_select = 0x00, // 0000 0000 - No Character Map Select
184  .sequencer_memory_mode = 0x06, // 0000 0110 - System addresses sequentially access data within a bit map.
185  // Enables the video memory from 64KB to 256KB
186  },
187  .crtc = {
188  .horizontal_total = 0x5F, // 95 (+5) - Number of character clocks per scan line.
189  .end_horizontal_display = 0x4F, //
190  .start_horizontal_blanking = 0x50,
191  .end_horizontal_blanking = 0x82,
192  .start_horizontal_retrace = 0x54,
193  .end_horizontal_retrace = 0x80,
194  .vertical_total = 0xBF,
195  .overflow = 0x1F,
196  .preset_row_scan = 0x00,
197  .maximum_scan_line = 0x41,
198  .cursor_start = 0x00,
199  .cursor_end = 0x00,
200  .start_address_high = 0x00,
201  .start_address_low = 0x00,
202  .cursor_location_high = 0x00,
203  .cursor_location_low = 0x00,
204  .vertical_retrace_start = 0x9C,
205  .vertical_retrace_end = 0xE3,
206  .vertical_display_end = 0x8F,
207  .offset = 0x28,
208  .underline_location = 0x40,
209  .start_vertical_blanking = 0x96,
210  .end_vertical_blanking = 0xB9,
211  .crtc_mode_control = 0xA3, // 0xA3 1010 0011
212  .line_compare = 0xFF,
213  },
214  .gc = {
215  .set_reset = 0x00,
216  .enable_set_reset = 0x00,
217  .color_compare = 0x00,
218  .data_rotate = 0x00,
219  .read_map = 0x00,
220  .graphics_mode = 0x40,
221  .misc_graphics = 0x05,
222  .color_dont_care = 0x0F,
223  .bit_mask = 0xFF,
224  },
225  .ac = {
226  .internal_palette_registers = {
227  0x00,
228  0x01,
229  0x02,
230  0x03,
231  0x04,
232  0x05,
233  0x06,
234  0x07,
235  0x08,
236  0x09,
237  0x0A,
238  0x0B,
239  0x0C,
240  0x0D,
241  0x0E,
242  0x0F,
243  },
244  .attribute_mode_control = 0x41,
245  .overscan_color = 0x00,
246  .color_plane_enable = 0x0F,
247  .horizontal_pixel_panning = 0x00,
248  .color_select = 0x00,
249  }
250 };
251 
254  // 3C2h (W): Miscellaneous Output Register
255  // bit 0 If set Color Emulation:
256  // Base Address = 3Dxh else Mono Emulation.
257  // Base Address = 3Bxh.
258  // 1 Enable CPU Access to video memory if set
259  // 2-3 Clock Select:
260  // 00: 25MHz (used for 320/640 pixel wide modes),
261  // 01: 28MHz (used for 360/720 pixel wide modes)
262  // 5 When in Odd/Even modes Select High 64k bank if set
263  // 6 Horizontal Sync Polarity. Negative if set
264  // 7 Vertical Sync Polarity. Negative if set
265  // Bit 6-7 indicates the number of lines on the display:
266  // 1: 400, 2: 350, 3: 480
267  // Note: Set to all zero on a hardware reset.
268  // Note: This register can be read from port 3CCh.
269  .misc = 0xE3, // 1110 0011
270  .sc = {
271  .reset = 0x03, // 0000 0011 - Bits 1 and 0 must be 1 to allow the sequencer to operate.
272  .clocking_mode = 0x01, // 0000 0001 - Selects 8 dots per character.
273  .map_mask = 0x0F, // 0000 1111 - Write operations affect all the planes.
274  .character_map_select = 0x00, // 0000 0000 - No Character Map Select
275  .sequencer_memory_mode = 0x06, // 0000 0110 - System addresses sequentially access data within a bit map.
276  // Enables the video memory from 64KB to 256KB
277  },
278  .crtc = {
279  .horizontal_total = 0x5F, // 95 (+5) - Number of character clocks per scan line.
280  .end_horizontal_display = 0x4F, //
281  .start_horizontal_blanking = 0x50,
282  .end_horizontal_blanking = 0x82,
283  .start_horizontal_retrace = 0x54,
284  .end_horizontal_retrace = 0x80,
285  .vertical_total = 0x0B,
286  .overflow = 0x3E,
287  .preset_row_scan = 0x00,
288  .maximum_scan_line = 0x40,
289  .cursor_start = 0x00,
290  .cursor_end = 0x00,
291  .start_address_high = 0x00,
292  .start_address_low = 0x00,
293  .cursor_location_high = 0x00,
294  .cursor_location_low = 0x00,
295  .vertical_retrace_start = 0xEA,
296  .vertical_retrace_end = 0x0C,
297  .vertical_display_end = 0xDF,
298  .offset = 0x28,
299  .underline_location = 0x00,
300  .start_vertical_blanking = 0xE7,
301  .end_vertical_blanking = 0x04,
302  .crtc_mode_control = 0xE3,
303  .line_compare = 0xFF,
304  },
305  .gc = {
306  .set_reset = 0x00,
307  .enable_set_reset = 0x00,
308  .color_compare = 0x00,
309  .data_rotate = 0x00,
310  .read_map = 0x03,
311  .graphics_mode = 0x00,
312  .misc_graphics = 0x05,
313  .color_dont_care = 0x0F,
314  .bit_mask = 0xFF,
315  },
316  .ac = {
317  .internal_palette_registers = {
318  0x00,
319  0x01,
320  0x02,
321  0x03,
322  0x04,
323  0x05,
324  0x14,
325  0x07,
326  0x38,
327  0x39,
328  0x3A,
329  0x3B,
330  0x3C,
331  0x3D,
332  0x3E,
333  0x3F,
334  },
335  .attribute_mode_control = 0x01, // 0b01000001, // 0x41,
336  .overscan_color = 0x00,
337  .color_plane_enable = 0x0F,
338  .horizontal_pixel_panning = 0x00,
339  .color_select = 0x00,
340  }
341 };
342 
345  // 3C2h (W): Miscellaneous Output Register
346  // bit 0 If set Color Emulation:
347  // Base Address = 3Dxh else Mono Emulation.
348  // Base Address = 3Bxh.
349  // 1 Enable CPU Access to video memory if set
350  // 2-3 Clock Select:
351  // 00: 25MHz (used for 320/640 pixel wide modes),
352  // 01: 28MHz (used for 360/720 pixel wide modes)
353  // 5 When in Odd/Even modes Select High 64k bank if set
354  // 6 Horizontal Sync Polarity. Negative if set
355  // 7 Vertical Sync Polarity. Negative if set
356  // Bit 6-7 indicates the number of lines on the display:
357  // 1: 400, 2: 350, 3: 480
358  // Note: Set to all zero on a hardware reset.
359  // Note: This register can be read from port 3CCh.
360  .misc = 0xE7, // 1110 0011
361  .sc = {
362  .reset = 0x03, // 0000 0011 - Bits 1 and 0 must be 1 to allow the sequencer to operate.
363  .clocking_mode = 0x01, // 0000 0001 - Selects 8 dots per character.
364  .map_mask = 0x08, // 0000 1111 - Write operations affect all the planes.
365  .character_map_select = 0x00, // 0000 0000 - No Character Map Select
366  .sequencer_memory_mode = 0x06, // 0000 0110 - System addresses sequentially access data within a bit map.
367  // Enables the video memory from 64KB to 256KB
368  },
369  .crtc = {
370  .horizontal_total = 0x6B, // 95 (+5) - Number of character clocks per scan line.
371  .end_horizontal_display = 0x59, //
372  .start_horizontal_blanking = 0x5A,
373  .end_horizontal_blanking = 0x82,
374  .start_horizontal_retrace = 0x60,
375  .end_horizontal_retrace = 0x8D,
376  .vertical_total = 0x0B,
377  .overflow = 0x3E,
378  .preset_row_scan = 0x00,
379  .maximum_scan_line = 0x40,
380  .cursor_start = 0x06,
381  .cursor_end = 0x07,
382  .start_address_high = 0x00,
383  .start_address_low = 0x00,
384  .cursor_location_high = 0x00,
385  .cursor_location_low = 0x00,
386  .vertical_retrace_start = 0xEA,
387  .vertical_retrace_end = 0x0C,
388  .vertical_display_end = 0xDF,
389  .offset = 0x2D,
390  .underline_location = 0x08,
391  .start_vertical_blanking = 0xE8,
392  .end_vertical_blanking = 0x05,
393  .crtc_mode_control = 0xE3,
394  .line_compare = 0xFF,
395  },
396  .gc = {
397  .set_reset = 0x00,
398  .enable_set_reset = 0x00,
399  .color_compare = 0x00,
400  .data_rotate = 0x00,
401  .read_map = 0x03,
402  .graphics_mode = 0x00,
403  .misc_graphics = 0x05,
404  .color_dont_care = 0x0F,
405  .bit_mask = 0xFF,
406  },
407  .ac = {
408  .internal_palette_registers = {
409  0x00,
410  0x01,
411  0x02,
412  0x03,
413  0x04,
414  0x05,
415  0x06,
416  0x07,
417  0x08,
418  0x09,
419  0x0A,
420  0x0B,
421  0x0C,
422  0x0D,
423  0x0E,
424  0x0F,
425  },
426  .attribute_mode_control = 0x01, // 0b01000001, // 0x41,
427  .overscan_color = 0x00,
428  .color_plane_enable = 0x0F,
429  .horizontal_pixel_panning = 0x00,
430  .color_select = 0x00,
431  }
432 };
Structure that holds the information about a VGA mode.
Definition: vga_mode.h:9
unsigned char maximum_scan_line
09h –
Definition: vga_mode.h:30
unsigned char misc
Definition: vga_mode.h:10
unsigned char read_map
04h –
Definition: vga_mode.h:53
unsigned char end_horizontal_display
01h –
Definition: vga_mode.h:22
unsigned char end_vertical_blanking
16h –
Definition: vga_mode.h:43
unsigned char cursor_end
0Bh –
Definition: vga_mode.h:32
unsigned char misc_graphics
06h –
Definition: vga_mode.h:55
unsigned char vertical_retrace_end
11h –
Definition: vga_mode.h:38
unsigned char start_vertical_blanking
15h –
Definition: vga_mode.h:42
unsigned char graphics_mode
05h –
Definition: vga_mode.h:54
unsigned char start_address_high
0Ch –
Definition: vga_mode.h:33
unsigned char end_horizontal_retrace
05h –
Definition: vga_mode.h:26
unsigned char vertical_total
06h –
Definition: vga_mode.h:27
unsigned char color_compare
02h –
Definition: vga_mode.h:51
unsigned char crtc_mode_control
17h –
Definition: vga_mode.h:44
unsigned char cursor_start
0Ah –
Definition: vga_mode.h:31
unsigned char start_horizontal_blanking
02h –
Definition: vga_mode.h:23
unsigned char bit_mask
08h –
Definition: vga_mode.h:57
unsigned char offset
13h –
Definition: vga_mode.h:40
unsigned char start_horizontal_retrace
04h –
Definition: vga_mode.h:25
unsigned char clocking_mode
01h –
Definition: vga_mode.h:14
unsigned char color_dont_care
07h –
Definition: vga_mode.h:56
unsigned char cursor_location_high
0Eh –
Definition: vga_mode.h:35
unsigned char vertical_retrace_start
10h –
Definition: vga_mode.h:37
unsigned char preset_row_scan
08h –
Definition: vga_mode.h:29
unsigned char vertical_display_end
12h –
Definition: vga_mode.h:39
unsigned char color_plane_enable
12h –
Definition: vga_mode.h:64
unsigned char cursor_location_low
0Fh –
Definition: vga_mode.h:36
unsigned char data_rotate
03h –
Definition: vga_mode.h:52
unsigned char reset
00h –
Definition: vga_mode.h:13
unsigned char horizontal_pixel_panning
13h –
Definition: vga_mode.h:65
unsigned char overscan_color
11h –
Definition: vga_mode.h:63
unsigned char character_map_select
03h –
Definition: vga_mode.h:16
unsigned char end_horizontal_blanking
03h –
Definition: vga_mode.h:24
unsigned char attribute_mode_control
10h –
Definition: vga_mode.h:62
unsigned char horizontal_total
00h –
Definition: vga_mode.h:21
unsigned char enable_set_reset
01h –
Definition: vga_mode.h:50
unsigned char color_select
14h –
Definition: vga_mode.h:66
unsigned char underline_location
14h –
Definition: vga_mode.h:41
unsigned char line_compare
18h –
Definition: vga_mode.h:45
unsigned char set_reset
00h –
Definition: vga_mode.h:49
unsigned char overflow
07h –
Definition: vga_mode.h:28
unsigned char map_mask
02h –
Definition: vga_mode.h:15
unsigned char start_address_low
0Dh –
Definition: vga_mode.h:34
unsigned char sequencer_memory_mode
04h –
Definition: vga_mode.h:17
vga_mode_t _mode_80_25_text
Size 80x25, 16 colors.
Definition: vga_mode.h:71
vga_mode_t _mode_320_200_256
Size 320x200, 256 colors.
Definition: vga_mode.h:162
vga_mode_t _mode_720_480_16
Size 720x480, 16 colors.
Definition: vga_mode.h:344
vga_mode_t _mode_640_480_16
Size 640x480, 16 colors.
Definition: vga_mode.h:253