Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

vidmodes.c 14.8 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, 1, 7, 0, 833, 1000, 320,  200},
15
	/* CO 40x25 */
16
	{C40, COLOUR_PALETTE,                 40, 25, 14, 15, 16, 8, 1, 7, 0, 833, 1000, 320,  200},
17
	/* BW 80x25 */
18
	{BW80, GREYSCALE_PALETTE,             80, 25, 14, 15, 16, 8, 1, 7, 0, 833, 1000, 640,  400},
19
	/* CO 80x25 */
20
	{C80, COLOUR_PALETTE,                 80, 25, 14, 15, 16, 8, 1, 7, 0, 833, 1000, 640,  400},
21
	/* MONO */
22
	{MONO, 0,                             80, 25, 14, 15, 16, 8, 1, 7, 0, 833, 1000, 640,  400},
23
	/* CO 40x14 */
24
	{C40X14, COLOUR_PALETTE,              40, 14, 14, 15, 16, 8, 1, 7, 0,   1,    1, 320,  224},
25
	/* CO 40x21 */
26
	{C40X21, COLOUR_PALETTE,              40, 21, 14, 15, 16, 8, 1, 7, 0,   1,    1, 320,  336},
27
	/* CO 40x28 */
28
	{C40X28, COLOUR_PALETTE,              40, 28, 12, 13, 14, 8, 1, 7, 0,   1,    1, 320,  392},
29
	/* CO 40x43 */
30
	{C40X43, COLOUR_PALETTE,              40, 43,  7,  7,  8, 8, 1, 7, 0,   1,    1, 320,  774},
31
	/* CO 40x50 */
32
	{C40X50, COLOUR_PALETTE,              40, 50,  7,  7,  8, 8, 1, 7, 0,   1,    1, 320,  400},
33
	/* CO 40x60 */
34
	{C40X60, COLOUR_PALETTE,              40, 60,  7,  7,  8, 8, 1, 7, 0,   1,    1, 320,  480},
35
	/* CO 80x14 */
36
	{C80X14, COLOUR_PALETTE,              80, 14, 14, 15, 16, 8, 1, 7, 0,   1,    1, 640,  224},
37
	/* CO 80x21 */
38
	{C80X21, COLOUR_PALETTE,              80, 21, 14, 15, 16, 8, 1, 7, 0,   1,    1, 640,  336},
39
	/* CO 80x28 */
40
	{C80X28, COLOUR_PALETTE,              80, 28, 12, 13, 14, 8, 1, 7, 0,   1,    1, 640,  392},
41
	/* CO 80x30 */
42
	{C80X30, COLOUR_PALETTE,              80, 30, 14, 15, 16, 8, 1, 7, 0,   1,    1, 640,  480},
43
	/* CO 80x43 */
44
	{C80X43, COLOUR_PALETTE,              80, 43,  7,  7,  8, 8, 1, 7, 0, 729, 1000, 640,  350},
45
	/* EGA 80x25 */
46
	{EGA80X25, COLOUR_PALETTE,            80, 25, 12, 13, 14, 8, 1, 7, 0, 729, 1000, 640,  350},
47
	/* CO 80x50 */
48
	{C80X50, COLOUR_PALETTE,              80, 50,  7,  7,  8, 8, 1, 7, 0, 833, 1000, 640,  400},
49
	/* CO 80x60 */
50
	{C80X60, COLOUR_PALETTE,              80, 60,  7,  7,  8, 8, 1, 7, 0,   1,    1, 640,  480},
51
	/* B 40x14 */
52
	{BW40X14, GREYSCALE_PALETTE,          40, 14, 14, 15, 16, 8, 1, 7, 0,   1,    1, 320,  224},
53
	/* BW 40x21 */
54
	{BW40X21, GREYSCALE_PALETTE,          40, 21, 14, 15, 16, 8, 1, 7, 0,   1,    1, 320,  336},
55
	/* BW 40x28 */
56
	{BW40X28, GREYSCALE_PALETTE,          40, 28, 12, 13, 14, 8, 1, 7, 0,   1,    1, 320,  392},
57
	/* BW 40x43 */
58
	{BW40X43, GREYSCALE_PALETTE,          40, 43,  7,  7, 14, 8, 1, 7, 0,   1,    1, 320,  350},
59
	/* BW 40x50 */
60
	{BW40X50, GREYSCALE_PALETTE,          40, 50,  7,  7,  8, 8, 1, 7, 0,   1,    1, 320,  400},
61
	/* BW 40x60 */
62
	{BW40X60, GREYSCALE_PALETTE,          40, 60,  7,  7,  8, 8, 1, 7, 0,   1,    1, 320,  480},
63
	/* BW 80x14 */
64
	{BW80X14, GREYSCALE_PALETTE,          80, 14, 14, 15, 16, 8, 1, 7, 0,   1,    1, 640,  224},
65
	/* BW 80x21 */
66
	{BW80X21, GREYSCALE_PALETTE,          80, 21, 14, 15, 16, 8, 1, 7, 0,   1,    1, 640,  336},
67
	/* BW 80x28 */
68
	{BW80X28, GREYSCALE_PALETTE,          80, 28, 12, 13, 14, 8, 1, 7, 0,   1,    1, 640,  392},
69
	/* BW 80x43 */
Deucе's avatar
Deucе committed
70
	{BW80X43, GREYSCALE_PALETTE,          80, 43,  7,  7, 14, 8, 1, 7, 0, 729, 1000, 640,  350},
71
	/* BW 80x50 */
72
	{BW80X50, GREYSCALE_PALETTE,          80, 50,  7,  7,  8, 8, 1, 7, 0, 833, 1000, 640,  400},
73
	/* BW 80x60 */
74
	{BW80X60, GREYSCALE_PALETTE,          80, 60,  7,  7,  8, 8, 1, 7, 0,   1,    1, 640,  480},
75
	/* MONO 80x14 */
76
	{MONO14, MONO_PALETTE,                80, 14, 14, 15, 16, 8, 1, 7, 0,   1,    1, 640,  224},
77
	/* MONO 80x21 */
78
	{MONO21, MONO_PALETTE,                80, 21, 14, 15, 16, 8, 1, 7, 0,   1,    1, 640,  336},
79
	/* MONO 80x28 */
80
	{MONO28, MONO_PALETTE,                80, 28, 12, 13, 14, 8, 1, 7, 0,   1,    1, 640,  392},
81
	/* MONO 80x43 */
82
	{MONO43, MONO_PALETTE,                80, 43,  7,  7, 14, 8, 1, 7, 0,   1,    1, 640,  350},
83
	/* MONO 80x50 */
84
	{MONO50, MONO_PALETTE,                80, 50,  7,  7,  8, 8, 1, 7, 0, 833, 1000, 640,  400},
85
	/* MONO 80x60 */
86
	{MONO60, MONO_PALETTE,                80, 60,  7,  7,  8, 8, 1, 7, 0,   1,    1, 640,  480},
87
	/* Magical C4350 Mode */
88
	{C4350, COLOUR_PALETTE,               80, 50,  7,  7,  8, 8, 1, 7, 0, 833, 1000, 640,  400},
89
	/* Commodore 64 40x25 mode */
Deucе's avatar
Deucе committed
90
	{C64_40X25, C64_PALETTE,              40, 25,  0,  7,  8, 8, 1, 0x6e, CIOLIB_VIDEO_BGBRIGHT|CIOLIB_VIDEO_NOBLINK, 240, 312, 320, 200},
91
	/* Commodore 128 40x25 mode */
Deucе's avatar
Deucе committed
92
	{C128_40X25, C64_PALETTE,             40, 25,  0,  7,  8, 8, 1, 0xbd, CIOLIB_VIDEO_BGBRIGHT|CIOLIB_VIDEO_NOBLINK, 240, 312, 320, 200},
93
	/* Commodore 128 80x25 mode */
Deucе's avatar
Deucе committed
94
	{C128_80X25, COLOUR_PALETTE,          80, 25,  0,  7,  8, 8, 2, 7,    CIOLIB_VIDEO_BGBRIGHT|CIOLIB_VIDEO_NOBLINK, 240, 312, 640, 200},
95
	/* Atari 800 40x24 mode */
96
	{ATARI_40X24, ATARI_PALETTE,          40, 24,  0,  7,  8, 8, 1, 7, 0,   1,    1, 320,  192},
97
	/* Atari 800 XEP80 80x25 mode */
98
	{ATARI_80X25, GREYSCALE_PALETTE,      80, 25,  0, 15, 16, 8, 1, 7, 0, 833, 1000, 640,  400},
deuce's avatar
deuce committed
99
	/* VESA 21x132 mode */
100
	{VESA_132X21, COLOUR_PALETTE,        132, 21, 14, 15, 16, 8, 1, 7, 0,   1,    1, 1056, 336},
deuce's avatar
deuce committed
101
	/* VESA 25x132 mode */
102
	{VESA_132X25, COLOUR_PALETTE,        132, 25, 14, 15, 16, 8, 1, 7, 0,   1,    1, 1056, 400},
deuce's avatar
deuce committed
103
	/* VESA 28x132 mode */
104
	{VESA_132X28, COLOUR_PALETTE,        132, 28, 12, 13, 14, 8, 1, 7, 0,   1,    1, 1056, 392},
deuce's avatar
deuce committed
105
	/* VESA 30x132 mode */
106
	{VESA_132X30, COLOUR_PALETTE,        132, 30, 14, 15, 16, 8, 1, 7, 0,   1,    1, 1056, 480},
deuce's avatar
deuce committed
107
	/* VESA 34x132 mode */
108
	{VESA_132X34, COLOUR_PALETTE,        132, 34, 12, 13, 14, 8, 1, 7, 0,   1,    1, 1056, 476},
deuce's avatar
deuce committed
109
	/* VESA 43x132 mode */
