Applied the last mainline PCem EGA-related commits.
This commit is contained in:
@@ -66,85 +66,84 @@ void ega_render_blank(ega_t *ega)
|
||||
}
|
||||
|
||||
void ega_render_text_standard(ega_t *ega, int drawcursor)
|
||||
{
|
||||
{
|
||||
int x, xx;
|
||||
int x_add = (enable_overscan) ? 8 : 0;
|
||||
int dl = ega_display_line(ega);
|
||||
uint8_t chr, dat, attr;
|
||||
uint32_t charaddr;
|
||||
int x, xx;
|
||||
uint32_t fg, bg;
|
||||
|
||||
for (x = 0; x < ega->hdisp; x++)
|
||||
{
|
||||
int drawcursor = ((ega->ma == ega->ca) && ega->con && ega->cursoron);
|
||||
uint8_t chr = ega->vram[(ega->ma << 1) & ega->vrammask];
|
||||
uint8_t attr = ega->vram[((ega->ma << 1) + 1) & ega->vrammask];
|
||||
uint8_t dat;
|
||||
uint32_t fg, bg;
|
||||
uint32_t charaddr;
|
||||
|
||||
if (attr & 8)
|
||||
charaddr = ega->charsetb + (chr * 128);
|
||||
else
|
||||
charaddr = ega->charseta + (chr * 128);
|
||||
|
||||
if (fullchange)
|
||||
{
|
||||
for (x = 0; x < ega->hdisp; x++)
|
||||
{
|
||||
drawcursor = ((ega->ma == ega->ca) && ega->con && ega->cursoron);
|
||||
chr = ega->vram[(ega->ma << 1) & ega->vrammask];
|
||||
attr = ega->vram[((ega->ma << 1) + 1) & ega->vrammask];
|
||||
if (drawcursor)
|
||||
{
|
||||
bg = ega->pallook[ega->egapal[attr & 15]];
|
||||
fg = ega->pallook[ega->egapal[attr >> 4]];
|
||||
}
|
||||
else
|
||||
{
|
||||
fg = ega->pallook[ega->egapal[attr & 15]];
|
||||
bg = ega->pallook[ega->egapal[attr >> 4]];
|
||||
if (attr & 0x80 && ega->attrregs[0x10] & 8)
|
||||
{
|
||||
bg = ega->pallook[ega->egapal[(attr >> 4) & 7]];
|
||||
if (ega->blink & 16)
|
||||
fg = bg;
|
||||
}
|
||||
}
|
||||
|
||||
if (attr & 8) charaddr = ega->charsetb + (chr * 128);
|
||||
else charaddr = ega->charseta + (chr * 128);
|
||||
|
||||
if (drawcursor)
|
||||
{
|
||||
bg = ega->pallook[ega->egapal[attr & 15]];
|
||||
fg = ega->pallook[ega->egapal[attr >> 4]];
|
||||
}
|
||||
else
|
||||
{
|
||||
fg = ega->pallook[ega->egapal[attr & 15]];
|
||||
bg = ega->pallook[ega->egapal[attr >> 4]];
|
||||
if (attr & 0x80 && ega->attrregs[0x10] & 8)
|
||||
{
|
||||
bg = ega->pallook[ega->egapal[(attr >> 4) & 7]];
|
||||
if (ega->blink & 16)
|
||||
fg = bg;
|
||||
}
|
||||
}
|
||||
|
||||
dat = ega->vram[charaddr + (ega->sc << 2)];
|
||||
if (ega->seqregs[1] & 8)
|
||||
{
|
||||
if (ega->seqregs[1] & 1)
|
||||
{
|
||||
for (xx = 0; xx < 8; xx++)
|
||||
((uint32_t *)buffer32->line[dl])[(((x << 4) + 32 + (xx << 1)) & 2047) + x_add] =
|
||||
((uint32_t *)buffer32->line[dl])[(((x << 4) + 33 + (xx << 1)) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (xx = 0; xx < 8; xx++)
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + (xx << 1)) & 2047) + x_add] =
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 18) + 33 + (xx << 1)) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg;
|
||||
if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4))
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + 16) & 2047) + x_add] =
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + 17) & 2047) + x_add] = bg;
|
||||
else
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + 16) & 2047) + x_add] =
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + 17) & 2047) + x_add] = (dat & 1) ? fg : bg;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ega->seqregs[1] & 1)
|
||||
{
|
||||
for (xx = 0; xx < 8; xx++)
|
||||
((uint32_t *)buffer32->line[dl])[(((x << 3) + 32 + xx) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (xx = 0; xx < 8; xx++)
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 9) + 32 + xx) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg;
|
||||
if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4))
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 9) + 32 + 8) & 2047) + x_add] = bg;
|
||||
else
|
||||
((uint32_t *)buffer32->line[dl])[(((x * 9) + 32 + 8) & 2047) + x_add] = (dat & 1) ? fg : bg;
|
||||
}
|
||||
}
|
||||
ega->ma += 4;
|
||||
ega->ma &= ega->vrammask;
|
||||
}
|
||||
}
|
||||
dat = ega->vram[charaddr + (ega->sc << 2)];
|
||||
if (ega->seqregs[1] & 8)
|
||||
{
|
||||
if (ega->seqregs[1] & 1)
|
||||
{
|
||||
for (xx = 0; xx < 8; xx++)
|
||||
((uint32_t *)buffer32->line[dl])[((x << 4) + 32 + (xx << 1) + x_add) & 2047] =
|
||||
((uint32_t *)buffer32->line[dl])[((x << 4) + 33 + (xx << 1) + x_add) & 2047] = (dat & (0x80 >> xx)) ? fg : bg;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (xx = 0; xx < 8; xx++)
|
||||
((uint32_t *)buffer32->line[dl])[((x * 18) + 32 + (xx << 1) + x_add) & 2047] =
|
||||
((uint32_t *)buffer32->line[dl])[((x * 18) + 33 + (xx << 1) + x_add) & 2047] = (dat & (0x80 >> xx)) ? fg : bg;
|
||||
if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4))
|
||||
((uint32_t *)buffer32->line[dl])[((x * 18) + 32 + 16 + x_add) & 2047] =
|
||||
((uint32_t *)buffer32->line[dl])[((x * 18) + 32 + 17 + x_add) & 2047] = bg;
|
||||
else
|
||||
((uint32_t *)buffer32->line[dl])[((x * 18) + 32 + 16 + x_add) & 2047] =
|
||||
((uint32_t *)buffer32->line[dl])[((x * 18) + 32 + 17 + x_add) & 2047] = (dat & 1) ? fg : bg;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ega->seqregs[1] & 1)
|
||||
{
|
||||
for (xx = 0; xx < 8; xx++)
|
||||
((uint32_t *)buffer32->line[dl])[((x << 3) + 32 + xx + x_add) & 2047] = (dat & (0x80 >> xx)) ? fg : bg;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (xx = 0; xx < 8; xx++)
|
||||
((uint32_t *)buffer32->line[dl])[((x * 9) + 32 + xx + x_add) & 2047] = (dat & (0x80 >> xx)) ? fg : bg;
|
||||
if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4))
|
||||
((uint32_t *)buffer32->line[dl])[((x * 9) + 32 + 8 + x_add) & 2047] = bg;
|
||||
else
|
||||
((uint32_t *)buffer32->line[dl])[((x * 9) + 32 + 8 + x_add) & 2047] = (dat & 1) ? fg : bg;
|
||||
}
|
||||
}
|
||||
ega->ma += 4;
|
||||
ega->ma &= ega->vrammask;
|
||||
}
|
||||
}
|
||||
|
||||
static __inline int is_kanji1(uint8_t chr)
|
||||
@@ -381,24 +380,35 @@ void ega_render_2bpp_lowres(ega_t *ega)
|
||||
int x_add = (enable_overscan) ? 8 : 0;
|
||||
int dl = ega_display_line(ega);
|
||||
int x;
|
||||
int offset;
|
||||
uint8_t edat[4];
|
||||
int offset = ((8 - ega->scrollcache) << 1) + 16;
|
||||
|
||||
for (x = 0; x <= ega->hdisp; x++)
|
||||
{
|
||||
uint8_t edat[2];
|
||||
uint32_t addr = ega->ma;
|
||||
|
||||
if (!(ega->crtc[0x17] & 0x40))
|
||||
{
|
||||
addr = (addr << 1) & ega->vrammask;
|
||||
addr &= ~7;
|
||||
if ((ega->crtc[0x17] & 0x20) && (ega->ma & 0x20000))
|
||||
addr |= 4;
|
||||
if (!(ega->crtc[0x17] & 0x20) && (ega->ma & 0x8000))
|
||||
addr |= 4;
|
||||
}
|
||||
if (!(ega->crtc[0x17] & 0x01))
|
||||
addr = (addr & ~0x8000) | ((ega->sc & 1) ? 0x8000 : 0);
|
||||
if (!(ega->crtc[0x17] & 0x02))
|
||||
addr = (addr & ~0x10000) | ((ega->sc & 2) ? 0x10000 : 0);
|
||||
|
||||
offset = ((8 - ega->scrollcache) << 1) + 16;
|
||||
for (x = 0; x <= ega->hdisp; x++)
|
||||
{
|
||||
if (ega->sc & 1 && !(ega->crtc[0x17] & 1))
|
||||
{
|
||||
edat[0] = ega->vram[(ega->ma << 1) + 0x8000];
|
||||
edat[1] = ega->vram[(ega->ma << 1) + 0x8001];
|
||||
}
|
||||
else
|
||||
{
|
||||
edat[0] = ega->vram[(ega->ma << 1)];
|
||||
edat[1] = ega->vram[(ega->ma << 1) + 1];
|
||||
}
|
||||
ega->ma += 4;
|
||||
ega->ma &= ega->vrammask;
|
||||
edat[0] = ega->vram[addr];
|
||||
edat[1] = ega->vram[addr | 0x1];
|
||||
if (ega->seqregs[1] & 4)
|
||||
ega->ma += 2;
|
||||
else
|
||||
ega->ma += 4;
|
||||
|
||||
ega->ma &= ega->vrammask;
|
||||
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 14 + offset + x_add]= ((uint32_t *)buffer32->line[dl])[(x << 4) + 15 + offset + x_add] = ega->pallook[ega->egapal[edat[1] & 3]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 12 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 13 + offset + x_add] = ega->pallook[ega->egapal[(edat[1] >> 2) & 3]];
|
||||
@@ -416,24 +426,35 @@ void ega_render_2bpp_highres(ega_t *ega)
|
||||
int x_add = (enable_overscan) ? 8 : 0;
|
||||
int dl = ega_display_line(ega);
|
||||
int x;
|
||||
int offset;
|
||||
uint8_t edat[4];
|
||||
int offset = ((8 - ega->scrollcache) << 1) + 16;
|
||||
|
||||
for (x = 0; x <= ega->hdisp; x++)
|
||||
{
|
||||
uint8_t edat[2];
|
||||
uint32_t addr = ega->ma;
|
||||
|
||||
if (!(ega->crtc[0x17] & 0x40))
|
||||
{
|
||||
addr = (addr << 1) & ega->vrammask;
|
||||
addr &= ~7;
|
||||
if ((ega->crtc[0x17] & 0x20) && (ega->ma & 0x20000))
|
||||
addr |= 4;
|
||||
if (!(ega->crtc[0x17] & 0x20) && (ega->ma & 0x8000))
|
||||
addr |= 4;
|
||||
}
|
||||
if (!(ega->crtc[0x17] & 0x01))
|
||||
addr = (addr & ~0x8000) | ((ega->sc & 1) ? 0x8000 : 0);
|
||||
if (!(ega->crtc[0x17] & 0x02))
|
||||
addr = (addr & ~0x10000) | ((ega->sc & 2) ? 0x10000 : 0);
|
||||
|
||||
offset = ((8 - ega->scrollcache) << 1) + 16;
|
||||
for (x = 0; x <= ega->hdisp; x++)
|
||||
{
|
||||
if (ega->sc & 1 && !(ega->crtc[0x17] & 1))
|
||||
{
|
||||
edat[0] = ega->vram[(ega->ma << 1) + 0x8000];
|
||||
edat[1] = ega->vram[(ega->ma << 1) + 0x8001];
|
||||
}
|
||||
else
|
||||
{
|
||||
edat[0] = ega->vram[(ega->ma << 1)];
|
||||
edat[1] = ega->vram[(ega->ma << 1) + 1];
|
||||
}
|
||||
ega->ma += 4;
|
||||
ega->ma &= ega->vrammask;
|
||||
edat[0] = ega->vram[addr];
|
||||
edat[1] = ega->vram[addr | 0x1];
|
||||
if (ega->seqregs[1] & 4)
|
||||
ega->ma += 2;
|
||||
else
|
||||
ega->ma += 4;
|
||||
|
||||
ega->ma &= ega->vrammask;
|
||||
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 7 + offset + x_add] = ega->pallook[ega->egapal[edat[1] & 3]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 6 + offset + x_add] = ega->pallook[ega->egapal[(edat[1] >> 2) & 3]];
|
||||
@@ -450,30 +471,49 @@ void ega_render_4bpp_lowres(ega_t *ega)
|
||||
{
|
||||
int x_add = (enable_overscan) ? 8 : 0;
|
||||
int dl = ega_display_line(ega);
|
||||
uint8_t dat;
|
||||
int x;
|
||||
int offset;
|
||||
uint8_t edat[4];
|
||||
int offset = ((8 - ega->scrollcache) << 1) + 16;
|
||||
|
||||
for (x = 0; x <= ega->hdisp; x++)
|
||||
{
|
||||
uint8_t edat[4];
|
||||
uint8_t dat;
|
||||
uint32_t addr = ega->ma;
|
||||
int oddeven = 0;
|
||||
|
||||
if (!(ega->crtc[0x17] & 0x40))
|
||||
{
|
||||
addr = (addr << 1) & ega->vrammask;
|
||||
if (ega->seqregs[1] & 4)
|
||||
oddeven = (addr & 4) ? 1 : 0;
|
||||
addr &= ~7;
|
||||
if ((ega->crtc[0x17] & 0x20) && (ega->ma & 0x20000))
|
||||
addr |= 4;
|
||||
if (!(ega->crtc[0x17] & 0x20) && (ega->ma & 0x8000))
|
||||
addr |= 4;
|
||||
}
|
||||
if (!(ega->crtc[0x17] & 0x01))
|
||||
addr = (addr & ~0x8000) | ((ega->sc & 1) ? 0x8000 : 0);
|
||||
if (!(ega->crtc[0x17] & 0x02))
|
||||
addr = (addr & ~0x10000) | ((ega->sc & 2) ? 0x10000 : 0);
|
||||
|
||||
if (ega->seqregs[1] & 4)
|
||||
{
|
||||
edat[0] = ega->vram[addr | oddeven];
|
||||
edat[2] = ega->vram[addr | oddeven | 0x2];
|
||||
edat[1] = edat[3] = 0;
|
||||
ega->ma += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
edat[0] = ega->vram[addr];
|
||||
edat[1] = ega->vram[addr | 0x1];
|
||||
edat[2] = ega->vram[addr | 0x2];
|
||||
edat[3] = ega->vram[addr | 0x3];
|
||||
ega->ma += 4;
|
||||
}
|
||||
ega->ma &= ega->vrammask;
|
||||
|
||||
offset = ((8 - ega->scrollcache) << 1) + 16;
|
||||
for (x = 0; x <= ega->hdisp; x++)
|
||||
{
|
||||
if (ega->sc & 1 && !(ega->crtc[0x17] & 1))
|
||||
{
|
||||
edat[0] = ega->vram[ega->ma | 0x8000];
|
||||
edat[1] = ega->vram[ega->ma | 0x8001];
|
||||
edat[2] = ega->vram[ega->ma | 0x8002];
|
||||
edat[3] = ega->vram[ega->ma | 0x8003];
|
||||
}
|
||||
else
|
||||
{
|
||||
edat[0] = ega->vram[ega->ma];
|
||||
edat[1] = ega->vram[ega->ma | 0x1];
|
||||
edat[2] = ega->vram[ega->ma | 0x2];
|
||||
edat[3] = ega->vram[ega->ma | 0x3];
|
||||
}
|
||||
ega->ma += 4;
|
||||
ega->ma &= ega->vrammask;
|
||||
dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2);
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 14 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 15 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]];
|
||||
((uint32_t *)buffer32->line[dl])[(x << 4) + 12 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 13 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]];
|
||||
@@ -493,30 +533,48 @@ void ega_render_4bpp_highres(ega_t *ega)
|
||||
{
|
||||
int x_add = (enable_overscan) ? 8 : 0;
|
||||
int dl = ega_display_line(ega);
|
||||
uint8_t dat;
|
||||
int x;
|
||||
int offset;
|
||||
uint8_t edat[4];
|
||||
int offset = (8 - ega->scrollcache) + 24;
|
||||
|
||||
for (x = 0; x <= ega->hdisp; x++)
|
||||
{
|
||||
uint8_t edat[4];
|
||||
uint8_t dat;
|
||||
uint32_t addr = ega->ma;
|
||||
int oddeven = 0;
|
||||
|
||||
offset = (8 - ega->scrollcache) + 24;
|
||||
for (x = 0; x <= ega->hdisp; x++)
|
||||
{
|
||||
if (ega->sc & 1 && !(ega->crtc[0x17] & 1))
|
||||
{
|
||||
edat[0] = ega->vram[ega->ma | 0x8000];
|
||||
edat[1] = ega->vram[ega->ma | 0x8001];
|
||||
edat[2] = ega->vram[ega->ma | 0x8002];
|
||||
edat[3] = ega->vram[ega->ma | 0x8003];
|
||||
}
|
||||
else
|
||||
{
|
||||
edat[0] = ega->vram[ega->ma];
|
||||
edat[1] = ega->vram[ega->ma | 0x1];
|
||||
edat[2] = ega->vram[ega->ma | 0x2];
|
||||
edat[3] = ega->vram[ega->ma | 0x3];
|
||||
}
|
||||
ega->ma += 4;
|
||||
ega->ma &= ega->vrammask;
|
||||
if (!(ega->crtc[0x17] & 0x40))
|
||||
{
|
||||
addr = (addr << 1) & ega->vrammask;
|
||||
if (ega->seqregs[1] & 4)
|
||||
oddeven = (addr & 4) ? 1 : 0;
|
||||
addr &= ~7;
|
||||
if ((ega->crtc[0x17] & 0x20) && (ega->ma & 0x20000))
|
||||
addr |= 4;
|
||||
if (!(ega->crtc[0x17] & 0x20) && (ega->ma & 0x8000))
|
||||
addr |= 4;
|
||||
}
|
||||
if (!(ega->crtc[0x17] & 0x01))
|
||||
addr = (addr & ~0x8000) | ((ega->sc & 1) ? 0x8000 : 0);
|
||||
if (!(ega->crtc[0x17] & 0x02))
|
||||
addr = (addr & ~0x10000) | ((ega->sc & 2) ? 0x10000 : 0);
|
||||
|
||||
if (ega->seqregs[1] & 4)
|
||||
{
|
||||
edat[0] = ega->vram[addr | oddeven];
|
||||
edat[2] = ega->vram[addr | oddeven | 0x2];
|
||||
edat[1] = edat[3] = 0;
|
||||
ega->ma += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
edat[0] = ega->vram[addr];
|
||||
edat[1] = ega->vram[addr | 0x1];
|
||||
edat[2] = ega->vram[addr | 0x2];
|
||||
edat[3] = ega->vram[addr | 0x3];
|
||||
ega->ma += 4;
|
||||
}
|
||||
ega->ma &= ega->vrammask;
|
||||
|
||||
dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2);
|
||||
((uint32_t *)buffer32->line[dl])[(x << 3) + 7 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]];
|
||||
|
||||
Reference in New Issue
Block a user