From 7abb8170126ca784cb5acfcf72debe7c08323a72 Mon Sep 17 00:00:00 2001 From: starfrost013 Date: Sat, 21 Jun 2025 01:32:59 +0100 Subject: [PATCH] clarify vga/8514 separation --- src/include/86box/vid_8514a.h | 34 +++--- src/include/86box/vid_xga.h | 14 +-- src/video/vid_8514a.c | 161 +++++++++++--------------- src/video/vid_ati_mach8.c | 206 ++++++++++++++-------------------- src/video/vid_svga.c | 10 +- src/video/vid_xga.c | 52 ++++----- 6 files changed, 200 insertions(+), 277 deletions(-) diff --git a/src/include/86box/vid_8514a.h b/src/include/86box/vid_8514a.h index 5d4b262c4..cecacc507 100644 --- a/src/include/86box/vid_8514a.h +++ b/src/include/86box/vid_8514a.h @@ -39,7 +39,7 @@ typedef enum { EXTENSIONS_MAX } ibm8514_extensions_t; -typedef struct hwcursor8514_t { +typedef struct ibm8514_hwcursor_s { int enable; int x; int y; @@ -49,14 +49,14 @@ typedef struct hwcursor8514_t { int cur_ysize; uint32_t addr; uint32_t pitch; -} hwcursor8514_t; +} ibm8514_hwcursor_t; typedef union { uint64_t q; uint32_t d[2]; uint16_t w[4]; uint8_t b[8]; -} latch8514_t; +} ibm8514_latch_t; typedef struct ibm8514_t { rom_t bios_rom; @@ -64,8 +64,8 @@ typedef struct ibm8514_t { mem_mapping_t bios_mapping; uint8_t *rom1; uint8_t *rom2; - hwcursor8514_t hwcursor; - hwcursor8514_t hwcursor_latch; + ibm8514_hwcursor_t hwcursor; + ibm8514_hwcursor_t hwcursor_latch; uint8_t pos_regs[8]; char *rom_path; @@ -160,20 +160,17 @@ typedef struct ibm8514_t { uint16_t dst_pitch; } accel; - int h_blankstart; int hblankstart; int hblankend; int hblank_ext; - int v_total_reg; - int v_total; + int vtotal_reg; + int vtotal_8514; int dispend; - int v_sync_start; - int v_syncstart; + int vsyncstart; int split; - int h_disp; - int h_total; - int h_disp_time; + int hdisp_8514; + int htotal_8514; int rowoffset; int dispon; int hdispon; @@ -197,26 +194,23 @@ typedef struct ibm8514_t { uint8_t linedbl; uint8_t data_available; - uint8_t data_available2; uint8_t rowcount; int hsync_start; int hsync_width; int htotal; - int hdisp; - int hdisp2; + int hdisp_vga; int hdisped; int scanline; int vsyncwidth; int vtotal; - int vdisp_latch; - int vdisp; + int vdisp_8514; + int vdisp_vga; int disp_cntl; int interlace; uint16_t subsys_cntl; uint8_t subsys_stat; atomic_int force_busy; - atomic_int force_busy2; atomic_int fifo_idx; int blitter_busy; @@ -235,7 +229,7 @@ typedef struct ibm8514_t { int _8514crt; PALETTE _8514pal; - latch8514_t latch; + ibm8514_latch_t latch; void (*vblank_start)(void *priv); void (*accel_out_fifo)(void *priv, uint16_t port, uint16_t val, int len); diff --git a/src/include/86box/vid_xga.h b/src/include/86box/vid_xga.h index a2ef1a530..a8c7e09cd 100644 --- a/src/include/86box/vid_xga.h +++ b/src/include/86box/vid_xga.h @@ -114,18 +114,16 @@ typedef struct xga_t { int dac_pos; int dac_r; int dac_g; - int v_total; + int vtotal_xga; int dispend; - int v_syncstart; int split; - int v_blankstart; - int h_disp; - int h_disp_old; - int h_total; - int h_disp_time; + int vblankstart_xga; + int hdisp_xga; + int hdispold_xga; + int htotal_xga; int rowoffset; int dispon; - int h_disp_on; + int hdispon_xga; int vc; int scanline; int linepos; diff --git a/src/video/vid_8514a.c b/src/video/vid_8514a.c index f911da6be..d8a9576b5 100644 --- a/src/video/vid_8514a.c +++ b/src/video/vid_8514a.c @@ -376,19 +376,19 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x12e8: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 2) { - dev->v_total_reg = val; - dev->v_total_reg &= 0x1fff; + dev->vtotal_reg = val; + dev->vtotal_reg &= 0x1fff; ibm8514_log("IBM 8514/A compatible: (0x%04x): vtotal=0x%02x.\n", port, val); svga_recalctimings(svga); } else { - WRITE8(port, dev->v_total_reg, val); + WRITE8(port, dev->vtotal_reg, val); } break; case 0x12e9: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 1) { - WRITE8(port, dev->v_total_reg, val >> 8); - dev->v_total_reg &= 0x1fff; + WRITE8(port, dev->vtotal_reg, val >> 8); + dev->vtotal_reg &= 0x1fff; ibm8514_log("IBM 8514/A compatible: (0x%04x): vtotal=0x%02x.\n", port, val); svga_recalctimings(svga); } @@ -397,21 +397,21 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x16e8: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 2) { - dev->vdisp_latch = val; - dev->vdisp_latch &= 0x1fff; - ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->vdisp_latch); + dev->vdisp_8514 = val; + dev->vdisp_8514 &= 0x1fff; + ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->vdisp_8514); ibm8514_log("IBM 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); svga_recalctimings(svga); } else { - WRITE8(port, dev->vdisp_latch, val); + WRITE8(port, dev->vdisp_8514, val); } break; case 0x16e9: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 1) { - WRITE8(port, dev->vdisp_latch, val >> 8); - dev->vdisp_latch &= 0x1fff; - ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->vdisp_latch); + WRITE8(port, dev->vdisp_8514, val >> 8); + dev->vdisp_8514 &= 0x1fff; + ibm8514_log("IBM 8514/A: V_DISP write 16E8 = %d\n", dev->vdisp_8514); ibm8514_log("IBM 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); svga_recalctimings(svga); } @@ -420,25 +420,26 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x1ae8: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 2) { - dev->v_sync_start = val; - dev->v_sync_start &= 0x1fff; - ibm8514_log("IBM 8514/A compatible: V_SYNCSTART write 1AE8 = %d\n", dev->v_syncstart); + dev->vsyncstart = val; + dev->vsyncstart &= 0x1fff; + ibm8514_log("IBM 8514/A compatible: VSYNCSTART write 1AE8 = %d\n", dev->vsyncstart); ibm8514_log("IBM 8514/A compatible: (0x%04x): vsyncstart=0x%02x.\n", port, val); svga_recalctimings(svga); } else { - WRITE8(port, dev->v_sync_start, val); + WRITE8(port, dev->vsyncstart, val); } break; case 0x1ae9: /*In preparation to switch from VGA to 8514/A mode*/ if (len == 1) { - WRITE8(port, dev->v_sync_start, val >> 8); - dev->v_sync_start &= 0x1fff; - dev->v_syncstart = dev->v_sync_start + 1; + WRITE8(port, dev->vsyncstart, val >> 8); + dev->vsyncstart &= 0x1fff; + dev->vsyncstart++; + // change this if it breaks if (dev->interlace) - dev->v_syncstart >>= 1; + dev->vsyncstart >>= 1; - ibm8514_log("IBM 8514/A compatible: V_SYNCSTART write 1AE8 = %d\n", dev->v_syncstart); + ibm8514_log("IBM 8514/A compatible: VSYNCSTART write 1AE8 = %d\n", dev->vsyncstart); ibm8514_log("IBM 8514/A compatible: (0x%04x): vsyncstart=0x%02x.\n", port, val); svga_recalctimings(svga); } @@ -465,7 +466,6 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) dev->subsys_stat &= ~val; if ((val & 0xc000) == 0x8000) { dev->force_busy = 0; - dev->force_busy2 = 0; } } else { WRITE8(port, dev->subsys_cntl, val); @@ -477,7 +477,6 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) WRITE8(port, dev->subsys_cntl, val); if ((val & 0xc0) == 0x80) { dev->force_busy = 0; - dev->force_busy2 = 0; } } break; @@ -485,7 +484,7 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x4ae8: WRITE8(port, dev->accel.advfunc_cntl, val); dev->on = dev->accel.advfunc_cntl & 0x01; - ibm8514_log("[%04X:%08X]: IBM 8514/A: (0x%04x): ON=%d, shadow crt=%x, hdisp=%d, vdisp=%d.\n", CS, cpu_state.pc, port, dev->on, dev->accel.advfunc_cntl & 0x04, dev->hdisp, dev->vdisp); + ibm8514_log("[%04X:%08X]: IBM 8514/A: (0x%04x): ON=%d, shadow crt=%x, hdisp=%d, vdisp=%d.\n", CS, cpu_state.pc, port, dev->on, dev->accel.advfunc_cntl & 0x04, dev->hdisp_vga, dev->vdisp_vga); ibm8514_log("IBM mode set %s resolution.\n", (dev->accel.advfunc_cntl & 0x04) ? "2: 1024x768" : "1: 640x480"); svga_recalctimings(svga); break; @@ -537,7 +536,6 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) dev->accel.ssv_state = 0; if (len == 2) { dev->data_available = 0; - dev->data_available2 = 0; dev->accel.cmd = val; dev->accel.cmd_back = 1; if (dev->accel.cmd & 0x100) @@ -847,12 +845,12 @@ ibm8514_accel_in_fifo(svga_t *svga, uint16_t port, int len) if (len == 1) { dev->fifo_idx = 0; - if (dev->force_busy2) + if (dev->force_busy) temp |= 0x02; /*Hardware busy*/ - dev->force_busy2 = 0; + dev->force_busy = 0; - if (dev->data_available2) { + if (dev->data_available) { temp |= 0x01; /*Read Data available*/ switch (dev->accel.cmd >> 13) { case 2: @@ -860,11 +858,11 @@ ibm8514_accel_in_fifo(svga_t *svga, uint16_t port, int len) case 4: case 6: if (dev->accel.sy < 0) - dev->data_available2 = 0; + dev->data_available = 0; break; default: if (!dev->accel.sy) - dev->data_available2 = 0; + dev->data_available = 0; break; } } @@ -910,7 +908,7 @@ ibm8514_accel_in(uint16_t port, svga_t *svga) switch (port) { case 0x2e8: - if (dev->vc == dev->v_syncstart) + if (dev->vc == dev->vsyncstart) temp |= 0x02; ibm8514_log("Read: Display Status1=%02x.\n", temp); @@ -962,9 +960,7 @@ ibm8514_accel_in(uint16_t port, svga_t *svga) if (!dev->fifo_idx && !dev->on) { dev->force_busy = 0; - dev->force_busy2 = 0; dev->data_available = 0; - dev->data_available2 = 0; temp |= INT_FIFO_EMP; } temp |= (dev->subsys_stat | (dev->vram_is_512k ? 0x00 : 0x80)); @@ -1020,9 +1016,7 @@ ibm8514_short_stroke_start(int count, int cpu_input, uint32_t mix_dat, uint32_t if (ibm8514_cpu_src(svga)) { dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 0; - dev->data_available2 = 0; return; /*Wait for data from CPU*/ } } @@ -1236,7 +1230,6 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.ssv_len) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1337,7 +1330,6 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.ssv_len) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1405,15 +1397,11 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat } } dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 0; - dev->data_available2 = 0; return; /*Wait for data from CPU*/ } else if (ibm8514_cpu_dest(svga)) { dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 1; - dev->data_available2 = 1; return; } } @@ -1521,7 +1509,6 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1646,7 +1633,6 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1754,7 +1740,6 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1858,9 +1843,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat } } dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 0; - dev->data_available2 = 0; return; /*Wait for data from CPU*/ } else if (ibm8514_cpu_dest(svga)) { if (!(dev->accel.cmd & 0x02)) { @@ -1877,9 +1860,7 @@ ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat } ibm8514_log("INPUT=%d.\n", dev->accel.input); dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 1; - dev->data_available2 = 1; return; /*Wait for data from CPU*/ } } @@ -2033,7 +2014,6 @@ skip_vector_rect_write: if (dev->accel.sy < 0) { dev->force_busy = 0; - dev->force_busy2 = 0; dev->fifo_idx = 0; dev->accel.cmd_back = 1; } @@ -2195,7 +2175,6 @@ skip_nibble_rect_write: dev->accel.cmd_back = 1; } dev->force_busy = 0; - dev->force_busy2 = 0; return; } } @@ -2579,15 +2558,11 @@ skip_nibble_rect_write: if (ibm8514_cpu_src(svga)) { dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 0; - dev->data_available2 = 0; return; /*Wait for data from CPU*/ } else if (ibm8514_cpu_dest(svga)) { dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 1; - dev->data_available2 = 1; return; } } @@ -2656,7 +2631,6 @@ skip_nibble_rect_write: if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -2765,7 +2739,6 @@ skip_nibble_rect_write: if (!dev->accel.sy) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -2853,15 +2826,11 @@ skip_nibble_rect_write: } } dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 0; - dev->data_available2 = 0; return; /*Wait for data from CPU*/ } else if (ibm8514_cpu_dest(svga)) { dev->force_busy = 1; - dev->force_busy2 = 1; dev->data_available = 1; - dev->data_available2 = 1; return; /*Wait for data from CPU*/ } else ibm8514_log("BitBLT normal: Parameters: DX=%d, DY=%d, CX=%d, CY=%d, dstwidth=%d, dstheight=%d, clipl=%d, clipr=%d, clipt=%d, clipb=%d.\n", dev->accel.dx, dev->accel.dy, dev->accel.cx, dev->accel.cy, dev->accel.sx, dev->accel.sy, clip_l, clip_r, clip_t, clip_b); @@ -3016,7 +2985,6 @@ skip_nibble_bitblt_write: if (dev->accel.sy < 0) { dev->accel.cmd_back = 1; dev->force_busy = 0; - dev->force_busy2 = 0; dev->fifo_idx = 0; } return; @@ -3366,9 +3334,9 @@ ibm8514_render_blank(svga_t *svga) dev->lastline_draw = dev->displine; uint32_t *line_ptr = &buffer32->line[dev->displine + svga->y_add][svga->x_add]; - uint32_t line_width = (uint32_t)(dev->h_disp) * sizeof(uint32_t); + uint32_t line_width = (uint32_t)(dev->hdisp_8514) * sizeof(uint32_t); - if (dev->h_disp > 0) + if (dev->hdisp_8514 > 0) memset(line_ptr, 0, line_width); } @@ -3389,7 +3357,7 @@ ibm8514_render_8bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (int x = 0; x <= dev->h_disp; x += 8) { + for (int x = 0; x <= dev->hdisp_8514; x += 8) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[0] = dev->pallook[dat & dev->dac_mask & 0xff]; p[1] = dev->pallook[(dat >> 8) & dev->dac_mask & 0xff]; @@ -3427,7 +3395,7 @@ ibm8514_render_15bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (x = 0; x <= dev->h_disp; x += 8) { + for (x = 0; x <= dev->hdisp_8514; x += 8) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 1)) & dev->vram_mask]); p[x] = video_15to32[dat & 0xffff]; p[x + 1] = video_15to32[dat >> 16]; @@ -3467,7 +3435,7 @@ ibm8514_render_16bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (x = 0; x <= dev->h_disp; x += 8) { + for (x = 0; x <= dev->hdisp_8514; x += 8) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 1)) & dev->vram_mask]); p[x] = video_16to32[dat & 0xffff]; p[x + 1] = video_16to32[dat >> 16]; @@ -3506,7 +3474,7 @@ ibm8514_render_24bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (int x = 0; x <= dev->h_disp; x += 4) { + for (int x = 0; x <= dev->hdisp_8514; x += 4) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[x] = dat & 0xffffff; @@ -3542,7 +3510,7 @@ ibm8514_render_BGR(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (int x = 0; x <= dev->h_disp; x += 4) { + for (int x = 0; x <= dev->hdisp_8514; x += 4) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[x] = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16); @@ -3579,7 +3547,7 @@ ibm8514_render_ABGR8888(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (x = 0; x <= dev->h_disp; x++) { + for (x = 0; x <= dev->hdisp_8514; x++) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 2)) & dev->vram_mask]); *p++ = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16); } @@ -3606,7 +3574,7 @@ ibm8514_render_32bpp(svga_t *svga) dev->firstline_draw = dev->displine; dev->lastline_draw = dev->displine; - for (x = 0; x <= dev->h_disp; x++) { + for (x = 0; x <= dev->hdisp_8514; x++) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 2)) & dev->vram_mask]); p[x] = dat & 0xffffff; } @@ -3621,7 +3589,7 @@ ibm8514_render_overscan_left(ibm8514_t *dev, svga_t *svga) if ((dev->displine + svga->y_add) < 0) return; - if (svga->scrblank || (dev->h_disp == 0)) + if (svga->scrblank || (dev->hdisp_8514 == 0)) return; for (int i = 0; i < svga->x_add; i++) @@ -3636,12 +3604,12 @@ ibm8514_render_overscan_right(ibm8514_t *dev, svga_t *svga) if ((dev->displine + svga->y_add) < 0) return; - if (svga->scrblank || (dev->h_disp == 0)) + if (svga->scrblank || (dev->hdisp_8514 == 0)) return; right = (overscan_x >> 1); for (int i = 0; i < right; i++) - buffer32->line[dev->displine + svga->y_add][svga->x_add + dev->h_disp + i] = svga->overscan_color; + buffer32->line[dev->displine + svga->y_add][svga->x_add + dev->hdisp_8514 + i] = svga->overscan_color; } void @@ -3754,10 +3722,10 @@ ibm8514_poll(void *priv) if (svga->fullchange) svga->fullchange--; } - if (dev->vc == dev->v_syncstart) { + if (dev->vc == dev->vsyncstart) { dev->dispon = 0; svga->cgastat |= 8; - x = dev->h_disp; + x = dev->hdisp_8514; if (dev->interlace && !dev->oddeven) dev->lastline++; @@ -3787,7 +3755,7 @@ ibm8514_poll(void *priv) dev->memaddr = (dev->memaddr << 2); dev->memaddr_backup = (dev->memaddr_backup << 2); } - if (dev->vc == dev->v_total) { + if (dev->vc == dev->vtotal_8514) { dev->vc = 0; dev->scanline = (svga->crtc[0x8] & 0x1f); dev->dispon = 1; @@ -3813,38 +3781,39 @@ ibm8514_recalctimings(svga_t *svga) ati8514_recalctimings(svga); } else { if (dev->on) { - dev->hdisp = (dev->hdisped + 1) << 3; - dev->h_total = dev->htotal + 1; + dev->hdisp_vga = (dev->hdisped + 1) << 3; + dev->htotal_8514 = dev->htotal + 1; - if (dev->h_total == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ - dev->h_total = 0x9e; + if (dev->htotal_8514 == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ + dev->htotal_8514 = 0x9e; - dev->vdisp = (dev->vdisp_latch + 1) >> 1; - if ((dev->vdisp == 478) || (dev->vdisp == 766)) - dev->vdisp += 2; + dev->vdisp_vga = (dev->vdisp_8514 + 1) >> 1; + if ((dev->vdisp_vga == 478) || (dev->vdisp_vga == 766)) + dev->vdisp_vga += 2; - dev->v_total = dev->v_total_reg + 1; + dev->vtotal_8514 = dev->vtotal_reg + 1; if (dev->interlace) - dev->v_total >>= 1; + dev->vtotal_8514 >>= 1; + + dev->vsyncstart++; - dev->v_syncstart = dev->v_sync_start + 1; if (dev->interlace) - dev->v_syncstart >>= 1; + dev->vsyncstart >>= 1; dev->rowcount = !!(dev->disp_cntl & 0x08); - if ((dev->hdisp != 640) && (dev->hdisp != 1024)) { + if ((dev->hdisp_vga != 640) && (dev->hdisp_vga != 1024)) { if (dev->accel.advfunc_cntl & 0x04) { - dev->hdisp = 1024; - dev->vdisp = 768; + dev->hdisp_vga = 1024; + dev->vdisp_vga = 768; } else { - dev->hdisp = 640; - dev->vdisp = 480; + dev->hdisp_vga = 640; + dev->vdisp_vga = 480; } } - dev->h_disp = dev->hdisp; - dev->dispend = dev->vdisp; + dev->hdisp_8514 = dev->hdisp_vga; + dev->dispend = dev->vdisp_vga; if (dev->accel.advfunc_cntl & 0x04) svga->clock_8514 = (cpuclock * (double) (1ULL << 32)) / 44900000.0; @@ -3860,7 +3829,7 @@ ibm8514_recalctimings(svga_t *svga) dev->pitch = 1024; dev->rowoffset = 0x80; if (dev->vram_is_512k) { - if (dev->h_disp == 640) + if (dev->hdisp_8514 == 640) dev->pitch = 640; } dev->accel_bpp = 8; @@ -3868,7 +3837,7 @@ ibm8514_recalctimings(svga_t *svga) ibm8514_log("BPP=%d, Pitch = %d, rowoffset = %d, crtc13 = %02x, highres bit = %02x, has_vga? = %d.\n", dev->bpp, dev->pitch, dev->rowoffset, svga->crtc[0x13], 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); + ibm8514_log("8514 enabled, hdisp_vga=%d, vtotal=%d, htotal=%d, dispend=%d, rowoffset=%d, split=%d, vsyncstart=%d, split=%08x\n", dev->hdisp_vga, dev->vtotal, dev->htotal, dev->dispend, dev->rowoffset, dev->split, dev->vsyncstart, dev->split); } static uint8_t diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index 4a73d6a8e..7bd550f0b 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -371,18 +371,14 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach_pixel_write(mach)) { mach_log("Extended Bresenham Write pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 0; - dev->data_available2 = 0; return; } else if (mach_pixel_read(mach)) { mach_log("Extended Bresenham Read pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 1; - dev->data_available2 = 1; return; } } @@ -530,7 +526,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (cpu_input) { mach->force_busy = 0; dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -539,7 +534,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (cpu_input) { mach->force_busy = 0; dev->force_busy = 0; - dev->force_busy2 = 0; } dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -740,7 +734,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if ((mono_src == 1) && !count) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -749,7 +742,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 } else if ((mono_src != 1) && (dev->accel.sx >= mach->accel.width)) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -959,18 +951,14 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach_pixel_write(mach)) { mach_log("Non-Conforming BitBLT Write pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 0; - dev->data_available2 = 0; return; } else if (mach_pixel_read(mach)) { mach_log("Non-Conforming BitBLT Read pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 1; - dev->data_available2 = 1; return; } } @@ -989,7 +977,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 mach_log("No DEST.\n"); if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1001,7 +988,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach->accel.sx_end == mach->accel.sx_start) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } mach_log("No SRC.\n"); @@ -1018,7 +1004,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (dev->accel.sy == mach->accel.height) { mach_log("No Blit on DPCONFIG=3251.\n"); dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; dev->fifo_idx = 0; dev->accel.cmd_back = 1; @@ -1228,7 +1213,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (dev->accel.sy >= mach->accel.height) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1276,18 +1260,14 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach_pixel_write(mach)) { mach_log("Direct Linedraw Write pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 0; - dev->data_available2 = 0; return; } else if (mach_pixel_read(mach)) { mach_log("Direct Linedraw Read pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 1; - dev->data_available2 = 1; return; } } @@ -1392,7 +1372,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (!count) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1538,7 +1517,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (dev->accel.sx >= mach->accel.width) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1659,7 +1637,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (!count) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1797,7 +1774,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (dev->accel.sx >= mach->accel.width) { if (cpu_input) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; } dev->fifo_idx = 0; @@ -1930,18 +1906,14 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 if (mach_pixel_write(mach)) { mach_log("Scan To X Write pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 0; - dev->data_available2 = 0; return; } else if (mach_pixel_read(mach)) { mach_log("Scan To X Read pixtrans.\n"); dev->force_busy = 1; - dev->force_busy2 = 1; mach->force_busy = 1; dev->data_available = 1; - dev->data_available2 = 1; return; } } @@ -2038,7 +2010,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 dev->fifo_idx = 0; dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; dev->accel.cmd_back = 1; dev->accel.cur_x = dev->accel.dx; @@ -2212,7 +2183,6 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3 dev->fifo_idx = 0; dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; dev->accel.cmd_back = 1; return; @@ -2627,7 +2597,7 @@ ati_render_24bpp(svga_t *svga) dev->lastline_draw = dev->displine; if (mach->accel.ext_ge_config & 0x400) { /*BGR, Blue-(23:16), Green-(15:8), Red-(7:0)*/ - for (int x = 0; x <= dev->h_disp; x += 4) { + for (int x = 0; x <= dev->hdisp_8514; x += 4) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[x] = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16); @@ -2643,7 +2613,7 @@ ati_render_24bpp(svga_t *svga) dev->memaddr += 12; } } else { /*RGB, Red-(23:16), Green-(15:8), Blue-(7:0)*/ - for (int x = 0; x <= dev->h_disp; x += 4) { + for (int x = 0; x <= dev->hdisp_8514; x += 4) { dat = *(uint32_t *) (&dev->vram[dev->memaddr & dev->vram_mask]); p[x] = dat & 0xffffff; @@ -2683,12 +2653,12 @@ ati_render_32bpp(svga_t *svga) dev->lastline_draw = dev->displine; if (mach->accel.ext_ge_config & 0x400) { /*BGR, Blue-(23:16), Green-(15:8), Red-(7:0)*/ - for (x = 0; x <= dev->h_disp; x++) { + for (x = 0; x <= dev->hdisp_8514; x++) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 2)) & dev->vram_mask]); *p++ = ((dat & 0x00ff0000) >> 16) | (dat & 0x0000ff00) | ((dat & 0x000000ff) << 16); } } else { /*RGB, Red-(31:24), Green-(23:16), Blue-(15:8)*/ - for (x = 0; x <= dev->h_disp; x++) { + for (x = 0; x <= dev->hdisp_8514; x++) { dat = *(uint32_t *) (&dev->vram[(dev->memaddr + (x << 2)) & dev->vram_mask]); *p++ = ((dat & 0xffffff00) >> 8); } @@ -2708,22 +2678,22 @@ mach_set_resolution(mach_t *mach, svga_t *svga) ibm8514_t *dev = (ibm8514_t *) svga->dev8514; int ret = 0; - dev->h_total = dev->htotal + 1; + dev->htotal_8514 = dev->htotal + 1; - if (dev->h_total == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ - dev->h_total = 0x9e; + if (dev->htotal_8514 == 1) /*Default to 1024x768 87hz 8514/A htotal timings if it goes to 0.*/ + dev->htotal_8514 = 0x9e; - dev->hdisp = (dev->hdisped + 1) << 3; + dev->hdisp_vga = (dev->hdisped + 1) << 3; - dev->vdisp = (dev->vdisp_latch + 1) >> 1; - if ((dev->vdisp == 478) || (dev->vdisp == 598) || (dev->vdisp == 766) || (dev->vdisp == 1022)) - dev->vdisp += 2; + dev->vdisp_vga = (dev->vdisp_8514 + 1) >> 1; + if ((dev->vdisp_vga == 478) || (dev->vdisp_vga == 598) || (dev->vdisp_vga == 766) || (dev->vdisp_vga == 1022)) + dev->vdisp_vga += 2; - dev->v_total = dev->v_total_reg + 1; + dev->vtotal_8514 = dev->vtotal_reg + 1; - dev->v_syncstart = dev->v_sync_start + 1; + dev->vsyncstart++; - mach_log("VSYNCSTART=%d, VTOTAL=%d, interlace=%02x, vdisp=%d.\n", dev->v_syncstart, dev->v_total, dev->interlace, dev->vdisp); + mach_log("VSYNCSTART=%d, VTOTAL=%d, interlace=%02x, vdisp=%d.\n", dev->vsyncstart, dev->vtotal_8514, dev->interlace, dev->vdisp_vga); if (!ATI_MACH32) { if ((mach->accel.clock_sel & 0x01) && @@ -2757,15 +2727,15 @@ mach_set_resolution(mach_t *mach, svga_t *svga) svga_recalctimings(svga); else { if (dev->accel.advfunc_cntl & 0x04) { - if (dev->hdisp == 640) { - dev->hdisp = 1024; - dev->vdisp = 768; + if (dev->hdisp_vga == 640) { + dev->hdisp_vga = 1024; + dev->vdisp_vga = 768; mach_log("1024x768.\n"); } } else { - if (dev->hdisp == 1024) { - dev->hdisp = 640; - dev->vdisp = 480; + if (dev->hdisp_vga == 1024) { + dev->hdisp_vga = 640; + dev->vdisp_vga = 480; mach_log("640x480.\n"); } } @@ -2785,7 +2755,7 @@ mach_set_resolution(mach_t *mach, svga_t *svga) } else svga_recalctimings(svga); - mach_log("Shadow set ATI=%x, shadow set 8514/A and on1=%x, on2=%x, resolution h=%d, v=%d, vtotal=%d, vsyncstart=%d, crtres=%d, ret=%d, actual passthrough=%x.\n", mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x05, mach->accel.clock_sel & 0x01, dev->hdisp, dev->vdisp, dev->v_total, dev->v_syncstart, mach->crt_resolution, ret, dev->on); + mach_log("Shadow set ATI=%x, shadow set 8514/A and on1=%x, on2=%x, resolution h=%d, v=%d, vtotal=%d, vsyncstart=%d, crtres=%d, ret=%d, actual passthrough=%x.\n", mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x05, mach->accel.clock_sel & 0x01, dev->hdisp_vga, dev->vdisp_vga, dev->vtotal_8514, dev->v_syncstart, mach->crt_resolution, ret, dev->on); } void @@ -2806,7 +2776,7 @@ ati8514_recalctimings(svga_t *svga) dev->accel.ge_offset -= mach->accel.crt_offset; mach_log("HDISP=%d, VDISP=%d, shadowset=%x, 8514/A mode=%x, clocksel=%02x.\n", - dev->hdisp, dev->vdisp, mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x05, mach->accel.clock_sel & 0x01); + dev->hdisp_vga, dev->vdisp_vga, mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x05, mach->accel.clock_sel & 0x01); mach->accel.src_pitch = dev->pitch; mach->accel.dst_pitch = dev->pitch; @@ -2817,11 +2787,11 @@ ati8514_recalctimings(svga_t *svga) mach_log("8514/A ON, pitch=%d, GE offset=%08x.\n", ((mach->accel.ge_pitch & 0xff) << 3), dev->accel.ge_offset); - dev->h_disp = dev->hdisp; - dev->dispend = dev->vdisp; + dev->hdisp_8514 = dev->hdisp_vga; + dev->dispend = dev->vdisp_vga; if (dev->dispend == 600) - dev->h_disp = 800; - else if (dev->h_disp == 640) + dev->hdisp_8514 = 800; + else if (dev->hdisp_8514 == 640) dev->dispend = 480; if (dev->accel.advfunc_cntl & 0x04) @@ -2833,10 +2803,10 @@ ati8514_recalctimings(svga_t *svga) dev->dispend >>= 1; mach_log("cntl=%d, hv(%d,%d), pitch=%d, rowoffset=%d, gextconfig=%03x, shadow=%x interlace=%d.\n", - dev->accel.advfunc_cntl & 0x04, dev->h_disp, dev->dispend, dev->pitch, dev->rowoffset, + dev->accel.advfunc_cntl & 0x04, dev->hdisp_8514, dev->dispend, dev->pitch, dev->rowoffset, mach->accel.ext_ge_config & 0xcec0, mach->shadow_set & 3, dev->interlace); if (dev->vram_is_512k) { - if (dev->h_disp == 640) + if (dev->hdisp_8514 == 640) dev->pitch = 640; else dev->pitch = 1024; @@ -2926,17 +2896,17 @@ mach_recalctimings(svga_t *svga) mach_log("RowCount=%x, rowoffset=%x, pitch=%d, geoffset=%x, crtoffset=%x.\n", dev->rowcount, dev->rowoffset, dev->pitch, dev->accel.ge_offset, mach->accel.crt_offset); mach_log("HDISP=%d, VDISP=%d, shadowset=%x, 8514/A mode=%x, clocksel=%02x, interlace=%x.\n", - dev->hdisp, dev->vdisp, mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x04, + dev->hdisp_vga, dev->vdisp_vga, mach->shadow_set & 0x03, dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0xfe, dev->interlace); - dev->h_disp = dev->hdisp; - dev->dispend = dev->vdisp; + dev->hdisp_8514 = dev->hdisp_vga; + dev->dispend = dev->vdisp_vga; if (dev->dispend == 959) { /*FIXME: vertical resolution mess on EEPROM tests on Mach8*/ dev->dispend >>= 1; dev->dispend++; } else if (dev->dispend == 600) - dev->h_disp = 800; - else if (dev->h_disp == 640) + dev->hdisp_8514 = 800; + else if (dev->hdisp_8514 == 640) dev->dispend = 480; svga->clock_8514 = (cpuclock * (double) (1ULL << 32)) / svga->getclock((mach->accel.clock_sel >> 2) & 0x0f, svga->clock_gen); @@ -3005,18 +2975,18 @@ mach_recalctimings(svga_t *svga) break; } mach_log("cntl=%d, clksel=%x, hv(%d,%d), pitch=%d, rowoffset=%d, gextconfig=%03x, shadow=%x interlace=%d, vgahdisp=%d.\n", - dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->h_disp, dev->dispend, dev->pitch, dev->rowoffset, + dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->hdisp_8514, dev->dispend, dev->pitch, dev->rowoffset, mach->accel.ext_ge_config & 0xcec0, mach->shadow_set & 3, dev->interlace, svga->hdisp); if ((mach->accel.ext_ge_config & 0x800) || (!(mach->accel.ext_ge_config & 0x8000) && !(mach->accel.ext_ge_config & 0x800))) { mach_log("hv=%d,%d, pitch=%d, rowoffset=%d, gextconfig=%03x, bpp=%d, shadow=%x, vgahdisp=%d.\n", - dev->h_disp, dev->dispend, dev->pitch, dev->ext_crt_pitch, mach->accel.ext_ge_config & 0xcec0, + dev->hdisp_8514, dev->dispend, dev->pitch, dev->ext_crt_pitch, mach->accel.ext_ge_config & 0xcec0, dev->accel_bpp, mach->shadow_set & 0x03, svga->hdisp); switch (dev->accel_bpp) { case 8: if ((mach->accel.ext_ge_config & 0x30) == 0x00) { if (dev->vram_is_512k) { - if (dev->h_disp == 640) + if (dev->hdisp_8514 == 640) dev->pitch = 640; else dev->pitch = 1024; @@ -3054,10 +3024,10 @@ mach_recalctimings(svga_t *svga) mach->accel.dst_ge_offset -= mach->accel.crt_offset; mach_log("cntl=%d, clksel=%x, hv(%d,%d), pitch=%d, rowoffset=%d, gextconfig=%03x, shadow=%x interlace=%d, vgahdisp=%d.\n", - dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->h_disp, dev->dispend, dev->pitch, dev->rowoffset, + dev->accel.advfunc_cntl & 0x04, mach->accel.clock_sel & 0x01, dev->hdisp_8514, dev->dispend, dev->pitch, dev->rowoffset, mach->accel.ext_ge_config & 0xcec0, mach->shadow_set & 0x03, dev->interlace, svga->hdisp); if (dev->vram_is_512k) { - if (dev->h_disp == 640) + if (dev->hdisp_8514 == 640) dev->pitch = 640; else dev->pitch = 1024; @@ -3199,15 +3169,15 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 2) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10) && val) { - dev->v_total_reg = val; - dev->v_total_reg &= 0x1fff; + dev->vtotal_reg = val; + dev->vtotal_reg &= 0x1fff; } } } else { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10)) { - WRITE8(port, dev->v_total_reg, val); - dev->v_total_reg &= 0x1fff; + WRITE8(port, dev->vtotal_reg, val); + dev->vtotal_reg &= 0x1fff; } } } @@ -3219,8 +3189,8 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 1) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { if (!(mach->shadow_cntl & 0x10)) { /*For 8514/A mode, take the shadow sets into account.*/ - WRITE8(port, dev->v_total_reg, val >> 8); - dev->v_total_reg &= 0x1fff; + WRITE8(port, dev->vtotal_reg, val >> 8); + dev->vtotal_reg &= 0x1fff; } } mach_log("[%04X:%08X]: ATI 8514/A: (0x%04x): hdisp=0x%02x.\n", CS, cpu_state.pc, port, val); @@ -3232,17 +3202,17 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 2) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x20) && val) { - dev->vdisp_latch = val; - dev->vdisp_latch &= 0x1fff; + dev->vdisp_8514 = val; + dev->vdisp_8514 &= 0x1fff; } } - mach_log("ATI 8514/A: V_DISP write 16E8=%d\n", dev->vdisp_latch); + mach_log("ATI 8514/A: V_DISP write 16E8=%d\n", dev->vdisp_8514); mach_log("ATI 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); } else { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x20)) { - WRITE8(port, dev->vdisp_latch, val); - dev->vdisp_latch &= 0x1fff; + WRITE8(port, dev->vdisp_8514, val); + dev->vdisp_8514 &= 0x1fff; } } } @@ -3252,11 +3222,11 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 1) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x20)) { - WRITE8(port, dev->vdisp_latch, val >> 8); - dev->vdisp_latch &= 0x1fff; + WRITE8(port, dev->vdisp_8514, val >> 8); + dev->vdisp_8514 &= 0x1fff; } } - mach_log("ATI 8514/A: V_DISP write 16E8=%d.\n", dev->vdisp_latch); + mach_log("ATI 8514/A: V_DISP write 16E8=%d.\n", dev->vdisp_8514); mach_log("ATI 8514/A: (0x%04x): vdisp=0x%02x.\n", port, val); } svga_recalctimings(svga); @@ -3266,17 +3236,17 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 2) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10) && val) { - dev->v_sync_start = val; - dev->v_sync_start &= 0x1fff; + dev->vsyncstart = val; + dev->vsyncstart &= 0x1fff; } } - mach_log("ATI 8514/A: V_SYNCSTART write 1AE8 = %d\n", dev->v_syncstart); + mach_log("ATI 8514/A: VSYNCSTART write 1AE8 = %d\n", dev->vsyncstart); mach_log("ATI 8514/A: (0x%04x): vsyncstart=0x%02x.\n", port, val); } else { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10)) { - WRITE8(port, dev->v_sync_start, val); - dev->v_sync_start &= 0x1fff; + WRITE8(port, dev->vsyncstart, val); + dev->vsyncstart &= 0x1fff; } } } @@ -3286,11 +3256,11 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if (len == 1) { if ((mach->accel.clock_sel & 0x01) || (!(mach->accel.clock_sel & 0x01) && (mach->shadow_set & 0x03))) { /*For 8514/A mode, take the shadow sets into account.*/ if (!(mach->shadow_cntl & 0x10)) { - WRITE8(port, dev->v_sync_start, val >> 8); - dev->v_sync_start &= 0x1fff; + WRITE8(port, dev->vsyncstart, val >> 8); + dev->vsyncstart &= 0x1fff; } } - mach_log("ATI 8514/A: V_SYNCSTART write 1AE8 = %d\n", dev->v_syncstart); + mach_log("ATI 8514/A: VSYNCSTART write 1AE8 = %d\n", dev->vsyncstart); mach_log("ATI 8514/A: (0x%04x): vsyncstart=0x%02x.\n", port, val); } svga_recalctimings(svga); @@ -3322,7 +3292,6 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u if ((dev->subsys_cntl & 0xc000) == 0x8000) { mach->force_busy = 0; dev->force_busy = 0; - dev->force_busy2 = 0; } break; @@ -3348,7 +3317,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u } mach_log("[%04X:%08X]: ATI 8514/A: (0x%04x): ON=%d, valxor=%x, shadow crt=%x, hdisp=%d, vdisp=%d, extmode=%02x, accelbpp=%d, crt=%d, crtres=%d.\n", - CS, cpu_state.pc, port, val & 0x01, dev->on, dev->accel.advfunc_cntl & 0x04, dev->hdisp, dev->vdisp, mach->regs[0xb0] & 0x20, dev->accel_bpp, dev->_8514crt, mach->crt_resolution); + CS, cpu_state.pc, port, val & 0x01, dev->on, dev->accel.advfunc_cntl & 0x04, dev->hdisp_vga, dev->vdisp_vga, mach->regs[0xb0] & 0x20, dev->accel_bpp, dev->_8514crt, mach->crt_resolution); if (ATI_MACH32) { mach_set_resolution(mach, svga); @@ -3531,7 +3500,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u } } } - mach_log("Write Port=%04x, Busy=%02x.\n", port, dev->force_busy2); + mach_log("Write Port=%04x, Busy=%02x.\n", port, dev->force_busy); break; case 0xaae8: @@ -3787,7 +3756,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u dev->vendor_mode = 1; mach_log("[%04X:%08X]: ATI 8514/A: (0x%04x): ON=%d, val=%04x, xor=%d, hdisp=%d, vdisp=%d, accelbpp=%d.\n", - CS, cpu_state.pc, port, mach->accel.clock_sel & 0x01, val, dev->on, dev->hdisp, dev->vdisp, dev->accel_bpp); + CS, cpu_state.pc, port, mach->accel.clock_sel & 0x01, val, dev->on, dev->hdisp_vga, dev->vdisp_vga, dev->accel_bpp); mach_log("Vendor ATI mode set %s resolution.\n", (dev->accel.advfunc_cntl & 0x04) ? "2: 1024x768" : "1: 640x480"); @@ -3995,7 +3964,6 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach->accel.bres_count = val & 0x7ff; mach_log("BresenhamDraw=%04x.\n", mach->accel.dp_config); dev->data_available = 0; - dev->data_available2 = 0; mach->accel.cmd_type = 1; frgd_sel = (mach->accel.dp_config >> 13) & 7; bkgd_sel = (mach->accel.dp_config >> 7) & 3; @@ -4048,7 +4016,6 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach->accel.dest_y_end = 0; } dev->data_available = 0; - dev->data_available2 = 0; mach_log("BitBLT=%04x, pattidx=%d.\n", mach->accel.dp_config, mach->accel.patt_idx); mach_log(".\n"); mach->accel.cmd_type = 2; /*Non-conforming BitBLT from dest_y_end register (0xaeee)*/ @@ -4111,7 +4078,6 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach->accel.scan_to_x = 0; } dev->data_available = 0; - dev->data_available2 = 0; mach->accel.cmd_type = 5; /*Horizontal Raster Draw from scan_to_x register (0xcaee)*/ mach_log("ScanToX len=%d.\n", val); mach_log(".\n"); @@ -4133,7 +4099,6 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u mach_log("Data Path Configuration (%04x) write val=%04x, len=%d.\n", port, val, len); if (len == 2) { dev->data_available = 0; - dev->data_available2 = 0; mach->accel.dp_config = val; } break; @@ -4371,26 +4336,26 @@ mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, in if (len == 1) { dev->fifo_idx = 0; - if (dev->force_busy2) + if (dev->force_busy) temp |= 0x02; /*Hardware busy*/ - dev->force_busy2 = 0; + dev->force_busy = 0; - if (dev->data_available2) { + if (dev->data_available) { temp |= 0x01; /*Read Data available*/ if (mach->accel.cmd_type >= 0) { switch (mach->accel.cmd_type) { case 2: if (dev->accel.sy >= mach->accel.height) - dev->data_available2 = 0; + dev->data_available = 0; break; case 5: if (dev->accel.sx >= mach->accel.width) - dev->data_available2 = 0; + dev->data_available = 0; break; default: if (dev->accel.sy < 0) - dev->data_available2 = 0; + dev->data_available = 0; break; } } else { @@ -4400,11 +4365,11 @@ mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, in case 4: case 6: if (dev->accel.sy < 0) - dev->data_available2 = 0; + dev->data_available = 0; break; default: if (!dev->accel.sy) - dev->data_available2 = 0; + dev->data_available = 0; break; } } @@ -4595,35 +4560,35 @@ mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, in case 0xc2ee: if (len == 2) - temp = dev->v_total_reg; + temp = dev->vtotal_reg; else - temp = dev->v_total_reg & 0xff; + temp = dev->vtotal_reg & 0xff; break; case 0xc2ef: if (len == 1) - temp = dev->v_total_reg >> 8; + temp = dev->vtotal_reg >> 8; break; case 0xc6ee: if (len == 2) - temp = dev->vdisp_latch; + temp = dev->vdisp_8514; else - temp = dev->vdisp_latch & 0xff; + temp = dev->vdisp_8514 & 0xff; break; case 0xc6ef: if (len == 1) - temp = dev->vdisp_latch >> 8; + temp = dev->vdisp_8514 >> 8; break; case 0xcaee: if (len == 2) - temp = dev->v_sync_start; + temp = dev->vsyncstart; else - temp = dev->v_sync_start & 0xff; + temp = dev->vsyncstart & 0xff; break; case 0xcaef: if (len == 1) - temp = dev->v_sync_start >> 8; + temp = dev->vsyncstart >> 8; break; case 0xceee: @@ -4787,10 +4752,8 @@ mach_accel_in_call(uint16_t port, mach_t *mach, svga_t *svga, ibm8514_t *dev) if (!dev->fifo_idx && !dev->on) { dev->force_busy = 0; - dev->force_busy2 = 0; mach->force_busy = 0; dev->data_available = 0; - dev->data_available2 = 0; temp |= INT_FIFO_EMP; mach_log("Fifo Empty.\n"); } @@ -5224,7 +5187,7 @@ mach32_write_common(uint32_t addr, uint8_t val, int linear, mach_t *mach, svga_t ibm8514_t *dev = (ibm8514_t *) svga->dev8514; int writemask2 = svga->writemask; int reset_wm = 0; - latch8514_t vall; + ibm8514_latch_t vall; uint8_t wm = svga->writemask; uint8_t i; @@ -7039,7 +7002,6 @@ mach_reset(void *priv) mach_disable_handlers(mach); mach->force_busy = 0; dev->force_busy = 0; - dev->force_busy2 = 0; if (mach->pci_bus) reset_state->pci_slot = mach->pci_slot; @@ -7246,10 +7208,10 @@ ati8514_init(svga_t *svga, void *ext8514, void *dev8514) dev->accel_bpp = 8; dev->rowoffset = 0x80; dev->hdisped = 0x7f; - dev->vdisp_latch = 0x05ff; + dev->vdisp_8514 = 0x05ff; dev->htotal = 0x9d; - dev->v_total_reg = 0x0668; - dev->v_sync_start = 0x0600; + dev->vtotal_reg = 0x0668; + dev->vsyncstart = 0x0600; dev->disp_cntl = 0x33; mach->accel.clock_sel = 0x1c; dev->accel.cmd_back = 1; diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 54856d9e0..8e87e5980 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -1030,16 +1030,16 @@ svga_recalctimings(svga_t *svga) if (ibm8514_active && (svga->dev8514 != NULL)) { if (dev->on) { - disptime8514 = dev->h_total; - _dispontime8514 = dev->h_disp; - svga_log("HTOTAL=%d, HDISP=%d.\n", dev->h_total, dev->h_disp); + disptime8514 = dev->htotal_8514; + _dispontime8514 = dev->hdisp_8514; + svga_log("HTOTAL=%d, HDISP=%d.\n", dev->htotal_8514, dev->hdisp_8514); } } if (xga_active && (svga->xga != NULL)) { if (xga->on) { - disptime_xga = xga->h_total ? xga->h_total : TIMER_USEC; - _dispontime_xga = xga->h_disp; + disptime_xga = xga->htotal_xga ? xga->htotal_xga : TIMER_USEC; + _dispontime_xga = xga->hdisp_xga; } } diff --git a/src/video/vid_xga.c b/src/video/vid_xga.c index 51f842cc5..f7a1464e5 100644 --- a/src/video/vid_xga.c +++ b/src/video/vid_xga.c @@ -257,9 +257,9 @@ xga_render_blank(svga_t *svga) xga->lastline_draw = xga->displine; uint32_t *line_ptr = &svga->monitor->target_buffer->line[xga->displine + svga->y_add][svga->x_add]; - uint32_t line_width = (uint32_t)(xga->h_disp) * sizeof(uint32_t); + uint32_t line_width = (uint32_t)(xga->hdisp_xga) * sizeof(uint32_t); - if (xga->h_disp > 0) + if (xga->hdisp_xga > 0) memset(line_ptr, 0, line_width); } @@ -268,14 +268,14 @@ xga_recalctimings(svga_t *svga) { xga_t *xga = (xga_t *) svga->xga; if (xga->on) { - xga->h_total = xga->htotal + 1; - xga->v_total = xga->vtotal + 1; + xga->htotal_xga = xga->htotal + 1; + xga->vtotal_xga = xga->vtotal + 1; xga->dispend = xga->vdispend + 1; - xga->v_syncstart = xga->vsyncstart + 1; + xga->vsyncstart++; xga->split = xga->linecmp + 1; - xga->v_blankstart = xga->vblankstart + 1; + xga->vblankstart_xga = xga->vblankstart + 1; - xga->h_disp = (xga->hdisp + 1) << 3; + xga->hdisp_xga = (xga->hdisp + 1) << 3; xga->rowoffset = xga->pix_map_width; @@ -283,11 +283,11 @@ xga_recalctimings(svga_t *svga) xga->rowcount = (xga->disp_cntl_2 & 0xc0) >> 6; if (xga->interlace) { - xga->v_total >>= 1; + xga->vtotal_xga >>= 1; xga->dispend >>= 1; - xga->v_syncstart >>= 1; + xga->vsyncstart >>= 1; xga->split >>= 1; - xga->v_blankstart >>= 1; + xga->vblankstart_xga >>= 1; } xga->memaddr_latch = xga->disp_start_addr; @@ -296,14 +296,14 @@ xga_recalctimings(svga_t *svga) xga_log("XGA ClkSel1 = %d, ClkSel2 = %02x, dispcntl2=%02x.\n", (xga->clk_sel_1 >> 2) & 3, xga->clk_sel_2 & 0x80, xga->disp_cntl_2 & 0xc0); switch ((xga->clk_sel_1 >> 2) & 3) { case 0: - xga_log("HDISP VGA0 = %d, XGA = %d.\n", svga->hdisp, xga->h_disp); + xga_log("HDISP VGA0 = %d, XGA = %d.\n", svga->hdisp, xga->hdisp_xga); if (xga->clk_sel_2 & 0x80) svga->clock_xga = (cpuclock * (double) (1ULL << 32)) / 41539000.0; else svga->clock_xga = (cpuclock * (double) (1ULL << 32)) / 25175000.0; break; case 1: - xga_log("HDISP VGA1 = %d, XGA = %d.\n", svga->hdisp, xga->h_disp); + xga_log("HDISP VGA1 = %d, XGA = %d.\n", svga->hdisp, xga->hdisp_xga); svga->clock_xga = (cpuclock * (double) (1ULL << 32)) / 28322000.0; break; case 3: @@ -1555,7 +1555,7 @@ xga_bitblt(svga_t *svga) if (srcheight == 7) xga->accel.pattern = 1; else { - if ((dstwidth == (xga->h_disp - 1)) && (srcwidth == 1)) { + if ((dstwidth == (xga->hdisp_xga - 1)) && (srcwidth == 1)) { if ((xga->accel.dst_map == 1) && (xga->accel.src_map == 2)) { if ((xga->accel.px_map_format[xga->accel.dst_map] >= 0x0a) && (xga->accel.px_map_format[xga->accel.src_map] >= 0x0a)) xga->accel.pattern = 1; @@ -1640,8 +1640,8 @@ xga_bitblt(svga_t *svga) else if ((xga->accel.src_map == 1) && (patwidth == 7)) xga->accel.pattern = 1; } else { - if (dstwidth == (xga->h_disp - 1)) { - if (srcwidth == (xga->h_disp - 1)) { + if (dstwidth == (xga->hdisp_xga - 1)) { + if (srcwidth == (xga->hdisp_xga - 1)) { if ((xga->accel.src_map == 1) && (xga->accel.dst_map == 1) && (xga->accel.pat_src == 2)) { if ((xga->accel.px_map_format[xga->accel.dst_map] >= 0x0a) && (xga->accel.px <= 7) && (xga->accel.py <= 3)) xga->accel.pattern = 1; @@ -2591,7 +2591,7 @@ xga_render_overscan_left(xga_t *xga, svga_t *svga) if ((xga->displine + svga->y_add) < 0) return; - if (svga->scrblank || (xga->h_disp == 0)) + if (svga->scrblank || (xga->hdisp_xga == 0)) return; uint32_t *line_ptr = buffer32->line[xga->displine + svga->y_add]; @@ -2607,10 +2607,10 @@ xga_render_overscan_right(xga_t *xga, svga_t *svga) if ((xga->displine + svga->y_add) < 0) return; - if (svga->scrblank || (xga->h_disp == 0)) + if (svga->scrblank || (xga->hdisp_xga == 0)) return; - uint32_t *line_ptr = &buffer32->line[xga->displine + svga->y_add][svga->x_add + xga->h_disp]; + uint32_t *line_ptr = &buffer32->line[xga->displine + svga->y_add][svga->x_add + xga->hdisp_xga]; right = (overscan_x >> 1); for (int i = 0; i < right; i++) *line_ptr++ = svga->overscan_color; @@ -2634,7 +2634,7 @@ xga_render_4bpp(svga_t *svga) xga->lastline_draw = xga->displine; - for (int x = 0; x <= xga->h_disp; x += 8) { + for (int x = 0; x <= xga->hdisp_xga; x += 8) { dat = *(uint32_t *) (&xga->vram[xga->memaddr & xga->vram_mask]); p[0] = xga->pallook[dat & 0x0f]; p[1] = xga->pallook[(dat >> 8) & 0x0f]; @@ -2671,7 +2671,7 @@ xga_render_8bpp(svga_t *svga) xga->firstline_draw = xga->displine; xga->lastline_draw = xga->displine; - for (int x = 0; x <= xga->h_disp; x += 8) { + for (int x = 0; x <= xga->hdisp_xga; x += 8) { dat = *(uint32_t *) (&xga->vram[xga->memaddr & xga->vram_mask]); p[0] = xga->pallook[dat & 0xff]; p[1] = xga->pallook[(dat >> 8) & 0xff]; @@ -2709,7 +2709,7 @@ xga_render_16bpp(svga_t *svga) xga->firstline_draw = xga->displine; xga->lastline_draw = xga->displine; - for (x = 0; x <= xga->h_disp; x += 8) { + for (x = 0; x <= xga->hdisp_xga; x += 8) { dat = *(uint32_t *) (&xga->vram[(xga->memaddr + (x << 1)) & xga->vram_mask]); p[x] = video_16to32[dat & 0xffff]; p[x + 1] = video_16to32[dat >> 16]; @@ -3107,7 +3107,7 @@ xga_poll(void *priv) xga->linepos = 1; if (xga->dispon) { - xga->h_disp_on = 1; + xga->hdispon_xga = 1; xga->memaddr &= xga->vram_mask; @@ -3149,7 +3149,7 @@ xga_poll(void *priv) if (xga->dispon) svga->cgastat &= ~1; - xga->h_disp_on = 0; + xga->hdispon_xga = 0; xga->linepos = 0; if (xga->dispon) { @@ -3194,10 +3194,10 @@ xga_poll(void *priv) if (svga->fullchange) svga->fullchange--; } - if (xga->vc == xga->v_syncstart) { + if (xga->vc == xga->vsyncstart) { xga->dispon = 0; svga->cgastat |= 8; - x = xga->h_disp; + x = xga->hdisp_xga; if (xga->interlace && !xga->oddeven) xga->lastline++; @@ -3227,7 +3227,7 @@ xga_poll(void *priv) xga->memaddr = (xga->memaddr << 2); xga->memaddr_backup = (xga->memaddr_backup << 2); } - if (xga->vc == xga->v_total) { + if (xga->vc == xga->vtotal_xga) { xga->vc = 0; xga->scanline = 0; xga->dispon = 1;