Added ability to choose monochrome displays (green, amber, and gray) for CGA MDA, and Hercules graphics cards, based on VileRancour's DOSBox patch.

This commit is contained in:
OBattler
2017-02-19 16:36:43 +01:00
parent b440d749de
commit 92be9c98df
10 changed files with 208 additions and 78 deletions

View File

@@ -12,6 +12,9 @@
#include "video.h"
#include "vid_cga.h"
#include "dosbox/vid_cga_comp.h"
#ifndef __unix
#include "win-cgapal.h"
#endif
#define CGA_RGB 0
#define CGA_COMPOSITE 1
@@ -461,6 +464,11 @@ void *cga_standalone_init()
io_sethandler(0x03d0, 0x0010, cga_in, NULL, NULL, cga_out, NULL, NULL, cga);
overscan_x = overscan_y = 16;
#ifndef __unix
cga_palette = device_get_config_int("rgb_type");
rebuild_cgapal();
#endif
return cga;
}
@@ -522,6 +530,48 @@ static device_config_t cga_config[] =
},
.default_int = COMPOSITE_OLD
},
#ifndef __unix
{
.name = "rgb_type",
.description = "RGB type",
.type = CONFIG_SELECTION,
.selection =
{
{
.description = "Full 16-color",
.value = 0
},
{
.description = "Green, 4-color",
.value = 1
},
{
.description = "Green, 16-color",
.value = 2
},
{
.description = "Amber, 4-color",
.value = 3
},
{
.description = "Amber, 16-color",
.value = 4
},
{
.description = "Gray, 4-color",
.value = 5
},
{
.description = "Gray, 16-color",
.value = 6
},
{
.description = ""
}
},
.default_int = 0
},
#endif
{
.name = "snow_enabled",
.description = "Snow emulation",

View File

@@ -9,6 +9,9 @@
#include "timer.h"
#include "video.h"
#include "vid_hercules.h"
#ifndef __unix
#include "win-cgapal.h"
#endif
typedef struct hercules_t
{
@@ -342,6 +345,11 @@ void *hercules_init()
overscan_x = overscan_y = 0;
#ifndef __unix
cga_palette = device_get_config_int("rgb_type");
rebuild_cgapal();
#endif
return hercules;
}
@@ -360,6 +368,40 @@ void hercules_speed_changed(void *p)
hercules_recalctimings(hercules);
}
#ifndef __unix
static device_config_t hercules_config[] =
{
{
.name = "rgb_type",
.description = "Display type",
.type = CONFIG_SELECTION,
.selection =
{
{
.description = "Default 4-color",
.value = 0
},
{
.description = "Green, 4-color",
.value = 1
},
{
.description = "Amber, 4-color",
.value = 3
},
{
.description = "Gray, 4-color",
.value = 5
},
{
.description = ""
}
},
.default_int = 0
}
};
#endif
device_t hercules_device =
{
"Hercules",
@@ -369,5 +411,10 @@ device_t hercules_device =
NULL,
hercules_speed_changed,
NULL,
#ifdef __unix
NULL
#else
NULL,
hercules_config
#endif
};

View File

@@ -10,6 +10,9 @@
#include "timer.h"
#include "video.h"
#include "vid_mda.h"
#ifndef __unix
#include "win-cgapal.h"
#endif
typedef struct mda_t
{
@@ -298,6 +301,11 @@ void *mda_init()
overscan_x = overscan_y = 0;
#ifndef __unix
cga_palette = device_get_config_int("rgb_type");
rebuild_cgapal();
#endif
return mda;
}
@@ -316,6 +324,40 @@ void mda_speed_changed(void *p)
mda_recalctimings(mda);
}
#ifndef __unix
static mda_config_t hercules_config[] =
{
{
.name = "rgb_type",
.description = "Display type",
.type = CONFIG_SELECTION,
.selection =
{
{
.description = "Default 4-color",
.value = 0
},
{
.description = "Green, 4-color",
.value = 1
},
{
.description = "Amber, 4-color",
.value = 3
},
{
.description = "Gray, 4-color",
.value = 5
},
{
.description = ""
}
},
.default_int = 0
}
};
#endif
device_t mda_device =
{
"MDA",
@@ -325,5 +367,10 @@ device_t mda_device =
NULL,
mda_speed_changed,
NULL,
#ifdef __unix
NULL
#else
NULL,
mda_config
#endif
};

