(S)VGA clean-ups and fixes (some parts of the COPPER demo should now work), and fixed the graphics modes on the ICS5341.

This commit is contained in:
OBattler
2021-03-24 19:35:07 +01:00
parent 468e1f772b
commit e045df2b50
4 changed files with 104 additions and 53 deletions

View File

@@ -44,7 +44,7 @@ sdac_control_write(sdac_ramdac_t *ramdac, svga_t *svga, uint8_t val)
{
ramdac->command = val;
if (ramdac->type == 1 || ramdac->type == 2) {
if (ramdac->type == 1) {
switch (val) {
case 0xa0:
svga->bpp = 15;
@@ -67,32 +67,61 @@ sdac_control_write(sdac_ramdac_t *ramdac, svga_t *svga, uint8_t val)
svga->bpp = 8;
break;
}
} else if (ramdac->type == 2) {
switch (val >> 4) {
case 0x00:
default:
svga->bpp = 8;
break;
case 0x01:
case 0x04:
case 0x05:
case 0x09:
svga->bpp = 15;
break;
case 0x08:
svga->bpp = 17; /* 15bpp_mix */
break;
case 0x03:
case 0x06:
case 0x0a:
svga->bpp = 16;
break;
case 0xc0:
svga->bpp = 24;
break;
case 0x02:
case 0x07:
case 0x0b:
svga->bpp = 32;
break;
}
} else {
switch (val >> 4) {
case 0x2:
case 0x3:
case 0xa:
case 0x8:
svga->bpp = 15;
break;
case 0x4:
case 0x9:
case 0xe:
svga->bpp = 24;
break;
case 0x5:
case 0x6:
case 0xc:
svga->bpp = 16;
break;
case 0x7:
svga->bpp = 32;
break;
case 0x0:
case 0x1:
default:
svga->bpp = 8;
break;
case 0x2:
case 0x3:
case 0xa:
case 0x8:
svga->bpp = 15;
break;
case 0x4:
case 0x9:
case 0xe:
svga->bpp = 24;
break;
case 0x5:
case 0x6:
case 0xc:
svga->bpp = 16;
break;
case 0x7:
svga->bpp = 32;
break;
case 0x0:
case 0x1:
default:
svga->bpp = 8;
break;
}
}
}

View File

@@ -503,6 +503,12 @@ svga_recalctimings(svga_t *svga)
else
svga->render = svga_render_16bpp_highres;
break;
case 17:
if (svga->lowres)
svga->render = svga_render_15bpp_mix_lowres;
else
svga->render = svga_render_15bpp_mix_highres;
break;
case 24:
if (svga->lowres)
svga->render = svga_render_24bpp_lowres;
@@ -1003,7 +1009,7 @@ svga_decode_addr(svga_t *svga, uint32_t addr, int write)
}
void
static __inline void
svga_write_common(uint32_t addr, uint8_t val, uint8_t linear, void *p)
{
svga_t *svga = (svga_t *)p;
@@ -1016,8 +1022,6 @@ svga_write_common(uint32_t addr, uint8_t val, uint8_t linear, void *p)
if (svga->adv_flags & FLAG_ADDR_BY8)
writemask2 = svga->seqregs[2];
egawrites++;
cycles -= video_timing_write_b;
if (!linear) {
@@ -1182,7 +1186,7 @@ svga_write_common(uint32_t addr, uint8_t val, uint8_t linear, void *p)
}
uint8_t
static __inline uint8_t
svga_read_common(uint32_t addr, uint8_t linear, void *p)
{
svga_t *svga = (svga_t *)p;
@@ -1197,8 +1201,6 @@ svga_read_common(uint32_t addr, uint8_t linear, void *p)
cycles -= video_timing_read_b;
egareads++;
if (!linear) {
addr = svga_decode_addr(svga, addr, 0);
@@ -1399,8 +1401,6 @@ svga_writeb_linear(uint32_t addr, uint8_t val, void *p)
return;
}
egawrites++;
addr &= svga->decode_mask;
if (addr >= svga->vram_max)
return;
@@ -1421,8 +1421,6 @@ svga_writew_common(uint32_t addr, uint16_t val, uint8_t linear, void *p)
return;
}
egawrites += 2;
cycles -= video_timing_write_w;
if (!linear) {
@@ -1482,8 +1480,6 @@ svga_writel_common(uint32_t addr, uint32_t val, uint8_t linear, void *p)
return;
}
egawrites += 4;
cycles -= video_timing_write_l;
if (!linear) {
@@ -1548,8 +1544,6 @@ svga_readb_linear(uint32_t addr, void *p)
if (!svga->fast)
return svga_read_linear(addr, p);
egareads++;
addr &= svga->decode_mask;
if (addr >= svga->vram_max)
return 0xff;
@@ -1566,8 +1560,6 @@ svga_readw_common(uint32_t addr, uint8_t linear, void *p)
if (!svga->fast)
return svga_read_common(addr, linear, p) | (svga_read_common(addr + 1, linear, p) << 8);
egareads += 2;
cycles -= video_timing_read_w;
if (!linear) {
@@ -1619,8 +1611,6 @@ svga_readl_common(uint32_t addr, uint8_t linear, void *p)
(svga_read_common(addr + 2, linear, p) << 16) | (svga_read_common(addr + 3, linear, p) << 24);
}
egareads += 4;
cycles -= video_timing_read_l;
if (!linear) {

View File

@@ -667,10 +667,21 @@ svga_render_8bpp_lowres(svga_t *svga)
for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += 8) {
if (svga->crtc[0x17] & 0x80) {
dat = *(uint32_t *)(&svga->vram[svga->ma & svga->vram_display_mask]);
if (svga->attrregs[0x10] & 0x80)
dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4);
p[0] = p[1] = svga->map8[dat & 0xff];
p[2] = p[3] = svga->map8[(dat >> 8) & 0xff];
p[4] = p[5] = svga->map8[(dat >> 16) & 0xff];
p[6] = p[7] = svga->map8[(dat >> 24) & 0xff];
dat >>= 8;
if (svga->attrregs[0x10] & 0x80)
dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4);
p[2] = p[3] = svga->map8[dat & 0xff];
dat >>= 8;
if (svga->attrregs[0x10] & 0x80)
dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4);
p[4] = p[5] = svga->map8[dat & 0xff];
dat >>= 8;
if (svga->attrregs[0x10] & 0x80)
dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4);
p[6] = p[7] = svga->map8[dat & 0xff];
} else
memset(p, 0x00, 8 * sizeof(uint32_t));
@@ -702,16 +713,38 @@ svga_render_8bpp_highres(svga_t *svga)
for (x = 0; x <= (svga->hdisp/* + svga->scrollcache*/); x += 8) {
if (svga->crtc[0x17] & 0x80) {
dat = *(uint32_t *)(&svga->vram[svga->ma & svga->vram_display_mask]);
if (svga->attrregs[0x10] & 0x80)
dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4);
p[0] = svga->map8[dat & 0xff];
p[1] = svga->map8[(dat >> 8) & 0xff];
p[2] = svga->map8[(dat >> 16) & 0xff];
p[3] = svga->map8[(dat >> 24) & 0xff];
dat >>= 8;
if (svga->attrregs[0x10] & 0x80)
dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4);
p[1] = svga->map8[dat & 0xff];
dat >>= 8;
if (svga->attrregs[0x10] & 0x80)
dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4);
p[2] = svga->map8[dat & 0xff];
dat >>= 8;
if (svga->attrregs[0x10] & 0x80)
dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4);
p[3] = svga->map8[dat & 0xff];
dat = *(uint32_t *)(&svga->vram[(svga->ma + 4) & svga->vram_display_mask]);
if (svga->attrregs[0x10] & 0x80)
dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4);
p[4] = svga->map8[dat & 0xff];
p[5] = svga->map8[(dat >> 8) & 0xff];
p[6] = svga->map8[(dat >> 16) & 0xff];
p[7] = svga->map8[(dat >> 24) & 0xff];
dat >>= 8;
if (svga->attrregs[0x10] & 0x80)
dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4);
p[5] = svga->map8[dat & 0xff];
dat >>= 8;
if (svga->attrregs[0x10] & 0x80)
dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4);
p[6] = svga->map8[dat & 0xff];
dat >>= 8;
if (svga->attrregs[0x10] & 0x80)
dat = (dat & ~0xf0) | ((svga->attrregs[0x14] & 0x0f) << 4);
p[7] = svga->map8[dat & 0xff];
} else
memset(p, 0x00, 8 * sizeof(uint32_t));

View File

@@ -85,7 +85,6 @@ dbcs_font_t *fontdatksc5601_user = NULL; /* Korean KSC-5601 user defined font */
uint32_t pal_lookup[256];
int xsize = 1,
ysize = 1;
int egareads = 0, egawrites = 0;
int cga_palette = 0,
herc_blend = 0;
uint32_t *video_6to8 = NULL,