Skip to content
Snippets Groups Projects
Commit 3a4512b1 authored by Robert 'Admiral' Coeyman's avatar Robert 'Admiral' Coeyman Committed by Alexandre Julliard
Browse files

Beginnings of the code that should allow DOS programs to set their

color palette.
parent b7d81995
No related branches found
No related tags found
No related merge requests found
......@@ -562,7 +562,9 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context )
case 0x10:
switch AL_reg(context) {
case 0x00: /* SET SINGLE PALETTE REGISTER */
FIXME("Set Single Palette Register - Not Supported\n");
FIXME("Set Single Palette Register - Not tested\n");
/* BH is the value BL is the register */
VGA_SetColor16((int)BL_reg(context),(int)BH_reg(context));
break;
case 0x01: /* SET BORDER (OVERSCAN) */
/* Text terminals have no overscan */
......@@ -570,12 +572,16 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context )
break;
case 0x02: /* SET ALL PALETTE REGISTERS */
FIXME("Set all palette registers - Not Supported\n");
/* DX:ES points to a 17 byte table of colors */
/* No return data listed */
/* I'll have to update my table and the default palette */
break;
case 0x03: /* TOGGLE INTENSITY/BLINKING BIT */
FIXME("Toggle Intensity/Blinking Bit - Not Supported\n");
break;
case 0x07: /* GET INDIVIDUAL PALETTE REGISTER */
FIXME("Get Individual Palette Register - Not Supported\n");
/* BL is register to read [ 0-15 ] BH is return value */
break;
case 0x08: /* READ OVERSCAN (BORDER COLOR) REGISTER */
FIXME(
......
......@@ -46,6 +46,33 @@ static int vga_depth;
typedef HRESULT (WINAPI *DirectDrawCreateProc)(LPGUID,LPDIRECTDRAW *,LPUNKNOWN);
static DirectDrawCreateProc pDirectDrawCreate;
/*
* For simplicity, I'm creating a second palette.
* 16 color accesses will use these pointers and insert
* entries from the 64-color palette into the default
* palette. --Robert 'Admiral' Coeyman
*/
static char vga_16_palette[17]={
0x00, /* 0 - Black */
0x01, /* 1 - Blue */
0x02, /* 2 - Green */
0x03, /* 3 - Cyan */
0x04, /* 4 - Red */
0x05, /* 5 - Magenta */
0x14, /* 6 - Brown */
0x07, /* 7 - Light gray */
0x38, /* 8 - Dark gray */
0x39, /* 9 - Light blue */
0x3a, /* A - Light green */
0x3b, /* B - Light cyan */
0x3c, /* C - Light red */
0x3d, /* D - Light magenta */
0x3e, /* E - Yellow */
0x3f, /* F - White */
0x00 /* Border Color */
};
static PALETTEENTRY vga_def_palette[256]={
/* red green blue */
{0x00, 0x00, 0x00}, /* 0 - Black */
......@@ -67,6 +94,80 @@ static PALETTEENTRY vga_def_palette[256]={
{0,0,0} /* FIXME: a series of continuous rainbow hues should follow */
};
/*
* This palette is the dos default, converted from 18 bit color to 24.
* It contains only 64 entries of colors--all others are zeros.
* --Robert 'Admiral' Coeyman
*/
static PALETTEENTRY vga_def64_palette[256]={
/* red green blue */
{0x00, 0x00, 0x00}, /* 0x00 Black */
{0x00, 0x00, 0xaa}, /* 0x01 Blue */
{0x00, 0xaa, 0x00}, /* 0x02 Green */
{0x00, 0xaa, 0xaa}, /* 0x03 Cyan */
{0xaa, 0x00, 0x00}, /* 0x04 Red */
{0xaa, 0x00, 0xaa}, /* 0x05 Magenta */
{0xaa, 0xaa, 0x00}, /* 0x06 */
{0xaa, 0xaa, 0xaa}, /* 0x07 Light Gray */
{0x00, 0x00, 0x55}, /* 0x08 */
{0x00, 0x00, 0xff}, /* 0x09 */
{0x00, 0xaa, 0x55}, /* 0x0a */
{0x00, 0xaa, 0xff}, /* 0x0b */
{0xaa, 0x00, 0x55}, /* 0x0c */
{0xaa, 0x00, 0xff}, /* 0x0d */
{0xaa, 0xaa, 0x55}, /* 0x0e */
{0xaa, 0xaa, 0xff}, /* 0x0f */
{0x00, 0x55, 0x00}, /* 0x10 */
{0x00, 0x55, 0xaa}, /* 0x11 */
{0x00, 0xff, 0x00}, /* 0x12 */
{0x00, 0xff, 0xaa}, /* 0x13 */
{0xaa, 0x55, 0x00}, /* 0x14 Brown */
{0xaa, 0x55, 0xaa}, /* 0x15 */
{0xaa, 0xff, 0x00}, /* 0x16 */
{0xaa, 0xff, 0xaa}, /* 0x17 */
{0x00, 0x55, 0x55}, /* 0x18 */
{0x00, 0x55, 0xff}, /* 0x19 */
{0x00, 0xff, 0x55}, /* 0x1a */
{0x00, 0xff, 0xff}, /* 0x1b */
{0xaa, 0x55, 0x55}, /* 0x1c */
{0xaa, 0x55, 0xff}, /* 0x1d */
{0xaa, 0xff, 0x55}, /* 0x1e */
{0xaa, 0xff, 0xff}, /* 0x1f */
{0x55, 0x00, 0x00}, /* 0x20 */
{0x55, 0x00, 0xaa}, /* 0x21 */
{0x55, 0xaa, 0x00}, /* 0x22 */
{0x55, 0xaa, 0xaa}, /* 0x23 */
{0xff, 0x00, 0x00}, /* 0x24 */
{0xff, 0x00, 0xaa}, /* 0x25 */
{0xff, 0xaa, 0x00}, /* 0x26 */
{0xff, 0xaa, 0xaa}, /* 0x27 */
{0x55, 0x00, 0x55}, /* 0x28 */
{0x55, 0x00, 0xff}, /* 0x29 */
{0x55, 0xaa, 0x55}, /* 0x2a */
{0x55, 0xaa, 0xff}, /* 0x2b */
{0xff, 0x00, 0x55}, /* 0x2c */
{0xff, 0x00, 0xff}, /* 0x2d */
{0xff, 0xaa, 0x55}, /* 0x2e */
{0xff, 0xaa, 0xff}, /* 0x2f */
{0x55, 0x55, 0x00}, /* 0x30 */
{0x55, 0x55, 0xaa}, /* 0x31 */
{0x55, 0xff, 0x00}, /* 0x32 */
{0x55, 0xff, 0xaa}, /* 0x33 */
{0xff, 0x55, 0x00}, /* 0x34 */
{0xff, 0x55, 0xaa}, /* 0x35 */
{0xff, 0xff, 0x00}, /* 0x36 */
{0xff, 0xff, 0xaa}, /* 0x37 */
{0x55, 0x55, 0x55}, /* 0x38 Dark Gray */
{0x55, 0x55, 0xff}, /* 0x39 Light Blue */
{0x55, 0xff, 0x55}, /* 0x3a Light Green */
{0x55, 0xff, 0xff}, /* 0x3b Light Cyan */
{0xff, 0x55, 0x55}, /* 0x3c Light Red */
{0xff, 0x55, 0xff}, /* 0x3d Light Magenta */
{0xff, 0xff, 0x55}, /* 0x3e Yellow */
{0xff, 0xff, 0xff}, /* 0x3f White */
{0,0,0} /* The next 192 entries are all zeros */
};
static void VGA_DeinstallTimer(void)
{
if (poll_timer) {
......@@ -224,6 +325,17 @@ void VGA_SetPalette(PALETTEENTRY*pal,int start,int len)
IDirectDrawPalette_SetEntries(lpddpal,0,start,len,pal);
}
/* set a single color in 16 color mode. */
void VGA_SetColor16(int reg,int color)
{
PALETTEENTRY *pal;
if (!lpddraw) return;
pal= &vga_def64_palette[color];
IDirectDrawPalette_SetEntries(lpddpal,0,reg,1,pal);
vga_16_palette[reg]=(char)color;
}
void VGA_SetQuadPalette(RGBQUAD*color,int start,int len)
{
PALETTEENTRY pal[256];
......
......@@ -29,6 +29,7 @@ int VGA_SetMode(unsigned Xres,unsigned Yres,unsigned Depth);
int VGA_GetMode(unsigned*Height,unsigned*Width,unsigned*Depth);
void VGA_Exit(void);
void VGA_SetPalette(PALETTEENTRY*pal,int start,int len);
void VGA_SetColor16(int reg,int color);
void VGA_SetQuadPalette(RGBQUAD*color,int start,int len);
LPSTR VGA_Lock(unsigned*Pitch,unsigned*Height,unsigned*Width,unsigned*Depth);
void VGA_Unlock(void);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment