From 1f5d00fe55aab2349733c726065082c41b80ee40 Mon Sep 17 00:00:00 2001 From: GreaseMonkey Date: Tue, 21 Nov 2023 10:26:13 +1300 Subject: [PATCH] Generate CGA-to-EGA tables in video.c; Remove redundant table generation in vid_ega.c --- src/include/86box/vid_svga_render.h | 1 + src/video/vid_ega.c | 28 ---------------------------- src/video/video.c | 13 +++++++++++++ 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/include/86box/vid_svga_render.h b/src/include/86box/vid_svga_render.h index 0c48303c9..3ad9e401c 100644 --- a/src/include/86box/vid_svga_render.h +++ b/src/include/86box/vid_svga_render.h @@ -34,6 +34,7 @@ extern int cgablink; extern int scrollcache; extern uint8_t edatlookup[4][4]; +extern uint8_t egaremap2bpp[256]; void svga_recalc_remap_func(svga_t *svga); diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index 957a81304..d4abebb39 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -61,8 +61,6 @@ static uint32_t pallook64[256]; static int ega_type = 0; static int old_overscan_color = 0; -uint8_t egaremap2bpp[256]; - /* 3C2 controls default mode on EGA. On VGA, it determines monitor type (mono or colour): 7=CGA mode (200 lines), 9=EGA mode (350 lines), 8=EGA mode (200 lines). */ int egaswitchread; @@ -1282,32 +1280,6 @@ ega_init(ega_t *ega, int monitor_type, int is_mono) } } - for (c = 0; c < 4; c++) { - for (d = 0; d < 4; d++) { - edatlookup[c][d] = 0; - if (c & 1) - edatlookup[c][d] |= 1; - if (d & 1) - edatlookup[c][d] |= 2; - if (c & 2) - edatlookup[c][d] |= 0x10; - if (d & 2) - edatlookup[c][d] |= 0x20; - } - } - - for (c = 0; c < 256; c++) { - egaremap2bpp[c] = 0; - if (c & 0x01) - egaremap2bpp[c] |= 0x01; - if (c & 0x04) - egaremap2bpp[c] |= 0x02; - if (c & 0x10) - egaremap2bpp[c] |= 0x04; - if (c & 0x40) - egaremap2bpp[c] |= 0x08; - } - if (is_mono) { for (c = 0; c < 256; c++) { if (((c >> 3) & 3) == 0) diff --git a/src/video/video.c b/src/video/video.c index 34e602e39..4c561e229 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -78,6 +78,7 @@ volatile int screenshots = 0; uint8_t edatlookup[4][4]; +uint8_t egaremap2bpp[256]; uint8_t fontdat[2048][8]; /* IBM CGA font */ uint8_t fontdatm[2048][16]; /* IBM MDA font */ uint8_t fontdat2[2048][8]; /* IBM CGA 2nd instance font */ @@ -915,6 +916,18 @@ video_init(void) } } + for (uint16_t c = 0; c < 256; c++) { + egaremap2bpp[c] = 0; + if (c & 0x01) + egaremap2bpp[c] |= 0x01; + if (c & 0x04) + egaremap2bpp[c] |= 0x02; + if (c & 0x10) + egaremap2bpp[c] |= 0x04; + if (c & 0x40) + egaremap2bpp[c] |= 0x08; + } + video_6to8 = malloc(4 * 256); for (uint16_t c = 0; c < 256; c++) video_6to8[c] = calc_6to8(c);