vidmodes.c 15.3 KB
Newer Older
1
/* $Id: vidmodes.c,v 1.33 2020/06/27 00:04:45 deuce Exp $ */
2

deuce's avatar
deuce committed
3
#include <stdlib.h>
4
#include <stdbool.h>
deuce's avatar
deuce committed
5

6
7
8
/* xpdev: */
#include <gen_defs.h>	/* FREE_AND_NULL */

9
#include "vidmodes.h"
deuce's avatar
deuce committed
10

11
// TODO: Pretty much all the 1:1 aspect ratios are wrong...
12
struct video_params vparams[] = {
13
	/* BW 40x25 */
14
	{BW40, GREYSCALE_PALETTE,             40, 25, 14, 15, 16, 8, 7, 0,  4, 3, 320,  200},
15
	/* CO 40x25 */
16
	{C40, COLOUR_PALETTE,                 40, 25, 14, 15, 16, 8, 7, 0,  4, 3, 320,  200},
17
	/* BW 80x25 */
18
	{BW80, GREYSCALE_PALETTE,             80, 25, 14, 15, 16, 8, 7, 0,  4, 3, 640,  400},
19
	/* CO 80x25 */
20
	{C80, COLOUR_PALETTE,                 80, 25, 14, 15, 16, 8, 7, 0,  4, 3, 640,  400},
21
	/* MONO */
22
	{MONO, 0,                             80, 25, 14, 15, 16, 8, 7, 0,  4, 3, 640,  400},
23
	/* CO 40x14 */
24
	{C40X14, COLOUR_PALETTE,              40, 14, 14, 15, 16, 8, 7, 0,  4, 3, 320,  224},
25
	/* CO 40x21 */
26
	{C40X21, COLOUR_PALETTE,              40, 21, 14, 15, 16, 8, 7, 0,  4, 3, 320,  336},
27
	/* CO 40x28 */
28
	{C40X28, COLOUR_PALETTE,              40, 28, 12, 13, 14, 8, 7, 0,  4, 3, 320,  392},
29
	/* CO 40x43 */
30
	{C40X43, COLOUR_PALETTE,              40, 43,  7,  7,  8, 8, 7, 0,  4, 3, 320,  774},
31
	/* CO 40x50 */
32
	{C40X50, COLOUR_PALETTE,              40, 50,  7,  7,  8, 8, 7, 0,  4, 3, 320,  400},
33
	/* CO 40x60 */
34
	{C40X60, COLOUR_PALETTE,              40, 60,  7,  7,  8, 8, 7, 0,  4, 3, 320,  480},
35
	/* CO 80x14 */
36
	{C80X14, COLOUR_PALETTE,              80, 14, 14, 15, 16, 8, 7, 0,  4, 3, 640,  224},
37
	/* CO 80x21 */
38
	{C80X21, COLOUR_PALETTE,              80, 21, 14, 15, 16, 8, 7, 0,  4, 3, 640,  336},
39
	/* CO 80x28 */
40
	{C80X28, COLOUR_PALETTE,              80, 28, 12, 13, 14, 8, 7, 0,  4, 3, 640,  392},
41
	/* CO 80x30 */
42
	{C80X30, COLOUR_PALETTE,              80, 30, 14, 15, 16, 8, 7, 0,  4, 3, 640,  480},
43
	/* CO 80x43 */
44
	{C80X43, COLOUR_PALETTE,              80, 43,  7,  7,  8, 8, 7, 0,  4, 3, 640,  350},
45
	/* EGA 80x25 */
46
	{EGA80X25, COLOUR_PALETTE,            80, 25, 12, 13, 14, 8, 7, 0,  4, 3, 640,  350},
47
	/* CO 80x50 */
48
	{C80X50, COLOUR_PALETTE,              80, 50,  7,  7,  8, 8, 7, 0,  4, 3, 640,  400},
49
	/* CO 80x60 */
50
	{C80X60, COLOUR_PALETTE,              80, 60,  7,  7,  8, 8, 7, 0,  4, 3, 640,  480},
51
	/* B 40x14 */
52
	{BW40X14, GREYSCALE_PALETTE,          40, 14, 14, 15, 16, 8, 7, 0,  4, 3, 320,  224},
53
	/* BW 40x21 */
54
	{BW40X21, GREYSCALE_PALETTE,          40, 21, 14, 15, 16, 8, 7, 0,  4, 3, 320,  336},
55
	/* BW 40x28 */
56
	{BW40X28, GREYSCALE_PALETTE,          40, 28, 12, 13, 14, 8, 7, 0,  4, 3, 320,  392},
57
	/* BW 40x43 */
58
	{BW40X43, GREYSCALE_PALETTE,          40, 43,  7,  7, 14, 8, 7, 0,  4, 3, 320,  350},
59
	/* BW 40x50 */
60
	{BW40X50, GREYSCALE_PALETTE,          40, 50,  7,  7,  8, 8, 7, 0,  4, 3, 320,  400},
61
	/* BW 40x60 */
62
	{BW40X60, GREYSCALE_PALETTE,          40, 60,  7,  7,  8, 8, 7, 0,  4, 3, 320,  480},
63
	/* BW 80x14 */
64
	{BW80X14, GREYSCALE_PALETTE,          80, 14, 14, 15, 16, 8, 7, 0,  4, 3, 640,  224},
65
	/* BW 80x21 */
66
	{BW80X21, GREYSCALE_PALETTE,          80, 21, 14, 15, 16, 8, 7, 0,  4, 3, 640,  336},
67
	/* BW 80x28 */
68
	{BW80X28, GREYSCALE_PALETTE,          80, 28, 12, 13, 14, 8, 7, 0,  4, 3, 640,  392},
69
	/* BW 80x43 */
70
	{BW80X43, GREYSCALE_PALETTE,          80, 43,  7,  7, 14, 8, 7, 0,  4, 3, 640,  350},
71
	/* BW 80x50 */
72
	{BW80X50, GREYSCALE_PALETTE,          80, 50,  7,  7,  8, 8, 7, 0,  4, 3, 640,  400},
73
	/* BW 80x60 */
74
	{BW80X60, GREYSCALE_PALETTE,          80, 60,  7,  7,  8, 8, 7, 0,  4, 3, 640,  480},
75
	/* MONO 80x14 */
76
	{MONO14, MONO_PALETTE,                80, 14, 14, 15, 16, 8, 7, 0,  4, 3, 640,  224},
77
	/* MONO 80x21 */
78
	{MONO21, MONO_PALETTE,                80, 21, 14, 15, 16, 8, 7, 0,  4, 3, 640,  336},
79
	/* MONO 80x28 */
80
	{MONO28, MONO_PALETTE,                80, 28, 12, 13, 14, 8, 7, 0,  4, 3, 640,  392},
81
	/* MONO 80x43 */
82
	{MONO43, MONO_PALETTE,                80, 43,  7,  7, 14, 8, 7, 0,  4, 3, 640,  350},
83
	/* MONO 80x50 */
84
	{MONO50, MONO_PALETTE,                80, 50,  7,  7,  8, 8, 7, 0,  4, 3, 640,  400},
85
	/* MONO 80x60 */
86
	{MONO60, MONO_PALETTE,                80, 60,  7,  7,  8, 8, 7, 0,  4, 3, 640,  480},
87
	/* Magical C4350 Mode */
88
	{C4350, COLOUR_PALETTE,               80, 50,  7,  7,  8, 8, 7, 0,  4, 3, 640,  400},
89
	/* Commodore 64 40x25 mode */
90
91
92
	// This is the NTSC aspect ratio... the pixel aspect ratio is about 75:100 due to the
	// borders.
	{C64_40X25, C64_PALETTE,              40, 25,  0,  7,  8, 8, 0x6e, CIOLIB_VIDEO_BGBRIGHT|CIOLIB_VIDEO_NOBLINK,  6, 5, 320, 200},
93
	/* Commodore 128 40x25 mode */
94
95
	// The C128 uses the same aspect ratio as the C64 in 40 column mode
	{C128_40X25, C64_PALETTE,             40, 25,  0,  7,  8, 8, 0xbd, CIOLIB_VIDEO_BGBRIGHT|CIOLIB_VIDEO_NOBLINK,  6, 5, 320, 200},
96
	/* Commodore 128 80x25 mode */
97
98
	// But in 80-column mode is a 4:3 CGA style output.
	{C128_80X25, COLOUR_PALETTE,          80, 25,  0,  7,  8, 8, 7,    CIOLIB_VIDEO_BGBRIGHT|CIOLIB_VIDEO_NOBLINK,  4, 3, 640, 200},
99
	/* Atari 800 40x24 mode */
100
	{ATARI_40X24, ATARI_PALETTE,          40, 24,  0,  7,  8, 8, 7, 0,  4, 3, 320,  192},
101
	/* Atari 800 XEP80 80x25 mode */
102
	{ATARI_80X25, GREYSCALE_PALETTE,      80, 25,  0, 15, 16, 8, 7, 0,  4, 3, 640,  400},
deuce's avatar
deuce committed
103
	/* VESA 21x132 mode */
104
	{VESA_132X21, COLOUR_PALETTE,        132, 21, 14, 15, 16, 8, 7, 0,  4, 3, 1056, 336},
deuce's avatar
deuce committed
105
	/* VESA 25x132 mode */
106
	{VESA_132X25, COLOUR_PALETTE,        132, 25, 14, 15, 16, 8, 7, 0,  4, 3, 1056, 400},
deuce's avatar
deuce committed
107
	/* VESA 28x132 mode */
108
	{VESA_132X28, COLOUR_PALETTE,        132, 28, 12, 13, 14, 8, 7, 0,  4, 3, 1056, 392},
deuce's avatar
deuce committed
109
	/* VESA 30x132 mode */
110
	{VESA_132X30, COLOUR_PALETTE,        132, 30, 14, 15, 16, 8, 7, 0,  4, 3, 1056, 480},
deuce's avatar
deuce committed
111
	/* VESA 34x132 mode */
112
	{VESA_132X34, COLOUR_PALETTE,        132, 34, 12, 13, 14, 8, 7, 0,  4, 3, 1056, 476},
deuce's avatar
deuce committed
113
	/* VESA 43x132 mode */
114
	{VESA_132X43, COLOUR_PALETTE,        132, 43,  7,  7,  8, 8, 7, 0,  4, 3, 1056, 350},
deuce's avatar
deuce committed
115
	/* VESA 50x132 mode */
116
	{VESA_132X50, COLOUR_PALETTE,        132, 50,  7,  7,  8, 8, 7, 0,  4, 3, 1056, 400},
deuce's avatar
deuce committed
117
	/* VESA 60x132 mode */
118
	{VESA_132X60, COLOUR_PALETTE,        132, 60,  7,  7,  8, 8, 7, 0,  4, 3, 1056, 480},
119
	/* Awesome modes */
120
121
	{ST132X37_16_9, COLOUR_PALETTE,      132, 37, 14, 15, 16, 8, 7, 0, 16, 9, 1056, 600},
	{ST132X52_5_4, COLOUR_PALETTE,       132, 52, 14, 15, 16, 8, 7, 0,  5, 4, 1056, 823},
Deucе's avatar
Deucе committed
122
	/* Stupid modes */
123
	{VGA80X25, COLOUR_PALETTE,            80, 25, 14, 15, 16, 9, 7, CIOLIB_VIDEO_EXPAND | CIOLIB_VIDEO_LINE_GRAPHICS_EXPAND, 4, 3, 720, 400},
124
125
	/* DigitalMon */
	{LCD80X25, COLOUR_PALETTE,            80, 25, 14, 15, 16, 8, 7, 0,  8, 5, 640,  400},
126
	/* Custom mode */
127
	{CIOLIB_MODE_CUSTOM, COLOUR_PALETTE, 80,  25, 14, 15, 16, 8, 7, 0,  0, 0,   -1,  -1},
128
129
};

130
uint32_t palettes[5][16] = {
131
132
133
134
135
136
137
138
139
	/* Mono */
	{ 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
	  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07
	},
	/* Black and White */
	{ 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
	  0x08, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f
	},
	/* Colour */
140
141
	{ 0x00, 0x04, 0x02, 0x06, 0x01, 0x05, 0x03, 0x07, 
	  0x08, 0x0c, 0x0a, 0x0e, 0x09, 0x0d, 0x0b, 0x0f
deuce's avatar
deuce committed
142
	},
143
	/* C64 */
144
145
	{ 0x100, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 
	  0x108, 0x109, 0x10a, 0x10b, 0x10c, 0x10d, 0x10e, 0x10f
146
	},
deuce's avatar
deuce committed
147
	/* Atari */
148
149
	{ 0x110, 0x111, 0x111, 0x111, 0x111, 0x111, 0x111, 0x111,
	  0x111, 0x111, 0x111, 0x111, 0x111, 0x111, 0x111, 0x111
deuce's avatar
deuce committed
150
	},
151
152
};

153
struct dac_colors dac_default[TOTAL_DAC_SIZE] = {
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
	/* "System" colours */
	{0, 0, 0},       // Black
	{168, 0, 0},     // Red
	{0, 168, 0},     // Green
	{168, 84, 0},    // Brown
	{0, 0, 168},     // Blue
	{168, 0, 168},   // Magenta
	{0, 168, 168},   // Cyan
	{168, 168, 168}, // Light Gray