110
	{VESA_132X43, COLOUR_PALETTE,        132, 43,  7,  7, 14, 8, 1, 7, 0,   1,    1, 1056, 350},
deuce's avatar
deuce committed
111
	/* VESA 50x132 mode */
112
	{VESA_132X50, COLOUR_PALETTE,        132, 50,  7,  7,  8, 8, 1, 7, 0,   1,    1, 1056, 400},
deuce's avatar
deuce committed
113
	/* VESA 60x132 mode */
114
	{VESA_132X60, COLOUR_PALETTE,        132, 60,  7,  7,  8, 8, 1, 7, 0,   1,    1, 1056, 480},
115
	/* Awesome modes */
116 117
	{ST132X37_16_9, COLOUR_PALETTE,      132, 37, 14, 15, 16, 8, 1, 7, 0,   1,    1, 1056, 600},
	{ST132X52_5_4, COLOUR_PALETTE,       132, 52, 14, 15, 16, 8, 1, 7, 0,   1,    1, 1056, 823},
Deucе's avatar
Deucе committed
118 119
	/* Stupid modes */
	{VGA80X25, COLOUR_PALETTE,            80, 25, 14, 15, 16, 9, 1, 7, CIOLIB_VIDEO_EXPAND | CIOLIB_VIDEO_LINE_GRAPHICS_EXPAND, 740, 1000, 720, 400},
120
	/* Custom mode */
121
	{CIOLIB_MODE_CUSTOM, COLOUR_PALETTE, 80,  25, 14, 15, 16, 8, 1, 7, 0,   1,    1,   -1,  -1},
122 123
};

124
uint32_t palettes[5][16] = {
125 126 127 128 129 130 131 132 133
	/* 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 */
134 135
	{ 0x00, 0x04, 0x02, 0x06, 0x01, 0x05, 0x03, 0x07, 
	  0x08, 0x0c, 0x0a, 0x0e, 0x09, 0x0d, 0x0b, 0x0f
deuce's avatar
deuce committed
136
	},
137
	/* C64 */
138 139
	{ 0x100, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 
	  0x108, 0x109, 0x10a, 0x10b, 0x10c, 0x10d, 0x10e, 0x10f
140
	},
deuce's avatar
deuce committed
141
	/* Atari */
142 143
	{ 0x110, 0x111, 0x111, 0x111, 0x111, 0x111, 0x111, 0x111,
	  0x111, 0x111, 0x111, 0x111, 0x111, 0x111, 0x111, 0x111
deuce's avatar
deuce committed
144
	},
145 146
};

147
struct dac_colors dac_default[TOTAL_DAC_SIZE] = {
148 149 150 151 152 153 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
	/* "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}, 

229 230 231
	/* C64 colours */
	/* Black, White, Red, Cyan, Purple, Green, Blue, Yellow */
	/* Orange, Brown, Lt Red, Dk Grey, Grey, Lt Green, Lt Blue, Lt Grey */
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
	/* 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
deuce's avatar
deuce committed
249 250
	/* Atari Colours */
	/* BG, FG */
deuce's avatar
deuce committed
251
	{0, 81, 129}, {96, 183, 231},
252 253 254 255 256 257 258 259 260 261 262 263 264
};

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
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
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);
	}
}

282
static struct vstat_vmem *new_vmem(int cols, int rows, bool palette)
deuce's avatar
deuce committed
283 284 285 286 287 288
{
	struct vstat_vmem *ret = malloc(sizeof(struct vstat_vmem));

	if (ret == NULL)
		return ret;
	ret->refcount = 1;
289
	ret->vmem = malloc(cols*rows*sizeof(ret->vmem[0]));
deuce's avatar
deuce committed
290 291 292 293 294 295 296
	if (ret->vmem == NULL) {
		free(ret);
		return NULL;
	}
	return ret;
}

297 298 299 300 301 302 303
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
304
	release_vmem(vs->vmem);
305
	vs->vmem=new_vmem(vparams[i].cols, vparams[i].rows, vs->flags & VIDMODES_FLAG_PALETTE_VMEM);
deuce's avatar
deuce committed
306 307
	if (vs->vmem == NULL)
		return -1;
308 309 310 311 312 313
	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
314
	vs->curs_blinks=1;
315
	vs->curs_visible=1;
deuce's avatar
deuce committed
316 317
	vs->curs_row=1;
	vs->curs_col=1;
318 319 320 321 322
	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
323 324 325 326 327 328 329 330
	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;
331 332 333 334 335 336 337 338
	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;
339
	memcpy(vs->palette, palettes[vparams[i].palette], sizeof(vs->palette));
340 341 342
	vs->charheight=vparams[i].charheight;
	vs->charwidth=vparams[i].charwidth;
	vs->mode=mode;
343
	vs->vmultiplier=vparams[i].vmultiplier;
344
	vs->currattr = vparams[i].default_attr;
345 346 347 348 349 350 351 352 353 354 355
	vs->scale_numerator = vparams[i].scale_numerator;
	vs->scale_denominator = vparams[i].scale_denominator;
	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;
356 357
	return(0);
}