View File

@@ -16,6 +16,9 @@
#include "rom.h"
#include "thread.h"
#include "timer.h"
#ifndef __unix
#include "win-cgapal.h"
#endif
#include "vid_ati18800.h"
#include "vid_ati28800.h"
@@ -49,6 +52,8 @@
#include "vid_vga.h"
#include "vid_wy700.h"
int cga_palette = 0;
typedef struct
{
char name[64];
@@ -255,6 +260,11 @@ void video_init()
{
pclog("Video_init %i %i\n",romset,gfxcard);
#ifndef __unix
cga_palette = 0;
cgapal_rebuild();
#endif
switch (romset)
{
case ROM_IBMPCJR:

View File

@@ -108,3 +108,5 @@ void ddraw_fs_take_screenshot(char *fn);
#ifdef __cplusplus
}
#endif
extern int cga_palette;

4
src/win-cgapal.h Normal file
View File

@@ -0,0 +1,4 @@
extern PALETTE cgapal;
extern PALETTE cgapal_mono[6];
void cgapal_rebuild();

View File

@@ -12,6 +12,7 @@
#include "video.h"
#include "win-d3d-fs.h"
#include "win.h"
#include "win-cgapal.h"
extern "C" void fatal(const char *format, ...);
extern "C" void pclog(const char *format, ...);
@@ -42,7 +43,7 @@ struct CUSTOMVERTEX
FLOAT tu, tv;
};
static PALETTE cgapal=
PALETTE cgapal =
{
{0,0,0},{0,42,0},{42,0,0},{42,21,0},
{0,0,0},{0,42,42},{42,0,42},{42,42,42},
@@ -65,6 +66,34 @@ static PALETTE cgapal=
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
};
PALETTE cgapal_mono[6] =
{
{ // 0 - green, 4-color-optimized contrast
{0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x17,0x05},{0x01,0x1a,0x06},{0x02,0x28,0x09},{0x02,0x2c,0x0a},{0x03,0x39,0x0d},{0x03,0x3c,0x0e},
{0x00,0x07,0x01},{0x01,0x13,0x04},{0x01,0x1f,0x07},{0x01,0x23,0x08},{0x02,0x31,0x0b},{0x02,0x35,0x0c},{0x05,0x3f,0x11},{0x0d,0x3f,0x17},
},
{ // 1 - green, 16-color-optimized contrast
{0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x15,0x05},{0x01,0x17,0x05},{0x01,0x21,0x08},{0x01,0x24,0x08},{0x02,0x2e,0x0b},{0x02,0x31,0x0b},
{0x01,0x22,0x08},{0x02,0x28,0x09},{0x02,0x30,0x0b},{0x02,0x32,0x0c},{0x03,0x39,0x0d},{0x03,0x3b,0x0e},{0x09,0x3f,0x14},{0x0d,0x3f,0x17},
},
{ // 2 - amber, 4-color-optimized contrast
{0x00,0x00,0x00},{0x15,0x05,0x00},{0x20,0x0b,0x00},{0x24,0x0d,0x00},{0x33,0x18,0x00},{0x37,0x1b,0x00},{0x3f,0x26,0x01},{0x3f,0x2b,0x06},
{0x0b,0x02,0x00},{0x1b,0x08,0x00},{0x29,0x11,0x00},{0x2e,0x14,0x00},{0x3b,0x1e,0x00},{0x3e,0x21,0x00},{0x3f,0x32,0x0a},{0x3f,0x38,0x0d},
},
{ // 3 - amber, 16-color-optimized contrast
{0x00,0x00,0x00},{0x15,0x05,0x00},{0x1e,0x09,0x00},{0x21,0x0b,0x00},{0x2b,0x12,0x00},{0x2f,0x15,0x00},{0x38,0x1c,0x00},{0x3b,0x1e,0x00},
{0x2c,0x13,0x00},{0x32,0x17,0x00},{0x3a,0x1e,0x00},{0x3c,0x1f,0x00},{0x3f,0x27,0x01},{0x3f,0x2a,0x04},{0x3f,0x36,0x0c},{0x3f,0x38,0x0d},
},
{ // 4 - grey, 4-color-optimized contrast
{0x00,0x00,0x00},{0x0d,0x0d,0x0d},{0x15,0x15,0x15},{0x18,0x18,0x18},{0x24,0x24,0x24},{0x27,0x27,0x27},{0x33,0x33,0x33},{0x37,0x37,0x37},
{0x08,0x08,0x08},{0x10,0x10,0x10},{0x1c,0x1c,0x1c},{0x20,0x20,0x20},{0x2c,0x2c,0x2c},{0x2f,0x2f,0x2f},{0x3b,0x3b,0x3b},{0x3f,0x3f,0x3f},
},
{ // 5 - grey, 16-color-optimized contrast
{0x00,0x00,0x00},{0x0d,0x0d,0x0d},{0x12,0x12,0x12},{0x15,0x15,0x15},{0x1e,0x1e,0x1e},{0x20,0x20,0x20},{0x29,0x29,0x29},{0x2c,0x2c,0x2c},
{0x1f,0x1f,0x1f},{0x23,0x23,0x23},{0x2b,0x2b,0x2b},{0x2d,0x2d,0x2d},{0x34,0x34,0x34},{0x36,0x36,0x36},{0x3d,0x3d,0x3d},{0x3f,0x3f,0x3f},
},
};
static uint32_t pal_lookup[256];
static CUSTOMVERTEX d3d_verts[] =
@@ -77,6 +106,17 @@ static CUSTOMVERTEX d3d_verts[] =
{2048.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f},
{2048.0f, 2048.0f, 1.0f, 1.0f, 1.0f, 1.0f},
};
void cgapal_rebuild()
{
for (c = 0; c < 256; c++)
pal_lookup[c] = makecol(cgapal[c].r << 2, cgapal[c].g << 2, cgapal[c].b << 2);
if (cga_palette > 1)
{
for (c = 0; c < 16; c++)
pal_lookup[c + 16] = makecol(cgapal_mono[cga_palette - 1][c].r, cgapal_mono[cga_palette - 1][c].g, cgapal_mono[cga_palette - 1][c].b);
}
}
void d3d_fs_init(HWND h)
{
@@ -87,8 +127,7 @@ void d3d_fs_init(HWND h)
d3d_fs_w = GetSystemMetrics(SM_CXSCREEN);
d3d_fs_h = GetSystemMetrics(SM_CYSCREEN);
for (c = 0; c < 256; c++)
pal_lookup[c] = makecol(cgapal[c].r << 2, cgapal[c].g << 2, cgapal[c].b << 2);
cgapal_rebuild();
d3d_hwnd = h;

View File

@@ -9,6 +9,7 @@
#include "resources.h"
#include "win-d3d.h"
#include "video.h"
#include "win-cgapal.h"
extern "C" void fatal(const char *format, ...);
extern "C" void pclog(const char *format, ...);
@@ -35,29 +36,6 @@ struct CUSTOMVERTEX
FLOAT tu, tv;
};
static PALETTE cgapal=
{
{0,0,0},{0,42,0},{42,0,0},{42,21,0},
{0,0,0},{0,42,42},{42,0,42},{42,42,42},
{0,0,0},{21,63,21},{63,21,21},{63,63,21},
{0,0,0},{21,63,63},{63,21,63},{63,63,63},
{0,0,0},{0,0,42},{0,42,0},{0,42,42},
{42,0,0},{42,0,42},{42,21,00},{42,42,42},
{21,21,21},{21,21,63},{21,63,21},{21,63,63},
{63,21,21},{63,21,63},{63,63,21},{63,63,63},
{0,0,0},{0,21,0},{0,0,42},{0,42,42},
{42,0,21},{21,10,21},{42,0,42},{42,0,63},
{21,21,21},{21,63,21},{42,21,42},{21,63,63},
{63,0,0},{42,42,0},{63,21,42},{41,41,41},
{0,0,0},{0,42,42},{42,0,0},{42,42,42},
{0,0,0},{0,42,42},{42,0,0},{42,42,42},
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
};
static uint32_t pal_lookup[256];
static CUSTOMVERTEX d3d_verts[] =
@@ -76,8 +54,7 @@ void d3d_init(HWND h)
int c;
HRESULT hr;
for (c = 0; c < 256; c++)
pal_lookup[c] = makecol(cgapal[c].r << 2, cgapal[c].g << 2, cgapal[c].b << 2);
cgapal_rebuild();
d3d_hwnd = h;

View File

@@ -8,6 +8,7 @@
#include "win-ddraw-fs.h"
#include "win-ddraw-screenshot.h"
#include "video.h"
#include "win-cgapal.h"
extern "C" void fatal(const char *format, ...);
extern "C" void pclog(const char *format, ...);
@@ -33,29 +34,6 @@ static DDSURFACEDESC2 ddsd;
static HWND ddraw_hwnd;
static int ddraw_w, ddraw_h;
static PALETTE cgapal =
{
{0,0,0},{0,42,0},{42,0,0},{42,21,0},
{0,0,0},{0,42,42},{42,0,42},{42,42,42},
{0,0,0},{21,63,21},{63,21,21},{63,63,21},
{0,0,0},{21,63,63},{63,21,63},{63,63,63},
{0,0,0},{0,0,42},{0,42,0},{0,42,42},
{42,0,0},{42,0,42},{42,21,00},{42,42,42},
{21,21,21},{21,21,63},{21,63,21},{21,63,63},
{63,21,21},{63,21,63},{63,63,21},{63,63,63},
{0,0,0},{0,21,0},{0,0,42},{0,42,42},
{42,0,21},{21,10,21},{42,0,42},{42,0,63},
{21,21,21},{21,63,21},{42,21,42},{21,63,63},
{63,0,0},{42,42,0},{63,21,42},{41,41,41},
{0,0,0},{0,42,42},{42,0,0},{42,42,42},
{0,0,0},{0,42,42},{42,0,0},{42,42,42},
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
};
static uint32_t pal_lookup[256];
void ddraw_fs_init(HWND h)
@@ -65,8 +43,7 @@ void ddraw_fs_init(HWND h)
ddraw_w = GetSystemMetrics(SM_CXSCREEN);
ddraw_h = GetSystemMetrics(SM_CYSCREEN);
for (c = 0; c < 256; c++)
pal_lookup[c] = makecol(cgapal[c].r << 2, cgapal[c].g << 2, cgapal[c].b << 2);
cgapal_rebuild();
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
fatal("DirectDrawCreate failed\n");

View File

@@ -9,6 +9,7 @@
#include "win-ddraw.h"
#include "win-ddraw-screenshot.h"
#include "video.h"
#include "win-cgapal.h"
extern "C" void fatal(const char *format, ...);
extern "C" void pclog(const char *format, ...);
@@ -33,37 +34,13 @@ static DDSURFACEDESC2 ddsd;
static HWND ddraw_hwnd;
static PALETTE cgapal=
{
{0,0,0},{0,42,0},{42,0,0},{42,21,0},
{0,0,0},{0,42,42},{42,0,42},{42,42,42},
{0,0,0},{21,63,21},{63,21,21},{63,63,21},
{0,0,0},{21,63,63},{63,21,63},{63,63,63},
{0,0,0},{0,0,42},{0,42,0},{0,42,42},
{42,0,0},{42,0,42},{42,21,00},{42,42,42},
{21,21,21},{21,21,63},{21,63,21},{21,63,63},
{63,21,21},{63,21,63},{63,63,21},{63,63,63},
{0,0,0},{0,21,0},{0,0,42},{0,42,42},
{42,0,21},{21,10,21},{42,0,42},{42,0,63},
{21,21,21},{21,63,21},{42,21,42},{21,63,63},
{63,0,0},{42,42,0},{63,21,42},{41,41,41},
{0,0,0},{0,42,42},{42,0,0},{42,42,42},
{0,0,0},{0,42,42},{42,0,0},{42,42,42},
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
};
static uint32_t pal_lookup[256];
void ddraw_init(HWND h)
{
int c;
for (c = 0; c < 256; c++)
pal_lookup[c] = makecol(cgapal[c].r << 2, cgapal[c].g << 2, cgapal[c].b << 2);
cgapal_rebuild();
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
fatal("DirectDrawCreate failed\n");