From 462ff300dab267808d95b68d5c756e0076ada87e Mon Sep 17 00:00:00 2001 From: TC1995 Date: Tue, 1 Dec 2020 21:06:01 +0100 Subject: [PATCH] Ported the most important patches from PCem. --- src/cpu/386_common.c | 4 +++ src/video/vid_voodoo_banshee.c | 41 ++++++++++++++++++++++---- src/video/vid_voodoo_banshee_blitter.c | 25 ++++++++++++---- 3 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/cpu/386_common.c b/src/cpu/386_common.c index 59ae935a1..062926e0a 100644 --- a/src/cpu/386_common.c +++ b/src/cpu/386_common.c @@ -1169,6 +1169,8 @@ enter_smm(int in_hlt) flushmmucache(); } + + oldcpl = 0; cpu_cur_status &= ~(CPU_STATUS_PMODE | CPU_STATUS_V86); CPU_BLOCK_END(); @@ -1265,6 +1267,8 @@ leave_smm(void) nmi_mask = 1; + oldcpl = CPL; + CPU_BLOCK_END(); x386_common_log("CS : seg = %04X, base = %08X, limit = %08X, limit_low = %08X, limit_high = %08X, access = %02X, ar_high = %02X\n", diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index 2be43715c..2d3a378d5 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -2357,11 +2357,11 @@ static uint8_t banshee_pci_read(int func, int addr, void *p) case 0x1a: ret = 0x00; break; case 0x1b: ret = 0x00; break; - /*Undocumented, but Voodoo 3 BIOS checks this*/ - case 0x2c: ret = 0x1a; break; - case 0x2d: ret = 0x12; break; - case 0x2e: ret = (banshee->type == TYPE_V3_3000) ? 0x3a : 0x30; break; - case 0x2f: ret = 0x00; break; + /*Subsystem vendor ID*/ + case 0x2c: ret = banshee->pci_regs[0x2c]; break; + case 0x2d: ret = banshee->pci_regs[0x2d]; break; + case 0x2e: ret = banshee->pci_regs[0x2e]; break; + case 0x2f: ret = banshee->pci_regs[0x2f]; break; case 0x30: ret = banshee->pci_regs[0x30] & 0x01; break; /*BIOS ROM address*/ case 0x31: ret = 0x00; break; @@ -2667,6 +2667,37 @@ static void *banshee_init_common(const device_t *info, wchar_t *fn, int has_sgra banshee->i2c_ddc = i2c_gpio_init("ddc_voodoo_banshee"); banshee->ddc = ddc_init(i2c_gpio_get_bus(banshee->i2c_ddc)); + switch (type) + { + case TYPE_BANSHEE: + if (has_sgram) { + banshee->pci_regs[0x2c] = 0x1a; + banshee->pci_regs[0x2d] = 0x12; + banshee->pci_regs[0x2e] = 0x04; + banshee->pci_regs[0x2f] = 0x00; + } else { + banshee->pci_regs[0x2c] = 0x02; + banshee->pci_regs[0x2d] = 0x11; + banshee->pci_regs[0x2e] = 0x17; + banshee->pci_regs[0x2f] = 0x10; + } + break; + + case TYPE_V3_2000: + banshee->pci_regs[0x2c] = 0x1a; + banshee->pci_regs[0x2d] = 0x12; + banshee->pci_regs[0x2e] = 0x30; + banshee->pci_regs[0x2f] = 0x00; + break; + + case TYPE_V3_3000: + banshee->pci_regs[0x2c] = 0x1a; + banshee->pci_regs[0x2d] = 0x12; + banshee->pci_regs[0x2e] = 0x3a; + banshee->pci_regs[0x2f] = 0x00; + break; + } + video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_banshee); return banshee; diff --git a/src/video/vid_voodoo_banshee_blitter.c b/src/video/vid_voodoo_banshee_blitter.c index d86ff8eb9..13ed8edbd 100644 --- a/src/video/vid_voodoo_banshee_blitter.c +++ b/src/video/vid_voodoo_banshee_blitter.c @@ -918,7 +918,7 @@ static void step_line(voodoo_t *voodoo) } -static void banshee_do_line(voodoo_t *voodoo) +static void banshee_do_line(voodoo_t *voodoo, int draw_last_pixel) { clip_t *clip = &voodoo->banshee_blt.clip[(voodoo->banshee_blt.command & COMMAND_CLIP_SEL) ? 1 : 0]; uint8_t rop = voodoo->banshee_blt.command >> 24; @@ -975,6 +975,15 @@ static void banshee_do_line(voodoo_t *voodoo) } } + if (draw_last_pixel) + { + int mask = stipple & (1 << voodoo->banshee_blt.line_bit_pos); + int pattern_trans = (voodoo->banshee_blt.command & COMMAND_TRANS_MONO) ? mask : 1; + + if (y >= clip->y_min && y < clip->y_max && x >= clip->x_min && x < clip->x_max && pattern_trans) + PLOT_LINE(voodoo, x, y, rop, mask ? voodoo->banshee_blt.colorFore : voodoo->banshee_blt.colorBack, COLORKEY_32); + } + voodoo->banshee_blt.srcXY = (x & 0xffff) | (y << 16); voodoo->banshee_blt.srcX = x; voodoo->banshee_blt.srcY = y; @@ -1112,8 +1121,12 @@ static void banshee_do_2d_blit(voodoo_t *voodoo, int count, uint32_t data) banshee_do_rectfill(voodoo); break; + case COMMAND_CMD_LINE: + banshee_do_line(voodoo, 1); + break; + case COMMAND_CMD_POLYLINE: - banshee_do_line(voodoo); + banshee_do_line(voodoo, 0); break; default: @@ -1386,18 +1399,18 @@ void voodoo_2d_reg_writel(voodoo_t *voodoo, uint32_t addr, uint32_t val) banshee_do_rectfill(voodoo); break; -/* case COMMAND_CMD_LINE: + case COMMAND_CMD_LINE: voodoo->banshee_blt.dstXY = val; voodoo->banshee_blt.dstX = ((int32_t)(val << 19)) >> 19; voodoo->banshee_blt.dstY = ((int32_t)(val << 3)) >> 19; - banshee_do_line(voodoo); - break;*/ + banshee_do_line(voodoo, 1); + break; case COMMAND_CMD_POLYLINE: voodoo->banshee_blt.dstXY = val; voodoo->banshee_blt.dstX = ((int32_t)(val << 19)) >> 19; voodoo->banshee_blt.dstY = ((int32_t)(val << 3)) >> 19; - banshee_do_line(voodoo); + banshee_do_line(voodoo, 0); break; case COMMAND_CMD_POLYFILL: