diff --git a/src/include/86box/vid_mda.h b/src/include/86box/vid_mda.h index 13e2f76e3..3e32ef848 100644 --- a/src/include/86box/vid_mda.h +++ b/src/include/86box/vid_mda.h @@ -25,11 +25,16 @@ typedef struct mda_t int con, coff, cursoron; int dispon, blink; int vsynctime; - int vadj; + int vadj; + int monitor_index; + int prev_monitor_index; uint8_t *vram; } mda_t; +#define VIDEO_MONITOR_PROLOGUE() { mda->prev_monitor_index = monitor_index_global; monitor_index_global = mda->monitor_index; } +#define VIDEO_MONITOR_EPILOGUE() { monitor_index_global = mda->prev_monitor_index; } + void mda_init(mda_t *mda); void mda_setcol(int chr, int blink, int fg, uint8_t cga_ink); void mda_out(uint16_t addr, uint8_t val, void *p); diff --git a/src/include/86box/video.h b/src/include/86box/video.h index da3251bb3..b37cfbcff 100644 --- a/src/include/86box/video.h +++ b/src/include/86box/video.h @@ -223,6 +223,7 @@ extern int video_is_mda(void); extern int video_is_cga(void); extern int video_is_ega_vga(void); extern void video_inform(int type, const video_timings_t *ptr); +extern void video_inform_monitor(int type, const video_timings_t *ptr, int monitor_index); extern int video_get_type(void); extern int video_get_type_monitor(int monitor_index); diff --git a/src/video/vid_mda.c b/src/video/vid_mda.c index abd6c7c88..0a4ed3c47 100644 --- a/src/video/vid_mda.c +++ b/src/video/vid_mda.c @@ -110,6 +110,8 @@ void mda_poll(void *p) uint8_t chr, attr; int oldsc; int blink; + + VIDEO_MONITOR_PROLOGUE() if (!mda->linepos) { timer_advance_u64(&mda->timer, mda->dispofftime); @@ -252,6 +254,7 @@ void mda_poll(void *p) mda->con = 1; } } + VIDEO_MONITOR_EPILOGUE(); } void mda_init(mda_t *mda) @@ -278,6 +281,7 @@ void mda_init(mda_t *mda) mdacols[0x88][0][1] = mdacols[0x88][1][1] = 16; overscan_x = overscan_y = 0; + mda->monitor_index = monitor_index_global; cga_palette = device_get_config_int("rgb_type") << 1; if (cga_palette > 6) diff --git a/src/video/vid_table.c b/src/video/vid_table.c index 68822679d..e1a799fbe 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -40,6 +40,7 @@ typedef struct { const device_t *device; + int flags; } VIDEO_CARD; @@ -293,16 +294,18 @@ video_prepare(void) fontdatksc5601 = NULL; } - /* Reset the CGA palette. */ - cga_palette = 0; - cgapal_rebuild(); - /* Reset the blend. */ herc_blend = 0; - /* Do an inform on the default values, so that that there's some sane values initialized - even if the device init function does not do an inform of its own. */ - video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_default); + for (int i = 0; i < MONITORS_NUM; i++) { + /* Reset the CGA palette. */ + monitors[i].mon_cga_palette = 0; + cgapal_rebuild_monitor(i); + + /* Do an inform on the default values, so that that there's some sane values initialized + even if the device init function does not do an inform of its own. */ + video_inform_monitor(VIDEO_FLAG_TYPE_SPECIAL, &timing_default, i); + } }