diff --git a/src/vid_cga.c b/src/vid_cga.c index b930a37..59aa6ef 100644 --- a/src/vid_cga.c +++ b/src/vid_cga.c @@ -10,9 +10,6 @@ #include "vid_cga.h" #include "dosbox/vid_cga_comp.h" -#define CGA_RGB 0 -#define CGA_COMPOSITE 1 - #define COMPOSITE_OLD 0 #define COMPOSITE_NEW 1 @@ -442,14 +439,15 @@ void cga_init(cga_t *cga) void *cga_standalone_init() { - int display_type; + int display_type, contrast; cga_t *cga = malloc(sizeof(cga_t)); memset(cga, 0, sizeof(cga_t)); display_type = device_get_config_int("display_type"); - cga->composite = (display_type != CGA_RGB); + cga->composite = (display_type == DISPLAY_COMPOSITE); cga->revision = device_get_config_int("composite_type"); cga->snow_enabled = device_get_config_int("snow_enabled"); + contrast = device_get_config_int("contrast"); cga->vram = malloc(0x4000); @@ -457,7 +455,9 @@ void *cga_standalone_init() timer_add(cga_poll, &cga->vidtime, TIMER_ALWAYS_ENABLED, cga); mem_mapping_add(&cga->mapping, 0xb8000, 0x08000, cga_read, NULL, NULL, cga_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, cga); io_sethandler(0x03d0, 0x0010, cga_in, NULL, NULL, cga_out, NULL, NULL, cga); - + + cgapal_rebuild(display_type, contrast); + return cga; } @@ -486,17 +486,33 @@ static device_config_t cga_config[] = { { .description = "RGB", - .value = CGA_RGB + .value = DISPLAY_RGB + }, + { + .description = "RGB (no brown)", + .value = DISPLAY_RGB_NO_BROWN + }, + { + .description = "Green Monochrome", + .value = DISPLAY_GREEN + }, + { + .description = "Amber Monochrome", + .value = DISPLAY_AMBER + }, + { + .description = "White Monochrome", + .value = DISPLAY_WHITE }, { .description = "Composite", - .value = CGA_COMPOSITE + .value = DISPLAY_COMPOSITE }, { .description = "" } }, - .default_int = CGA_RGB + .default_int = DISPLAY_RGB }, { .name = "composite_type", @@ -524,6 +540,12 @@ static device_config_t cga_config[] = .type = CONFIG_BINARY, .default_int = 1 }, + { + .name = "contrast", + .description = "Alternate monochrome contrast", + .type = CONFIG_BINARY, + .default_int = 0 + }, { .type = -1 } diff --git a/src/vid_hercules.c b/src/vid_hercules.c index 1a70db6..899de86 100644 --- a/src/vid_hercules.c +++ b/src/vid_hercules.c @@ -153,7 +153,7 @@ void hercules_poll(void *p) dat = (hercules->vram[((hercules->ma << 1) & 0x1fff) + ca] << 8) | hercules->vram[((hercules->ma << 1) & 0x1fff) + ca + 1]; hercules->ma++; for (c = 0; c < 16; c++) - ((uint32_t *)buffer32->line[hercules->displine])[(x << 4) + c] = (dat & (32768 >> c)) ? 0xaaaaaa : 0; + ((uint32_t *)buffer32->line[hercules->displine])[(x << 4) + c] = (dat & (32768 >> c)) ? cgapal[0x7] : 0; } } else @@ -307,6 +307,7 @@ void hercules_poll(void *p) void *hercules_init() { + int display_type; int c; hercules_t *hercules = malloc(sizeof(hercules_t)); memset(hercules, 0, sizeof(hercules_t)); @@ -317,24 +318,27 @@ void *hercules_init() mem_mapping_add(&hercules->mapping, 0xb0000, 0x08000, hercules_read, NULL, NULL, hercules_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, hercules); io_sethandler(0x03b0, 0x0010, hercules_in, NULL, NULL, hercules_out, NULL, NULL, hercules); + display_type = device_get_config_int("display_type"); + cgapal_rebuild(display_type, 0); + for (c = 0; c < 256; c++) { - mdacols[c][0][0] = mdacols[c][1][0] = mdacols[c][1][1] = makecol32(0, 0, 0); - if (c & 8) mdacols[c][0][1] = makecol32(0xff, 0xff, 0xff); - else mdacols[c][0][1] = makecol32(0xaa, 0xaa, 0xaa); + mdacols[c][0][0] = mdacols[c][1][0] = mdacols[c][1][1] = cgapal[0]; + if (c & 8) mdacols[c][0][1] = cgapal[0xf]; + else mdacols[c][0][1] = cgapal[0x7]; } - mdacols[0x70][0][1] = makecol32(0, 0, 0); - mdacols[0x70][0][0] = mdacols[0x70][1][0] = mdacols[0x70][1][1] = makecol32(0xff, 0xff, 0xff); - mdacols[0xF0][0][1] = makecol32(0, 0, 0); - mdacols[0xF0][0][0] = mdacols[0xF0][1][0] = mdacols[0xF0][1][1] = makecol32(0xff, 0xff, 0xff); - mdacols[0x78][0][1] = makecol32(0xaa, 0xaa, 0xaa); - mdacols[0x78][0][0] = mdacols[0x78][1][0] = mdacols[0x78][1][1] = makecol32(0xff, 0xff, 0xff); - mdacols[0xF8][0][1] = makecol32(0xaa, 0xaa, 0xaa); - mdacols[0xF8][0][0] = mdacols[0xF8][1][0] = mdacols[0xF8][1][1] = makecol32(0xff, 0xff, 0xff); - mdacols[0x00][0][1] = mdacols[0x00][1][1] = makecol32(0, 0, 0); - mdacols[0x08][0][1] = mdacols[0x08][1][1] = makecol32(0, 0, 0); - mdacols[0x80][0][1] = mdacols[0x80][1][1] = makecol32(0, 0, 0); - mdacols[0x88][0][1] = mdacols[0x88][1][1] = makecol32(0, 0, 0); + mdacols[0x70][0][1] = cgapal[0]; + mdacols[0x70][0][0] = mdacols[0x70][1][0] = mdacols[0x70][1][1] = cgapal[0xf]; + mdacols[0xF0][0][1] = cgapal[0]; + mdacols[0xF0][0][0] = mdacols[0xF0][1][0] = mdacols[0xF0][1][1] = cgapal[0xf]; + mdacols[0x78][0][1] = cgapal[0x7]; + mdacols[0x78][0][0] = mdacols[0x78][1][0] = mdacols[0x78][1][1] = cgapal[0xf]; + mdacols[0xF8][0][1] = cgapal[0x7]; + mdacols[0xF8][0][0] = mdacols[0xF8][1][0] = mdacols[0xF8][1][1] = cgapal[0xf]; + mdacols[0x00][0][1] = mdacols[0x00][1][1] = cgapal[0]; + mdacols[0x08][0][1] = mdacols[0x08][1][1] = cgapal[0]; + mdacols[0x80][0][1] = mdacols[0x80][1][1] = cgapal[0]; + mdacols[0x88][0][1] = mdacols[0x88][1][1] = cgapal[0]; return hercules; } @@ -354,6 +358,37 @@ void hercules_speed_changed(void *p) hercules_recalctimings(hercules); } +static device_config_t hercules_config[] = +{ + { + .name = "display_type", + .description = "Display type", + .type = CONFIG_SELECTION, + .selection = + { + { + .description = "Green", + .value = DISPLAY_GREEN + }, + { + .description = "Amber", + .value = DISPLAY_AMBER + }, + { + .description = "White", + .value = DISPLAY_WHITE + }, + { + .description = "" + } + }, + .default_int = DISPLAY_WHITE + }, + { + .type = -1 + } +}; + device_t hercules_device = { "Hercules", @@ -363,5 +398,6 @@ device_t hercules_device = NULL, hercules_speed_changed, NULL, - NULL + NULL, + hercules_config }; diff --git a/src/vid_mda.c b/src/vid_mda.c index 495b794..fdb549e 100644 --- a/src/vid_mda.c +++ b/src/vid_mda.c @@ -263,6 +263,7 @@ void mda_poll(void *p) void *mda_init() { + int display_type; int c; mda_t *mda = malloc(sizeof(mda_t)); memset(mda, 0, sizeof(mda_t)); @@ -273,24 +274,27 @@ void *mda_init() mem_mapping_add(&mda->mapping, 0xb0000, 0x08000, mda_read, NULL, NULL, mda_write, NULL, NULL, NULL, MEM_MAPPING_EXTERNAL, mda); io_sethandler(0x03b0, 0x0010, mda_in, NULL, NULL, mda_out, NULL, NULL, mda); + display_type = device_get_config_int("display_type"); + cgapal_rebuild(display_type, 0); + for (c = 0; c < 256; c++) { - mdacols[c][0][0] = mdacols[c][1][0] = mdacols[c][1][1] = makecol32(0, 0, 0); - if (c & 8) mdacols[c][0][1] = makecol32(0xff, 0xff, 0xff); - else mdacols[c][0][1] = makecol32(0xaa, 0xaa, 0xaa); + mdacols[c][0][0] = mdacols[c][1][0] = mdacols[c][1][1] = cgapal[0]; + if (c & 8) mdacols[c][0][1] = cgapal[0xf]; + else mdacols[c][0][1] = cgapal[0x7]; } - mdacols[0x70][0][1] = makecol32(0, 0, 0); - mdacols[0x70][0][0] = mdacols[0x70][1][0] = mdacols[0x70][1][1] = makecol32(0xff, 0xff, 0xff); - mdacols[0xF0][0][1] = makecol32(0, 0, 0); - mdacols[0xF0][0][0] = mdacols[0xF0][1][0] = mdacols[0xF0][1][1] = makecol32(0xff, 0xff, 0xff); - mdacols[0x78][0][1] = makecol32(0xaa, 0xaa, 0xaa); - mdacols[0x78][0][0] = mdacols[0x78][1][0] = mdacols[0x78][1][1] = makecol32(0xff, 0xff, 0xff); - mdacols[0xF8][0][1] = makecol32(0xaa, 0xaa, 0xaa); - mdacols[0xF8][0][0] = mdacols[0xF8][1][0] = mdacols[0xF8][1][1] = makecol32(0xff, 0xff, 0xff); - mdacols[0x00][0][1] = mdacols[0x00][1][1] = makecol32(0, 0, 0); - mdacols[0x08][0][1] = mdacols[0x08][1][1] = makecol32(0, 0, 0); - mdacols[0x80][0][1] = mdacols[0x80][1][1] = makecol32(0, 0, 0); - mdacols[0x88][0][1] = mdacols[0x88][1][1] = makecol32(0, 0, 0); + mdacols[0x70][0][1] = cgapal[0]; + mdacols[0x70][0][0] = mdacols[0x70][1][0] = mdacols[0x70][1][1] = cgapal[0xf]; + mdacols[0xF0][0][1] = cgapal[0]; + mdacols[0xF0][0][0] = mdacols[0xF0][1][0] = mdacols[0xF0][1][1] = cgapal[0xf]; + mdacols[0x78][0][1] = cgapal[0x7]; + mdacols[0x78][0][0] = mdacols[0x78][1][0] = mdacols[0x78][1][1] = cgapal[0xf]; + mdacols[0xF8][0][1] = cgapal[0x7]; + mdacols[0xF8][0][0] = mdacols[0xF8][1][0] = mdacols[0xF8][1][1] = cgapal[0xf]; + mdacols[0x00][0][1] = mdacols[0x00][1][1] = cgapal[0]; + mdacols[0x08][0][1] = mdacols[0x08][1][1] = cgapal[0]; + mdacols[0x80][0][1] = mdacols[0x80][1][1] = cgapal[0]; + mdacols[0x88][0][1] = mdacols[0x88][1][1] = cgapal[0]; return mda; } @@ -310,6 +314,37 @@ void mda_speed_changed(void *p) mda_recalctimings(mda); } +static device_config_t mda_config[] = +{ + { + .name = "display_type", + .description = "Display type", + .type = CONFIG_SELECTION, + .selection = + { + { + .description = "Green", + .value = DISPLAY_GREEN + }, + { + .description = "Amber", + .value = DISPLAY_AMBER + }, + { + .description = "White", + .value = DISPLAY_WHITE + }, + { + .description = "" + } + }, + .default_int = DISPLAY_WHITE + }, + { + .type = -1 + } +}; + device_t mda_device = { "MDA", @@ -319,5 +354,6 @@ device_t mda_device = NULL, mda_speed_changed, NULL, - NULL + NULL, + mda_config }; diff --git a/src/video.c b/src/video.c index 80753cc..490a349 100644 --- a/src/video.c +++ b/src/video.c @@ -466,22 +466,7 @@ void initvideo() for (c = 0; c < 65536; c++) video_16to32[c] = ((c & 31) << 3) | (((c >> 5) & 63) << 10) | (((c >> 11) & 31) << 19); - cgapal[0x0] = makecol(0x00, 0x00, 0x00); - cgapal[0x1] = makecol(0x00, 0x00, 0xaa); - cgapal[0x2] = makecol(0x00, 0xaa, 0x00); - cgapal[0x3] = makecol(0x00, 0xaa, 0xaa); - cgapal[0x4] = makecol(0xaa, 0x00, 0x00); - cgapal[0x5] = makecol(0xaa, 0x00, 0xaa); - cgapal[0x6] = makecol(0xaa, 0x55, 0x00); - cgapal[0x7] = makecol(0xaa, 0xaa, 0xaa); - cgapal[0x8] = makecol(0x55, 0x55, 0x55); - cgapal[0x9] = makecol(0x55, 0x55, 0xff); - cgapal[0xa] = makecol(0x55, 0xff, 0x55); - cgapal[0xb] = makecol(0x55, 0xff, 0xff); - cgapal[0xc] = makecol(0xff, 0x55, 0x55); - cgapal[0xd] = makecol(0xff, 0x55, 0xff); - cgapal[0xe] = makecol(0xff, 0xff, 0x55); - cgapal[0xf] = makecol(0xff, 0xff, 0xff); + cgapal_rebuild(DISPLAY_RGB, 0); blit_data.wake_blit_thread = thread_create_event(); blit_data.blit_complete = thread_create_event(); @@ -548,3 +533,156 @@ void video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) blit_data.h = h; thread_set_event(blit_data.wake_blit_thread); } + +void cgapal_rebuild(int display_type, int contrast) +{ + switch (display_type) + { + case DISPLAY_GREEN: + if (contrast) + { + cgapal[0x0] = makecol(0x00, 0x00, 0x00); + cgapal[0x1] = makecol(0x00, 0x34, 0x0c); + cgapal[0x2] = makecol(0x04, 0x5d, 0x14); + cgapal[0x3] = makecol(0x04, 0x69, 0x18); + cgapal[0x4] = makecol(0x08, 0xa2, 0x24); + cgapal[0x5] = makecol(0x08, 0xb2, 0x28); + cgapal[0x6] = makecol(0x0c, 0xe7, 0x34); + cgapal[0x7] = makecol(0x0c, 0xf3, 0x38); + cgapal[0x8] = makecol(0x00, 0x1c, 0x04); + cgapal[0x9] = makecol(0x04, 0x4d, 0x10); + cgapal[0xa] = makecol(0x04, 0x7d, 0x1c); + cgapal[0xb] = makecol(0x04, 0x8e, 0x20); + cgapal[0xc] = makecol(0x08, 0xc7, 0x2c); + cgapal[0xd] = makecol(0x08, 0xd7, 0x30); + cgapal[0xe] = makecol(0x14, 0xff, 0x45); + cgapal[0xf] = makecol(0x34, 0xff, 0x5d); + } + else + { + cgapal[0x0] = makecol(0x00, 0x00, 0x00); + cgapal[0x1] = makecol(0x00, 0x34, 0x0c); + cgapal[0x2] = makecol(0x04, 0x55, 0x14); + cgapal[0x3] = makecol(0x04, 0x5d, 0x14); + cgapal[0x4] = makecol(0x04, 0x86, 0x20); + cgapal[0x5] = makecol(0x04, 0x92, 0x20); + cgapal[0x6] = makecol(0x08, 0xba, 0x2c); + cgapal[0x7] = makecol(0x08, 0xc7, 0x2c); + cgapal[0x8] = makecol(0x04, 0x8a, 0x20); + cgapal[0x9] = makecol(0x08, 0xa2, 0x24); + cgapal[0xa] = makecol(0x08, 0xc3, 0x2c); + cgapal[0xb] = makecol(0x08, 0xcb, 0x30); + cgapal[0xc] = makecol(0x0c, 0xe7, 0x34); + cgapal[0xd] = makecol(0x0c, 0xef, 0x38); + cgapal[0xe] = makecol(0x24, 0xff, 0x51); + cgapal[0xf] = makecol(0x34, 0xff, 0x5d); + } + break; + case DISPLAY_AMBER: + if (contrast) + { + cgapal[0x0] = makecol(0x00, 0x00, 0x00); + cgapal[0x1] = makecol(0x55, 0x14, 0x00); + cgapal[0x2] = makecol(0x82, 0x2c, 0x00); + cgapal[0x3] = makecol(0x92, 0x34, 0x00); + cgapal[0x4] = makecol(0xcf, 0x61, 0x00); + cgapal[0x5] = makecol(0xdf, 0x6d, 0x00); + cgapal[0x6] = makecol(0xff, 0x9a, 0x04); + cgapal[0x7] = makecol(0xff, 0xae, 0x18); + cgapal[0x8] = makecol(0x2c, 0x08, 0x00); + cgapal[0x9] = makecol(0x6d, 0x20, 0x00); + cgapal[0xa] = makecol(0xa6, 0x45, 0x00); + cgapal[0xb] = makecol(0xba, 0x51, 0x00); + cgapal[0xc] = makecol(0xef, 0x79, 0x00); + cgapal[0xd] = makecol(0xfb, 0x86, 0x00); + cgapal[0xe] = makecol(0xff, 0xcb, 0x28); + cgapal[0xf] = makecol(0xff, 0xe3, 0x34); + } + else + { + cgapal[0x0] = makecol(0x00, 0x00, 0x00); + cgapal[0x1] = makecol(0x55, 0x14, 0x00); + cgapal[0x2] = makecol(0x79, 0x24, 0x00); + cgapal[0x3] = makecol(0x86, 0x2c, 0x00); + cgapal[0x4] = makecol(0xae, 0x49, 0x00); + cgapal[0x5] = makecol(0xbe, 0x55, 0x00); + cgapal[0x6] = makecol(0xe3, 0x71, 0x00); + cgapal[0x7] = makecol(0xef, 0x79, 0x00); + cgapal[0x8] = makecol(0xb2, 0x4d, 0x00); + cgapal[0x9] = makecol(0xcb, 0x5d, 0x00); + cgapal[0xa] = makecol(0xeb, 0x79, 0x00); + cgapal[0xb] = makecol(0xf3, 0x7d, 0x00); + cgapal[0xc] = makecol(0xff, 0x9e, 0x04); + cgapal[0xd] = makecol(0xff, 0xaa, 0x10); + cgapal[0xe] = makecol(0xff, 0xdb, 0x30); + cgapal[0xf] = makecol(0xff, 0xe3, 0x34); + } + break; + case DISPLAY_WHITE: + if (contrast) + { + cgapal[0x0] = makecol(0x00, 0x00, 0x00); + cgapal[0x1] = makecol(0x37, 0x3d, 0x40); + cgapal[0x2] = makecol(0x55, 0x5c, 0x5f); + cgapal[0x3] = makecol(0x61, 0x67, 0x6b); + cgapal[0x4] = makecol(0x8f, 0x95, 0x95); + cgapal[0x5] = makecol(0x9b, 0xa0, 0x9f); + cgapal[0x6] = makecol(0xcc, 0xcf, 0xc8); + cgapal[0x7] = makecol(0xdf, 0xde, 0xd4); + cgapal[0x8] = makecol(0x24, 0x27, 0x29); + cgapal[0x9] = makecol(0x42, 0x48, 0x4c); + cgapal[0xa] = makecol(0x70, 0x76, 0x78); + cgapal[0xb] = makecol(0x81, 0x87, 0x87); + cgapal[0xc] = makecol(0xaf, 0xb3, 0xb0); + cgapal[0xd] = makecol(0xbb, 0xbf, 0xba); + cgapal[0xe] = makecol(0xef, 0xed, 0xdf); + cgapal[0xf] = makecol(0xff, 0xfd, 0xed); + } + else + { + cgapal[0x0] = makecol(0x00, 0x00, 0x00); + cgapal[0x1] = makecol(0x37, 0x3d, 0x40); + cgapal[0x2] = makecol(0x4a, 0x50, 0x54); + cgapal[0x3] = makecol(0x55, 0x5c, 0x5f); + cgapal[0x4] = makecol(0x78, 0x7e, 0x80); + cgapal[0x5] = makecol(0x81, 0x87, 0x87); + cgapal[0x6] = makecol(0xa3, 0xa7, 0xa6); + cgapal[0x7] = makecol(0xaf, 0xb3, 0xb0); + cgapal[0x8] = makecol(0x7a, 0x81, 0x83); + cgapal[0x9] = makecol(0x8c, 0x92, 0x92); + cgapal[0xa] = makecol(0xac, 0xb0, 0xad); + cgapal[0xb] = makecol(0xb3, 0xb7, 0xb4); + cgapal[0xc] = makecol(0xd1, 0xd3, 0xcb); + cgapal[0xd] = makecol(0xd9, 0xdb, 0xd2); + cgapal[0xe] = makecol(0xf7, 0xf5, 0xe7); + cgapal[0xf] = makecol(0xff, 0xfd, 0xed); + } + break; + + default: + cgapal[0x0] = makecol(0x00, 0x00, 0x00); + cgapal[0x1] = makecol(0x00, 0x00, 0xaa); + cgapal[0x2] = makecol(0x00, 0xaa, 0x00); + cgapal[0x3] = makecol(0x00, 0xaa, 0xaa); + cgapal[0x4] = makecol(0xaa, 0x00, 0x00); + cgapal[0x5] = makecol(0xaa, 0x00, 0xaa); + if (display_type == DISPLAY_RGB_NO_BROWN) + { + cgapal[0x6] = makecol(0xaa, 0xaa, 0x00); + } + else + { + cgapal[0x6] = makecol(0xaa, 0x55, 0x00); + } + cgapal[0x7] = makecol(0xaa, 0xaa, 0xaa); + cgapal[0x8] = makecol(0x55, 0x55, 0x55); + cgapal[0x9] = makecol(0x55, 0x55, 0xff); + cgapal[0xa] = makecol(0x55, 0xff, 0x55); + cgapal[0xb] = makecol(0x55, 0xff, 0xff); + cgapal[0xc] = makecol(0xff, 0x55, 0x55); + cgapal[0xd] = makecol(0xff, 0x55, 0xff); + cgapal[0xe] = makecol(0xff, 0xff, 0x55); + cgapal[0xf] = makecol(0xff, 0xff, 0xff); + break; + } +} diff --git a/src/video.h b/src/video.h index ffca4e8..c342b4c 100644 --- a/src/video.h +++ b/src/video.h @@ -99,3 +99,12 @@ void hline(BITMAP *b, int x1, int y, int x2, int col); void destroy_bitmap(BITMAP *b); extern uint32_t cgapal[16]; + +#define DISPLAY_RGB 0 +#define DISPLAY_COMPOSITE 1 +#define DISPLAY_RGB_NO_BROWN 2 +#define DISPLAY_GREEN 3 +#define DISPLAY_AMBER 4 +#define DISPLAY_WHITE 5 + +void cgapal_rebuild(int display_type, int contrast); diff --git a/src/win-deviceconfig.c b/src/win-deviceconfig.c index 4160523..45780a1 100644 --- a/src/win-deviceconfig.c +++ b/src/win-deviceconfig.c @@ -235,7 +235,7 @@ void deviceconfig_open(HWND hwnd, device_t *device) item->y = y; item->id = id++; - item->cx = 80; + item->cx = 200; item->cy = 15; item->style = WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX;