Fixed off by one errors in (S)VGA horizontal blanking start calculation.

This commit is contained in:
OBattler
2024-02-18 17:54:14 +01:00
parent 0b5bf60aaf
commit 4c3cceec69
14 changed files with 28 additions and 34 deletions

View File

@@ -914,7 +914,7 @@ ibm8514_accel_out(uint16_t port, uint32_t val, svga_t *svga, int len)
if (!(port & 1)) {
if (((dev->disp_cntl & 0x60) == 0x20) || (((dev->disp_cntl & 0x60) == 0x40) && !(dev->accel.advfunc_cntl & 0x04))) {
dev->hsync_start = val;
dev->hblankstart = (dev->hsync_start & 0x07) + 1;
dev->hblankstart = (dev->hsync_start & 0x07);
}
}
ibm8514_log("IBM 8514/A: H_SYNC_STRT write 0AE8 = %d\n", val + 1);

View File

@@ -408,7 +408,7 @@ ati28800_recalctimings(svga_t *svga)
int clock_sel;
if (ati28800->regs[0xad] & 0x08)
svga->hblankstart = ((ati28800->regs[0x0d] >> 2) << 8) + svga->crtc[2] + 1;
svga->hblankstart = ((ati28800->regs[0x0d] >> 2) << 8) + svga->crtc[2];
clock_sel = ((svga->miscout >> 2) & 3) | ((ati28800->regs[0xbe] & 0x10) >> 1) |
((ati28800->regs[0xb9] & 2) << 1);
@@ -492,8 +492,7 @@ ati28800_recalctimings(svga_t *svga)
else {
svga->render = svga_render_15bpp_highres;
svga->hdisp >>= 1;
svga->hblankstart = ((svga->hblankstart - 1) >> 1) + 1;
svga->hblank_end_val >>= 1;
svga->dots_per_clock >>= 1;
svga->rowoffset <<= 1;
svga->ma_latch <<= 1;
}

View File

@@ -516,7 +516,7 @@ mach64_recalctimings(svga_t *svga)
svga->htotal = (mach64->crtc_h_total_disp & 255) + 1;
svga->hdisp_time = svga->hdisp = ((mach64->crtc_h_total_disp >> 16) & 255) + 1;
svga->hblankstart = (mach64->crtc_h_sync_strt_wid & 255) +
((mach64->crtc_h_sync_strt_wid >> 8) & 7) + 1;
((mach64->crtc_h_sync_strt_wid >> 8) & 7);
svga->hblank_end_val = (svga->hblankstart +
((mach64->crtc_h_sync_strt_wid >> 16) & 31) - 1) & 63;
svga->vsyncstart = (mach64->crtc_v_sync_strt_wid & 2047) + 1;

View File

@@ -2547,7 +2547,7 @@ mach_recalctimings(svga_t *svga)
int clock_sel;
if (mach->regs[0xad] & 0x08)
svga->hblankstart = ((mach->regs[0x0d] >> 2) << 8) + svga->crtc[2] + 1;
svga->hblankstart = ((mach->regs[0x0d] >> 2) << 8) + svga->crtc[2];
clock_sel = ((svga->miscout >> 2) & 3) | ((mach->regs[0xbe] & 0x10) >> 1) | ((mach->regs[0xb9] & 2) << 1);
@@ -3636,7 +3636,7 @@ mach_accel_out_call(uint16_t port, uint8_t val, mach_t *mach, svga_t *svga, ibm8
if (!(port & 1)) {
if (((dev->disp_cntl & 0x60) == 0x20) || (((dev->disp_cntl & 0x60) == 0x40) && !(dev->accel.advfunc_cntl & 0x04)) || (mach->accel.clock_sel & 0x01)) {
dev->hsync_start = val;
dev->hblankstart = (dev->hsync_start & 0x07) + 1;
dev->hblankstart = (dev->hsync_start & 0x07);
}
}
mach_log("ATI 8514/A: H_SYNC_STRT write 0AE8 = %d\n", val + 1);

View File

@@ -1886,10 +1886,10 @@ chips_69000_pci_write(int func, int addr, uint8_t val, void *p)
}
case 0x13:
{
if (!(chips->pci_conf_status & PCI_COMMAND_MEM)) {
// if (!(chips->pci_conf_status & PCI_COMMAND_MEM)) {
chips->linear_mapping.base = val << 24;
break;
}
// break;
// }
mem_mapping_set_addr(&chips->linear_mapping, val << 24, (1 << 24));
break;
}

View File

@@ -1750,7 +1750,7 @@ gd54xx_recalctimings(svga_t *svga)
uint8_t rdmask;
uint8_t linedbl = svga->dispend * 9 / 10 >= svga->hdisp;
svga->hblankstart = svga->crtc[2] + 1;
svga->hblankstart = svga->crtc[2];
if (svga->crtc[0x1b] & ((svga->crtc[0x27] >= CIRRUS_ID_CLGD5424) ? 0xa0 : 0x20)) {
/* Special blanking mode: the blank start and end become components of the window generator,
@@ -1763,7 +1763,7 @@ gd54xx_recalctimings(svga_t *svga)
svga->hblank_end_mask = 0x000000ff;
if (svga->crtc[0x1b] & 0x20) {
svga->hblankstart = svga->crtc[1]/* + ((svga->crtc[3] >> 5) & 3)*/ + 1;
svga->hblankstart = svga->crtc[1]/* + ((svga->crtc[3] >> 5) & 3) + 1*/;
svga->hblank_end_val = svga->htotal - 1 /* + ((svga->crtc[3] >> 5) & 3)*/;
/* In this mode, the dots per clock are always 8 or 16, never 9 or 18. */

View File

@@ -650,7 +650,7 @@ et4000_recalctimings(svga_t *svga)
svga->ma_latch |= (svga->crtc[0x33] & 3) << 16;
svga->hblankstart = (((svga->crtc[0x3f] & 0x10) >> 4) << 8) + svga->crtc[2] + 1;
svga->hblankstart = (((svga->crtc[0x3f] & 0x10) >> 4) << 8) + svga->crtc[2];
if (svga->crtc[0x35] & 1)
svga->vblankstart += 0x400;
@@ -690,14 +690,12 @@ et4000_recalctimings(svga_t *svga)
case 15:
case 16:
svga->hdisp /= 2;
svga->hblankstart /= 2;
svga->hblank_end_val /= 2;
svga->dots_per_clock /= 2;
break;
case 24:
svga->hdisp /= 3;
svga->hblankstart /= 3;
svga->hblank_end_val /= 3;
svga->dots_per_clock /= 3;
break;
default:

View File

@@ -432,7 +432,7 @@ et4000w32p_recalctimings(svga_t *svga)
svga->ma_latch |= (svga->crtc[0x33] & 0x7) << 16;
svga->hblankstart = (((svga->crtc[0x3f] & 0x10) >> 4) << 8) + svga->crtc[2] + 1;
svga->hblankstart = (((svga->crtc[0x3f] & 0x10) >> 4) << 8) + svga->crtc[2];
if (svga->crtc[0x35] & 0x01)
svga->vblankstart += 0x400;

View File

@@ -714,7 +714,7 @@ ht216_recalctimings(svga_t *svga)
svga->vram_display_mask = (ht216->ht_regs[0xf6] & 0x40) ? ht216->vram_mask : 0x3ffff;
if (ht216->ht_regs[0xe0] & 0x20)
svga->hblankstart = ((ht216->ht_regs[0xca] >> 2) << 8) + svga->crtc[4] + 1;
svga->hblankstart = ((ht216->ht_regs[0xca] >> 2) << 8) + svga->crtc[4];
}
static void

View File

@@ -945,7 +945,7 @@ mystique_recalctimings(svga_t *svga)
if (mystique->crtcext_regs[1] & CRTCX_R1_HTOTAL8)
svga->htotal |= 0x100;
svga->hblankstart = (((mystique->crtcext_regs[1] & 0x02) >> 2) << 8) + svga->crtc[2] + 1;
svga->hblankstart = (((mystique->crtcext_regs[1] & 0x02) >> 2) << 8) + svga->crtc[2];
if (mystique->crtcext_regs[2] & CRTCX_R2_VTOTAL10)
svga->vtotal |= 0x400;

View File

@@ -3312,7 +3312,7 @@ s3_recalctimings(svga_t *svga)
if (svga->crtc[0x33] & 0x20) {
/* The S3 version of the Cirrus' special blanking mode, with identical behavior. */
svga->hblankstart = (((svga->crtc[0x5d] & 0x02) >> 1) << 8) + svga->crtc[1]/* +
((svga->crtc[3] >> 5) & 3)*/ + 1;
((svga->crtc[3] >> 5) & 3) + 1*/;
svga->hblank_end_val = svga->htotal - 1 /* + ((svga->crtc[3] >> 5) & 3)*/;
svga->monitor->mon_overscan_y = 0;
@@ -3324,7 +3324,7 @@ s3_recalctimings(svga_t *svga)
if (s3->chip >= S3_VISION964)
svga->hblank_end_mask = 0x7f;
} else if (s3->chip >= S3_86C801) {
svga->hblankstart = (((svga->crtc[0x5d] & 0x04) >> 2) << 8) + svga->crtc[2] + 1;
svga->hblankstart = (((svga->crtc[0x5d] & 0x04) >> 2) << 8) + svga->crtc[2];
if (s3->chip >= S3_VISION964) {
/* NOTE: The S3 Trio64V+ datasheet says this is bit 7, but then where is bit 6?
@@ -4160,7 +4160,7 @@ s3_trio64v_recalctimings(svga_t *svga)
if ((svga->crtc[0x33] & 0x20) || ((svga->crtc[0x67] & 0xc) == 0xc)) {
/* The S3 version of the Cirrus' special blanking mode, with identical behavior. */
svga->hblankstart = (((svga->crtc[0x5d] & 0x02) >> 1) << 8) + svga->crtc[1]/* +
((svga->crtc[3] >> 5) & 3)*/ + 1;
((svga->crtc[3] >> 5) & 3) + 1*/;
svga->hblank_end_val = svga->htotal - 1 /* + ((svga->crtc[3] >> 5) & 3)*/;
svga->monitor->mon_overscan_y = 0;
@@ -4169,7 +4169,7 @@ s3_trio64v_recalctimings(svga_t *svga)
/* Also make sure vertical blanking starts on display end. */
svga->vblankstart = svga->dispend;
} else {
svga->hblankstart = (((svga->crtc[0x5d] & 0x04) >> 2) << 8) + svga->crtc[2] + 1;
svga->hblankstart = (((svga->crtc[0x5d] & 0x04) >> 2) << 8) + svga->crtc[2];
/* NOTE: The S3 Trio64V+ datasheet says this is bit 7, but then where is bit 6?
The datasheets for the pre-Trio64V+ cards say +64, which implies bit 6,

View File

@@ -827,7 +827,7 @@ s3_virge_recalctimings(svga_t *svga)
if ((svga->crtc[0x33] & 0x20) || ((svga->crtc[0x67] & 0xc) == 0xc)) {
/* The S3 version of the Cirrus' special blanking mode, with identical behavior. */
svga->hblankstart = (((svga->crtc[0x5d] & 0x02) >> 1) << 8) + svga->crtc[1]/* +
((svga->crtc[3] >> 5) & 3)*/ + 1;
((svga->crtc[3] >> 5) & 3) + 1*/;
svga->hblank_end_val = svga->htotal - 1 /* + ((svga->crtc[3] >> 5) & 3)*/;
svga->monitor->mon_overscan_y = 0;
@@ -836,7 +836,7 @@ s3_virge_recalctimings(svga_t *svga)
/* Also make sure vertical blanking starts on display end. */
svga->vblankstart = svga->dispend;
} else {
svga->hblankstart = (((svga->crtc[0x5d] & 0x04) >> 2) << 8) + svga->crtc[2] + 1;
svga->hblankstart = (((svga->crtc[0x5d] & 0x04) >> 2) << 8) + svga->crtc[2];
svga->hblank_end_val = (svga->crtc[3] & 0x1f) | (((svga->crtc[5] & 0x80) >> 7) << 5) |
(((svga->crtc[0x5d] & 0x08) >> 3) << 6);

View File

@@ -750,7 +750,7 @@ svga_recalctimings(svga_t *svga)
} else
svga->monitor->mon_overscan_x = 16;
svga->hblankstart = svga->crtc[2] + 1;
svga->hblankstart = svga->crtc[2];
svga->hblank_end_val = (svga->crtc[3] & 0x1f) | ((svga->crtc[5] & 0x80) ? 0x20 : 0x00);
svga->hblank_end_mask = 0x0000003f;

View File

@@ -558,10 +558,10 @@ banshee_recalctimings(svga_t *svga)
that is, no overscan and relying on display end to blank. */
if (banshee->vgaInit0 & 0x40) {
svga->hblankstart = svga->crtc[1]/* + ((svga->crtc[3] >> 5) & 3)*/ +
(((svga->crtc[0x1a] & 0x04) >> 2) << 8) + 1;
(((svga->crtc[0x1a] & 0x04) >> 2) << 8);
svga->hblank_end_mask = 0x0000007f;
} else {
svga->hblankstart = svga->crtc[1]/* + ((svga->crtc[3] >> 5) & 3)*/ + 1;
svga->hblankstart = svga->crtc[1]/* + ((svga->crtc[3] >> 5) & 3)*/;
svga->hblank_end_mask = 0x0000003f;
}
svga->hblank_end_val = svga->htotal - 1 /* + ((svga->crtc[3] >> 5) & 3)*/;
@@ -579,12 +579,12 @@ banshee_recalctimings(svga_t *svga)
svga->linedbl = 0;
} else {
if (banshee->vgaInit0 & 0x40) {
svga->hblankstart = (((svga->crtc[0x1a] & 0x10) >> 4) << 8) + svga->crtc[2] + 1;
svga->hblankstart = (((svga->crtc[0x1a] & 0x10) >> 4) << 8) + svga->crtc[2];
svga->hblank_end_val = (svga->crtc[3] & 0x1f) | (((svga->crtc[5] & 0x80) >> 7) << 5) |
(((svga->crtc[0x1a] & 0x20) >> 5) << 6);
svga->hblank_end_mask = 0x0000007f;
} else {
svga->hblankstart = svga->crtc[2] + 1;
svga->hblankstart = svga->crtc[2];
svga->hblank_end_val = (svga->crtc[3] & 0x1f) | (((svga->crtc[5] & 0x80) >> 7) << 5);
svga->hblank_end_mask = 0x0000003f;
}
@@ -652,9 +652,6 @@ banshee_recalctimings(svga_t *svga)
if (banshee->vidProcCfg & VIDPROCCFG_2X_MODE) {
svga->hdisp *= 2;
// svga->htotal *= 2;
// svga->hblankstart *= 2;
// svga->hblank_end_val *= 2;
svga->dots_per_clock *= 2;
}