Preparation for monochrome video selection

This commit is contained in:
Cacodemon345
2022-07-06 17:44:43 +06:00
parent 20d3f0971c
commit 07663ceb7e
4 changed files with 21 additions and 8 deletions

View File

@@ -26,10 +26,15 @@ typedef struct mda_t
int dispon, blink; int dispon, blink;
int vsynctime; int vsynctime;
int vadj; int vadj;
int monitor_index;
int prev_monitor_index;
uint8_t *vram; uint8_t *vram;
} mda_t; } 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_init(mda_t *mda);
void mda_setcol(int chr, int blink, int fg, uint8_t cga_ink); void mda_setcol(int chr, int blink, int fg, uint8_t cga_ink);
void mda_out(uint16_t addr, uint8_t val, void *p); void mda_out(uint16_t addr, uint8_t val, void *p);

View File

@@ -223,6 +223,7 @@ extern int video_is_mda(void);
extern int video_is_cga(void); extern int video_is_cga(void);
extern int video_is_ega_vga(void); extern int video_is_ega_vga(void);
extern void video_inform(int type, const video_timings_t *ptr); 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(void);
extern int video_get_type_monitor(int monitor_index); extern int video_get_type_monitor(int monitor_index);

View File

@@ -110,6 +110,8 @@ void mda_poll(void *p)
uint8_t chr, attr; uint8_t chr, attr;
int oldsc; int oldsc;
int blink; int blink;
VIDEO_MONITOR_PROLOGUE()
if (!mda->linepos) if (!mda->linepos)
{ {
timer_advance_u64(&mda->timer, mda->dispofftime); timer_advance_u64(&mda->timer, mda->dispofftime);
@@ -252,6 +254,7 @@ void mda_poll(void *p)
mda->con = 1; mda->con = 1;
} }
} }
VIDEO_MONITOR_EPILOGUE();
} }
void mda_init(mda_t *mda) 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; mdacols[0x88][0][1] = mdacols[0x88][1][1] = 16;
overscan_x = overscan_y = 0; overscan_x = overscan_y = 0;
mda->monitor_index = monitor_index_global;
cga_palette = device_get_config_int("rgb_type") << 1; cga_palette = device_get_config_int("rgb_type") << 1;
if (cga_palette > 6) if (cga_palette > 6)

View File

@@ -40,6 +40,7 @@
typedef struct { typedef struct {
const device_t *device; const device_t *device;
int flags;
} VIDEO_CARD; } VIDEO_CARD;
@@ -293,16 +294,18 @@ video_prepare(void)
fontdatksc5601 = NULL; fontdatksc5601 = NULL;
} }
/* Reset the CGA palette. */
cga_palette = 0;
cgapal_rebuild();
/* Reset the blend. */ /* Reset the blend. */
herc_blend = 0; herc_blend = 0;
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 /* 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. */ even if the device init function does not do an inform of its own. */
video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_default); video_inform_monitor(VIDEO_FLAG_TYPE_SPECIAL, &timing_default, i);
}
} }