	{84, 84, 84},    // Dark Gray
	{255, 84, 84},   // Light Red
	{84, 255, 84},   // Light Green
	{255, 255, 84},  // Yellow
	{84, 84, 255},   // Light Blue
	{255, 84, 255},  // Light Magenta
	{84, 255, 255},  // Light Cyan
	{255, 255, 255}, // White

	/* XTerm 256 colour palette */
	{0, 0, 0}, {0, 0, 95}, {0, 0, 135}, {0, 0, 175},
	{0, 0, 215}, {0, 0, 255}, {0, 95, 0}, {0, 95, 95},
	{0, 95, 135}, {0, 95, 175}, {0, 95, 215}, {0, 95, 255},
	{0, 135, 0}, {0, 135, 95}, {0, 135, 135}, {0, 135, 175},
	{0, 135, 215}, {0, 135, 255}, {0, 175, 0}, {0, 175, 95},
	{0, 175, 135}, {0, 175, 175}, {0, 175, 215}, {0, 175, 255},
	{0, 215, 0}, {0, 215, 95}, {0, 215, 135}, {0, 215, 175},
	{0, 215, 215}, {0, 215, 255}, {0, 255, 0}, {0, 255, 95},
	{0, 255, 135}, {0, 255, 175}, {0, 255, 215}, {0, 255, 255},
	{95, 0, 0}, {95, 0, 95}, {95, 0, 135}, {95, 0, 175},
	{95, 0, 215}, {95, 0, 255}, {95, 95, 0}, {95, 95, 95},
	{95, 95, 135}, {95, 95, 175}, {95, 95, 215}, {95, 95, 255},
	{95, 135, 0}, {95, 135, 95}, {95, 135, 135}, {95, 135, 175},
	{95, 135, 215}, {95, 135, 255}, {95, 175, 0}, {95, 175, 95},
	{95, 175, 135}, {95, 175, 175}, {95, 175, 215}, {95, 175, 255},
	{95, 215, 0}, {95, 215, 95}, {95, 215, 135}, {95, 215, 175},
	{95, 215, 215}, {95, 215, 255}, {95, 255, 0}, {95, 255, 95},
	{95, 255, 135}, {95, 255, 175}, {95, 255, 215}, {95, 255, 255},
	{135, 0, 0}, {135, 0, 95}, {135, 0, 135}, {135, 0, 175},
	{135, 0, 215}, {135, 0, 255}, {135, 95, 0}, {135, 95, 95},
	{135, 95, 135}, {135, 95, 175}, {135, 95, 215}, {135, 95, 255},
	{135, 135, 0}, {135, 135, 95}, {135, 135, 135}, {135, 135, 175},
	{135, 135, 215}, {135, 135, 255}, {135, 175, 0}, {135, 175, 95},
	{135, 175, 135}, {135, 175, 175}, {135, 175, 215}, {135, 175, 255},
	{135, 215, 0}, {135, 215, 95}, {135, 215, 135}, {135, 215, 175},
	{135, 215, 215}, {135, 215, 255}, {135, 255, 0}, {135, 255, 95},
	{135, 255, 135}, {135, 255, 175}, {135, 255, 215}, {135, 255, 255},
	{175, 0, 0}, {175, 0, 95}, {175, 0, 135}, {175, 0, 175},
	{175, 0, 215}, {175, 0, 255}, {175, 95, 0}, {175, 95, 95},
	{175, 95, 135}, {175, 95, 175}, {175, 95, 215}, {175, 95, 255},
	{175, 135, 0}, {175, 135, 95}, {175, 135, 135}, {175, 135, 175},
	{175, 135, 215}, {175, 135, 255}, {175, 175, 0}, {175, 175, 95},
	{175, 175, 135}, {175, 175, 175}, {175, 175, 215}, {175, 175, 255},
	{175, 215, 0}, {175, 215, 95}, {175, 215, 135}, {175, 215, 175},
	{175, 215, 215}, {175, 215, 255}, {175, 255, 0}, {175, 255, 95},
	{175, 255, 135}, {175, 255, 175}, {175, 255, 215}, {175, 255, 255},
	{215, 0, 0}, {215, 0, 95}, {215, 0, 135}, {215, 0, 175},
	{215, 0, 215}, {215, 0, 255}, {215, 95, 0}, {215, 95, 95},
	{215, 95, 135}, {215, 95, 175}, {215, 95, 215}, {215, 95, 255},
	{215, 135, 0}, {215, 135, 95}, {215, 135, 135}, {215, 135, 175},
	{215, 135, 215}, {215, 135, 255}, {215, 175, 0}, {215, 175, 95},
	{215, 175, 135}, {215, 175, 175}, {215, 175, 215}, {215, 175, 255},
	{215, 215, 0}, {215, 215, 95}, {215, 215, 135}, {215, 215, 175},
	{215, 215, 215}, {215, 215, 255}, {215, 255, 0}, {215, 255, 95},
	{215, 255, 135}, {215, 255, 175}, {215, 255, 215}, {215, 255, 255},
	{255, 0, 0}, {255, 0, 95}, {255, 0, 135}, {255, 0, 175},
	{255, 0, 215}, {255, 0, 255}, {255, 95, 0}, {255, 95, 95},
	{255, 95, 135}, {255, 95, 175}, {255, 95, 215}, {255, 95, 255},
	{255, 135, 0}, {255, 135, 95}, {255, 135, 135}, {255, 135, 175},
	{255, 135, 215}, {255, 135, 255}, {255, 175, 0}, {255, 175, 95},
	{255, 175, 135}, {255, 175, 175}, {255, 175, 215}, {255, 175, 255},
	{255, 215, 0}, {255, 215, 95}, {255, 215, 135}, {255, 215, 175},
	{255, 215, 215}, {255, 215, 255}, {255, 255, 0}, {255, 255, 95},
	{255, 255, 135}, {255, 255, 175}, {255, 255, 215}, {255, 255, 255},
	{8, 8, 8}, {18, 18, 18}, {28, 28, 28}, {38, 38, 38},
	{48, 48, 48}, {58, 58, 58}, {68, 68, 68}, {78, 78, 78},
	{88, 88, 88}, {98, 98, 98}, {108, 108, 108}, {118, 118, 118},
	{128, 128, 128}, {138, 138, 138}, {148, 148, 148}, {158, 158, 158},
	{168, 168, 168}, {178, 178, 178}, {188, 188, 188}, {198, 198, 198},
	{208, 208, 208}, {218, 218, 218}, {228, 228, 228}, {238, 238, 238}, 

235
236
237
	/* C64 colours */
	/* Black, White, Red, Cyan, Purple, Green, Blue, Yellow */
	/* Orange, Brown, Lt Red, Dk Grey, Grey, Lt Green, Lt Blue, Lt Grey */
238
#if 0
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
	/* Taken from CTerm source */
	{0x00, 0x00, 0x00},	// Black
	{0xFD, 0xFE, 0xFC},	// White
	{0xBE, 0x1A, 0x24},	// Red
	{0x30, 0xE6, 0xC6},	// Cyan
	{0xB4, 0x1A, 0xE2},	// Purple
	{0x1F, 0xD2, 0x1E},	// Green
	{0x21, 0x1B, 0xAE},	// Blue
	{0xDF, 0xF6, 0x0A},	// Yellow
	{0xB8, 0x41, 0x04},	// Orange
	{0x6A, 0x33, 0x04},	// Brown
	{0xFE, 0x4A, 0x57},	// Light Red
	{0x42, 0x45, 0x40},	// Dark Grey
	{0x70, 0x74, 0x6F},	// Grey
	{0x59, 0xFE, 0x59},	// Light Green
	{0x5F, 0x53, 0xFE},	// Light Blue
	{0xA4, 0xA7, 0xA2},	// Light Grey
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#else
	/*
	 * Taken from https://www.pepto.de/projects/colorvic/
	 * a much more convincing source.
	 */
	{0x00, 0x00, 0x00},
	{0xFF, 0xFF, 0xFF},
	{0x81, 0x33, 0x38},
	{0x75, 0xCE, 0xC8},
	{0x8E, 0x3C, 0x97},
	{0x56, 0xAC, 0x4D},
	{0x2E, 0x2C, 0x9B},
	{0xED, 0xF1, 0x71},
	{0x8E, 0x50, 0x29},
	{0x55, 0x38, 0x00},
	{0xC4, 0x6C, 0x71},
	{0x4A, 0x4A, 0x4A},
	{0x7B, 0x7B, 0x7B},
	{0xA9, 0xFF, 0x9F},
	{0x70, 0x6D, 0xEB},
	{0xB2, 0xB2, 0xB2},
#endif

deuce's avatar
deuce committed
279
280
	/* Atari Colours */
	/* BG, FG */
deuce's avatar
deuce committed
281
	{0, 81, 129}, {96, 183, 231},
282
283
284
285
286
287
288
289
290
291
292
293
294
};

