Debian Codegraph @

src/hardware/vga_seq.cpp

raw
1 /*
2 * Copyright (C) 2002-2010 The DOSBox Team
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 /* $Id: vga_seq.cpp,v 1.24 2009-05-27 09:15:41 qbix79 Exp $ */
20
21 #include "dosbox.h"
22 #include "inout.h"
23 #include "vga.h"
24
25 #define seq(blah) vga.seq.blah
26
27 Bitu read_p3c4(Bitu /*port*/,Bitu /*iolen*/) {
28 return seq(index);
29 }
30
31 void write_p3c4(Bitu /*port*/,Bitu val,Bitu /*iolen*/) {
32 seq(index)=val;
33 }
34
35 void write_p3c5(Bitu /*port*/,Bitu val,Bitu iolen) {
36 // LOG_MSG("SEQ WRITE reg %X val %X",seq(index),val);
37 switch(seq(index)) {
38 case 0: /* Reset */
39 seq(reset)=val;
40 break;
41 case 1: /* Clocking Mode */
42 if (val!=seq(clocking_mode)) {
43 // don't resize if only the screen off bit was changed
44 if ((val&(~0x20))!=(seq(clocking_mode)&(~0x20))) {
45 seq(clocking_mode)=val;
46 VGA_StartResize();
47 } else {
48 seq(clocking_mode)=val;
49 }
50 if (val & 0x20) vga.attr.disabled |= 0x2;
51 else vga.attr.disabled &= ~0x2;
52 }
53 /* TODO Figure this out :)
54 0 If set character clocks are 8 dots wide, else 9.
55 2 If set loads video serializers every other character
56 clock cycle, else every one.
57 3 If set the Dot Clock is Master Clock/2, else same as Master Clock
58 (See 3C2h bit 2-3). (Doubles pixels). Note: on some SVGA chipsets
59 this bit also affects the Sequencer mode.
60 4 If set loads video serializers every fourth character clock cycle,
61 else every one.
62 5 if set turns off screen and gives all memory cycles to the CPU
63 interface.
64 */
65 break;
66 case 2: /* Map Mask */
67 seq(map_mask)=val & 15;
68 vga.config.full_map_mask=FillTable[val & 15];
69 vga.config.full_not_map_mask=~vga.config.full_map_mask;
70 /*
71 0 Enable writes to plane 0 if set
72 1 Enable writes to plane 1 if set
73 2 Enable writes to plane 2 if set
74 3 Enable writes to plane 3 if set
75 */
76 break;
77 case 3: /* Character Map Select */
78 {
79 seq(character_map_select)=val;
80 Bit8u font1=(val & 0x3) << 1;
81 if (IS_VGA_ARCH) font1|=(val & 0x10) >> 4;
82 vga.draw.font_tables[0]=&vga.draw.font[font1*8*1024];
83 Bit8u font2=((val & 0xc) >> 1);
84 if (IS_VGA_ARCH) font2|=(val & 0x20) >> 5;
85 vga.draw.font_tables[1]=&vga.draw.font[font2*8*1024];
86 }
87 /*
88 0,1,4 Selects VGA Character Map (0..7) if bit 3 of the character
89 attribute is clear.
90 2,3,5 Selects VGA Character Map (0..7) if bit 3 of the character
91 attribute is set.
92 Note: Character Maps are placed as follows:
93 Map 0 at 0k, 1 at 16k, 2 at 32k, 3: 48k, 4: 8k, 5: 24k, 6: 40k, 7: 56k
94 */
95 break;
96 case 4: /* Memory Mode */
97 /*
98 0 Set if in an alphanumeric mode, clear in graphics modes.
99 1 Set if more than 64kbytes on the adapter.
100 2 Enables Odd/Even addressing mode if set. Odd/Even mode places all odd
101 bytes in plane 1&3, and all even bytes in plane 0&2.
102 3 If set address bit 0-1 selects video memory planes (256 color mode),
103 rather than the Map Mask and Read Map Select Registers.
104 */
105 seq(memory_mode)=val;
106 if (IS_VGA_ARCH) {
107 /* Changing this means changing the VGA Memory Read/Write Handler */
108 if (val&0x08) vga.config.chained=true;
109 else vga.config.chained=false;
110 VGA_SetupHandlers();
111 }
112 break;
113 default:
114 if (svga.write_p3c5) {
115 svga.write_p3c5(seq(index), val, iolen);
116 } else {
117 LOG(LOG_VGAMISC,LOG_NORMAL)("VGA:SEQ:Write to illegal index %2X",seq(index));
118 }
119 break;
120 }
121 }
122
123
124 Bitu read_p3c5(Bitu /*port*/,Bitu iolen) {
125 // LOG_MSG("VGA:SEQ:Read from index %2X",seq(index));
126 switch(seq(index)) {
127 case 0: /* Reset */
128 return seq(reset);
129 break;
130 case 1: /* Clocking Mode */
131 return seq(clocking_mode);
132 break;
133 case 2: /* Map Mask */
134 return seq(map_mask);
135 break;
136 case 3: /* Character Map Select */
137 return seq(character_map_select);
138 break;
139 case 4: /* Memory Mode */
140 return seq(memory_mode);
141 break;
142 default:
143 if (svga.read_p3c5)
144 return svga.read_p3c5(seq(index), iolen);
145 break;
146 }
147 return 0;
148 }
149
150
151 void VGA_SetupSEQ(void) {
152 if (IS_EGAVGA_ARCH) {
153 IO_RegisterWriteHandler(0x3c4,write_p3c4,IO_MB);
154 IO_RegisterWriteHandler(0x3c5,write_p3c5,IO_MB);
155 if (IS_VGA_ARCH) {
156 IO_RegisterReadHandler(0x3c4,read_p3c4,IO_MB);
157 IO_RegisterReadHandler(0x3c5,read_p3c5,IO_MB);
158 }
159 }
160 }
161