Merge pull request #3622 from lemondrops/xgafixes

8514/A and XGA handling refactor
This commit is contained in:
Miran Grča
2023-08-22 22:43:19 +02:00
committed by GitHub
12 changed files with 85 additions and 84 deletions

View File

@@ -188,7 +188,7 @@ ibm8514_log(const char *fmt, ...)
dev->changedvram[(((addr)) & (dev->vram_mask)) >> 12] = changeframecount; \
}
int ibm8514_has_vga = 0;
int ibm8514_active = 0;
int
ibm8514_cpu_src(svga_t *svga)
@@ -4224,7 +4224,7 @@ ibm8514_recalctimings(svga_t *svga)
svga->clock = (cpuclock * (double) (1ULL << 32)) / 25175000.0;
}
svga->render8514 = ibm8514_render_8bpp;
ibm8514_log("BPP=%d, Pitch = %d, rowoffset = %d, crtc13 = %02x, mode = %d, highres bit = %02x, has_vga? = %d.\n", dev->bpp, dev->pitch, dev->rowoffset, svga->crtc[0x13], dev->ibm_mode, dev->accel.advfunc_cntl & 4, ibm8514_has_vga);
ibm8514_log("BPP=%d, Pitch = %d, rowoffset = %d, crtc13 = %02x, mode = %d, highres bit = %02x, has_vga? = %d.\n", dev->bpp, dev->pitch, dev->rowoffset, svga->crtc[0x13], dev->ibm_mode, dev->accel.advfunc_cntl & 4, !ibm8514_standalone_enabled);
}
ibm8514_log("8514 enabled, hdisp=%d, vtotal=%d, htotal=%d, dispend=%d, rowoffset=%d, split=%d, vsyncstart=%d, split=%08x\n", dev->hdisp, dev->vtotal, dev->htotal, dev->dispend, dev->rowoffset, dev->split, dev->vsyncstart, dev->split);
}
@@ -4351,7 +4351,7 @@ const device_t ibm8514_mca_device = {
void
ibm8514_device_add(void)
{
if (!ibm8514_enabled || (ibm8514_enabled && ibm8514_has_vga))
if (!ibm8514_standalone_enabled)
return;
if (machine_has_bus(machine, MACHINE_BUS_MCA))

View File

@@ -207,9 +207,9 @@ svga_out(uint16_t addr, uint8_t val, void *priv)
svga_recalctimings(svga);
break;
case 0x3c3:
if (xga_enabled)
if (xga_active)
xga->on = (val & 0x01) ? 0 : 1;
if (ibm8514_enabled)
if (ibm8514_active)
dev->on = (val & 0x01) ? 0 : 1;
vga_on = val & 0x01;
@@ -517,7 +517,7 @@ svga_set_ramdac_type(svga_t *svga, int type)
svga->ramdac_type = type;
for (int c = 0; c < 256; c++) {
if (ibm8514_enabled) {
if (ibm8514_active) {
if (svga->ramdac_type == RAMDAC_8BIT)
dev->pallook[c] = makecol32(svga->vgapal[c].r, svga->vgapal[c].g, svga->vgapal[c].b);
else
@@ -706,12 +706,12 @@ svga_recalctimings(svga_t *svga)
svga->recalctimings_ex(svga);
}
if (ibm8514_enabled) {
if (ibm8514_active) {
if (!dev->local)
ibm8514_recalctimings(svga);
}
if (xga_enabled)
if (xga_active)
xga_recalctimings(svga);
if (svga->hdisp >= 2048)
@@ -815,11 +815,11 @@ svga_poll(void *priv)
int ret;
int old_ma;
if (ibm8514_enabled && dev->on) {
if (ibm8514_active && dev->on) {
ibm8514_poll(dev, svga);
return;
}
if (xga_enabled && xga->on) {
if (xga_active && xga->on) {
xga_poll(xga, svga);
return;
}
@@ -1231,7 +1231,7 @@ svga_write_common(uint32_t addr, uint8_t val, uint8_t linear, void *priv)
cycles -= svga->monitor->mon_video_timing_write_b;
if (!linear) {
if (xga_enabled) {
if (xga_active) {
if (((xga->op_mode & 7) >= 4) && (xga->aperture_cntl >= 1)) {
if (val == 0xa5) { /*Memory size test of XGA*/
xga->test = val;
@@ -1438,7 +1438,7 @@ svga_read_common(uint32_t addr, uint8_t linear, void *priv)
cycles -= svga->monitor->mon_video_timing_read_b;
if (!linear) {
if (xga_enabled) {
if (xga_active) {
if (((xga->op_mode & 7) >= 4) && (xga->aperture_cntl >= 1)) {
if (xga->test == 0xa5) { /*Memory size test of XGA*/
xga->on = 1;

View File

@@ -370,6 +370,7 @@ video_reset(int card)
void
video_post_reset(void)
{
int ibm8514_has_vga = 0;
if (gfxcard[0] == VID_INTERNAL)
ibm8514_has_vga = (video_get_type_monitor(0) == VIDEO_FLAG_TYPE_8514);
else if (gfxcard[0] != VID_NONE)
@@ -378,14 +379,12 @@ video_post_reset(void)
ibm8514_has_vga = 0;
if (ibm8514_has_vga)
ibm8514_enabled = 1;
ibm8514_active = 1;
if (ibm8514_enabled) {
if (!ibm8514_has_vga)
ibm8514_device_add();
}
if (ibm8514_standalone_enabled)
ibm8514_device_add();
if (xga_enabled)
if (xga_standalone_enabled)
xga_device_add();
/* Reset the graphics card (or do nothing if it was already done

View File

@@ -49,7 +49,7 @@ static uint8_t xga_ext_inb(uint16_t addr, void *priv);
static void xga_writew(uint32_t addr, uint16_t val, void *priv);
static uint16_t xga_readw(uint32_t addr, void *priv);
int xga_has_vga = 0;
int xga_active = 0;
#ifdef ENABLE_XGA_LOG
int xga_do_log = ENABLE_XGA_LOG;
@@ -2133,7 +2133,7 @@ xga_mem_read(uint32_t addr, xga_t *xga, UNUSED(svga_t *svga))
addr &= 0x1fff;
if (addr < 0x1800) {
if (!xga_has_vga)
if (xga_standalone_enabled)
temp = xga->bios_rom.rom[addr];
else
temp = xga->vga_bios_rom.rom[addr];
@@ -2938,7 +2938,7 @@ xga_pos_in(uint16_t addr, void *priv)
xga_t *xga = &svga->xga;
uint8_t ret = 0xff;
if (xga_has_vga) {
if (!xga_standalone_enabled) {
switch (addr) {
case 0x0100:
case 0x0101:
@@ -3053,7 +3053,7 @@ xga_pos_out(uint16_t addr, uint8_t val, void *priv)
svga_t *svga = (svga_t *) priv;
xga_t *xga = &svga->xga;
if (xga_has_vga) {
if (!xga_standalone_enabled) {
switch (addr) {
case 0x0106:
xga->pos_idx = (xga->pos_idx & 0x00ff) | (val << 8);
@@ -3148,7 +3148,7 @@ xga_init(const device_t *info)
xga->rom_addr = 0;
rom_init(&xga->bios_rom, xga->type ? XGA2_BIOS_PATH : XGA_BIOS_PATH, 0xc0000, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL);
} else {
if (xga_has_vga) {
if (!xga_standalone_enabled) {
rom_init(&xga->vga_bios_rom, INMOS_XGA_BIOS_PATH, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL);
} else
video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_xga_isa);
@@ -3168,7 +3168,7 @@ xga_init(const device_t *info)
NULL, MEM_MAPPING_EXTERNAL, svga);
mem_mapping_add(&xga->memio_mapping, 0, 0, xga_memio_readb, xga_memio_readw, xga_memio_readl,
xga_memio_writeb, xga_memio_writew, xga_memio_writel,
xga_has_vga ? xga->vga_bios_rom.rom : xga->bios_rom.rom, MEM_MAPPING_EXTERNAL, svga);
!xga_standalone_enabled ? xga->vga_bios_rom.rom : xga->bios_rom.rom, MEM_MAPPING_EXTERNAL, svga);
mem_mapping_disable(&xga->video_mapping);
mem_mapping_disable(&xga->linear_mapping);
@@ -3181,7 +3181,7 @@ xga_init(const device_t *info)
mca_add(xga_mca_read, xga_mca_write, xga_mca_feedb, xga_mca_reset, svga);
} else {
io_sethandler(0x0100, 0x0008, xga_pos_in, NULL, NULL, NULL, NULL, NULL, svga);
if (xga_has_vga)
if (!xga_standalone_enabled)
io_sethandler(0x0106, 0x0002, NULL, NULL, NULL, xga_pos_out, NULL, NULL, svga);
io_sethandler(0x2100 + (xga->instance << 4), 0x0010, xga_ext_inb, NULL, NULL, xga_ext_outb, NULL, NULL, svga);
@@ -3209,8 +3209,7 @@ svga_xga_init(const device_t *info)
svga->bpp = 8;
svga->miscout = 1;
xga_has_vga = 1;
xga_enabled = 1;
xga_active = 1;
return xga_init(info);
}
@@ -3411,7 +3410,7 @@ const device_t inmos_isa_device = {
void
xga_device_add(void)
{
if (!xga_enabled || (xga_has_vga && xga_enabled))
if (!xga_standalone_enabled)
return;
if (machine_has_bus(machine, MACHINE_BUS_MCA))