int find_vmode(int mode)
{
    unsigned i;

	for (i = 0; i < NUMMODES; i++)
		if (vparams[i].mode == mode)
			return i;

	return -1;
}

deuce's avatar
deuce committed
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
struct vstat_vmem *get_vmem(struct video_stats *vs)
{
	vs->vmem->refcount++;
	return vs->vmem;
}

void release_vmem(struct vstat_vmem *vm)
{
	if (vm == NULL)
		return;
	vm->refcount--;
	if (vm->refcount == 0) {
		FREE_AND_NULL(vm->vmem);
		FREE_AND_NULL(vm);
	}
}

312
static struct vstat_vmem *new_vmem(int cols, int rows, bool palette)
deuce's avatar
deuce committed
313
314
315
316
317
318
{
	struct vstat_vmem *ret = malloc(sizeof(struct vstat_vmem));

	if (ret == NULL)
		return ret;
	ret->refcount = 1;
319
	ret->vmem = malloc(cols*rows*sizeof(ret->vmem[0]));
deuce's avatar
deuce committed
320
321
322
323
324
325
326
	if (ret->vmem == NULL) {
		free(ret);
		return NULL;
	}
	return ret;
}

327
328
329
330
331
332
333
int load_vmode(struct video_stats *vs, int mode)
{
	int i;

	i=find_vmode(mode);
	if(i==-1)
		return(-1);
deuce's avatar
deuce committed
334
	release_vmem(vs->vmem);
335
	vs->vmem=new_vmem(vparams[i].cols, vparams[i].rows, vs->flags & VIDMODES_FLAG_PALETTE_VMEM);
deuce's avatar
deuce committed
336
337
	if (vs->vmem == NULL)
		return -1;
338
339
340
341
342
343
	vs->rows=vparams[i].rows;
	vs->cols=vparams[i].cols;
	vs->curs_start=vparams[i].curs_start;
	vs->curs_end=vparams[i].curs_end;
	vs->default_curs_start=vparams[i].curs_start;
	vs->default_curs_end=vparams[i].curs_end;
deuce's avatar
deuce committed
344
	vs->curs_blinks=1;
345
	vs->curs_visible=1;
deuce's avatar
deuce committed
346
347
	vs->curs_row=1;
	vs->curs_col=1;
348
349
350
351
352
	vs->bright_background=vparams[i].flags & CIOLIB_VIDEO_BGBRIGHT;
	vs->no_bright=vparams[i].flags & CIOLIB_VIDEO_NOBRIGHT;
	vs->bright_altcharset=vparams[i].flags & CIOLIB_VIDEO_ALTCHARS;
	vs->no_blink=vparams[i].flags & CIOLIB_VIDEO_NOBLINK;
	vs->blink_altcharset=vparams[i].flags & CIOLIB_VIDEO_BLINKALTCHARS;
Deucе's avatar
Deucе committed
353
354
355
356
357
358
359
360
	if (vparams[i].flags & CIOLIB_VIDEO_EXPAND)
		vs->flags |= VIDMODES_FLAG_EXPAND;
	else
		vs->flags &= ~VIDMODES_FLAG_EXPAND;
	if (vparams[i].flags & CIOLIB_VIDEO_LINE_GRAPHICS_EXPAND)
		vs->flags |= VIDMODES_FLAG_LINE_GRAPHICS_EXPAND;
	else
		vs->flags &= ~VIDMODES_FLAG_LINE_GRAPHICS_EXPAND;
361
362
363
364
365
366
367
368
	if(vs->curs_row < 0)
		vs->curs_row=0;
	if(vs->curs_row >= vparams[i].rows)
		vs->curs_row=vparams[i].rows-1;
	if(vs->curs_col < 0)
		vs->curs_col=0;
	if(vs->curs_col >= vparams[i].cols)
		vs->curs_col=vparams[i].cols-1;
369
	memcpy(vs->palette, palettes[vparams[i].palette], sizeof(vs->palette));
370
371
372
	vs->charheight=vparams[i].charheight;
	vs->charwidth=vparams[i].charwidth;
	vs->mode=mode;
373
	vs->currattr = vparams[i].default_attr;
374
375
376
377
378
379
	vs->aspect_width = vparams[i].aspect_width;
	vs->aspect_height = vparams[i].aspect_height;
	if (vs->aspect_width == 0 || vs->aspect_height == 0) {
		vs->aspect_width = vs->scrnwidth;
		vs->aspect_height = vs->scrnheight;
	}
380
381
382
383
384
385
386
387
388
	if (vparams[i].xres > 0)
		vs->scrnwidth = vparams[i].xres;
	else
		vs->scrnwidth = vs->charwidth * vs->cols;
	if (vparams[i].yres > 0)
		vs->scrnheight = vparams[i].yres;
	else
		vs->scrnheight = vs->charheight * vs->rows;
	vs->forced_font = NULL;
389
390
	return(0);
}