mdacols -> mda_attr_to_color_table; cgacols -> cga_attr_to_color_table

This commit is contained in:
starfrost013
2025-06-11 20:36:56 +01:00
parent 317a5b7ade
commit 5d8b3412e9
9 changed files with 131 additions and 125 deletions

View File

@@ -115,7 +115,7 @@ typedef struct ega_t {
int chipset;
int mono_display;
int mdacols[256][2][2];
int mda_attr_to_color_table[256][2][2];
uint32_t charseta;
uint32_t charsetb;

View File

@@ -13,10 +13,12 @@
* Authors: Sarah Walker, <https://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Jasmine Iwanek, <jriwanek@gmail.com>
*
* Connor Hyde / starfrost, <mario64crashed@gmail.com
*
* Copyright 2008-2019 Sarah Walker.
* Copyright 2016-2019 Miran Grca.
* Copyright 2021 Jasmine Iwanek.
* Copyright 2025 starfrost
*/
#ifndef VIDEO_HERCULES_H
@@ -53,10 +55,10 @@ typedef struct {
int vsynctime;
int vadj;
int lp_ff;
int fullchange;
int lp_ff;
int fullchange;
int cols[256][2][2];
int cols[256][2][2];
uint8_t *vram;
int monitor_index;

View File

@@ -60,8 +60,9 @@ typedef enum mda_crtc_registers_e
typedef enum mda_mode_flags_e
{
MDA_MODE_HIGHRES = 1 << 0,
MDA_MODE_VIDEO_ENABLE = 1 << 3,
MDA_MODE_HIGHRES = 1 << 0, // MUST be enabled for sane operation
MDA_MODE_BLACKANDWHITE = 1 << 1, // UNUSED in most cases. Not present on Hercules
MDA_MODE_VIDEO_ENABLE = 1 << 3,
MDA_MODE_BLINK = 1 << 5,
} mda_mode_flags;

View File

@@ -412,7 +412,9 @@ vid_poll_1512(void *priv)
for (x = 0; x < 40; x++) {
chr = vid->vram[(vid->memaddr<< 1) & 0x3fff];
attr = vid->vram[((vid->memaddr<< 1) + 1) & 0x3fff];
drawcursor = ((vid->memaddr== cursoraddr) && vid->cursorvisible && vid->cursoron);
drawcursor = ((vid->memaddr == cursoraddr)
&& vid->cursorvisible && vid->cursoron);
if (vid->cgamode & CGA_MODE_FLAG_BLINK) {
cols[1] = (attr & 15) + 16;
cols[0] = ((attr >> 4) & 7) + 16;

View File

@@ -16,7 +16,7 @@
*
* Copyright 2008-2019 Sarah Walker.
* Copyright 2016-2019 Miran Grca.
* Copyright 2023 W. M. Martine
* Copyright 2023 W. M. Martinez
*/
#include <stdio.h>
#include <stdint.h>
@@ -256,7 +256,7 @@ cga_render(cga_t *cga, int line)
uint16_t cursoraddr = (cga->crtc[CGA_CRTC_CURSOR_ADDR_LOW] | (cga->crtc[CGA_CRTC_CURSOR_ADDR_HIGH] << 8)) & 0x3fff;
int drawcursor;
int x;
int c;
int column;
uint8_t chr;
uint8_t attr;
uint16_t dat;
@@ -266,20 +266,20 @@ cga_render(cga_t *cga, int line)
int32_t highres_graphics_flag = (CGA_MODE_FLAG_HIGHRES_GRAPHICS | CGA_MODE_FLAG_GRAPHICS);
if (((cga->cgamode & highres_graphics_flag) == highres_graphics_flag)) {
for (c = 0; c < 8; ++c) {
buffer32->line[line][c] = 0;
for (column = 0; column < 8; ++column) {
buffer32->line[line][column] = 0;
if (cga->cgamode & CGA_MODE_FLAG_HIGHRES)
buffer32->line[line][c + (cga->crtc[CGA_CRTC_HDISP] << 3) + 8] = 0;
buffer32->line[line][column + (cga->crtc[CGA_CRTC_HDISP] << 3) + 8] = 0;
else
buffer32->line[line][c + (cga->crtc[CGA_CRTC_HDISP] << 4) + 8] = 0;
buffer32->line[line][column + (cga->crtc[CGA_CRTC_HDISP] << 4) + 8] = 0;
}
} else {
for (c = 0; c < 8; ++c) {
buffer32->line[line][c] = (cga->cgacol & 15) + 16;
for (column = 0; column < 8; ++column) {
buffer32->line[line][column] = (cga->cgacol & 15) + 16;
if (cga->cgamode & CGA_MODE_FLAG_HIGHRES)
buffer32->line[line][c + (cga->crtc[CGA_CRTC_HDISP] << 3) + 8] = (cga->cgacol & 15) + 16;
buffer32->line[line][column + (cga->crtc[CGA_CRTC_HDISP] << 3) + 8] = (cga->cgacol & 15) + 16;
else
buffer32->line[line][c + (cga->crtc[CGA_CRTC_HDISP] << 4) + 8] = (cga->cgacol & 15) + 16;
buffer32->line[line][column + (cga->crtc[CGA_CRTC_HDISP] << 4) + 8] = (cga->cgacol & 15) + 16;
}
}
if (cga->cgamode & CGA_MODE_FLAG_HIGHRES) {
@@ -298,14 +298,14 @@ cga_render(cga_t *cga, int line)
} else
cols[0] = (attr >> 4) + 16;
if (drawcursor) {
for (c = 0; c < 8; c++) {
buffer32->line[line][(x << 3) + c + 8]
= cols[(fontdat[chr + cga->fontbase][cga->scanline & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15;
for (column = 0; column < 8; column++) {
buffer32->line[line][(x << 3) + column + 8]
= cols[(fontdat[chr + cga->fontbase][cga->scanline & 7] & (1 << (column ^ 7))) ? 1 : 0] ^ 15;
}
} else {
for (c = 0; c < 8; c++) {
buffer32->line[line][(x << 3) + c + 8]
= cols[(fontdat[chr + cga->fontbase][cga->scanline & 7] & (1 << (c ^ 7))) ? 1 : 0];
for (column = 0; column < 8; column++) {
buffer32->line[line][(x << 3) + column + 8]
= cols[(fontdat[chr + cga->fontbase][cga->scanline & 7] & (1 << (column ^ 7))) ? 1 : 0];
}
}
cga->memaddr++;
@@ -327,16 +327,16 @@ cga_render(cga_t *cga, int line)
cols[0] = (attr >> 4) + 16;
cga->memaddr++;
if (drawcursor) {
for (c = 0; c < 8; c++) {
buffer32->line[line][(x << 4) + (c << 1) + 8]
= buffer32->line[line][(x << 4) + (c << 1) + 9]
= cols[(fontdat[chr + cga->fontbase][cga->scanline & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15;
for (column = 0; column < 8; column++) {
buffer32->line[line][(x << 4) + (column << 1) + 8]
= buffer32->line[line][(x << 4) + (column << 1) + 9]
= cols[(fontdat[chr + cga->fontbase][cga->scanline & 7] & (1 << (column ^ 7))) ? 1 : 0] ^ 15;
}
} else {
for (c = 0; c < 8; c++) {
buffer32->line[line][(x << 4) + (c << 1) + 8]
= buffer32->line[line][(x << 4) + (c << 1) + 9]
= cols[(fontdat[chr + cga->fontbase][cga->scanline & 7] & (1 << (c ^ 7))) ? 1 : 0];
for (column = 0; column < 8; column++) {
buffer32->line[line][(x << 4) + (column << 1) + 8]
= buffer32->line[line][(x << 4) + (column << 1) + 9]
= cols[(fontdat[chr + cga->fontbase][cga->scanline & 7] & (1 << (column ^ 7))) ? 1 : 0];
}
}
}
@@ -363,9 +363,9 @@ cga_render(cga_t *cga, int line)
else
dat = 0;
cga->memaddr++;
for (c = 0; c < 8; c++) {
buffer32->line[line][(x << 4) + (c << 1) + 8]
= buffer32->line[line][(x << 4) + (c << 1) + 9]
for (column = 0; column < 8; column++) {
buffer32->line[line][(x << 4) + (column << 1) + 8]
= buffer32->line[line][(x << 4) + (column << 1) + 9]
= cols[dat >> 14];
dat <<= 2;
}
@@ -380,8 +380,8 @@ cga_render(cga_t *cga, int line)
else
dat = 0;
cga->memaddr++;
for (c = 0; c < 16; c++) {
buffer32->line[line][(x << 4) + c + 8] = cols[dat >> 15];
for (column = 0; column < 16; column++) {
buffer32->line[line][(x << 4) + column + 8] = cols[dat >> 15];
dat <<= 1;
}
}

View File

@@ -1512,24 +1512,24 @@ ega_init(ega_t *ega, int monitor_type, int is_mono)
ega->pallook = pallook16;
for (uint16_t c = 0; c < 256; c++) {
ega->mdacols[c][0][0] = ega->mdacols[c][1][0] = ega->mdacols[c][1][1] = 16;
ega->mda_attr_to_color_table[c][0][0] = ega->mda_attr_to_color_table[c][1][0] = ega->mda_attr_to_color_table[c][1][1] = 16;
if (c & 8)
ega->mdacols[c][0][1] = 15 + 16;
ega->mda_attr_to_color_table[c][0][1] = 15 + 16;
else
ega->mdacols[c][0][1] = 7 + 16;
ega->mda_attr_to_color_table[c][0][1] = 7 + 16;
}
ega->mdacols[0x70][0][1] = 16;
ega->mdacols[0x70][0][0] = ega->mdacols[0x70][1][0] = ega->mdacols[0x70][1][1] = 16 + 15;
ega->mdacols[0xF0][0][1] = 16;
ega->mdacols[0xF0][0][0] = ega->mdacols[0xF0][1][0] = ega->mdacols[0xF0][1][1] = 16 + 15;
ega->mdacols[0x78][0][1] = 16 + 7;
ega->mdacols[0x78][0][0] = ega->mdacols[0x78][1][0] = ega->mdacols[0x78][1][1] = 16 + 15;
ega->mdacols[0xF8][0][1] = 16 + 7;
ega->mdacols[0xF8][0][0] = ega->mdacols[0xF8][1][0] = ega->mdacols[0xF8][1][1] = 16 + 15;
ega->mdacols[0x00][0][1] = ega->mdacols[0x00][1][1] = 16;
ega->mdacols[0x08][0][1] = ega->mdacols[0x08][1][1] = 16;
ega->mdacols[0x80][0][1] = ega->mdacols[0x80][1][1] = 16;
ega->mdacols[0x88][0][1] = ega->mdacols[0x88][1][1] = 16;
ega->mda_attr_to_color_table[0x70][0][1] = 16;
ega->mda_attr_to_color_table[0x70][0][0] = ega->mda_attr_to_color_table[0x70][1][0] = ega->mda_attr_to_color_table[0x70][1][1] = 16 + 15;
ega->mda_attr_to_color_table[0xF0][0][1] = 16;
ega->mda_attr_to_color_table[0xF0][0][0] = ega->mda_attr_to_color_table[0xF0][1][0] = ega->mda_attr_to_color_table[0xF0][1][1] = 16 + 15;
ega->mda_attr_to_color_table[0x78][0][1] = 16 + 7;
ega->mda_attr_to_color_table[0x78][0][0] = ega->mda_attr_to_color_table[0x78][1][0] = ega->mda_attr_to_color_table[0x78][1][1] = 16 + 15;
ega->mda_attr_to_color_table[0xF8][0][1] = 16 + 7;
ega->mda_attr_to_color_table[0xF8][0][0] = ega->mda_attr_to_color_table[0xF8][1][0] = ega->mda_attr_to_color_table[0xF8][1][1] = 16 + 15;
ega->mda_attr_to_color_table[0x00][0][1] = ega->mda_attr_to_color_table[0x00][1][1] = 16;
ega->mda_attr_to_color_table[0x08][0][1] = ega->mda_attr_to_color_table[0x08][1][1] = 16;
ega->mda_attr_to_color_table[0x80][0][1] = ega->mda_attr_to_color_table[0x80][1][1] = 16;
ega->mda_attr_to_color_table[0x88][0][1] = ega->mda_attr_to_color_table[0x88][1][1] = 16;
egaswitches = monitor_type & 0xf;

View File

@@ -185,11 +185,11 @@ ega_render_text(ega_t *ega)
int bit = (dat & (0x100 >> (xx >> dwshift))) ? 1 : 0;
int blink = (!drawcursor && (attr & 0x80) && attrblink && blinked);
if ((ega->scanline == ega->crtc[0x14]) && ((attr & 7) == 1))
p[xx] = ega->mdacols[attr][blink][1];
p[xx] = ega->mda_attr_to_color_table[attr][blink][1];
else
p[xx] = ega->mdacols[attr][blink][bit];
p[xx] = ega->mda_attr_to_color_table[attr][blink][bit];
if (drawcursor)
p[xx] ^= ega->mdacols[attr][0][1];
p[xx] ^= ega->mda_attr_to_color_table[attr][0][1];
p[xx] = ega->pallook[ega->egapal[p[xx] & 0x0f]];
} else
p[xx] = (dat & (0x100 >> (xx >> dwshift))) ? fg : bg;

View File

@@ -35,7 +35,7 @@
#include <86box/vid_mda.h>
#include <86box/plat_unused.h>
static int mdacols[256][2][2];
static int mda_attr_to_color_table[256][2][2];
static video_timings_t timing_mda = { .type = VIDEO_ISA, .write_b = 8, .write_w = 16, .write_l = 32, .read_b = 8, .read_w = 16, .read_l = 32 };
@@ -86,7 +86,6 @@ mda_in(uint16_t addr, void *priv)
{
case MDA_REGISTER_CRT_STATUS:
return mda->status | 0xF0;
default:
if (addr < MDA_REGISTER_START
|| addr > MDA_REGISTER_CRT_STATUS) // Maintain old behaviour for printer registers, just in case
@@ -169,19 +168,19 @@ mda_poll(void *priv)
blink = ((mda->blink & 16) && (mda->mode & MDA_MODE_BLINK) && (attr & 0x80) && !drawcursor);
if (mda->scanline == 12 && ((attr & 7) == 1)) {
for (c = 0; c < 9; c++)
buffer32->line[mda->displine][(x * 9) + c] = mdacols[attr][blink][1];
buffer32->line[mda->displine][(x * 9) + c] = mda_attr_to_color_table[attr][blink][1];
} else {
for (c = 0; c < 8; c++)
buffer32->line[mda->displine][(x * 9) + c] = mdacols[attr][blink][(fontdatm[chr + mda->fontbase][mda->scanline] & (1 << (c ^ 7))) ? 1 : 0];
buffer32->line[mda->displine][(x * 9) + c] = mda_attr_to_color_table[attr][blink][(fontdatm[chr + mda->fontbase][mda->scanline] & (1 << (c ^ 7))) ? 1 : 0];
if ((chr & ~0x1f) == 0xc0)
buffer32->line[mda->displine][(x * 9) + 8] = mdacols[attr][blink][fontdatm[chr + mda->fontbase][mda->scanline] & 1];
buffer32->line[mda->displine][(x * 9) + 8] = mda_attr_to_color_table[attr][blink][fontdatm[chr + mda->fontbase][mda->scanline] & 1];
else
buffer32->line[mda->displine][(x * 9) + 8] = mdacols[attr][blink][0];
buffer32->line[mda->displine][(x * 9) + 8] = mda_attr_to_color_table[attr][blink][0];
}
mda->memaddr++;
if (drawcursor) {
for (c = 0; c < 9; c++)
buffer32->line[mda->displine][(x * 9) + c] ^= mdacols[attr][0][1];
buffer32->line[mda->displine][(x * 9) + c] ^= mda_attr_to_color_table[attr][0][1];
}
}
@@ -218,14 +217,14 @@ mda_poll(void *priv)
if (!mda->vadj) {
mda->dispon = 1;
mda->memaddr = mda->memaddr_backup = (mda->crtc[MDA_CRTC_START_ADDR_LOW] | (mda->crtc[MDA_CRTC_START_ADDR_HIGH] << 8)) & 0x3fff;
mda->scanline = 0;
mda->scanline = 0;
}
} else if (mda->scanline == mda->crtc[MDA_CRTC_MAX_SCANLINE_ADDR]
|| ((mda->crtc[MDA_CRTC_INTERLACE] & 3) == 3
&& mda->scanline == (mda->crtc[MDA_CRTC_MAX_SCANLINE_ADDR] >> 1))) {
mda->memaddr_backup = mda->memaddr;
mda->scanline = 0;
oldvc = mda->vc;
mda->scanline = 0;
oldvc = mda->vc;
mda->vc++;
mda->vc &= 127;
if (mda->vc == mda->crtc[MDA_CRTC_VDISP])
@@ -242,6 +241,7 @@ mda_poll(void *priv)
else
mda->cursoron = mda->blink & 16;
}
if (mda->vc == mda->crtc[MDA_CRTC_VSYNC]) {
mda->dispon = 0;
mda->displine = 0;
@@ -276,6 +276,7 @@ mda_poll(void *priv)
mda->scanline &= 31;
mda->memaddr = mda->memaddr_backup;
}
if (mda->scanline == (mda->crtc[MDA_CRTC_CURSOR_START] & 31)
|| ((mda->crtc[MDA_CRTC_INTERLACE] & 3) == 3
&& mda->scanline == ((mda->crtc[MDA_CRTC_CURSOR_START] & 31) >> 1))) {
@@ -289,24 +290,24 @@ void
mda_init(mda_t *mda)
{
for (uint16_t c = 0; c < 256; c++) {
mdacols[c][0][0] = mdacols[c][1][0] = mdacols[c][1][1] = 16;
mda_attr_to_color_table[c][0][0] = mda_attr_to_color_table[c][1][0] = mda_attr_to_color_table[c][1][1] = 16;
if (c & 8)
mdacols[c][0][1] = 15 + 16;
mda_attr_to_color_table[c][0][1] = 15 + 16;
else
mdacols[c][0][1] = 7 + 16;
mda_attr_to_color_table[c][0][1] = 7 + 16;
}
mdacols[0x70][0][1] = 16;
mdacols[0x70][0][0] = mdacols[0x70][1][0] = mdacols[0x70][1][1] = 16 + 15;
mdacols[0xF0][0][1] = 16;
mdacols[0xF0][0][0] = mdacols[0xF0][1][0] = mdacols[0xF0][1][1] = 16 + 15;
mdacols[0x78][0][1] = 16 + 7;
mdacols[0x78][0][0] = mdacols[0x78][1][0] = mdacols[0x78][1][1] = 16 + 15;
mdacols[0xF8][0][1] = 16 + 7;
mdacols[0xF8][0][0] = mdacols[0xF8][1][0] = mdacols[0xF8][1][1] = 16 + 15;
mdacols[0x00][0][1] = mdacols[0x00][1][1] = 16;
mdacols[0x08][0][1] = mdacols[0x08][1][1] = 16;
mdacols[0x80][0][1] = mdacols[0x80][1][1] = 16;
mdacols[0x88][0][1] = mdacols[0x88][1][1] = 16;
mda_attr_to_color_table[0x70][0][1] = 16;
mda_attr_to_color_table[0x70][0][0] = mda_attr_to_color_table[0x70][1][0] = mda_attr_to_color_table[0x70][1][1] = 16 + 15;
mda_attr_to_color_table[0xF0][0][1] = 16;
mda_attr_to_color_table[0xF0][0][0] = mda_attr_to_color_table[0xF0][1][0] = mda_attr_to_color_table[0xF0][1][1] = 16 + 15;
mda_attr_to_color_table[0x78][0][1] = 16 + 7;
mda_attr_to_color_table[0x78][0][0] = mda_attr_to_color_table[0x78][1][0] = mda_attr_to_color_table[0x78][1][1] = 16 + 15;
mda_attr_to_color_table[0xF8][0][1] = 16 + 7;
mda_attr_to_color_table[0xF8][0][0] = mda_attr_to_color_table[0xF8][1][0] = mda_attr_to_color_table[0xF8][1][1] = 16 + 15;
mda_attr_to_color_table[0x00][0][1] = mda_attr_to_color_table[0x00][1][1] = 16;
mda_attr_to_color_table[0x08][0][1] = mda_attr_to_color_table[0x08][1][1] = 16;
mda_attr_to_color_table[0x80][0][1] = mda_attr_to_color_table[0x80][1][1] = 16;
mda_attr_to_color_table[0x88][0][1] = mda_attr_to_color_table[0x88][1][1] = 16;
overscan_x = overscan_y = 0;
mda->monitor_index = monitor_index_global;
@@ -366,7 +367,7 @@ mda_standalone_init(UNUSED(const device_t *info))
void
mda_setcol(int chr, int blink, int fg, uint8_t cga_ink)
{
mdacols[chr][blink][fg] = 16 + cga_ink;
mda_attr_to_color_table[chr][blink][fg] = 16 + cga_ink;
}
void

View File

@@ -212,9 +212,9 @@ typedef struct wy700_t {
} wy700_t;
/* Mapping of attributes to colours, in CGA emulation... */
static int cgacols[256][2][2];
static int cga_attr_to_color_table[256][2][2];
/* ... and MDA emulation. */
static int mdacols[256][2][2];
static int mda_attr_to_color_table[256][2][2];
void wy700_recalctimings(wy700_t *wy700);
void wy700_write(uint32_t addr, uint8_t val, void *priv);
@@ -570,7 +570,7 @@ wy700_textline(wy700_t *wy700)
/* MDA underline */
if (scanline == 14 && mda && ((attr & 7) == 1)) {
for (c = 0; c < cw; c++)
buffer32->line[wy700->displine][(x * cw) + c] = mdacols[attr][blink][1];
buffer32->line[wy700->displine][(x * cw) + c] = mda_attr_to_color_table[attr][blink][1];
} else /* Draw 16 pixels of character */
{
bitmap[0] = fontbase[chr * 32 + 2 * scanline];
@@ -578,11 +578,11 @@ wy700_textline(wy700_t *wy700)
for (c = 0; c < 16; c++) {
int col;
if (c < 8)
col = (mda ? mdacols : cgacols)[attr][blink][(bitmap[0] & (1 << (c ^ 7))) ? 1 : 0];
col = (mda ? mda_attr_to_color_table : cga_attr_to_color_table)[attr][blink][(bitmap[0] & (1 << (c ^ 7))) ? 1 : 0];
else
col = (mda ? mdacols : cgacols)[attr][blink][(bitmap[1] & (1 << ((c & 7) ^ 7))) ? 1 : 0];
col = (mda ? mda_attr_to_color_table : cga_attr_to_color_table)[attr][blink][(bitmap[1] & (1 << ((c & 7) ^ 7))) ? 1 : 0];
if (!(wy700->enabled) || !(wy700->cga_ctrl & 8))
col = mdacols[0][0][0];
col = mda_attr_to_color_table[0][0][0];
if (w == 40) {
buffer32->line[wy700->displine][(x * cw) + 2 * c] = col;
buffer32->line[wy700->displine][(x * cw) + 2 * c + 1] = col;
@@ -592,7 +592,7 @@ wy700_textline(wy700_t *wy700)
if (drawcursor) {
for (c = 0; c < cw; c++)
buffer32->line[wy700->displine][(x * cw) + c] ^= (mda ? mdacols : cgacols)[attr][0][1];
buffer32->line[wy700->displine][(x * cw) + c] ^= (mda ? mda_attr_to_color_table : cga_attr_to_color_table)[attr][0][1];
}
++memaddr;
}
@@ -902,74 +902,74 @@ wy700_init(UNUSED(const device_t *info))
/* Set up the emulated attributes.
* CGA is done in four groups: 00-0F, 10-7F, 80-8F, 90-FF */
for (c = 0; c < 0x10; c++) {
cgacols[c][0][0] = cgacols[c][1][0] = cgacols[c][1][1] = 16;
cga_attr_to_color_table[c][0][0] = cga_attr_to_color_table[c][1][0] = cga_attr_to_color_table[c][1][1] = 16;
if (c & 8)
cgacols[c][0][1] = 15 + 16;
cga_attr_to_color_table[c][0][1] = 15 + 16;
else
cgacols[c][0][1] = 7 + 16;
cga_attr_to_color_table[c][0][1] = 7 + 16;
}
for (c = 0x10; c < 0x80; c++) {
cgacols[c][0][0] = cgacols[c][1][0] = cgacols[c][1][1] = 16 + 7;
cga_attr_to_color_table[c][0][0] = cga_attr_to_color_table[c][1][0] = cga_attr_to_color_table[c][1][1] = 16 + 7;
if (c & 8)
cgacols[c][0][1] = 15 + 16;
cga_attr_to_color_table[c][0][1] = 15 + 16;
else
cgacols[c][0][1] = 0 + 16;
cga_attr_to_color_table[c][0][1] = 0 + 16;
if ((c & 0x0F) == 8)
cgacols[c][0][1] = 8 + 16;
cga_attr_to_color_table[c][0][1] = 8 + 16;
}
/* With special cases for 00, 11, 22, ... 77 */
cgacols[0x00][0][1] = cgacols[0x00][1][1] = 16;
cga_attr_to_color_table[0x00][0][1] = cga_attr_to_color_table[0x00][1][1] = 16;
for (c = 0x11; c <= 0x77; c += 0x11) {
cgacols[c][0][1] = cgacols[c][1][1] = 16 + 7;
cga_attr_to_color_table[c][0][1] = cga_attr_to_color_table[c][1][1] = 16 + 7;
}
for (c = 0x80; c < 0x90; c++) {
cgacols[c][0][0] = 16 + 8;
cga_attr_to_color_table[c][0][0] = 16 + 8;
if (c & 8)
cgacols[c][0][1] = 15 + 16;
cga_attr_to_color_table[c][0][1] = 15 + 16;
else
cgacols[c][0][1] = 7 + 16;
cgacols[c][1][0] = cgacols[c][1][1] = cgacols[c - 0x80][0][0];
cga_attr_to_color_table[c][0][1] = 7 + 16;
cga_attr_to_color_table[c][1][0] = cga_attr_to_color_table[c][1][1] = cga_attr_to_color_table[c - 0x80][0][0];
}
for (c = 0x90; c < 0x100; c++) {
cgacols[c][0][0] = 16 + 15;
cga_attr_to_color_table[c][0][0] = 16 + 15;
if (c & 8)
cgacols[c][0][1] = 8 + 16;
cga_attr_to_color_table[c][0][1] = 8 + 16;
else
cgacols[c][0][1] = 7 + 16;
cga_attr_to_color_table[c][0][1] = 7 + 16;
if ((c & 0x0F) == 0)
cgacols[c][0][1] = 16;
cgacols[c][1][0] = cgacols[c][1][1] = cgacols[c - 0x80][0][0];
cga_attr_to_color_table[c][0][1] = 16;
cga_attr_to_color_table[c][1][0] = cga_attr_to_color_table[c][1][1] = cga_attr_to_color_table[c - 0x80][0][0];
}
/* Also special cases for 99, AA, ..., FF */
for (c = 0x99; c <= 0xFF; c += 0x11) {
cgacols[c][0][1] = 16 + 15;
cga_attr_to_color_table[c][0][1] = 16 + 15;
}
/* Special cases for 08, 80 and 88 */
cgacols[0x08][0][1] = 16 + 8;
cgacols[0x80][0][1] = 16;
cgacols[0x88][0][1] = 16 + 8;
cga_attr_to_color_table[0x08][0][1] = 16 + 8;
cga_attr_to_color_table[0x80][0][1] = 16;
cga_attr_to_color_table[0x88][0][1] = 16 + 8;
/* MDA attributes */
for (c = 0; c < 256; c++) {
mdacols[c][0][0] = mdacols[c][1][0] = mdacols[c][1][1] = 16;
mda_attr_to_color_table[c][0][0] = mda_attr_to_color_table[c][1][0] = mda_attr_to_color_table[c][1][1] = 16;
if (c & 8)
mdacols[c][0][1] = 15 + 16;
mda_attr_to_color_table[c][0][1] = 15 + 16;
else
mdacols[c][0][1] = 7 + 16;
mda_attr_to_color_table[c][0][1] = 7 + 16;
}
mdacols[0x70][0][1] = 16;
mdacols[0x70][0][0] = mdacols[0x70][1][0] = mdacols[0x70][1][1] = 16 + 15;
mdacols[0xF0][0][1] = 16;
mdacols[0xF0][0][0] = mdacols[0xF0][1][0] = mdacols[0xF0][1][1] = 16 + 15;
mdacols[0x78][0][1] = 16 + 7;
mdacols[0x78][0][0] = mdacols[0x78][1][0] = mdacols[0x78][1][1] = 16 + 15;
mdacols[0xF8][0][1] = 16 + 7;
mdacols[0xF8][0][0] = mdacols[0xF8][1][0] = mdacols[0xF8][1][1] = 16 + 15;
mdacols[0x00][0][1] = mdacols[0x00][1][1] = 16;
mdacols[0x08][0][1] = mdacols[0x08][1][1] = 16;
mdacols[0x80][0][1] = mdacols[0x80][1][1] = 16;
mdacols[0x88][0][1] = mdacols[0x88][1][1] = 16;
mda_attr_to_color_table[0x70][0][1] = 16;
mda_attr_to_color_table[0x70][0][0] = mda_attr_to_color_table[0x70][1][0] = mda_attr_to_color_table[0x70][1][1] = 16 + 15;
mda_attr_to_color_table[0xF0][0][1] = 16;
mda_attr_to_color_table[0xF0][0][0] = mda_attr_to_color_table[0xF0][1][0] = mda_attr_to_color_table[0xF0][1][1] = 16 + 15;
mda_attr_to_color_table[0x78][0][1] = 16 + 7;
mda_attr_to_color_table[0x78][0][0] = mda_attr_to_color_table[0x78][1][0] = mda_attr_to_color_table[0x78][1][1] = 16 + 15;
mda_attr_to_color_table[0xF8][0][1] = 16 + 7;
mda_attr_to_color_table[0xF8][0][0] = mda_attr_to_color_table[0xF8][1][0] = mda_attr_to_color_table[0xF8][1][1] = 16 + 15;
mda_attr_to_color_table[0x00][0][1] = mda_attr_to_color_table[0x00][1][1] = 16;
mda_attr_to_color_table[0x08][0][1] = mda_attr_to_color_table[0x08][1][1] = 16;
mda_attr_to_color_table[0x80][0][1] = mda_attr_to_color_table[0x80][1][1] = 16;
mda_attr_to_color_table[0x88][0][1] = mda_attr_to_color_table[0x88][1][1] = 16;
/* Start off in 80x25 text mode */
wy700->cga_stat = 0xF4;