Debian Codegraph @

src/ints/int10_modes.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: int10_modes.cpp,v 1.91 2009-10-19 16:00:22 h-a-l-9000 Exp $ */
20
21 #include <string.h>
22
23 #include "dosbox.h"
24 #include "mem.h"
25 #include "inout.h"
26 #include "int10.h"
27 #include "mouse.h"
28 #include "vga.h"
29
30 #define _EGA_HALF_CLOCK 0x0001
31 #define _EGA_LINE_DOUBLE 0x0002
32 #define _VGA_PIXEL_DOUBLE 0x0004
33
34 #define SEQ_REGS 0x05
35 #define GFX_REGS 0x09
36 #define ATT_REGS 0x15
37
38 VideoModeBlock ModeList_VGA[]={
39 /* mode ,type ,sw ,sh ,tw ,th ,cw,ch ,pt,pstart ,plength,htot,vtot,hde,vde special flags */
40 { 0x000 ,M_TEXT ,360 ,400 ,40 ,25 ,9 ,16 ,8 ,0xB8000 ,0x0800 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK },
41 { 0x001 ,M_TEXT ,360 ,400 ,40 ,25 ,9 ,16 ,8 ,0xB8000 ,0x0800 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK },
42 { 0x002 ,M_TEXT ,720 ,400 ,80 ,25 ,9 ,16 ,8 ,0xB8000 ,0x1000 ,100 ,449 ,80 ,400 ,0 },
43 { 0x003 ,M_TEXT ,720 ,400 ,80 ,25 ,9 ,16 ,8 ,0xB8000 ,0x1000 ,100 ,449 ,80 ,400 ,0 },
44 { 0x004 ,M_CGA4 ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xB8000 ,0x4000 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE},
45 { 0x005 ,M_CGA4 ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xB8000 ,0x4000 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE},
46 { 0x006 ,M_CGA2 ,640 ,200 ,80 ,25 ,8 ,8 ,1 ,0xB8000 ,0x4000 ,100 ,449 ,80 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE},
47 { 0x007 ,M_TEXT ,720 ,400 ,80 ,25 ,9 ,16 ,8 ,0xB0000 ,0x1000 ,100 ,449 ,80 ,400 ,0 },
48
49 { 0x00D ,M_EGA ,320 ,200 ,40 ,25 ,8 ,8 ,8 ,0xA0000 ,0x2000 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE },
50 { 0x00E ,M_EGA ,640 ,200 ,80 ,25 ,8 ,8 ,4 ,0xA0000 ,0x4000 ,100 ,449 ,80 ,400 ,_EGA_LINE_DOUBLE },
51 { 0x00F ,M_EGA ,640 ,350 ,80 ,25 ,8 ,14 ,2 ,0xA0000 ,0x8000 ,100 ,449 ,80 ,350 ,0 },/*was EGA_2*/
52 { 0x010 ,M_EGA ,640 ,350 ,80 ,25 ,8 ,14 ,2 ,0xA0000 ,0x8000 ,100 ,449 ,80 ,350 ,0 },
53 { 0x011 ,M_EGA ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0xA000 ,100 ,525 ,80 ,480 ,0 },/*was EGA_2 */
54 { 0x012 ,M_EGA ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0xA000 ,100 ,525 ,80 ,480 ,0 },
55 { 0x013 ,M_VGA ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xA0000 ,0x2000 ,100 ,449 ,80 ,400 ,0 },
56
57 { 0x054 ,M_TEXT ,1056,688, 132,43, 8, 16, 1 ,0xB8000 ,0x4000, 192, 800, 132,688, 0 },
58 { 0x055 ,M_TEXT ,1056,400, 132,25, 8, 16, 1 ,0xB8000 ,0x2000, 192, 449, 132,400, 0 },
59
60 /* Alias of mode 101 */
61 { 0x069 ,M_LIN8 ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0x10000,100 ,525 ,80 ,480 ,0 },
62 /* Alias of mode 102 */
63 { 0x06A ,M_LIN4 ,800 ,600 ,100,37 ,8 ,16 ,1 ,0xA0000 ,0x10000,128 ,663 ,100,600 ,0 },
64
65 /* Follow vesa 1.2 for first 0x20 */
66 { 0x100 ,M_LIN8 ,640 ,400 ,80 ,25 ,8 ,16 ,1 ,0xA0000 ,0x10000,100 ,449 ,80 ,400 ,0 },
67 { 0x101 ,M_LIN8 ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0x10000,100 ,525 ,80 ,480 ,0 },
68 { 0x102 ,M_LIN4 ,800 ,600 ,100,37 ,8 ,16 ,1 ,0xA0000 ,0x10000,132 ,628 ,100,600 ,0 },
69 { 0x103 ,M_LIN8 ,800 ,600 ,100,37 ,8 ,16 ,1 ,0xA0000 ,0x10000,132 ,628 ,100,600 ,0 },
70 { 0x104 ,M_LIN4 ,1024,768 ,128,48 ,8 ,16 ,1 ,0xA0000 ,0x10000,168 ,806 ,128,768 ,0 },
71 { 0x105 ,M_LIN8 ,1024,768 ,128,48 ,8 ,16 ,1 ,0xA0000 ,0x10000,168 ,806 ,128,768 ,0 },
72 { 0x106 ,M_LIN4 ,1280,1024,160,64 ,8 ,16 ,1 ,0xA0000 ,0x10000,212 ,1066,160,1024,0 },
73 { 0x107 ,M_LIN8 ,1280,1024,160,64 ,8 ,16 ,1 ,0xA0000 ,0x10000,212 ,1066,160,1024,0 },
74
75 { 0x10D ,M_LIN15 ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xA0000 ,0x10000,100 ,449 ,80 ,400 , _VGA_PIXEL_DOUBLE | _EGA_LINE_DOUBLE },
76 { 0x10E ,M_LIN16 ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xA0000 ,0x10000,100 ,449 ,80 ,400 , _VGA_PIXEL_DOUBLE | _EGA_LINE_DOUBLE },
77 { 0x10F ,M_LIN32 ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xA0000 ,0x10000,50 ,449 ,40 ,400 , _VGA_PIXEL_DOUBLE | _EGA_LINE_DOUBLE },
78 { 0x110 ,M_LIN15 ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0x10000,200 ,525 ,160,480 ,0 },
79 { 0x111 ,M_LIN16 ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0x10000,200 ,525 ,160,480 ,0 },
80 { 0x112 ,M_LIN32 ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0x10000,100 ,525 ,80 ,480 ,0 },
81 { 0x113 ,M_LIN15 ,800 ,600 ,100,37 ,8 ,16 ,1 ,0xA0000 ,0x10000,264 ,628 ,200,600 ,0 },
82 { 0x114 ,M_LIN16 ,800 ,600 ,100,37 ,8 ,16 ,1 ,0xA0000 ,0x10000,264 ,628 ,200,600 ,0 },
83 { 0x115 ,M_LIN32 ,800 ,600 ,100,37 ,8 ,16 ,1 ,0xA0000 ,0x10000,132 ,628 ,100,600 ,0 },
84
85 { 0x116 ,M_LIN15 ,1024,768 ,128,48 ,8 ,16 ,1 ,0xA0000 ,0x10000,336 ,806 ,256,768 ,0 },
86 { 0x117 ,M_LIN16 ,1024,768 ,128,48 ,8 ,16 ,1 ,0xA0000 ,0x10000,336 ,806 ,256,768 ,0 },
87 { 0x118 ,M_LIN32 ,1024,768 ,128,48 ,8 ,16 ,1 ,0xA0000 ,0x10000,168 ,806 ,128,768 ,0 },
88 /* those should be interlaced but ok */
89 //{ 0x119 ,M_LIN15 ,1280,1024,160,64 ,8 ,16 ,1 ,0xA0000 ,0x10000,424 ,1066,320,1024,0 },
90 //{ 0x11A ,M_LIN16 ,1280,1024,160,64 ,8 ,16 ,1 ,0xA0000 ,0x10000,424 ,1066,320,1024,0 },
91
92 { 0x150 ,M_LIN8 ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xA0000 ,0x10000,100 ,449 ,80 ,400 , _VGA_PIXEL_DOUBLE | _EGA_LINE_DOUBLE },
93 { 0x151 ,M_LIN8 ,320 ,240 ,40 ,30 ,8 ,8 ,1 ,0xA0000 ,0x10000,100 ,525 ,80 ,480 , _VGA_PIXEL_DOUBLE | _EGA_LINE_DOUBLE },
94 { 0x152 ,M_LIN8 ,320 ,400 ,40 ,50 ,8 ,8 ,1 ,0xA0000 ,0x10000,100 ,449 ,80 ,400 , _VGA_PIXEL_DOUBLE },
95 { 0x153 ,M_LIN8 ,320 ,480 ,40 ,60 ,8 ,8 ,1 ,0xA0000 ,0x10000,100 ,525 ,80 ,480 , _VGA_PIXEL_DOUBLE },
96
97 { 0x160 ,M_LIN15 ,320 ,240 ,40 ,30 ,8 ,8 ,1 ,0xA0000 ,0x10000,100 ,525 , 80 ,480 , _VGA_PIXEL_DOUBLE | _EGA_LINE_DOUBLE },
98 { 0x161 ,M_LIN15 ,320 ,400 ,40 ,50 ,8 ,8 ,1 ,0xA0000 ,0x10000,100 ,449 , 80 ,400 , _VGA_PIXEL_DOUBLE },
99 { 0x162 ,M_LIN15 ,320 ,480 ,40 ,60 ,8 ,8 ,1 ,0xA0000 ,0x10000,100 ,525 , 80 ,480 , _VGA_PIXEL_DOUBLE },
100 { 0x165 ,M_LIN15 ,640 ,400 ,80 ,25 ,8 ,16 ,1 ,0xA0000 ,0x10000,200 ,449 ,160 ,400 ,0 },
101
102 { 0x170 ,M_LIN16 ,320 ,240 ,40 ,30 ,8 ,8 ,1 ,0xA0000 ,0x10000,100 ,525 , 80 ,480 , _VGA_PIXEL_DOUBLE | _EGA_LINE_DOUBLE },
103 { 0x171 ,M_LIN16 ,320 ,400 ,40 ,50 ,8 ,8 ,1 ,0xA0000 ,0x10000,100 ,449 , 80 ,400 , _VGA_PIXEL_DOUBLE },
104 { 0x172 ,M_LIN16 ,320 ,480 ,40 ,60 ,8 ,8 ,1 ,0xA0000 ,0x10000,100 ,525 , 80 ,480 , _VGA_PIXEL_DOUBLE },
105 { 0x175 ,M_LIN16 ,640 ,400 ,80 ,25 ,8 ,16 ,1 ,0xA0000 ,0x10000,200 ,449 ,160 ,400 ,0 },
106
107 { 0x190 ,M_LIN32 ,320 ,240 ,40 ,30 ,8 ,8 ,1 ,0xA0000 ,0x10000, 50 ,525 ,40 ,480 , _VGA_PIXEL_DOUBLE | _EGA_LINE_DOUBLE },
108 { 0x191 ,M_LIN32 ,320 ,400 ,40 ,50 ,8 ,8 ,1 ,0xA0000 ,0x10000, 50 ,449 ,40 ,400 , _VGA_PIXEL_DOUBLE },
109 { 0x192 ,M_LIN32 ,320 ,480 ,40 ,60 ,8 ,8 ,1 ,0xA0000 ,0x10000, 50 ,525 ,40 ,480 , _VGA_PIXEL_DOUBLE },
110
111 /* S3 specific modes */
112 { 0x207 ,M_LIN8 ,1152,864,160,64 ,8 ,16 ,1 ,0xA0000 ,0x10000,182 ,948 ,144,864 ,0 },
113 { 0x209 ,M_LIN15 ,1152,864,160,64 ,8 ,16 ,1 ,0xA0000 ,0x10000,364 ,948 ,288,864 ,0 },
114 { 0x20A ,M_LIN16 ,1152,864,160,64 ,8 ,16 ,1 ,0xA0000 ,0x10000,364 ,948 ,288,864 ,0 },
115 //{ 0x20B ,M_LIN32 ,1152,864,160,64 ,8 ,16 ,1 ,0xA0000 ,0x10000,182 ,948 ,144,864 ,0 },
116 { 0x213 ,M_LIN32 ,640 ,400,80 ,25 ,8 ,16 ,1 ,0xA0000 ,0x10000,100 ,449 ,80 ,400 ,0 },
117
118 /* Some custom modes */
119 //{ 0x220 ,M_LIN32 ,1280,1024,160,64 ,8 ,16 ,1 ,0xA0000 ,0x10000,212 ,1066,160,1024,0 },
120 // A nice 16:9 mode
121 { 0x222 ,M_LIN8 ,848 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0x10000,132 ,525 ,106 ,480 ,0 },
122 { 0x223 ,M_LIN15 ,848 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0x10000,264 ,525 ,212 ,480 ,0 },
123 { 0x224 ,M_LIN16 ,848 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0x10000,264 ,525 ,212 ,480 ,0 },
124 { 0x225 ,M_LIN32 ,848 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0x10000,132 ,525 ,106 ,480 ,0 },
125
126 {0xFFFF ,M_ERROR ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x00000 ,0x0000 ,0 ,0 ,0 ,0 ,0 },
127 };
128
129 VideoModeBlock ModeList_VGA_Text_200lines[]={
130 /* mode ,type ,sw ,sh ,tw ,th ,cw,ch ,pt,pstart ,plength,htot,vtot,hde,vde special flags */
131 { 0x000 ,M_TEXT ,320 ,200 ,40 ,25 ,8 , 8 ,8 ,0xB8000 ,0x0800 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE},
132 { 0x001 ,M_TEXT ,320 ,200 ,40 ,25 ,8 , 8 ,8 ,0xB8000 ,0x0800 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE},
133 { 0x002 ,M_TEXT ,640 ,200 ,80 ,25 ,8 , 8 ,8 ,0xB8000 ,0x1000 ,100 ,449 ,80 ,400 ,_EGA_LINE_DOUBLE },
134 { 0x003 ,M_TEXT ,640 ,200 ,80 ,25 ,8 , 8 ,8 ,0xB8000 ,0x1000 ,100 ,449 ,80 ,400 ,_EGA_LINE_DOUBLE }
135 };
136
137 VideoModeBlock ModeList_VGA_Text_350lines[]={
138 /* mode ,type ,sw ,sh ,tw ,th ,cw,ch ,pt,pstart ,plength,htot,vtot,hde,vde special flags */
139 { 0x000 ,M_TEXT ,320 ,350 ,40 ,25 ,8 ,14 ,8 ,0xB8000 ,0x0800 ,50 ,449 ,40 ,350 ,_EGA_HALF_CLOCK },
140 { 0x001 ,M_TEXT ,320 ,350 ,40 ,25 ,8 ,14 ,8 ,0xB8000 ,0x0800 ,50 ,449 ,40 ,350 ,_EGA_HALF_CLOCK },
141 { 0x002 ,M_TEXT ,640 ,350 ,80 ,25 ,8 ,14 ,8 ,0xB8000 ,0x1000 ,100 ,449 ,80 ,350 ,0 },
142 { 0x003 ,M_TEXT ,640 ,350 ,80 ,25 ,8 ,14 ,8 ,0xB8000 ,0x1000 ,100 ,449 ,80 ,350 ,0 }
143 };
144
145 VideoModeBlock ModeList_VGA_Tseng[]={
146 /* mode ,type ,sw ,sh ,tw ,th ,cw,ch ,pt,pstart ,plength,htot,vtot,hde,vde special flags */
147 { 0x000 ,M_TEXT ,360 ,400 ,40 ,25 ,9 ,16 ,8 ,0xB8000 ,0x0800 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK },
148 { 0x001 ,M_TEXT ,360 ,400 ,40 ,25 ,9 ,16 ,8 ,0xB8000 ,0x0800 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK },
149 { 0x002 ,M_TEXT ,720 ,400 ,80 ,25 ,9 ,16 ,8 ,0xB8000 ,0x1000 ,100 ,449 ,80 ,400 ,0 },
150 { 0x003 ,M_TEXT ,720 ,400 ,80 ,25 ,9 ,16 ,8 ,0xB8000 ,0x1000 ,100 ,449 ,80 ,400 ,0 },
151 { 0x004 ,M_CGA4 ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xB8000 ,0x4000 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE},
152 { 0x005 ,M_CGA4 ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xB8000 ,0x4000 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE},
153 { 0x006 ,M_CGA2 ,640 ,200 ,80 ,25 ,8 ,8 ,1 ,0xB8000 ,0x4000 ,100 ,449 ,80 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE},
154 { 0x007 ,M_TEXT ,720 ,400 ,80 ,25 ,9 ,16 ,8 ,0xB0000 ,0x1000 ,100 ,449 ,80 ,400 ,0 },
155
156 { 0x00D ,M_EGA ,320 ,200 ,40 ,25 ,8 ,8 ,8 ,0xA0000 ,0x2000 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE },
157 { 0x00E ,M_EGA ,640 ,200 ,80 ,25 ,8 ,8 ,4 ,0xA0000 ,0x4000 ,100 ,449 ,80 ,400 ,_EGA_LINE_DOUBLE },
158 { 0x00F ,M_EGA ,640 ,350 ,80 ,25 ,8 ,14 ,2 ,0xA0000 ,0x8000 ,100 ,449 ,80 ,350 ,0 },/*was EGA_2*/
159 { 0x010 ,M_EGA ,640 ,350 ,80 ,25 ,8 ,14 ,2 ,0xA0000 ,0x8000 ,100 ,449 ,80 ,350 ,0 },
160 { 0x011 ,M_EGA ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0xA000 ,100 ,525 ,80 ,480 ,0 },/*was EGA_2 */
161 { 0x012 ,M_EGA ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0xA000 ,100 ,525 ,80 ,480 ,0 },
162 { 0x013 ,M_VGA ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xA0000 ,0x2000 ,100 ,449 ,80 ,400 ,0 },
163
164 { 0x018 ,M_TEXT ,1056 ,688, 132,44, 8, 8, 1 ,0xB0000 ,0x4000, 192, 800, 132, 704, 0 },
165 { 0x019 ,M_TEXT ,1056 ,400, 132,25, 8, 16,1 ,0xB0000 ,0x2000, 192, 449, 132, 400, 0 },
166 { 0x01A ,M_TEXT ,1056 ,400, 132,28, 8, 16,1 ,0xB0000 ,0x2000, 192, 449, 132, 448, 0 },
167 { 0x022 ,M_TEXT ,1056 ,688, 132,44, 8, 8, 1 ,0xB8000 ,0x4000, 192, 800, 132, 704, 0 },
168 { 0x023 ,M_TEXT ,1056 ,400, 132,25, 8, 16,1 ,0xB8000 ,0x2000, 192, 449, 132, 400, 0 },
169 { 0x024 ,M_TEXT ,1056 ,400, 132,28, 8, 16,1 ,0xB8000 ,0x2000, 192, 449, 132, 448, 0 },
170 { 0x025 ,M_LIN4 ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0xA000 ,100 ,525 ,80 ,480 , 0 },
171 { 0x029 ,M_LIN4 ,800 ,600 ,100,37 ,8 ,16 ,1 ,0xA0000 ,0xA000, 128 ,663 ,100,600 , 0 },
172 { 0x02D ,M_LIN8 ,640 ,350 ,80 ,21 ,8 ,16 ,1 ,0xA0000 ,0x10000,100 ,449 ,80 ,350 , 0 },
173 { 0x02E ,M_LIN8 ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0x10000,100 ,525 ,80 ,480 , 0 },
174 { 0x02F ,M_LIN8 ,640 ,400 ,80 ,25 ,8 ,16 ,1 ,0xA0000 ,0x10000,100 ,449 ,80 ,400 , 0 },/* ET4000 only */
175 { 0x030 ,M_LIN8 ,800 ,600 ,100,37 ,8 ,16 ,1 ,0xA0000 ,0x10000,128 ,663 ,100,600 , 0 },
176 { 0x036 ,M_LIN4 ,960 , 720,120,45 ,8 ,16 ,1 ,0xA0000 ,0xA000, 120 ,800 ,120,720 , 0 },/* STB only */
177 { 0x037 ,M_LIN4 ,1024, 768,128,48 ,8 ,16 ,1 ,0xA0000 ,0xA000, 128 ,800 ,128,768 , 0 },
178 { 0x038 ,M_LIN8 ,1024 ,768,128,48 ,8 ,16 ,1 ,0xA0000 ,0x10000,128 ,800 ,128,768 , 0 },/* ET4000 only */
179 { 0x03D ,M_LIN4 ,1280,1024,160,64 ,8 ,16 ,1 ,0xA0000 ,0xA000, 160 ,1152,160,1024, 0 },/* newer ET4000 */
180 { 0x03E ,M_LIN4 ,1280, 960,160,60 ,8 ,16 ,1 ,0xA0000 ,0xA000, 160 ,1024,160,960 , 0 },/* Definicon only */
181 { 0x06A ,M_LIN4 ,800 ,600 ,100,37 ,8 ,16 ,1 ,0xA0000 ,0xA000, 128 ,663 ,100,600 , 0 },/* newer ET4000 */
182
183 {0xFFFF ,M_ERROR ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x00000 ,0x0000 ,0 ,0 ,0 ,0 ,0 },
184 };
185
186 VideoModeBlock ModeList_VGA_Paradise[]={
187 /* mode ,type ,sw ,sh ,tw ,th ,cw,ch ,pt,pstart ,plength,htot,vtot,hde,vde special flags */
188 { 0x000 ,M_TEXT ,360 ,400 ,40 ,25 ,9 ,16 ,8 ,0xB8000 ,0x0800 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK },
189 { 0x001 ,M_TEXT ,360 ,400 ,40 ,25 ,9 ,16 ,8 ,0xB8000 ,0x0800 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK },
190 { 0x002 ,M_TEXT ,720 ,400 ,80 ,25 ,9 ,16 ,8 ,0xB8000 ,0x1000 ,100 ,449 ,80 ,400 ,0 },
191 { 0x003 ,M_TEXT ,720 ,400 ,80 ,25 ,9 ,16 ,8 ,0xB8000 ,0x1000 ,100 ,449 ,80 ,400 ,0 },
192 { 0x004 ,M_CGA4 ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xB8000 ,0x4000 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE},
193 { 0x005 ,M_CGA4 ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xB8000 ,0x4000 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE},
194 { 0x006 ,M_CGA2 ,640 ,200 ,80 ,25 ,8 ,8 ,1 ,0xB8000 ,0x4000 ,100 ,449 ,80 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE},
195 { 0x007 ,M_TEXT ,720 ,400 ,80 ,25 ,9 ,16 ,8 ,0xB0000 ,0x1000 ,100 ,449 ,80 ,400 ,0 },
196
197 { 0x00D ,M_EGA ,320 ,200 ,40 ,25 ,8 ,8 ,8 ,0xA0000 ,0x2000 ,50 ,449 ,40 ,400 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE },
198 { 0x00E ,M_EGA ,640 ,200 ,80 ,25 ,8 ,8 ,4 ,0xA0000 ,0x4000 ,100 ,449 ,80 ,400 ,_EGA_LINE_DOUBLE },
199 { 0x00F ,M_EGA ,640 ,350 ,80 ,25 ,8 ,14 ,2 ,0xA0000 ,0x8000 ,100 ,449 ,80 ,350 ,0 },/*was EGA_2*/
200 { 0x010 ,M_EGA ,640 ,350 ,80 ,25 ,8 ,14 ,2 ,0xA0000 ,0x8000 ,100 ,449 ,80 ,350 ,0 },
201 { 0x011 ,M_EGA ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0xA000 ,100 ,525 ,80 ,480 ,0 },/*was EGA_2 */
202 { 0x012 ,M_EGA ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xA0000 ,0xA000 ,100 ,525 ,80 ,480 ,0 },
203 { 0x013 ,M_VGA ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xA0000 ,0x2000 ,100 ,449 ,80 ,400 ,0 },
204
205 { 0x054 ,M_TEXT ,1056 ,688, 132,43, 8, 9, 1, 0xB0000, 0x4000, 192, 720, 132,688, 0 },
206 { 0x055 ,M_TEXT ,1056 ,400, 132,25, 8, 16,1, 0xB0000, 0x2000, 192, 449, 132,400, 0 },
207 { 0x056 ,M_TEXT ,1056 ,688, 132,43, 8, 9, 1, 0xB0000, 0x4000, 192, 720, 132,688, 0 },
208 { 0x057 ,M_TEXT ,1056 ,400, 132,25, 8, 16,1, 0xB0000, 0x2000, 192, 449, 132,400, 0 },
209 { 0x058 ,M_LIN4 ,800 , 600, 100,37, 8, 16,1, 0xA0000, 0xA000, 128 ,663 ,100,600, 0 },
210 { 0x05D ,M_LIN4 ,1024, 768, 128,48 ,8, 16,1, 0xA0000, 0x10000,128 ,800 ,128,768 ,0 }, // documented only on C00 upwards
211 { 0x05E ,M_LIN8 ,640 , 400, 80 ,25, 8, 16,1, 0xA0000, 0x10000,100 ,449 ,80 ,400, 0 },
212 { 0x05F ,M_LIN8 ,640 , 480, 80 ,30, 8, 16,1, 0xA0000, 0x10000,100 ,525 ,80 ,480, 0 },
213
214 {0xFFFF ,M_ERROR ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x00000 ,0x0000 ,0 ,0 ,0 ,0 ,0 },
215 };
216
217
218 VideoModeBlock ModeList_EGA[]={
219 /* mode ,type ,sw ,sh ,tw ,th ,cw,ch ,pt,pstart ,plength,htot,vtot,hde,vde special flags */
220 { 0x000 ,M_TEXT ,320 ,350 ,40 ,25 ,8 ,14 ,8 ,0xB8000 ,0x0800 ,50 ,366 ,40 ,350 ,_EGA_HALF_CLOCK },
221 { 0x001 ,M_TEXT ,320 ,350 ,40 ,25 ,8 ,14 ,8 ,0xB8000 ,0x0800 ,50 ,366 ,40 ,350 ,_EGA_HALF_CLOCK },
222 { 0x002 ,M_TEXT ,640 ,350 ,80 ,25 ,8 ,14 ,8 ,0xB8000 ,0x1000 ,96 ,366 ,80 ,350 ,0 },
223 { 0x003 ,M_TEXT ,640 ,350 ,80 ,25 ,8 ,14 ,8 ,0xB8000 ,0x1000 ,96 ,366 ,80 ,350 ,0 },
224 { 0x004 ,M_CGA4 ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xB8000 ,0x4000 ,60 ,262 ,40 ,200 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE},
225 { 0x005 ,M_CGA4 ,320 ,200 ,40 ,25 ,8 ,8 ,1 ,0xB8000 ,0x4000 ,60 ,262 ,40 ,200 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE},
226 { 0x006 ,M_CGA2 ,640 ,200 ,80 ,25 ,8 ,8 ,1 ,0xB8000 ,0x4000 ,120 ,262 ,80 ,200 ,_EGA_LINE_DOUBLE},
227 { 0x007 ,M_TEXT ,720 ,350 ,80 ,25 ,9 ,14 ,8 ,0xB0000 ,0x1000 ,120 ,440 ,80 ,350 ,0 },
228
229 { 0x00D ,M_EGA ,320 ,200 ,40 ,25 ,8 ,8 ,8 ,0xA0000 ,0x2000 ,60 ,262 ,40 ,200 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE },
230 { 0x00E ,M_EGA ,640 ,200 ,80 ,25 ,8 ,8 ,4 ,0xA0000 ,0x4000 ,120 ,262 ,80 ,200 ,_EGA_LINE_DOUBLE },
231 { 0x00F ,M_EGA ,640 ,350 ,80 ,25 ,8 ,14 ,2 ,0xA0000 ,0x8000 ,96 ,366 ,80 ,350 ,0 },/*was EGA_2*/
232 { 0x010 ,M_EGA ,640 ,350 ,80 ,25 ,8 ,14 ,2 ,0xA0000 ,0x8000 ,96 ,366 ,80 ,350 ,0 },
233
234 {0xFFFF ,M_ERROR ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x00000 ,0x0000 ,0 ,0 ,0 ,0 ,0 },
235 };
236
237 VideoModeBlock ModeList_OTHER[]={
238 /* mode ,type ,sw ,sh ,tw ,th ,cw,ch ,pt,pstart ,plength,htot,vtot,hde,vde ,special flags */
239 { 0x000 ,M_TEXT ,320 ,400 ,40 ,25 ,8 ,8 ,8 ,0xB8000 ,0x0800 ,56 ,31 ,40 ,25 ,0 },
240 { 0x001 ,M_TEXT ,320 ,400 ,40 ,25 ,8 ,8 ,8 ,0xB8000 ,0x0800 ,56 ,31 ,40 ,25 ,0 },
241 { 0x002 ,M_TEXT ,640 ,400 ,80 ,25 ,8 ,8 ,4 ,0xB8000 ,0x1000 ,113 ,31 ,80 ,25 ,0 },
242 { 0x003 ,M_TEXT ,640 ,400 ,80 ,25 ,8 ,8 ,4 ,0xB8000 ,0x1000 ,113 ,31 ,80 ,25 ,0 },
243 { 0x004 ,M_CGA4 ,320 ,200 ,40 ,25 ,8 ,8 ,4 ,0xB8000 ,0x0800 ,56 ,127 ,40 ,100 ,0 },
244 { 0x005 ,M_CGA4 ,320 ,200 ,40 ,25 ,8 ,8 ,4 ,0xB8000 ,0x0800 ,56 ,127 ,40 ,100 ,0 },
245 { 0x006 ,M_CGA2 ,640 ,200 ,80 ,25 ,8 ,8 ,4 ,0xB8000 ,0x0800 ,56 ,127 ,40 ,100 ,0 },
246 { 0x008 ,M_TANDY16,160 ,200 ,20 ,25 ,8 ,8 ,8 ,0xB8000 ,0x2000 ,56 ,127 ,40 ,100 ,0 },
247 { 0x009 ,M_TANDY16,320 ,200 ,40 ,25 ,8 ,8 ,8 ,0xB8000 ,0x2000 ,113 ,63 ,80 ,50 ,0 },
248 { 0x00A ,M_CGA4 ,640 ,200 ,80 ,25 ,8 ,8 ,8 ,0xB8000 ,0x2000 ,113 ,63 ,80 ,50 ,0 },
249 {0xFFFF ,M_ERROR ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x00000 ,0x0000 ,0 ,0 ,0 ,0 ,0 },
250 };
251
252 VideoModeBlock Hercules_Mode=
253 { 0x007 ,M_TEXT ,640 ,400 ,80 ,25 ,8 ,14 ,1 ,0xB0000 ,0x1000 ,97 ,25 ,80 ,25 ,0 };
254
255 static Bit8u text_palette[64][3]=
256 {
257 {0x00,0x00,0x00},{0x00,0x00,0x2a},{0x00,0x2a,0x00},{0x00,0x2a,0x2a},{0x2a,0x00,0x00},{0x2a,0x00,0x2a},{0x2a,0x2a,0x00},{0x2a,0x2a,0x2a},
258 {0x00,0x00,0x15},{0x00,0x00,0x3f},{0x00,0x2a,0x15},{0x00,0x2a,0x3f},{0x2a,0x00,0x15},{0x2a,0x00,0x3f},{0x2a,0x2a,0x15},{0x2a,0x2a,0x3f},
259 {0x00,0x15,0x00},{0x00,0x15,0x2a},{0x00,0x3f,0x00},{0x00,0x3f,0x2a},{0x2a,0x15,0x00},{0x2a,0x15,0x2a},{0x2a,0x3f,0x00},{0x2a,0x3f,0x2a},
260 {0x00,0x15,0x15},{0x00,0x15,0x3f},{0x00,0x3f,0x15},{0x00,0x3f,0x3f},{0x2a,0x15,0x15},{0x2a,0x15,0x3f},{0x2a,0x3f,0x15},{0x2a,0x3f,0x3f},
261 {0x15,0x00,0x00},{0x15,0x00,0x2a},{0x15,0x2a,0x00},{0x15,0x2a,0x2a},{0x3f,0x00,0x00},{0x3f,0x00,0x2a},{0x3f,0x2a,0x00},{0x3f,0x2a,0x2a},
262 {0x15,0x00,0x15},{0x15,0x00,0x3f},{0x15,0x2a,0x15},{0x15,0x2a,0x3f},{0x3f,0x00,0x15},{0x3f,0x00,0x3f},{0x3f,0x2a,0x15},{0x3f,0x2a,0x3f},
263 {0x15,0x15,0x00},{0x15,0x15,0x2a},{0x15,0x3f,0x00},{0x15,0x3f,0x2a},{0x3f,0x15,0x00},{0x3f,0x15,0x2a},{0x3f,0x3f,0x00},{0x3f,0x3f,0x2a},
264 {0x15,0x15,0x15},{0x15,0x15,0x3f},{0x15,0x3f,0x15},{0x15,0x3f,0x3f},{0x3f,0x15,0x15},{0x3f,0x15,0x3f},{0x3f,0x3f,0x15},{0x3f,0x3f,0x3f}
265 };
266
267 static Bit8u mtext_palette[64][3]=
268 {
269 {0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},
270 {0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},
271 {0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},
272 {0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},
273 {0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},
274 {0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},
275 {0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},
276 {0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f}
277 };
278
279 static Bit8u mtext_s3_palette[64][3]=
280 {
281 {0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},
282 {0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},
283 {0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},
284 {0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},
285 {0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},
286 {0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},
287 {0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},{0x2a,0x2a,0x2a},
288 {0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f},{0x3f,0x3f,0x3f}
289 };
290
291 static Bit8u ega_palette[64][3]=
292 {
293 {0x00,0x00,0x00}, {0x00,0x00,0x2a}, {0x00,0x2a,0x00}, {0x00,0x2a,0x2a}, {0x2a,0x00,0x00}, {0x2a,0x00,0x2a}, {0x2a,0x15,0x00}, {0x2a,0x2a,0x2a},
294 {0x00,0x00,0x00}, {0x00,0x00,0x2a}, {0x00,0x2a,0x00}, {0x00,0x2a,0x2a}, {0x2a,0x00,0x00}, {0x2a,0x00,0x2a}, {0x2a,0x15,0x00}, {0x2a,0x2a,0x2a},
295 {0x15,0x15,0x15}, {0x15,0x15,0x3f}, {0x15,0x3f,0x15}, {0x15,0x3f,0x3f}, {0x3f,0x15,0x15}, {0x3f,0x15,0x3f}, {0x3f,0x3f,0x15}, {0x3f,0x3f,0x3f},
296 {0x15,0x15,0x15}, {0x15,0x15,0x3f}, {0x15,0x3f,0x15}, {0x15,0x3f,0x3f}, {0x3f,0x15,0x15}, {0x3f,0x15,0x3f}, {0x3f,0x3f,0x15}, {0x3f,0x3f,0x3f},
297 {0x00,0x00,0x00}, {0x00,0x00,0x2a}, {0x00,0x2a,0x00}, {0x00,0x2a,0x2a}, {0x2a,0x00,0x00}, {0x2a,0x00,0x2a}, {0x2a,0x15,0x00}, {0x2a,0x2a,0x2a},
298 {0x00,0x00,0x00}, {0x00,0x00,0x2a}, {0x00,0x2a,0x00}, {0x00,0x2a,0x2a}, {0x2a,0x00,0x00}, {0x2a,0x00,0x2a}, {0x2a,0x15,0x00}, {0x2a,0x2a,0x2a},
299 {0x15,0x15,0x15}, {0x15,0x15,0x3f}, {0x15,0x3f,0x15}, {0x15,0x3f,0x3f}, {0x3f,0x15,0x15}, {0x3f,0x15,0x3f}, {0x3f,0x3f,0x15}, {0x3f,0x3f,0x3f},
300 {0x15,0x15,0x15}, {0x15,0x15,0x3f}, {0x15,0x3f,0x15}, {0x15,0x3f,0x3f}, {0x3f,0x15,0x15}, {0x3f,0x15,0x3f}, {0x3f,0x3f,0x15}, {0x3f,0x3f,0x3f}
301 };
302
303 static Bit8u cga_palette[16][3]=
304 {
305 {0x00,0x00,0x00}, {0x00,0x00,0x2a}, {0x00,0x2a,0x00}, {0x00,0x2a,0x2a}, {0x2a,0x00,0x00}, {0x2a,0x00,0x2a}, {0x2a,0x15,0x00}, {0x2a,0x2a,0x2a},
306 {0x15,0x15,0x15}, {0x15,0x15,0x3f}, {0x15,0x3f,0x15}, {0x15,0x3f,0x3f}, {0x3f,0x15,0x15}, {0x3f,0x15,0x3f}, {0x3f,0x3f,0x15}, {0x3f,0x3f,0x3f},
307 };
308
309 static Bit8u cga_palette_2[64][3]=
310 {
311 {0x00,0x00,0x00}, {0x00,0x00,0x2a}, {0x00,0x2a,0x00}, {0x00,0x2a,0x2a}, {0x2a,0x00,0x00}, {0x2a,0x00,0x2a}, {0x2a,0x15,0x00}, {0x2a,0x2a,0x2a},
312 {0x00,0x00,0x00}, {0x00,0x00,0x2a}, {0x00,0x2a,0x00}, {0x00,0x2a,0x2a}, {0x2a,0x00,0x00}, {0x2a,0x00,0x2a}, {0x2a,0x15,0x00}, {0x2a,0x2a,0x2a},
313 {0x15,0x15,0x15}, {0x15,0x15,0x3f}, {0x15,0x3f,0x15}, {0x15,0x3f,0x3f}, {0x3f,0x15,0x15}, {0x3f,0x15,0x3f}, {0x3f,0x3f,0x15}, {0x3f,0x3f,0x3f},
314 {0x15,0x15,0x15}, {0x15,0x15,0x3f}, {0x15,0x3f,0x15}, {0x15,0x3f,0x3f}, {0x3f,0x15,0x15}, {0x3f,0x15,0x3f}, {0x3f,0x3f,0x15}, {0x3f,0x3f,0x3f},
315 {0x00,0x00,0x00}, {0x00,0x00,0x2a}, {0x00,0x2a,0x00}, {0x00,0x2a,0x2a}, {0x2a,0x00,0x00}, {0x2a,0x00,0x2a}, {0x2a,0x15,0x00}, {0x2a,0x2a,0x2a},
316 {0x00,0x00,0x00}, {0x00,0x00,0x2a}, {0x00,0x2a,0x00}, {0x00,0x2a,0x2a}, {0x2a,0x00,0x00}, {0x2a,0x00,0x2a}, {0x2a,0x15,0x00}, {0x2a,0x2a,0x2a},
317 {0x15,0x15,0x15}, {0x15,0x15,0x3f}, {0x15,0x3f,0x15}, {0x15,0x3f,0x3f}, {0x3f,0x15,0x15}, {0x3f,0x15,0x3f}, {0x3f,0x3f,0x15}, {0x3f,0x3f,0x3f},
318 {0x15,0x15,0x15}, {0x15,0x15,0x3f}, {0x15,0x3f,0x15}, {0x15,0x3f,0x3f}, {0x3f,0x15,0x15}, {0x3f,0x15,0x3f}, {0x3f,0x3f,0x15}, {0x3f,0x3f,0x3f},
319 };
320
321 static Bit8u vga_palette[256][3]=
322 {
323 {0x00,0x00,0x00},{0x00,0x00,0x2a},{0x00,0x2a,0x00},{0x00,0x2a,0x2a},{0x2a,0x00,0x00},{0x2a,0x00,0x2a},{0x2a,0x15,0x00},{0x2a,0x2a,0x2a},
324 {0x15,0x15,0x15},{0x15,0x15,0x3f},{0x15,0x3f,0x15},{0x15,0x3f,0x3f},{0x3f,0x15,0x15},{0x3f,0x15,0x3f},{0x3f,0x3f,0x15},{0x3f,0x3f,0x3f},
325 {0x00,0x00,0x00},{0x05,0x05,0x05},{0x08,0x08,0x08},{0x0b,0x0b,0x0b},{0x0e,0x0e,0x0e},{0x11,0x11,0x11},{0x14,0x14,0x14},{0x18,0x18,0x18},
326 {0x1c,0x1c,0x1c},{0x20,0x20,0x20},{0x24,0x24,0x24},{0x28,0x28,0x28},{0x2d,0x2d,0x2d},{0x32,0x32,0x32},{0x38,0x38,0x38},{0x3f,0x3f,0x3f},
327 {0x00,0x00,0x3f},{0x10,0x00,0x3f},{0x1f,0x00,0x3f},{0x2f,0x00,0x3f},{0x3f,0x00,0x3f},{0x3f,0x00,0x2f},{0x3f,0x00,0x1f},{0x3f,0x00,0x10},
328 {0x3f,0x00,0x00},{0x3f,0x10,0x00},{0x3f,0x1f,0x00},{0x3f,0x2f,0x00},{0x3f,0x3f,0x00},{0x2f,0x3f,0x00},{0x1f,0x3f,0x00},{0x10,0x3f,0x00},
329 {0x00,0x3f,0x00},{0x00,0x3f,0x10},{0x00,0x3f,0x1f},{0x00,0x3f,0x2f},{0x00,0x3f,0x3f},{0x00,0x2f,0x3f},{0x00,0x1f,0x3f},{0x00,0x10,0x3f},
330 {0x1f,0x1f,0x3f},{0x27,0x1f,0x3f},{0x2f,0x1f,0x3f},{0x37,0x1f,0x3f},{0x3f,0x1f,0x3f},{0x3f,0x1f,0x37},{0x3f,0x1f,0x2f},{0x3f,0x1f,0x27},
331
332 {0x3f,0x1f,0x1f},{0x3f,0x27,0x1f},{0x3f,0x2f,0x1f},{0x3f,0x37,0x1f},{0x3f,0x3f,0x1f},{0x37,0x3f,0x1f},{0x2f,0x3f,0x1f},{0x27,0x3f,0x1f},
333 {0x1f,0x3f,0x1f},{0x1f,0x3f,0x27},{0x1f,0x3f,0x2f},{0x1f,0x3f,0x37},{0x1f,0x3f,0x3f},{0x1f,0x37,0x3f},{0x1f,0x2f,0x3f},{0x1f,0x27,0x3f},
334 {0x2d,0x2d,0x3f},{0x31,0x2d,0x3f},{0x36,0x2d,0x3f},{0x3a,0x2d,0x3f},{0x3f,0x2d,0x3f},{0x3f,0x2d,0x3a},{0x3f,0x2d,0x36},{0x3f,0x2d,0x31},
335 {0x3f,0x2d,0x2d},{0x3f,0x31,0x2d},{0x3f,0x36,0x2d},{0x3f,0x3a,0x2d},{0x3f,0x3f,0x2d},{0x3a,0x3f,0x2d},{0x36,0x3f,0x2d},{0x31,0x3f,0x2d},
336 {0x2d,0x3f,0x2d},{0x2d,0x3f,0x31},{0x2d,0x3f,0x36},{0x2d,0x3f,0x3a},{0x2d,0x3f,0x3f},{0x2d,0x3a,0x3f},{0x2d,0x36,0x3f},{0x2d,0x31,0x3f},
337 {0x00,0x00,0x1c},{0x07,0x00,0x1c},{0x0e,0x00,0x1c},{0x15,0x00,0x1c},{0x1c,0x00,0x1c},{0x1c,0x00,0x15},{0x1c,0x00,0x0e},{0x1c,0x00,0x07},
338 {0x1c,0x00,0x00},{0x1c,0x07,0x00},{0x1c,0x0e,0x00},{0x1c,0x15,0x00},{0x1c,0x1c,0x00},{0x15,0x1c,0x00},{0x0e,0x1c,0x00},{0x07,0x1c,0x00},
339 {0x00,0x1c,0x00},{0x00,0x1c,0x07},{0x00,0x1c,0x0e},{0x00,0x1c,0x15},{0x00,0x1c,0x1c},{0x00,0x15,0x1c},{0x00,0x0e,0x1c},{0x00,0x07,0x1c},
340
341 {0x0e,0x0e,0x1c},{0x11,0x0e,0x1c},{0x15,0x0e,0x1c},{0x18,0x0e,0x1c},{0x1c,0x0e,0x1c},{0x1c,0x0e,0x18},{0x1c,0x0e,0x15},{0x1c,0x0e,0x11},
342 {0x1c,0x0e,0x0e},{0x1c,0x11,0x0e},{0x1c,0x15,0x0e},{0x1c,0x18,0x0e},{0x1c,0x1c,0x0e},{0x18,0x1c,0x0e},{0x15,0x1c,0x0e},{0x11,0x1c,0x0e},
343 {0x0e,0x1c,0x0e},{0x0e,0x1c,0x11},{0x0e,0x1c,0x15},{0x0e,0x1c,0x18},{0x0e,0x1c,0x1c},{0x0e,0x18,0x1c},{0x0e,0x15,0x1c},{0x0e,0x11,0x1c},
344 {0x14,0x14,0x1c},{0x16,0x14,0x1c},{0x18,0x14,0x1c},{0x1a,0x14,0x1c},{0x1c,0x14,0x1c},{0x1c,0x14,0x1a},{0x1c,0x14,0x18},{0x1c,0x14,0x16},
345 {0x1c,0x14,0x14},{0x1c,0x16,0x14},{0x1c,0x18,0x14},{0x1c,0x1a,0x14},{0x1c,0x1c,0x14},{0x1a,0x1c,0x14},{0x18,0x1c,0x14},{0x16,0x1c,0x14},
346 {0x14,0x1c,0x14},{0x14,0x1c,0x16},{0x14,0x1c,0x18},{0x14,0x1c,0x1a},{0x14,0x1c,0x1c},{0x14,0x1a,0x1c},{0x14,0x18,0x1c},{0x14,0x16,0x1c},
347 {0x00,0x00,0x10},{0x04,0x00,0x10},{0x08,0x00,0x10},{0x0c,0x00,0x10},{0x10,0x00,0x10},{0x10,0x00,0x0c},{0x10,0x00,0x08},{0x10,0x00,0x04},
348 {0x10,0x00,0x00},{0x10,0x04,0x00},{0x10,0x08,0x00},{0x10,0x0c,0x00},{0x10,0x10,0x00},{0x0c,0x10,0x00},{0x08,0x10,0x00},{0x04,0x10,0x00},
349
350 {0x00,0x10,0x00},{0x00,0x10,0x04},{0x00,0x10,0x08},{0x00,0x10,0x0c},{0x00,0x10,0x10},{0x00,0x0c,0x10},{0x00,0x08,0x10},{0x00,0x04,0x10},
351 {0x08,0x08,0x10},{0x0a,0x08,0x10},{0x0c,0x08,0x10},{0x0e,0x08,0x10},{0x10,0x08,0x10},{0x10,0x08,0x0e},{0x10,0x08,0x0c},{0x10,0x08,0x0a},
352 {0x10,0x08,0x08},{0x10,0x0a,0x08},{0x10,0x0c,0x08},{0x10,0x0e,0x08},{0x10,0x10,0x08},{0x0e,0x10,0x08},{0x0c,0x10,0x08},{0x0a,0x10,0x08},
353 {0x08,0x10,0x08},{0x08,0x10,0x0a},{0x08,0x10,0x0c},{0x08,0x10,0x0e},{0x08,0x10,0x10},{0x08,0x0e,0x10},{0x08,0x0c,0x10},{0x08,0x0a,0x10},
354 {0x0b,0x0b,0x10},{0x0c,0x0b,0x10},{0x0d,0x0b,0x10},{0x0f,0x0b,0x10},{0x10,0x0b,0x10},{0x10,0x0b,0x0f},{0x10,0x0b,0x0d},{0x10,0x0b,0x0c},
355 {0x10,0x0b,0x0b},{0x10,0x0c,0x0b},{0x10,0x0d,0x0b},{0x10,0x0f,0x0b},{0x10,0x10,0x0b},{0x0f,0x10,0x0b},{0x0d,0x10,0x0b},{0x0c,0x10,0x0b},
356 {0x0b,0x10,0x0b},{0x0b,0x10,0x0c},{0x0b,0x10,0x0d},{0x0b,0x10,0x0f},{0x0b,0x10,0x10},{0x0b,0x0f,0x10},{0x0b,0x0d,0x10},{0x0b,0x0c,0x10},
357 {0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00},{0x00,0x00,0x00}
358 };
359 VideoModeBlock * CurMode;
360
361 static bool SetCurMode(VideoModeBlock modeblock[],Bit16u mode) {
362 Bitu i=0;
363 while (modeblock[i].mode!=0xffff) {
364 if (modeblock[i].mode!=mode) i++;
365 else {
366 if ((!int10.vesa_oldvbe) || (ModeList_VGA[i].mode<0x120)) {
367 CurMode=&modeblock[i];
368 return true;
369 }
370 return false;
371 }
372 }
373 return false;
374 }
375
376
377 static void FinishSetMode(bool clearmem) {
378 /* Clear video memory if needs be */
379 if (clearmem) {
380 switch (CurMode->type) {
381 case M_CGA4:
382 case M_CGA2:
383 case M_TANDY16:
384 for (Bit16u ct=0;ct<16*1024;ct++) {
385 real_writew( 0xb800,ct*2,0x0000);
386 }
387 break;
388 case M_TEXT: {
389 Bit16u seg = (CurMode->mode==7)?0xb000:0xb800;
390 for (Bit16u ct=0;ct<16*1024;ct++) real_writew(seg,ct*2,0x0720);
391 break;
392 }
393 case M_EGA:
394 case M_VGA:
395 case M_LIN8:
396 case M_LIN4:
397 case M_LIN15:
398 case M_LIN16:
399 case M_LIN32:
400 /* Hack we just acess the memory directly */
401 memset(vga.mem.linear,0,vga.vmemsize);
402 memset(vga.fastmem, 0, vga.vmemsize<<1);
403 }
404 }
405 /* Setup the BIOS */
406 if (CurMode->mode<128) real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE,(Bit8u)CurMode->mode);
407 else real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE,(Bit8u)(CurMode->mode-0x98)); //Looks like the s3 bios
408 real_writew(BIOSMEM_SEG,BIOSMEM_NB_COLS,(Bit16u)CurMode->twidth);
409 real_writew(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE,(Bit16u)CurMode->plength);
410 real_writew(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS,((CurMode->mode==7 )|| (CurMode->mode==0x0f)) ? 0x3b4 : 0x3d4);
411 real_writeb(BIOSMEM_SEG,BIOSMEM_NB_ROWS,(Bit8u)(CurMode->theight-1));
412 real_writew(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT,(Bit16u)CurMode->cheight);
413 real_writeb(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL,(0x60|(clearmem?0:0x80)));
414 real_writeb(BIOSMEM_SEG,BIOSMEM_SWITCHES,0x09);
415
416 // this is an index into the dcc table:
417 if (IS_VGA_ARCH) real_writeb(BIOSMEM_SEG,BIOSMEM_DCC_INDEX,0x0b);
418 real_writed(BIOSMEM_SEG,BIOSMEM_VS_POINTER,int10.rom.video_save_pointers);
419
420 // Set cursor shape
421 if (CurMode->type==M_TEXT) {
422 INT10_SetCursorShape(0x06,07);
423 }
424 // Set cursor pos for page 0..7
425 for (Bit8u ct=0;ct<8;ct++) INT10_SetCursorPos(0,0,ct);
426 // Set active page 0
427 INT10_SetActivePage(0);
428 /* Set some interrupt vectors */
429 switch (CurMode->cheight) {
430 case 8:RealSetVec(0x43,int10.rom.font_8_first);break;
431 case 14:RealSetVec(0x43,int10.rom.font_14);break;
432 case 16:RealSetVec(0x43,int10.rom.font_16);break;
433 }
434 /* Tell mouse resolution change */
435 Mouse_NewVideoMode();
436 }
437
438 bool INT10_SetVideoMode_OTHER(Bit16u mode,bool clearmem) {
439 switch (machine) {
440 case MCH_CGA:
441 if (mode>6) return false;
442 case TANDY_ARCH_CASE:
443 if (mode>0xa) return false;
444 if (mode==7) mode=0; // PCJR defaults to 0 on illegal mode 7
445 if (!SetCurMode(ModeList_OTHER,mode)) {
446 LOG(LOG_INT10,LOG_ERROR)("Trying to set illegal mode %X",mode);
447 return false;
448 }
449 break;
450 case MCH_HERC:
451 // Only init the adapter if the equipment word is set to monochrome (Testdrive)
452 if ((real_readw(BIOSMEM_SEG,BIOSMEM_INITIAL_MODE)&0x30)!=0x30) return false;
453 CurMode=&Hercules_Mode;
454 mode=7; // in case the video parameter table is modified
455 break;
456 }
457 LOG(LOG_INT10,LOG_NORMAL)("Set Video Mode %X",mode);
458
459 /* Setup the VGA to the correct mode */
460 // VGA_SetMode(CurMode->type);
461 /* Setup the CRTC */
462 Bitu crtc_base=machine==MCH_HERC ? 0x3b4 : 0x3d4;
463 //Horizontal total
464 IO_WriteW(crtc_base,0x00 | (CurMode->htotal) << 8);
465 //Horizontal displayed
466 IO_WriteW(crtc_base,0x01 | (CurMode->hdispend) << 8);
467 //Horizontal sync position
468 IO_WriteW(crtc_base,0x02 | (CurMode->hdispend+1) << 8);
469 //Horizontal sync width, seems to be fixed to 0xa, for cga at least, hercules has 0xf
470 IO_WriteW(crtc_base,0x03 | (0xa) << 8);
471 ////Vertical total
472 IO_WriteW(crtc_base,0x04 | (CurMode->vtotal) << 8);
473 //Vertical total adjust, 6 for cga,hercules,tandy
474 IO_WriteW(crtc_base,0x05 | (6) << 8);
475 //Vertical displayed
476 IO_WriteW(crtc_base,0x06 | (CurMode->vdispend) << 8);
477 //Vertical sync position
478 IO_WriteW(crtc_base,0x07 | (CurMode->vdispend + ((CurMode->vtotal - CurMode->vdispend)/2)-1) << 8);
479 //Maximum scanline
480 Bit8u scanline,crtpage;
481 scanline=8;
482 switch(CurMode->type) {
483 case M_TEXT:
484 if (machine==MCH_HERC) scanline=14;
485 else scanline=8;
486 break;
487 case M_CGA2:
488 scanline=2;
489 break;
490 case M_CGA4:
491 if (CurMode->mode!=0xa) scanline=2;
492 else scanline=4;
493 break;
494 case M_TANDY16:
495 if (CurMode->mode!=0x9) scanline=2;
496 else scanline=4;
497 break;
498 }
499 IO_WriteW(crtc_base,0x09 | (scanline-1) << 8);
500 //Setup the CGA palette using VGA DAC palette
501 for (Bit8u ct=0;ct<16;ct++) VGA_DAC_SetEntry(ct,cga_palette[ct][0],cga_palette[ct][1],cga_palette[ct][2]);
502 //Setup the tandy palette
503 for (Bit8u ct=0;ct<16;ct++) VGA_DAC_CombineColor(ct,ct);
504 //Setup the special registers for each machine type
505 Bit8u mode_control_list[0xa+1]={
506 0x2c,0x28,0x2d,0x29, //0-3
507 0x2a,0x2e,0x1e,0x29, //4-7
508 0x2a,0x2b,0x3b //8-a
509 };
510 Bit8u mode_control_list_pcjr[0xa+1]={
511 0x0c,0x08,0x0d,0x09, //0-3
512 0x0a,0x0e,0x0e,0x09, //4-7
513 0x1a,0x1b,0x0b //8-a
514 };
515 Bit8u mode_control,color_select;
516 switch (machine) {
517 case MCH_HERC:
518 IO_WriteB(0x3b8,0x28); // TEXT mode and blinking characters
519
520 Herc_Palette();
521 VGA_DAC_CombineColor(0,0);
522 VGA_DAC_CombineColor(1,7);
523
524 real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MSR,0x29); // attribute controls blinking
525 break;
526 case MCH_CGA:
527 mode_control=mode_control_list[CurMode->mode];
528 if (CurMode->mode == 0x6) color_select=0x3f;
529 else color_select=0x30;
530 IO_WriteB(0x3d8,mode_control);
531 IO_WriteB(0x3d9,color_select);
532 real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MSR,mode_control);
533 real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAL,color_select);
534 break;
535 case MCH_TANDY:
536 /* Init some registers */
537 IO_WriteB(0x3da,0x1);IO_WriteB(0x3de,0xf); //Palette mask always 0xf
538 IO_WriteB(0x3da,0x2);IO_WriteB(0x3de,0x0); //black border
539 IO_WriteB(0x3da,0x3); //Tandy color overrides?
540 switch (CurMode->mode) {
541 case 0x8:
542 IO_WriteB(0x3de,0x14);break;
543 case 0x9:
544 IO_WriteB(0x3de,0x14);break;
545 case 0xa:
546 IO_WriteB(0x3de,0x0c);break;
547 default:
548 IO_WriteB(0x3de,0x0);break;
549 }
550 //Clear extended mapping
551 IO_WriteB(0x3da,0x5);
552 IO_WriteB(0x3de,0x0);
553 //Clear monitor mode
554 IO_WriteB(0x3da,0x8);
555 IO_WriteB(0x3de,0x0);
556 crtpage=(CurMode->mode>=0x9) ? 0xf6 : 0x3f;
557 IO_WriteB(0x3df,crtpage);
558 real_writeb(BIOSMEM_SEG,BIOSMEM_CRTCPU_PAGE,crtpage);
559 mode_control=mode_control_list[CurMode->mode];
560 if (CurMode->mode == 0x6 || CurMode->mode==0xa) color_select=0x3f;
561 else color_select=0x30;
562 IO_WriteB(0x3d8,mode_control);
563 IO_WriteB(0x3d9,color_select);
564 real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MSR,mode_control);
565 real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAL,color_select);
566 break;
567 case MCH_PCJR:
568 /* Init some registers */
569 IO_ReadB(0x3da);
570 IO_WriteB(0x3da,0x1);IO_WriteB(0x3da,0xf); //Palette mask always 0xf
571 IO_WriteB(0x3da,0x2);IO_WriteB(0x3da,0x0); //black border
572 IO_WriteB(0x3da,0x3);
573 if (CurMode->mode<=0x04) IO_WriteB(0x3da,0x02);
574 else if (CurMode->mode==0x06) IO_WriteB(0x3da,0x08);
575 else IO_WriteB(0x3da,0x00);
576
577 /* set CRT/Processor page register */
578 if (CurMode->mode<0x04) crtpage=0x3f;
579 else if (CurMode->mode>=0x09) crtpage=0xf6;
580 else crtpage=0x7f;
581 IO_WriteB(0x3df,crtpage);
582 real_writeb(BIOSMEM_SEG,BIOSMEM_CRTCPU_PAGE,crtpage);
583
584 mode_control=mode_control_list_pcjr[CurMode->mode];
585 IO_WriteB(0x3da,0x0);IO_WriteB(0x3da,mode_control);
586 real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MSR,mode_control);
587
588 if (CurMode->mode == 0x6 || CurMode->mode==0xa) color_select=0x3f;
589 else color_select=0x30;
590 IO_WriteB(0x3d9,color_select);
591 real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAL,color_select);
592 break;
593 }
594
595 RealPt vparams = RealGetVec(0x1d);
596 if ((vparams != RealMake(0xf000,0xf0a4)) && (mode < 8)) {
597 // load crtc parameters from video params table
598 Bit16u crtc_block_index = 0;
599 if (mode < 2) crtc_block_index = 0;
600 else if (mode < 4) crtc_block_index = 1;
601 else if (mode < 7) crtc_block_index = 2;
602 else if (mode == 7) crtc_block_index = 3; // MDA mono mode; invalid for others
603 else if (mode < 9) crtc_block_index = 2;
604 else crtc_block_index = 3; // Tandy/PCjr modes
605
606 // init CRTC registers
607 for (Bit16u i = 0; i < 16; i++)
608 IO_WriteW(crtc_base, i | (real_readb(RealSeg(vparams),
609 RealOff(vparams) + i + crtc_block_index*16) << 8));
610 }
611 FinishSetMode(clearmem);
612 return true;
613 }
614
615
616 bool INT10_SetVideoMode(Bit16u mode) {
617 bool clearmem=true;Bitu i;
618 if (mode>=0x100) {
619 if ((mode & 0x4000) && int10.vesa_nolfb) return false;
620 if (mode & 0x8000) clearmem=false;
621 mode&=0xfff;
622 }
623 if ((mode<0x100) && (mode & 0x80)) {
624 clearmem=false;
625 mode-=0x80;
626 }
627 int10.vesa_setmode=0xffff;
628 LOG(LOG_INT10,LOG_NORMAL)("Set Video Mode %X",mode);
629 if (!IS_EGAVGA_ARCH) return INT10_SetVideoMode_OTHER(mode,clearmem);
630
631 /* First read mode setup settings from bios area */
632 // Bit8u video_ctl=real_readb(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL);
633 // Bit8u vga_switches=real_readb(BIOSMEM_SEG,BIOSMEM_SWITCHES);
634 Bit8u modeset_ctl=real_readb(BIOSMEM_SEG,BIOSMEM_MODESET_CTL);
635
636 if (IS_VGA_ARCH) {
637 if (svga.accepts_mode) {
638 if (!svga.accepts_mode(mode)) return false;
639 }
640
641 switch(svgaCard) {
642 case SVGA_TsengET4K:
643 case SVGA_TsengET3K:
644 if (!SetCurMode(ModeList_VGA_Tseng,mode)){
645 LOG(LOG_INT10,LOG_ERROR)("VGA:Trying to set illegal mode %X",mode);
646 return false;
647 }
648 break;
649 case SVGA_ParadisePVGA1A:
650 if (!SetCurMode(ModeList_VGA_Paradise,mode)){
651 LOG(LOG_INT10,LOG_ERROR)("VGA:Trying to set illegal mode %X",mode);
652 return false;
653 }
654 break;
655 default:
656 if (!SetCurMode(ModeList_VGA,mode)){
657 LOG(LOG_INT10,LOG_ERROR)("VGA:Trying to set illegal mode %X",mode);
658 return false;
659 }
660 }
661 // check for scanline backwards compatibility (VESA text modes??)
662 if (CurMode->type==M_TEXT) {
663 if ((modeset_ctl&0x90)==0x80) { // 200 lines emulation
664 if (CurMode->mode <= 3) {
665 CurMode = &ModeList_VGA_Text_200lines[CurMode->mode];
666 }
667 } else if ((modeset_ctl&0x90)==0x00) { // 350 lines emulation
668 if (CurMode->mode <= 3) {
669 CurMode = &ModeList_VGA_Text_350lines[CurMode->mode];
670 }
671 }
672 }
673 } else {
674 if (!SetCurMode(ModeList_EGA,mode)){
675 LOG(LOG_INT10,LOG_ERROR)("EGA:Trying to set illegal mode %X",mode);
676 return false;
677 }
678 }
679
680 /* Setup the VGA to the correct mode */
681
682 Bit16u crtc_base;
683 bool mono_mode=(mode == 7) || (mode==0xf);
684 if (mono_mode) crtc_base=0x3b4;
685 else crtc_base=0x3d4;
686
687 if (IS_VGA_ARCH && (svgaCard == SVGA_S3Trio)) {
688 // Disable MMIO here so we can read / write memory
689 IO_Write(crtc_base,0x53);
690 IO_Write(crtc_base+1,0x0);
691 }
692
693 /* Setup MISC Output Register */
694 Bit8u misc_output=0x2 | (mono_mode ? 0x0 : 0x1);
695
696 if ((CurMode->type==M_TEXT) && (CurMode->cwidth==9)) {
697 // 28MHz (16MHz EGA) clock for 9-pixel wide chars
698 misc_output|=0x4;
699 }
700
701 switch (CurMode->vdispend) {
702 case 400:
703 misc_output|=0x60;
704 break;
705 case 480:
706 misc_output|=0xe0;
707 break;
708 case 350:
709 misc_output|=0xa0;
710 break;
711 default:
712 misc_output|=0x60;
713 }
714 IO_Write(0x3c2,misc_output); //Setup for 3b4 or 3d4
715
716 /* Program Sequencer */
717 Bit8u seq_data[SEQ_REGS];
718 memset(seq_data,0,SEQ_REGS);
719 seq_data[1]|=0x01; //8 dot fonts by default
720 if (CurMode->special & _EGA_HALF_CLOCK) seq_data[1]|=0x08; //Check for half clock
721 if ((machine==MCH_EGA) && (CurMode->special & _EGA_HALF_CLOCK)) seq_data[1]|=0x02;
722 seq_data[4]|=0x02; //More than 64kb
723 switch (CurMode->type) {
724 case M_TEXT:
725 if (CurMode->cwidth==9) seq_data[1] &= ~1;
726 seq_data[2]|=0x3; //Enable plane 0 and 1
727 seq_data[4]|=0x01; //Alpanumeric
728 if (IS_VGA_ARCH) seq_data[4]|=0x04; //odd/even enabled
729 break;
730 case M_CGA2:
731 seq_data[2]|=0xf; //Enable plane 0
732 if (machine==MCH_EGA) seq_data[4]|=0x04; //odd/even enabled
733 break;
734 case M_CGA4:
735 if (machine==MCH_EGA) seq_data[2]|=0x03; //Enable plane 0 and 1
736 break;
737 case M_LIN4:
738 case M_EGA:
739 seq_data[2]|=0xf; //Enable all planes for writing
740 if (machine==MCH_EGA) seq_data[4]|=0x04; //odd/even enabled
741 break;
742 case M_LIN8: //Seems to have the same reg layout from testing
743 case M_LIN15:
744 case M_LIN16:
745 case M_LIN32:
746 case M_VGA:
747 seq_data[2]|=0xf; //Enable all planes for writing
748 seq_data[4]|=0xc; //Graphics - odd/even - Chained
749 break;
750 }
751 for (Bit8u ct=0;ct<SEQ_REGS;ct++) {
752 IO_Write(0x3c4,ct);
753 IO_Write(0x3c5,seq_data[ct]);
754 }
755 vga.config.compatible_chain4 = true; // this may be changed by SVGA chipset emulation
756
757 /* Program CRTC */
758 /* First disable write protection */
759 IO_Write(crtc_base,0x11);
760 IO_Write(crtc_base+1,IO_Read(crtc_base+1)&0x7f);
761 /* Clear all the regs */
762 for (Bit8u ct=0x0;ct<=0x18;ct++) {
763 IO_Write(crtc_base,ct);IO_Write(crtc_base+1,0);
764 }
765 Bit8u overflow=0;Bit8u max_scanline=0;
766 Bit8u ver_overflow=0;Bit8u hor_overflow=0;
767 /* Horizontal Total */
768 IO_Write(crtc_base,0x00);IO_Write(crtc_base+1,(Bit8u)(CurMode->htotal-5));
769 hor_overflow|=((CurMode->htotal-5) & 0x100) >> 8;
770 /* Horizontal Display End */
771 IO_Write(crtc_base,0x01);IO_Write(crtc_base+1,(Bit8u)(CurMode->hdispend-1));
772 hor_overflow|=((CurMode->hdispend-1) & 0x100) >> 7;
773 /* Start horizontal Blanking */
774 IO_Write(crtc_base,0x02);IO_Write(crtc_base+1,(Bit8u)CurMode->hdispend);
775 hor_overflow|=((CurMode->hdispend) & 0x100) >> 6;
776 /* End horizontal Blanking */
777 Bitu blank_end=(CurMode->htotal-2) & 0x7f;
778 IO_Write(crtc_base,0x03);IO_Write(crtc_base+1,0x80|(blank_end & 0x1f));
779
780 /* Start Horizontal Retrace */
781 Bitu ret_start;
782 if ((CurMode->special & _EGA_HALF_CLOCK) && (CurMode->type!=M_CGA2)) ret_start = (CurMode->hdispend+3);
783 else if (CurMode->type==M_TEXT) ret_start = (CurMode->hdispend+5);
784 else ret_start = (CurMode->hdispend+4);
785 IO_Write(crtc_base,0x04);IO_Write(crtc_base+1,(Bit8u)ret_start);
786 hor_overflow|=(ret_start & 0x100) >> 4;
787
788 /* End Horizontal Retrace */
789 Bitu ret_end;
790 if (CurMode->special & _EGA_HALF_CLOCK) {
791 if (CurMode->type==M_CGA2) ret_end=0; // mode 6
792 else if (CurMode->special & _EGA_LINE_DOUBLE) ret_end = (CurMode->htotal-18) & 0x1f;
793 else ret_end = ((CurMode->htotal-18) & 0x1f) | 0x20; // mode 0&1 have 1 char sync delay
794 } else if (CurMode->type==M_TEXT) ret_end = (CurMode->htotal-3) & 0x1f;
795 else ret_end = (CurMode->htotal-4) & 0x1f;
796
797 IO_Write(crtc_base,0x05);IO_Write(crtc_base+1,(Bit8u)(ret_end | (blank_end & 0x20) << 2));
798
799 /* Vertical Total */
800 IO_Write(crtc_base,0x06);IO_Write(crtc_base+1,(Bit8u)(CurMode->vtotal-2));
801 overflow|=((CurMode->vtotal-2) & 0x100) >> 8;
802 overflow|=((CurMode->vtotal-2) & 0x200) >> 4;
803 ver_overflow|=((CurMode->vtotal-2) & 0x400) >> 10;
804
805 Bitu vretrace;
806 if (IS_VGA_ARCH) {
807 switch (CurMode->vdispend) {
808 case 400: vretrace=CurMode->vdispend+12;
809 break;
810 case 480: vretrace=CurMode->vdispend+10;
811 break;
812 case 350: vretrace=CurMode->vdispend+37;
813 break;
814 default: vretrace=CurMode->vdispend+12;
815 }
816 } else {
817 switch (CurMode->vdispend) {
818 case 350: vretrace=CurMode->vdispend;
819 break;
820 default: vretrace=CurMode->vdispend+24;
821 }
822 }
823
824 /* Vertical Retrace Start */
825 IO_Write(crtc_base,0x10);IO_Write(crtc_base+1,(Bit8u)vretrace);
826 overflow|=(vretrace & 0x100) >> 6;
827 overflow|=(vretrace & 0x200) >> 2;
828 ver_overflow|=(vretrace & 0x400) >> 6;
829
830 /* Vertical Retrace End */
831 IO_Write(crtc_base,0x11);IO_Write(crtc_base+1,(vretrace+2) & 0xF);
832
833 /* Vertical Display End */
834 IO_Write(crtc_base,0x12);IO_Write(crtc_base+1,(Bit8u)(CurMode->vdispend-1));
835 overflow|=((CurMode->vdispend-1) & 0x100) >> 7;
836 overflow|=((CurMode->vdispend-1) & 0x200) >> 3;
837 ver_overflow|=((CurMode->vdispend-1) & 0x400) >> 9;
838
839 Bitu vblank_trim;
840 if (IS_VGA_ARCH) {
841 switch (CurMode->vdispend) {
842 case 400: vblank_trim=6;
843 break;
844 case 480: vblank_trim=7;
845 break;
846 case 350: vblank_trim=5;
847 break;
848 default: vblank_trim=8;
849 }
850 } else {
851 switch (CurMode->vdispend) {
852 case 350: vblank_trim=0;
853 break;
854 default: vblank_trim=23;
855 }
856 }
857
858 /* Vertical Blank Start */
859 IO_Write(crtc_base,0x15);IO_Write(crtc_base+1,(Bit8u)(CurMode->vdispend+vblank_trim));
860 overflow|=((CurMode->vdispend+vblank_trim) & 0x100) >> 5;
861 max_scanline|=((CurMode->vdispend+vblank_trim) & 0x200) >> 4;
862 ver_overflow|=((CurMode->vdispend+vblank_trim) & 0x400) >> 8;
863
864 /* Vertical Blank End */
865 IO_Write(crtc_base,0x16);IO_Write(crtc_base+1,(Bit8u)(CurMode->vtotal-vblank_trim-2));
866
867 /* Line Compare */
868 Bitu line_compare=(CurMode->vtotal < 1024) ? 1023 : 2047;
869 IO_Write(crtc_base,0x18);IO_Write(crtc_base+1,line_compare&0xff);
870 overflow|=(line_compare & 0x100) >> 4;
871 max_scanline|=(line_compare & 0x200) >> 3;
872 ver_overflow|=(line_compare & 0x400) >> 4;
873 Bit8u underline=0;
874 /* Maximum scanline / Underline Location */
875 if (CurMode->special & _EGA_LINE_DOUBLE) {
876 if (machine!=MCH_EGA) max_scanline|=0x80;
877 }
878 switch (CurMode->type) {
879 case M_TEXT:
880 max_scanline|=CurMode->cheight-1;
881 underline=mono_mode ? 0x0f : 0x1f; // mode 7 uses a diff underline position
882 break;
883 case M_VGA:
884 underline=0x40;
885 max_scanline|=1; //Vga doesn't use double line but this
886 break;
887 case M_LIN8:
888 case M_LIN15:
889 case M_LIN16:
890 case M_LIN32:
891 underline=0x60; //Seems to enable the every 4th clock on my s3
892 break;
893 case M_CGA2:
894 case M_CGA4:
895 max_scanline|=1;
896 break;
897 }
898 if (CurMode->vdispend==350) underline=0x0f;
899
900 IO_Write(crtc_base,0x09);IO_Write(crtc_base+1,max_scanline);
901 IO_Write(crtc_base,0x14);IO_Write(crtc_base+1,underline);
902
903 /* OverFlow */
904 IO_Write(crtc_base,0x07);IO_Write(crtc_base+1,overflow);
905
906 if (svgaCard == SVGA_S3Trio) {
907 /* Extended Horizontal Overflow */
908 IO_Write(crtc_base,0x5d);IO_Write(crtc_base+1,hor_overflow);
909 /* Extended Vertical Overflow */
910 IO_Write(crtc_base,0x5e);IO_Write(crtc_base+1,ver_overflow);
911 }
912
913 /* Offset Register */
914 Bitu offset;
915 switch (CurMode->type) {
916 case M_LIN8:
917 offset = CurMode->swidth/8;
918 break;
919 case M_LIN15:
920 case M_LIN16:
921 offset = 2 * CurMode->swidth/8;
922 break;
923 case M_LIN32:
924 offset = 4 * CurMode->swidth/8;
925 break;
926 default:
927 offset = CurMode->hdispend/2;
928 }
929 IO_Write(crtc_base,0x13);
930 IO_Write(crtc_base + 1,offset & 0xff);
931
932 if (svgaCard == SVGA_S3Trio) {
933 /* Extended System Control 2 Register */
934 /* This register actually has more bits but only use the extended offset ones */
935 IO_Write(crtc_base,0x51);
936 IO_Write(crtc_base + 1,(Bit8u)((offset & 0x300) >> 4));
937 /* Clear remaining bits of the display start */
938 IO_Write(crtc_base,0x69);
939 IO_Write(crtc_base + 1,0);
940 /* Extended Vertical Overflow */
941 IO_Write(crtc_base,0x5e);IO_Write(crtc_base+1,ver_overflow);
942 }
943
944 /* Mode Control */
945 Bit8u mode_control=0;
946
947 switch (CurMode->type) {
948 case M_CGA2:
949 mode_control=0xc2; // 0x06 sets address wrap.
950 break;
951 case M_CGA4:
952 mode_control=0xa2;
953 break;
954 case M_LIN4:
955 case M_EGA:
956 if (CurMode->mode==0x11) // 0x11 also sets address wrap. thought maybe all 2 color modes did but 0x0f doesn't.
957 mode_control=0xc3; // so.. 0x11 or 0x0f a one off?
958 else {
959 if (machine==MCH_EGA) {
960 if (CurMode->special & _EGA_LINE_DOUBLE) mode_control=0xc3;
961 else mode_control=0x8b;
962 } else {
963 mode_control=0xe3;
964 }
965 }
966 break;
967 case M_TEXT:
968 case M_VGA:
969 case M_LIN8:
970 case M_LIN15:
971 case M_LIN16:
972 case M_LIN32:
973 mode_control=0xa3;
974 if (CurMode->special & _VGA_PIXEL_DOUBLE)
975 mode_control |= 0x08;
976 break;
977 }
978
979 IO_Write(crtc_base,0x17);IO_Write(crtc_base+1,mode_control);
980 /* Renable write protection */
981 IO_Write(crtc_base,0x11);
982 IO_Write(crtc_base+1,IO_Read(crtc_base+1)|0x80);
983
984 if (svgaCard == SVGA_S3Trio) {
985 /* Setup the correct clock */
986 if (CurMode->mode>=0x100) {
987 misc_output|=0xef; //Select clock 3
988 Bitu clock=CurMode->vtotal*8*CurMode->htotal*70;
989 VGA_SetClock(3,clock/1000);
990 }
991 Bit8u misc_control_2;
992 /* Setup Pixel format */
993 switch (CurMode->type) {
994 case M_LIN8:
995 misc_control_2=0x00;
996 break;
997 case M_LIN15:
998 misc_control_2=0x30;
999 break;
1000 case M_LIN16:
1001 misc_control_2=0x50;
1002 break;
1003 case M_LIN32:
1004 misc_control_2=0xd0;
1005 break;
1006 default:
1007 misc_control_2=0x0;
1008 break;
1009 }
1010 IO_WriteB(crtc_base,0x67);IO_WriteB(crtc_base+1,misc_control_2);
1011 }
1012
1013 /* Write Misc Output */
1014 IO_Write(0x3c2,misc_output);
1015 /* Program Graphics controller */
1016 Bit8u gfx_data[GFX_REGS];
1017 memset(gfx_data,0,GFX_REGS);
1018 gfx_data[0x7]=0xf; /* Color don't care */
1019 gfx_data[0x8]=0xff; /* BitMask */
1020 switch (CurMode->type) {
1021 case M_TEXT:
1022 gfx_data[0x5]|=0x10; //Odd-Even Mode
1023 gfx_data[0x6]|=mono_mode ? 0x0a : 0x0e; //Either b800 or b000
1024 break;
1025 case M_LIN8:
1026 case M_LIN15:
1027 case M_LIN16:
1028 case M_LIN32:
1029 case M_VGA:
1030 gfx_data[0x5]|=0x40; //256 color mode
1031 gfx_data[0x6]|=0x05; //graphics mode at 0xa000-affff
1032 break;
1033 case M_LIN4:
1034 case M_EGA:
1035 gfx_data[0x6]|=0x05; //graphics mode at 0xa000-affff
1036 break;
1037 case M_CGA4:
1038 gfx_data[0x5]|=0x20; //CGA mode
1039 gfx_data[0x6]|=0x0f; //graphics mode at at 0xb800=0xbfff
1040 if (machine==MCH_EGA) gfx_data[0x5]|=0x10;
1041 break;
1042 case M_CGA2:
1043 if (machine==MCH_EGA) {
1044 gfx_data[0x6]|=0x0d; //graphics mode at at 0xb800=0xbfff
1045 } else {
1046 gfx_data[0x6]|=0x0f; //graphics mode at at 0xb800=0xbfff
1047 }
1048 break;
1049 }
1050 for (Bit8u ct=0;ct<GFX_REGS;ct++) {
1051 IO_Write(0x3ce,ct);
1052 IO_Write(0x3cf,gfx_data[ct]);
1053 }
1054 Bit8u att_data[ATT_REGS];
1055 memset(att_data,0,ATT_REGS);
1056 att_data[0x12]=0xf; //Always have all color planes enabled
1057 /* Program Attribute Controller */
1058 switch (CurMode->type) {
1059 case M_EGA:
1060 case M_LIN4:
1061 att_data[0x10]=0x01; //Color Graphics
1062 switch (CurMode->mode) {
1063 case 0x0f:
1064 att_data[0x10]|=0x0a; //Monochrome
1065 att_data[0x01]=0x08;
1066 att_data[0x04]=0x18;
1067 att_data[0x05]=0x18;
1068 att_data[0x09]=0x08;
1069 att_data[0x0d]=0x18;
1070 break;
1071 case 0x11:
1072 for (i=1;i<16;i++) att_data[i]=0x3f;
1073 break;
1074 case 0x10:
1075 case 0x12:
1076 goto att_text16;
1077 default:
1078 if ( CurMode->type == M_LIN4 )
1079 goto att_text16;
1080 for (Bit8u ct=0;ct<8;ct++) {
1081 att_data[ct]=ct;
1082 att_data[ct+8]=ct+0x10;
1083 }
1084 break;
1085 }
1086 break;
1087 case M_TANDY16:
1088 att_data[0x10]=0x01; //Color Graphics
1089 for (Bit8u ct=0;ct<16;ct++) att_data[ct]=ct;
1090 break;
1091 case M_TEXT:
1092 if (CurMode->cwidth==9) {
1093 att_data[0x13]=0x08; //Pel panning on 8, although we don't have 9 dot text mode
1094 att_data[0x10]=0x0C; //Color Text with blinking, 9 Bit characters
1095 } else {
1096 att_data[0x13]=0x00;
1097 att_data[0x10]=0x08; //Color Text with blinking, 8 Bit characters
1098 }
1099 real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAL,0x30);
1100 att_text16:
1101 if (CurMode->mode==7) {
1102 att_data[0]=0x00;
1103 att_data[8]=0x10;
1104 for (i=1; i<8; i++) {
1105 att_data[i]=0x08;
1106 att_data[i+8]=0x18;
1107 }
1108 } else {
1109 for (Bit8u ct=0;ct<8;ct++) {
1110 att_data[ct]=ct;
1111 att_data[ct+8]=ct+0x38;
1112 }
1113 if (IS_VGA_ARCH) att_data[0x06]=0x14; //Odd Color 6 yellow/brown.
1114 }
1115 break;
1116 case M_CGA2:
1117 att_data[0x10]=0x01; //Color Graphics
1118 att_data[0]=0x0;
1119 for (i=1;i<0x10;i++) att_data[i]=0x17;
1120 att_data[0x12]=0x1; //Only enable 1 plane
1121 real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAL,0x3f);
1122 break;
1123 case M_CGA4:
1124 att_data[0x10]=0x01; //Color Graphics
1125 att_data[0]=0x0;
1126 att_data[1]=0x13;
1127 att_data[2]=0x15;
1128 att_data[3]=0x17;
1129 att_data[4]=0x02;
1130 att_data[5]=0x04;
1131 att_data[6]=0x06;
1132 att_data[7]=0x07;
1133 for (Bit8u ct=0x8;ct<0x10;ct++)
1134 att_data[ct] = ct + 0x8;
1135 real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAL,0x30);
1136 break;
1137 case M_VGA:
1138 case M_LIN8:
1139 case M_LIN15:
1140 case M_LIN16:
1141 case M_LIN32:
1142 for (Bit8u ct=0;ct<16;ct++) att_data[ct]=ct;
1143 att_data[0x10]=0x41; //Color Graphics 8-bit
1144 break;
1145 }
1146 IO_Read(mono_mode ? 0x3ba : 0x3da);
1147 if ((modeset_ctl & 8)==0) {
1148 for (Bit8u ct=0;ct<ATT_REGS;ct++) {
1149 IO_Write(0x3c0,ct);
1150 IO_Write(0x3c0,att_data[ct]);
1151 }
1152 vga.config.pel_panning = 0;
1153 IO_Write(0x3c0,0x20); IO_Write(0x3c0,0x00); //Disable palette access
1154 IO_Write(0x3c6,0xff); //Reset Pelmask
1155 /* Setup the DAC */
1156 IO_Write(0x3c8,0);
1157 switch (CurMode->type) {
1158 case M_EGA:
1159 if (CurMode->mode>0xf) {
1160 goto dac_text16;
1161 } else if (CurMode->mode==0xf) {
1162 for (i=0;i<64;i++) {
1163 IO_Write(0x3c9,mtext_s3_palette[i][0]);
1164 IO_Write(0x3c9,mtext_s3_palette[i][1]);
1165 IO_Write(0x3c9,mtext_s3_palette[i][2]);
1166 }
1167 } else {
1168 for (i=0;i<64;i++) {
1169 IO_Write(0x3c9,ega_palette[i][0]);
1170 IO_Write(0x3c9,ega_palette[i][1]);
1171 IO_Write(0x3c9,ega_palette[i][2]);
1172 }
1173 }
1174 break;
1175 case M_CGA2:
1176 case M_CGA4:
1177 case M_TANDY16:
1178 for (i=0;i<64;i++) {
1179 IO_Write(0x3c9,cga_palette_2[i][0]);
1180 IO_Write(0x3c9,cga_palette_2[i][1]);
1181 IO_Write(0x3c9,cga_palette_2[i][2]);
1182 }
1183 break;
1184 case M_TEXT:
1185 if (CurMode->mode==7) {
1186 if ((IS_VGA_ARCH) && (svgaCard == SVGA_S3Trio)) {
1187 for (i=0;i<64;i++) {
1188 IO_Write(0x3c9,mtext_s3_palette[i][0]);
1189 IO_Write(0x3c9,mtext_s3_palette[i][1]);
1190 IO_Write(0x3c9,mtext_s3_palette[i][2]);
1191 }
1192 } else {
1193 for (i=0;i<64;i++) {
1194 IO_Write(0x3c9,mtext_palette[i][0]);
1195 IO_Write(0x3c9,mtext_palette[i][1]);
1196 IO_Write(0x3c9,mtext_palette[i][2]);
1197 }
1198 }
1199 break;
1200 } //FALLTHROUGH!!!!
1201 case M_LIN4: //Added for CAD Software
1202 dac_text16:
1203 for (i=0;i<64;i++) {
1204 IO_Write(0x3c9,text_palette[i][0]);
1205 IO_Write(0x3c9,text_palette[i][1]);
1206 IO_Write(0x3c9,text_palette[i][2]);
1207 }
1208 break;
1209 case M_VGA:
1210 case M_LIN8:
1211 case M_LIN15:
1212 case M_LIN16:
1213 case M_LIN32:
1214 for (i=0;i<256;i++) {
1215 IO_Write(0x3c9,vga_palette[i][0]);
1216 IO_Write(0x3c9,vga_palette[i][1]);
1217 IO_Write(0x3c9,vga_palette[i][2]);
1218 }
1219 break;
1220 }
1221 if (IS_VGA_ARCH) {
1222 /* check if gray scale summing is enabled */
1223 if (real_readb(BIOSMEM_SEG,BIOSMEM_MODESET_CTL) & 2) {
1224 INT10_PerformGrayScaleSumming(0,256);
1225 }
1226 }
1227 } else {
1228 for (Bit8u ct=0x10;ct<ATT_REGS;ct++) {
1229 if (ct==0x11) continue; // skip overscan register
1230 IO_Write(0x3c0,ct);
1231 IO_Write(0x3c0,att_data[ct]);
1232 }
1233 vga.config.pel_panning = 0;
1234 IO_Write(0x3c0,0x20); //Disable palette access
1235 }
1236 /* Setup some special stuff for different modes */
1237 Bit8u feature=real_readb(BIOSMEM_SEG,BIOSMEM_INITIAL_MODE);
1238 switch (CurMode->type) {
1239 case M_CGA2:
1240 feature=(feature&~0x30)|0x20;
1241 real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MSR,0x1e);
1242 break;
1243 case M_CGA4:
1244 feature=(feature&~0x30)|0x20;
1245 if (CurMode->mode==4) real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MSR,0x2a);
1246 else if (CurMode->mode==5) real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MSR,0x2e);
1247 else real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MSR,0x2);
1248 break;
1249 case M_TANDY16:
1250 feature=(feature&~0x30)|0x20;
1251 break;
1252 case M_TEXT:
1253 feature=(feature&~0x30)|0x20;
1254 switch (CurMode->mode) {
1255 case 0:real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MSR,0x2c);break;
1256 case 1:real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MSR,0x28);break;
1257 case 2:real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MSR,0x2d);break;
1258 case 3:
1259 case 7:real_writeb(BIOSMEM_SEG,BIOSMEM_CURRENT_MSR,0x29);break;
1260 }
1261 break;
1262 case M_LIN4:
1263 case M_EGA:
1264 case M_VGA:
1265 feature=(feature&~0x30);
1266 break;
1267 }
1268 // disabled, has to be set in bios.cpp exclusively
1269 // real_writeb(BIOSMEM_SEG,BIOSMEM_INITIAL_MODE,feature);
1270
1271 if (svgaCard == SVGA_S3Trio) {
1272 /* Setup the CPU Window */
1273 IO_Write(crtc_base,0x6a);
1274 IO_Write(crtc_base+1,0);
1275 /* Setup the linear frame buffer */
1276 IO_Write(crtc_base,0x59);
1277 IO_Write(crtc_base+1,(Bit8u)((S3_LFB_BASE >> 24)&0xff));
1278 IO_Write(crtc_base,0x5a);
1279 IO_Write(crtc_base+1,(Bit8u)((S3_LFB_BASE >> 16)&0xff));
1280 IO_Write(crtc_base,0x6b); // BIOS scratchpad
1281 IO_Write(crtc_base+1,(Bit8u)((S3_LFB_BASE >> 24)&0xff));
1282
1283 /* Setup some remaining S3 registers */
1284 IO_Write(crtc_base,0x41); // BIOS scratchpad
1285 IO_Write(crtc_base+1,0x88);
1286 IO_Write(crtc_base,0x52); // extended BIOS scratchpad
1287 IO_Write(crtc_base+1,0x80);
1288
1289 IO_Write(0x3c4,0x15);
1290 IO_Write(0x3c5,0x03);
1291
1292 // Accellerator setup
1293 Bitu reg_50=S3_XGA_8BPP;
1294 switch (CurMode->type) {
1295 case M_LIN15:
1296 case M_LIN16: reg_50|=S3_XGA_16BPP; break;
1297 case M_LIN32: reg_50|=S3_XGA_32BPP; break;
1298 default: break;
1299 }
1300 switch(CurMode->swidth) {
1301 case 640: reg_50|=S3_XGA_640; break;
1302 case 800: reg_50|=S3_XGA_800; break;
1303 case 1024: reg_50|=S3_XGA_1024; break;
1304 case 1152: reg_50|=S3_XGA_1152; break;
1305 case 1280: reg_50|=S3_XGA_1280; break;
1306 default: break;
1307 }
1308 IO_WriteB(crtc_base,0x50); IO_WriteB(crtc_base+1,reg_50);
1309
1310 Bit8u reg_31, reg_3a;
1311 switch (CurMode->type) {
1312 case M_LIN15:
1313 case M_LIN16:
1314 case M_LIN32:
1315 reg_3a=0x15;
1316 break;
1317 case M_LIN8:
1318 // S3VBE20 does it this way. The other double pixel bit does not
1319 // seem to have an effect on the Trio64.
1320 if(CurMode->special&_VGA_PIXEL_DOUBLE) reg_3a=0x5;
1321 else reg_3a=0x15;
1322 break;
1323 default:
1324 reg_3a=5;
1325 break;
1326 };
1327
1328 switch (CurMode->type) {
1329 case M_LIN4: // <- Theres a discrepance with real hardware on this
1330 case M_LIN8:
1331 case M_LIN15:
1332 case M_LIN16:
1333 case M_LIN32:
1334 reg_31 = 9;
1335 break;
1336 default:
1337 reg_31 = 5;
1338 break;
1339 }
1340 IO_Write(crtc_base,0x3a);IO_Write(crtc_base+1,reg_3a);
1341 IO_Write(crtc_base,0x31);IO_Write(crtc_base+1,reg_31); //Enable banked memory and 256k+ access
1342 IO_Write(crtc_base,0x58);IO_Write(crtc_base+1,0x3); //Enable 8 mb of linear addressing
1343
1344 IO_Write(crtc_base,0x38);IO_Write(crtc_base+1,0x48); //Register lock 1
1345 IO_Write(crtc_base,0x39);IO_Write(crtc_base+1,0xa5); //Register lock 2
1346 } else if (svga.set_video_mode) {
1347 VGA_ModeExtraData modeData;
1348 modeData.ver_overflow = ver_overflow;
1349 modeData.hor_overflow = hor_overflow;
1350 modeData.offset = offset;
1351 modeData.modeNo = CurMode->mode;
1352 modeData.htotal = CurMode->htotal;
1353 modeData.vtotal = CurMode->vtotal;
1354 svga.set_video_mode(crtc_base, &modeData);
1355 }
1356
1357 FinishSetMode(clearmem);
1358
1359 /* Set vga attrib register into defined state */
1360 IO_Read(mono_mode ? 0x3ba : 0x3da);
1361 IO_Write(0x3c0,0x20);
1362
1363 /* Load text mode font */
1364 if (CurMode->type==M_TEXT) {
1365 INT10_ReloadFont();
1366 }
1367 return true;
1368 }
1369
1370 Bitu VideoModeMemSize(Bitu mode) {
1371 if (!IS_VGA_ARCH)
1372 return 0;
1373
1374 VideoModeBlock* modelist = NULL;
1375
1376 switch (svgaCard) {
1377 case SVGA_TsengET4K:
1378 case SVGA_TsengET3K:
1379 modelist = ModeList_VGA_Tseng;
1380 break;
1381 case SVGA_ParadisePVGA1A:
1382 modelist = ModeList_VGA_Paradise;
1383 break;
1384 default:
1385 modelist = ModeList_VGA;
1386 break;
1387 }
1388
1389 VideoModeBlock* vmodeBlock = NULL;
1390 Bitu i=0;
1391 while (modelist[i].mode!=0xffff) {
1392 if (modelist[i].mode==mode) {
1393 vmodeBlock = &modelist[i];
1394 break;
1395 }
1396 i++;
1397 }
1398 if (!vmodeBlock)
1399 return 0;
1400
1401 switch(vmodeBlock->type) {
1402 case M_LIN4:
1403 return vmodeBlock->swidth*vmodeBlock->sheight/2;
1404 case M_LIN8:
1405 return vmodeBlock->swidth*vmodeBlock->sheight;
1406 case M_LIN15: case M_LIN16:
1407 return vmodeBlock->swidth*vmodeBlock->sheight*2;
1408 case M_LIN32:
1409 return vmodeBlock->swidth*vmodeBlock->sheight*4;
1410 case M_TEXT:
1411 return vmodeBlock->twidth*vmodeBlock->theight*2;
1412 }
1413 // Return 0 for all other types, those always fit in memory
1414 return 0;
1415 }