Skip to content
Snippets Groups Projects
Commit e684aaab authored by deuce's avatar deuce
Browse files

More cleanup... reduce DAC table to 16 colours since that's all we use.

Don't bother copying the palette since we don't allow changes in it.
Export CurrMode for use by gettextinfo().
Add the true MONO palette.
Use an enum for palette selection.
Change name of 'colour' member to more accurate 'palette'
parent 576dc93a
No related branches found
No related tags found
No related merge requests found
...@@ -60,7 +60,6 @@ int CurrMode; ...@@ -60,7 +60,6 @@ int CurrMode;
sem_t console_mode_changed; sem_t console_mode_changed;
int InitCS; int InitCS;
int InitCE; int InitCE;
BYTE VideoMode;
int FW, FH; int FW, FH;
WORD DpyCols; WORD DpyCols;
BYTE DpyRows; BYTE DpyRows;
...@@ -118,7 +117,6 @@ struct x11 { ...@@ -118,7 +117,6 @@ struct x11 {
struct x11 x11; struct x11 x11;
/* X pixel values for the RGB triples */ /* X pixel values for the RGB triples */
struct dac_colors *dac_rgb;
DWORD pixels[16]; DWORD pixels[16];
#define NUMMODES (sizeof(vparams) / sizeof(struct video_params)) #define NUMMODES (sizeof(vparams) / sizeof(struct video_params))
...@@ -996,9 +994,9 @@ dac2rgb(XColor *color, int i) ...@@ -996,9 +994,9 @@ dac2rgb(XColor *color, int i)
{ {
int m; int m;
color->red = dac_rgb[palette[i]].red << 10; color->red = dac_default16[palette[i]].red << 10;
color->green = dac_rgb[palette[i]].green << 10; color->green = dac_default16[palette[i]].green << 10;
color->blue = dac_rgb[palette[i]].blue << 10; color->blue = dac_default16[palette[i]].blue << 10;
} }
/* Calculate 'pixels[]' from the current DAC table and palette. /* Calculate 'pixels[]' from the current DAC table and palette.
...@@ -1049,6 +1047,7 @@ init_mode(int mode) ...@@ -1049,6 +1047,7 @@ init_mode(int mode)
idx = find_vmode(mode); idx = find_vmode(mode);
if (idx == -1) { if (idx == -1) {
fprintf(stderr,"Cannot initialize selected mode (%d)\n",mode); fprintf(stderr,"Cannot initialize selected mode (%d)\n",mode);
console_new_mode=NO_NEW_MODE;
sem_post(&console_mode_changed); sem_post(&console_mode_changed);
return(-1); return(-1);
} }
...@@ -1065,7 +1064,7 @@ init_mode(int mode) ...@@ -1065,7 +1064,7 @@ init_mode(int mode)
/* Point 'palette[]' to the Attribute Controller space. We will only use /* Point 'palette[]' to the Attribute Controller space. We will only use
the first 16 slots. */ the first 16 slots. */
palette = palettes[vmode.colour]; palette = palettes[vmode.palette];
/* Load 'pixels[]' from default DAC values. */ /* Load 'pixels[]' from default DAC values. */
update_pixels(); update_pixels();
...@@ -1132,28 +1131,6 @@ init_window() ...@@ -1132,28 +1131,6 @@ init_window()
return(0); return(0);
} }
/* Initialize the VGA emulator
XXX This is not nearly finished right now.
*/
static int
init_vga(void)
{
int i;
/* Zero-fill 'dac_rgb' on allocation; the default (EGA) table has only
64 entries. */
dac_rgb = (struct dac_colors *)calloc(256, sizeof(struct dac_colors));
if (dac_rgb == NULL)
return(-1);
/* Copy the default DAC table to a working copy we can trash. */
for (i = 0; i < 64; i++)
dac_rgb[i] = dac_default64[i]; /* Structure copy */
return(0);
}
int int
kbd_init() kbd_init()
{ {
...@@ -1293,10 +1270,6 @@ video_init() ...@@ -1293,10 +1270,6 @@ video_init()
if(init_window()) if(init_window())
return(-1); return(-1);
/* Set VGA emulator to a sane state */
if(init_vga())
return(-1);
/* Initialize mode 3 (text, 80x25, 16 colors) */ /* Initialize mode 3 (text, 80x25, 16 colors) */
if(init_mode(3)) { if(init_mode(3)) {
return(-1); return(-1);
......
...@@ -50,9 +50,7 @@ struct dac_colors { ...@@ -50,9 +50,7 @@ struct dac_colors {
BYTE blue; BYTE blue;
}; };
/* We need a working copy of the default DAC table. This is filled from extern int CurrMode;
'dac_default{64,256}[]' in 'video.c:init_vga()'. */
extern struct dac_colors *dac_rgb;
extern int InitCS; extern int InitCS;
extern int InitCE; extern int InitCE;
...@@ -64,7 +62,6 @@ extern BYTE CursCol; ...@@ -64,7 +62,6 @@ extern BYTE CursCol;
extern BYTE CursStart; extern BYTE CursStart;
extern BYTE CursEnd; extern BYTE CursEnd;
extern BYTE VideoMode;
extern WORD DpyCols; extern WORD DpyCols;
extern BYTE DpyRows; extern BYTE DpyRows;
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
struct video_params { struct video_params {
int mode; int mode;
int colour; int palette;
int cols; int cols;
int rows; int rows;
int curs_start; int curs_start;
...@@ -50,110 +50,105 @@ struct video_params { ...@@ -50,110 +50,105 @@ struct video_params {
int charwidth; int charwidth;
}; };
enum {
MONO_PALETTE
,GREYSCALE_PALETTE
,COLOUR_PALETTE
};
struct video_params vparams[] = { struct video_params vparams[] = {
/* BW 40x25 */ /* BW 40x25 */
{BW40, 0, 40, 25, 14, 15, 16, 8}, {BW40, GREYSCALE_PALETTE, 40, 25, 14, 15, 16, 8},
/* CO 40x25 */ /* CO 40x25 */
{C40, 1, 40, 25, 14, 15, 16, 8}, {C40, COLOUR_PALETTE, 40, 25, 14, 15, 16, 8},
/* BW 80x25 */ /* BW 80x25 */
{BW80, 0, 80, 25, 14, 15, 16, 8}, {BW80, GREYSCALE_PALETTE, 80, 25, 14, 15, 16, 8},
/* CO 80x25 */ /* CO 80x25 */
{C80, 1, 80, 25, 14, 15, 16, 8}, {C80, COLOUR_PALETTE, 80, 25, 14, 15, 16, 8},
/* MONO */ /* MONO */
{MONO, 0, 80, 25, 14, 15, 16, 8}, {MONO, 0, 80, 25, 14, 15, 16, 8},
/* CO 40x14 */ /* CO 40x14 */
{C40X14, 1, 40, 14, 14, 15, 16, 8}, {C40X14, COLOUR_PALETTE, 40, 14, 14, 15, 16, 8},
/* CO 40x21 */ /* CO 40x21 */
{C40X21, 1, 40, 21, 14, 15, 16, 8}, {C40X21, COLOUR_PALETTE, 40, 21, 14, 15, 16, 8},
/* CO 40x28 */ /* CO 40x28 */
{C40X28, 1, 40, 28, 12, 13, 14, 8}, {C40X28, COLOUR_PALETTE, 40, 28, 12, 13, 14, 8},
/* CO 40x43 */ /* CO 40x43 */
{C40X43, 1, 40, 43, 7, 7, 8, 8}, {C40X43, COLOUR_PALETTE, 40, 43, 7, 7, 8, 8},
/* CO 40x50 */ /* CO 40x50 */
{C40X50, 1, 40, 50, 7, 7, 8, 8}, {C40X50, COLOUR_PALETTE, 40, 50, 7, 7, 8, 8},
/* CO 40x60 */ /* CO 40x60 */
{C40X60, 1, 40, 60, 7, 7, 8, 8}, {C40X60, COLOUR_PALETTE, 40, 60, 7, 7, 8, 8},
/* CO 80x14 */ /* CO 80x14 */
{C80X14, 1, 80, 14, 14, 15, 16, 8}, {C80X14, COLOUR_PALETTE, 80, 14, 14, 15, 16, 8},
/* CO 80x21 */ /* CO 80x21 */
{C80X21, 1, 80, 21, 14, 15, 16, 8}, {C80X21, COLOUR_PALETTE, 80, 21, 14, 15, 16, 8},
/* CO 80x28 */ /* CO 80x28 */
{C80X28, 1, 80, 28, 12, 13, 14, 8}, {C80X28, COLOUR_PALETTE, 80, 28, 12, 13, 14, 8},
/* CO 80x43 */ /* CO 80x43 */
{C80X43, 1, 80, 43, 7, 7, 8, 8}, {C80X43, COLOUR_PALETTE, 80, 43, 7, 7, 8, 8},
/* CO 80x50 */ /* CO 80x50 */
{C80X50, 1, 80, 50, 7, 7, 8, 8}, {C80X50, COLOUR_PALETTE, 80, 50, 7, 7, 8, 8},
/* CO 80x60 */ /* CO 80x60 */
{C80X60, 1, 80, 60, 7, 7, 8, 8}, {C80X60, COLOUR_PALETTE, 80, 60, 7, 7, 8, 8},
/* B 40x14 */ /* B 40x14 */
{BW40X14, 0, 40, 14, 14, 15, 16, 8}, {BW40X14, GREYSCALE_PALETTE, 40, 14, 14, 15, 16, 8},
/* BW 40x21 */ /* BW 40x21 */
{BW40X21, 0, 40, 21, 14, 15, 16, 8}, {BW40X21, GREYSCALE_PALETTE, 40, 21, 14, 15, 16, 8},
/* BW 40x28 */ /* BW 40x28 */
{BW40X28, 0, 40, 28, 12, 13, 14, 8}, {BW40X28, GREYSCALE_PALETTE, 40, 28, 12, 13, 14, 8},
/* BW 40x43 */ /* BW 40x43 */
{BW40X43, 0, 40, 43, 7, 7, 8, 8}, {BW40X43, GREYSCALE_PALETTE, 40, 43, 7, 7, 8, 8},
/* BW 40x50 */ /* BW 40x50 */
{BW40X50, 0, 40, 50, 7, 7, 8, 8}, {BW40X50, GREYSCALE_PALETTE, 40, 50, 7, 7, 8, 8},
/* BW 40x60 */ /* BW 40x60 */
{BW40X60, 0, 40, 60, 7, 7, 8, 8}, {BW40X60, GREYSCALE_PALETTE, 40, 60, 7, 7, 8, 8},
/* BW 80x14 */ /* BW 80x14 */
{BW80X14, 0, 80, 14, 14, 15, 16, 8}, {BW80X14, GREYSCALE_PALETTE, 80, 14, 14, 15, 16, 8},
/* BW 80x21 */ /* BW 80x21 */
{BW80X21, 0, 80, 21, 14, 15, 16, 8}, {BW80X21, GREYSCALE_PALETTE, 80, 21, 14, 15, 16, 8},
/* BW 80x28 */ /* BW 80x28 */
{BW80X28, 0, 80, 28, 12, 13, 14, 8}, {BW80X28, GREYSCALE_PALETTE, 80, 28, 12, 13, 14, 8},
/* BW 80x43 */ /* BW 80x43 */
{BW80X43, 0, 80, 43, 7, 7, 8, 8}, {BW80X43, GREYSCALE_PALETTE, 80, 43, 7, 7, 8, 8},
/* BW 80x50 */ /* BW 80x50 */
{BW80X50, 0, 80, 50, 7, 7, 8, 8}, {BW80X50, GREYSCALE_PALETTE, 80, 50, 7, 7, 8, 8},
/* BW 80x60 */ /* BW 80x60 */
{BW80X60, 0, 80, 60, 7, 7, 8, 8}, {BW80X60, GREYSCALE_PALETTE, 80, 60, 7, 7, 8, 8},
/* MONO 80x14 */ /* MONO 80x14 */
{MONO14, 0, 80, 14, 14, 15, 16, 8}, {MONO14, MONO_PALETTE, 80, 14, 14, 15, 16, 8},
/* MONO 80x21 */ /* MONO 80x21 */
{MONO21, 0, 80, 21, 14, 15, 16, 8}, {MONO21, MONO_PALETTE, 80, 21, 14, 15, 16, 8},
/* MONO 80x28 */ /* MONO 80x28 */
{MONO28, 0, 80, 28, 12, 13, 14, 8}, {MONO28, MONO_PALETTE, 80, 28, 12, 13, 14, 8},
/* MONO 80x43 */ /* MONO 80x43 */
{MONO43, 0, 80, 43, 7, 7, 8, 8}, {MONO43, MONO_PALETTE, 80, 43, 7, 7, 8, 8},
/* MONO 80x50 */ /* MONO 80x50 */
{MONO50, 0, 80, 50, 7, 7, 8, 8}, {MONO50, MONO_PALETTE, 80, 50, 7, 7, 8, 8},
/* MONO 80x60 */ /* MONO 80x60 */
{MONO60, 0, 80, 60, 7, 7, 8, 8}, {MONO60, MONO_PALETTE, 80, 60, 7, 7, 8, 8},
/* Magical C4350 Mode */ /* Magical C4350 Mode */
{C4350, 1, 80, 50, 7, 7, 8, 8}, {C4350, COLOUR_PALETTE, 80, 50, 7, 7, 8, 8},
}; };
unsigned char palettes[][16] = { unsigned char palettes[][16] = {
/* Mono */
{ 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07
},
/* Black and White */ /* Black and White */
{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, { 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 0x08, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f
}, },
/* Colour */ /* Colour */
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
} }
}; };
/* The default DAC table for the EGA and VGA 16 color modes. This table is struct dac_colors dac_default16[] = {
installed on startup. The values are taken from the output of 'scon -p
list'. */
struct dac_colors dac_default64[] = {
{0, 0, 0}, {0, 0, 42}, {0, 42, 0}, {0, 42, 42}, {0, 0, 0}, {0, 0, 42}, {0, 42, 0}, {0, 42, 42},
{42, 0, 0}, {42, 0, 42}, {42, 42, 0}, {42, 42, 42}, {42, 0, 0}, {42, 0, 42}, {42, 21, 0}, {42, 42, 42},
{0, 0, 21}, {0, 0, 63}, {0, 42, 21}, {0, 42, 63},
{42, 0, 21}, {42, 0, 63}, {42, 42, 21}, {42, 42, 63},
{0, 21, 0}, {0, 21, 42}, {0, 63, 0}, {0, 63, 42},
{42, 21, 0}, {42, 21, 42}, {42, 63, 0}, {42, 63, 42},
{0, 21, 21}, {0, 21, 63}, {0, 63, 21}, {0, 63, 63},
{42, 21, 21}, {42, 21, 63}, {42, 63, 21}, {42, 63, 63},
{21, 0, 0}, {21, 0, 42}, {21, 42, 0}, {21, 42, 42},
{63, 0, 0}, {63, 0, 42}, {63, 42, 0}, {63, 42, 42},
{21, 0, 21}, {21, 0, 63}, {21, 42, 21}, {21, 42, 63},
{63, 0, 21}, {63, 0, 63}, {63, 42, 21}, {63, 42, 63},
{21, 21, 0}, {21, 21, 42}, {21, 63, 0}, {21, 63, 42},
{63, 21, 0}, {63, 21, 42}, {63, 63, 0}, {63, 63, 42},
{21, 21, 21}, {21, 21, 63}, {21, 63, 21}, {21, 63, 63}, {21, 21, 21}, {21, 21, 63}, {21, 63, 21}, {21, 63, 63},
{63, 21, 21}, {63, 21, 63}, {63, 63, 21}, {63, 63, 63} {63, 21, 21}, {63, 21, 63}, {63, 63, 21}, {63, 63, 63}
}; };
...@@ -177,7 +177,7 @@ void x_gotoxy(int x, int y) ...@@ -177,7 +177,7 @@ void x_gotoxy(int x, int y)
void x_gettextinfo(struct text_info *info) void x_gettextinfo(struct text_info *info)
{ {
info->currmode=VideoMode; info->currmode=CurrMode;
info->screenheight=DpyRows+1; info->screenheight=DpyRows+1;
info->screenwidth=DpyCols; info->screenwidth=DpyCols;
info->curx=wherex(); info->curx=wherex();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment