From 901e2568fe382115e7aac711b5f52ba6501645b7 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 29 Feb 2024 06:46:37 +0100 Subject: [PATCH 1/4] Mask out serial passthrough MSR bits when in loopback mode, fixes #4217. --- src/device/serial.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/device/serial.c b/src/device/serial.c index 37aadf8fec..dcdffb71c8 100644 --- a/src/device/serial.c +++ b/src/device/serial.c @@ -686,7 +686,10 @@ serial_read(uint16_t addr, void *priv) serial_update_ints(dev); break; case 6: - ret = dev->msr | dev->msr_set; + if (dev->mctrl & 0x10) + ret = dev->msr; + else + ret = dev->msr | dev->msr_set; dev->msr &= ~0x0f; dev->int_status &= ~SERIAL_INT_MSR; serial_update_ints(dev); From 5af0ccd145bbfcfafd456640c8bcc0442db124e1 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 29 Feb 2024 06:48:16 +0100 Subject: [PATCH 2/4] Assorted Voodoo and warning fixes. --- src/network/net_pcnet.c | 3 +- src/video/vid_voodoo_banshee.c | 3 ++ src/video/vid_voodoo_banshee_blitter.c | 48 ++++++++++++++++++++++++++ src/video/vid_voodoo_render.c | 4 ++- 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/network/net_pcnet.c b/src/network/net_pcnet.c index 9ddcfe29d6..1e28c58469 100644 --- a/src/network/net_pcnet.c +++ b/src/network/net_pcnet.c @@ -787,8 +787,9 @@ static int ladr_match(nic_t *dev, const uint8_t *buf, UNUSED(size_t size)) { const struct ether_header *hdr = (const struct ether_header *) buf; + uint64_t *p = (uint64_t *) &dev->aCSR[8]; - if ((hdr->ether_dhost[0] & 0x01) && ((uint64_t *) &dev->aCSR[8])[0] != 0LL) { + if ((hdr->ether_dhost[0] & 0x01) && p[0] != 0LL) { int index; uint8_t ladr[8]; ladr[0] = dev->aCSR[8] & 0xff; diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index 098e919d48..a333062e1d 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -510,6 +510,9 @@ banshee_render_16bpp_tiled(svga_t *svga) else addr = banshee->desktop_addr + (banshee->desktop_y & 31) * 128 + ((banshee->desktop_y >> 5) * banshee->desktop_stride_tiled); + if (addr >= svga->vram_max) + return; + for (int x = 0; x <= svga->hdisp; x += 64) { if (svga->hwcursor_on || svga->overlay_on) svga->changedvram[addr >> 12] = 2; diff --git a/src/video/vid_voodoo_banshee_blitter.c b/src/video/vid_voodoo_banshee_blitter.c index 33ee602b54..b8809d3fd7 100644 --- a/src/video/vid_voodoo_banshee_blitter.c +++ b/src/video/vid_voodoo_banshee_blitter.c @@ -216,6 +216,9 @@ PLOT(voodoo_t *voodoo, int x, int y, int pat_x, int pat_y, uint8_t pattern_mask, uint32_t dest = voodoo->vram[addr]; uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : voodoo->banshee_blt.colorPattern8[(pat_x & 7) + (pat_y & 7) * 8]; + if (addr > voodoo->fb_mask) + break; + voodoo->vram[addr] = MIX(voodoo, dest, src, pattern, src_colorkey, COLORKEY_8); voodoo->changedvram[addr >> 12] = changeframecount; break; @@ -226,6 +229,9 @@ PLOT(voodoo_t *voodoo, int x, int y, int pat_x, int pat_y, uint8_t pattern_mask, uint32_t dest = *(uint16_t *) &voodoo->vram[addr]; uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : voodoo->banshee_blt.colorPattern16[(pat_x & 7) + (pat_y & 7) * 8]; + if (addr > voodoo->fb_mask) + break; + *(uint16_t *) &voodoo->vram[addr] = MIX(voodoo, dest, src, pattern, src_colorkey, COLORKEY_16); voodoo->changedvram[addr >> 12] = changeframecount; break; @@ -236,6 +242,9 @@ PLOT(voodoo_t *voodoo, int x, int y, int pat_x, int pat_y, uint8_t pattern_mask, uint32_t dest = *(uint32_t *) &voodoo->vram[addr]; uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : voodoo->banshee_blt.colorPattern24[(pat_x & 7) + (pat_y & 7) * 8]; + if (addr > voodoo->fb_mask) + break; + *(uint32_t *) &voodoo->vram[addr] = (MIX(voodoo, dest, src, pattern, src_colorkey, COLORKEY_32) & 0xffffff) | (dest & 0xff000000); voodoo->changedvram[addr >> 12] = changeframecount; break; @@ -246,6 +255,9 @@ PLOT(voodoo_t *voodoo, int x, int y, int pat_x, int pat_y, uint8_t pattern_mask, uint32_t dest = *(uint32_t *) &voodoo->vram[addr]; uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : voodoo->banshee_blt.colorPattern[(pat_x & 7) + (pat_y & 7) * 8]; + if (addr > voodoo->fb_mask) + break; + *(uint32_t *) &voodoo->vram[addr] = MIX(voodoo, dest, src, pattern, src_colorkey, COLORKEY_32); voodoo->changedvram[addr >> 12] = changeframecount; break; @@ -265,6 +277,9 @@ PLOT_LINE(voodoo_t *voodoo, int x, int y, UNUSED(uint8_t rop), uint32_t pattern, uint32_t addr = get_addr(voodoo, x, y, 0, 0); //(voodoo->banshee_blt.dstBaseAddr + x + y*voodoo->banshee_blt.dst_stride) & voodoo->fb_mask; uint32_t dest = voodoo->vram[addr]; + if (addr > voodoo->fb_mask) + break; + voodoo->vram[addr] = MIX(voodoo, dest, voodoo->banshee_blt.colorFore, pattern, src_colorkey, COLORKEY_8); voodoo->changedvram[addr >> 12] = changeframecount; break; @@ -274,6 +289,9 @@ PLOT_LINE(voodoo_t *voodoo, int x, int y, UNUSED(uint8_t rop), uint32_t pattern, uint32_t addr = get_addr(voodoo, x * 2, y, 0, 0); //(voodoo->banshee_blt.dstBaseAddr + x*2 + y*voodoo->banshee_blt.dst_stride) & voodoo->fb_mask; uint32_t dest = *(uint16_t *) &voodoo->vram[addr]; + if (addr > voodoo->fb_mask) + break; + *(uint16_t *) &voodoo->vram[addr] = MIX(voodoo, dest, voodoo->banshee_blt.colorFore, pattern, src_colorkey, COLORKEY_16); voodoo->changedvram[addr >> 12] = changeframecount; break; @@ -283,6 +301,9 @@ PLOT_LINE(voodoo_t *voodoo, int x, int y, UNUSED(uint8_t rop), uint32_t pattern, uint32_t addr = get_addr(voodoo, x * 3, y, 0, 0); //(voodoo->banshee_blt.dstBaseAddr + x*3 + y*voodoo->banshee_blt.dst_stride) & voodoo->fb_mask; uint32_t dest = *(uint32_t *) &voodoo->vram[addr]; + if (addr > voodoo->fb_mask) + break; + *(uint32_t *) &voodoo->vram[addr] = (MIX(voodoo, dest, voodoo->banshee_blt.colorFore, pattern, src_colorkey, COLORKEY_32) & 0xffffff) | (dest & 0xff000000); voodoo->changedvram[addr >> 12] = changeframecount; break; @@ -292,6 +313,9 @@ PLOT_LINE(voodoo_t *voodoo, int x, int y, UNUSED(uint8_t rop), uint32_t pattern, uint32_t addr = get_addr(voodoo, x * 4, y, 0, 0); //(voodoo->banshee_blt.dstBaseAddr + x*4 + y*voodoo->banshee_blt.dst_stride) & voodoo->fb_mask; uint32_t dest = *(uint32_t *) &voodoo->vram[addr]; + if (addr > voodoo->fb_mask) + break; + *(uint32_t *) &voodoo->vram[addr] = MIX(voodoo, dest, voodoo->banshee_blt.colorFore, pattern, src_colorkey, COLORKEY_32); voodoo->changedvram[addr >> 12] = changeframecount; break; @@ -573,6 +597,9 @@ do_screen_to_screen_line(voodoo_t *voodoo, uint8_t *src_p, int use_x_dir, int sr uint32_t dest = voodoo->vram[dst_addr]; uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : voodoo->banshee_blt.colorPattern8[(pat_x & 7) + (pat_y & 7) * 8]; + if (dst_addr > voodoo->fb_mask) + break; + voodoo->vram[dst_addr] = MIX(voodoo, dest, src, pattern, COLORKEY_8, COLORKEY_8); voodoo->changedvram[dst_addr >> 12] = changeframecount; break; @@ -584,6 +611,9 @@ do_screen_to_screen_line(voodoo_t *voodoo, uint8_t *src_p, int use_x_dir, int sr uint32_t dest = *(uint16_t *) &voodoo->vram[dst_addr]; uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : voodoo->banshee_blt.colorPattern16[(pat_x & 7) + (pat_y & 7) * 8]; + if (dst_addr > voodoo->fb_mask) + break; + *(uint16_t *) &voodoo->vram[dst_addr] = MIX(voodoo, dest, src, pattern, COLORKEY_16, COLORKEY_16); voodoo->changedvram[dst_addr >> 12] = changeframecount; break; @@ -595,6 +625,9 @@ do_screen_to_screen_line(voodoo_t *voodoo, uint8_t *src_p, int use_x_dir, int sr uint32_t dest = *(uint32_t *) &voodoo->vram[dst_addr]; uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : voodoo->banshee_blt.colorPattern24[(pat_x & 7) + (pat_y & 7) * 8]; + if (dst_addr > voodoo->fb_mask) + break; + *(uint32_t *) &voodoo->vram[dst_addr] = (MIX(voodoo, dest, src, pattern, COLORKEY_32, COLORKEY_32) & 0xffffff) | (dest & 0xff000000); voodoo->changedvram[dst_addr >> 12] = changeframecount; break; @@ -606,6 +639,9 @@ do_screen_to_screen_line(voodoo_t *voodoo, uint8_t *src_p, int use_x_dir, int sr uint32_t dest = *(uint32_t *) &voodoo->vram[dst_addr]; uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : voodoo->banshee_blt.colorPattern[(pat_x & 7) + (pat_y & 7) * 8]; + if (dst_addr > voodoo->fb_mask) + break; + *(uint32_t *) &voodoo->vram[dst_addr] = MIX(voodoo, dest, src, pattern, COLORKEY_32, COLORKEY_32); voodoo->changedvram[dst_addr >> 12] = changeframecount; break; @@ -904,6 +940,9 @@ do_screen_to_screen_stretch_line(voodoo_t *voodoo, uint8_t *src_p, int src_x, in uint32_t dest = voodoo->vram[dst_addr]; uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : colorPattern[(pat_x & 7) + (pat_y & 7) * 8]; + if (dst_addr > voodoo->fb_mask) + break; + voodoo->vram[dst_addr] = MIX(voodoo, dest, src, pattern, COLORKEY_8, COLORKEY_8); #if 0 bansheeblt_log("%i,%i : sdp=%02x,%02x,%02x res=%02x\n", voodoo->banshee_blt.cur_x, voodoo->banshee_blt.cur_y, src, dest, pattern, voodoo->vram[dst_addr]); @@ -918,6 +957,9 @@ do_screen_to_screen_stretch_line(voodoo_t *voodoo, uint8_t *src_p, int src_x, in uint32_t dest = *(uint16_t *) &voodoo->vram[dst_addr]; uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : colorPattern[(pat_x & 7) + (pat_y & 7) * 8]; + if (dst_addr > voodoo->fb_mask) + break; + *(uint16_t *) &voodoo->vram[dst_addr] = MIX(voodoo, dest, src, pattern, COLORKEY_16, COLORKEY_16); #if 0 bansheeblt_log("%i,%i : sdp=%02x,%02x,%02x res=%02x\n", voodoo->banshee_blt.cur_x, voodoo->banshee_blt.cur_y, src, dest, pattern, *(uint16_t *)&voodoo->vram[dst_addr]); @@ -932,6 +974,9 @@ do_screen_to_screen_stretch_line(voodoo_t *voodoo, uint8_t *src_p, int src_x, in uint32_t dest = *(uint32_t *) &voodoo->vram[dst_addr]; uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : colorPattern[(pat_x & 7) + (pat_y & 7) * 8]; + if (dst_addr > voodoo->fb_mask) + break; + *(uint32_t *) &voodoo->vram[dst_addr] = (MIX(voodoo, dest, src, pattern, COLORKEY_32, COLORKEY_32) & 0xffffff) | (*(uint32_t *) &voodoo->vram[dst_addr] & 0xff000000); #if 0 bansheeblt_log("%i,%i : sdp=%02x,%02x,%02x res=%02x\n", voodoo->banshee_blt.cur_x, voodoo->banshee_blt.cur_y, src, dest, pattern, voodoo->vram[dst_addr]); @@ -946,6 +991,9 @@ do_screen_to_screen_stretch_line(voodoo_t *voodoo, uint8_t *src_p, int src_x, in uint32_t dest = *(uint32_t *) &voodoo->vram[dst_addr]; uint32_t pattern = (voodoo->banshee_blt.command & COMMAND_PATTERN_MONO) ? ((pattern_mask & (1 << (7 - (pat_x & 7)))) ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack) : colorPattern[(pat_x & 7) + (pat_y & 7) * 8]; + if (dst_addr > voodoo->fb_mask) + break; + *(uint32_t *) &voodoo->vram[dst_addr] = MIX(voodoo, dest, src, pattern, COLORKEY_32, COLORKEY_32); #if 0 bansheeblt_log("%i,%i : sdp=%02x,%02x,%02x res=%02x\n", voodoo->banshee_blt.cur_x, voodoo->banshee_blt.cur_y, src, dest, pattern, voodoo->vram[dst_addr]); diff --git a/src/video/vid_voodoo_render.c b/src/video/vid_voodoo_render.c index 42426744a5..0f31fbc9f7 100644 --- a/src/video/vid_voodoo_render.c +++ b/src/video/vid_voodoo_render.c @@ -1394,7 +1394,7 @@ voodoo_half_triangle(voodoo_t *voodoo, voodoo_params_t *params, voodoo_state_t * void voodoo_triangle(voodoo_t *voodoo, voodoo_params_t *params, int odd_even) { - voodoo_state_t state; + voodoo_state_t state = { 0 }; int vertexAy_adjusted; int vertexCy_adjusted; int dx; @@ -1406,6 +1406,8 @@ voodoo_triangle(voodoo_t *voodoo, voodoo_params_t *params, int odd_even) int LOD; int lodbias; + state.dx1 = state.dx2 = 0; + voodoo->tri_count++; dx = 8 - (params->vertexAx & 0xf); From 71ecdc1b55b31a81cf64c3358a5c56fe222a2e8b Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 29 Feb 2024 06:52:45 +0100 Subject: [PATCH 3/4] No longer raise TS# when (CS & 0xFFF8) is zero and (CS & 0x0004) is not, fixes #4214. --- src/cpu/x86seg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpu/x86seg.c b/src/cpu/x86seg.c index c50c97a399..d912a755bc 100644 --- a/src/cpu/x86seg.c +++ b/src/cpu/x86seg.c @@ -2401,7 +2401,7 @@ taskswitch286(uint16_t seg, uint16_t *segdat, int is32) ldt.base |= (readmemb(0, templ + 7) << 24); } - if (!(new_cs & 0xfff8)) { + if (!(new_cs & 0xfff8) && !(new_cs & 0x0004)) { x86ts(NULL, 0); return; } From fd31aba2a1e2ffe8c67efe42363d09c470ffcd7b Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Thu, 29 Feb 2024 13:58:05 +0600 Subject: [PATCH 4/4] MGA: Implement X11 hardware cursor --- src/video/vid_mga.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/video/vid_mga.c b/src/video/vid_mga.c index 6b0c563b22..0743035533 100644 --- a/src/video/vid_mga.c +++ b/src/video/vid_mga.c @@ -6016,6 +6016,17 @@ mystique_hwcursor_draw(svga_t *svga, int displine) } break; + case XCURCTRL_CURMODE_XWIN: + for (uint8_t x = 0; x < 64; x++) { + if ((dat[1] & (1ULL << 63))) + svga->monitor->target_buffer->line[displine][(offset + svga->x_add) & 2047] = (dat[0] & (1ULL << 63)) ? (mystique->cursor.col[1]) : (mystique->cursor.col[0]); + + offset++; + dat[0] <<= 1; + dat[1] <<= 1; + } + break; + default: break; }