From f8569950de57f0b12eb48aa58fc733f52801b43f Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 18 Nov 2020 05:46:08 +0100 Subject: [PATCH 01/10] Removed code from win/win_settings.c that was doing what should never have been done, fixes the multiple selections that shouldn't have been in the Settings dialog. --- src/win/win_settings.c | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 89cdc504b..215f1f7ab 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -3096,13 +3096,6 @@ win_settings_hard_disks_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPar lv1_current_sel = get_selected_hard_disk(hdlg); if (lv1_current_sel == old_sel) return FALSE; - else if (lv1_current_sel == -1) { - ignore_change = 1; - lv1_current_sel = old_sel; - settings_listview_select(hdlg, IDC_LIST_HARD_DISKS, lv1_current_sel); - ignore_change = 0; - return FALSE; - } ignore_change = 1; settings_set_cur_sel(hdlg, IDC_COMBO_HD_BUS, temp_hdd[lv1_current_sel].bus - 1); recalc_location_controls(hdlg, 0, 0); @@ -4179,13 +4172,6 @@ win_settings_floppy_and_cdrom_drives_proc(HWND hdlg, UINT message, WPARAM wParam lv1_current_sel = get_selected_drive(hdlg, IDC_LIST_FLOPPY_DRIVES); if (lv1_current_sel == old_sel) return FALSE; - else if (lv1_current_sel == -1) { - ignore_change = 1; - lv1_current_sel = old_sel; - settings_listview_select(hdlg, IDC_LIST_FLOPPY_DRIVES, lv1_current_sel); - ignore_change = 0; - return FALSE; - } ignore_change = 1; settings_set_cur_sel(hdlg, IDC_COMBO_FD_TYPE, temp_fdd_types[lv1_current_sel]); settings_set_check(hdlg, IDC_CHECKTURBO, temp_fdd_turbo[lv1_current_sel]); @@ -4196,13 +4182,6 @@ win_settings_floppy_and_cdrom_drives_proc(HWND hdlg, UINT message, WPARAM wParam lv2_current_sel = get_selected_drive(hdlg, IDC_LIST_CDROM_DRIVES); if (lv2_current_sel == old_sel) return FALSE; - else if (lv2_current_sel == -1) { - ignore_change = 1; - lv2_current_sel = old_sel; - settings_listview_select(hdlg, IDC_LIST_CDROM_DRIVES, lv2_current_sel); - ignore_change = 0; - return FALSE; - } ignore_change = 1; switch (temp_cdrom[lv2_current_sel].bus_type) { @@ -4377,13 +4356,6 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam lv1_current_sel = get_selected_drive(hdlg, IDC_LIST_MO_DRIVES); if (lv1_current_sel == old_sel) return FALSE; - else if (lv1_current_sel == -1) { - ignore_change = 1; - lv1_current_sel = old_sel; - settings_listview_select(hdlg, IDC_LIST_MO_DRIVES, lv1_current_sel); - ignore_change = 0; - return FALSE; - } ignore_change = 1; switch (temp_mo_drives[lv1_current_sel].bus_type) { @@ -4407,13 +4379,6 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam lv2_current_sel = get_selected_drive(hdlg, IDC_LIST_ZIP_DRIVES); if (lv2_current_sel == old_sel) return FALSE; - else if (lv2_current_sel == -1) { - ignore_change = 1; - lv2_current_sel = old_sel; - settings_listview_select(hdlg, IDC_LIST_ZIP_DRIVES, lv2_current_sel); - ignore_change = 0; - return FALSE; - } ignore_change = 1; switch (temp_zip_drives[lv2_current_sel].bus_type) { From 9fb3a3ed5617c7cf2dabcbce0e235a678530511a Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 18 Nov 2020 06:00:13 +0100 Subject: [PATCH 02/10] Fixed a warning in cpu/cpu_table.c. --- src/cpu/cpu_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpu/cpu_table.c b/src/cpu/cpu_table.c index cf0e4cd20..5f0f7d3dd 100644 --- a/src/cpu/cpu_table.c +++ b/src/cpu/cpu_table.c @@ -1215,5 +1215,5 @@ cpu_legacy_machine_t cpu_legacy_table[] = { {"p6bap", {cpus_Celeron, cpus_Cyrix3}}, {"603tcf", {cpus_Celeron, cpus_Cyrix3}}, {"vpc2007", {cpus_PentiumIID, cpus_Celeron}}, - {NULL, NULL} + {NULL, {NULL}} }; From 85089127cf678163b2405abbdec41f7a44d470f2 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Wed, 18 Nov 2020 13:33:10 +0100 Subject: [PATCH 03/10] Fixed busy status on the S3 family of chips using the fifo. --- src/video/vid_s3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/vid_s3.c b/src/video/vid_s3.c index 85aaf22d9..704d193ae 100644 --- a/src/video/vid_s3.c +++ b/src/video/vid_s3.c @@ -2664,7 +2664,7 @@ s3_accel_in(uint16_t port, void *p) wake_fifo_thread(s3); temp = 0; if ((s3->chip >= S3_86C928) && s3_enable_fifo(s3)) { - if (!FIFO_EMPTY || s3->busy || s3->force_busy) + if (!FIFO_EMPTY || s3->force_busy) temp |= 0x02; /*Hardware busy*/ else temp |= 0x04; /*FIFO empty*/ From 9e4acc08b81a1fc4ae4a48d1263e16c9674cfc29 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Wed, 18 Nov 2020 13:33:10 +0100 Subject: [PATCH 04/10] Fixed busy status on the S3 family of chips using the fifo. --- src/video/vid_s3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/vid_s3.c b/src/video/vid_s3.c index 85aaf22d9..704d193ae 100644 --- a/src/video/vid_s3.c +++ b/src/video/vid_s3.c @@ -2664,7 +2664,7 @@ s3_accel_in(uint16_t port, void *p) wake_fifo_thread(s3); temp = 0; if ((s3->chip >= S3_86C928) && s3_enable_fifo(s3)) { - if (!FIFO_EMPTY || s3->busy || s3->force_busy) + if (!FIFO_EMPTY || s3->force_busy) temp |= 0x02; /*Hardware busy*/ else temp |= 0x04; /*FIFO empty*/ From 889c19c650a1b8941917903cefb7e9a5a6697b92 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 18 Nov 2020 16:15:01 +0100 Subject: [PATCH 05/10] The Voodoos now correctly lock and unlock mutexes. --- src/video/vid_voodoo.c | 4 ++++ src/video/vid_voodoo_banshee.c | 6 ++++++ src/video/vid_voodoo_display.c | 8 ++++++++ src/video/vid_voodoo_fifo.c | 4 ++++ src/video/vid_voodoo_reg.c | 4 ++++ 5 files changed, 26 insertions(+) diff --git a/src/video/vid_voodoo.c b/src/video/vid_voodoo.c index da9ab2038..74dd5723b 100644 --- a/src/video/vid_voodoo.c +++ b/src/video/vid_voodoo.c @@ -450,7 +450,9 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) case SST_swapbufferCMD: voodoo->cmd_written++; + thread_wait_mutex(voodoo->swap_mutex); voodoo->swap_count++; + thread_release_mutex(voodoo->swap_mutex); if (voodoo->fbiInit7 & FBIINIT7_CMDFIFO_ENABLE) return; voodoo_queue_command(voodoo, addr | FIFO_WRITEL_REG, val); @@ -531,7 +533,9 @@ static void voodoo_writel(uint32_t addr, uint32_t val, void *p) if ((voodoo->fbiInit1 & FBIINIT1_VIDEO_RESET) && !(val & FBIINIT1_VIDEO_RESET)) { voodoo->line = 0; + thread_wait_mutex(voodoo->swap_mutex); voodoo->swap_count = 0; + thread_release_mutex(voodoo->swap_mutex); voodoo->retrace_count = 0; } voodoo->fbiInit1 = (val & ~5) | (voodoo->fbiInit1 & 5); diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index 4399e4fe9..bea894523 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -1307,7 +1307,9 @@ static void banshee_reg_writel(uint32_t addr, uint32_t val, void *p) break; case SST_swapPending: + thread_wait_mutex(voodoo->swap_mutex); voodoo->swap_count++; + thread_release_mutex(voodoo->swap_mutex); // voodoo->cmd_written++; break; @@ -2246,11 +2248,13 @@ static void banshee_vsync_callback(svga_t *svga) voodoo_t *voodoo = banshee->voodoo; voodoo->retrace_count++; + thread_wait_mutex(voodoo->swap_mutex); if (voodoo->swap_pending && (voodoo->retrace_count > voodoo->swap_interval)) { if (voodoo->swap_count > 0) voodoo->swap_count--; voodoo->swap_pending = 0; + thread_release_mutex(voodoo->swap_mutex); memset(voodoo->dirty_line, 1, sizeof(voodoo->dirty_line)); voodoo->retrace_count = 0; @@ -2258,6 +2262,8 @@ static void banshee_vsync_callback(svga_t *svga) thread_set_event(voodoo->wake_fifo_thread); voodoo->frame_count++; } + else + thread_release_mutex(voodoo->swap_mutex); voodoo->overlay.src_y = 0; banshee->desktop_addr = banshee->vidDesktopStartAddr; diff --git a/src/video/vid_voodoo_display.c b/src/video/vid_voodoo_display.c index fad39ac19..a3548920a 100644 --- a/src/video/vid_voodoo_display.c +++ b/src/video/vid_voodoo_display.c @@ -574,6 +574,7 @@ skip_draw: { voodoo_t *voodoo_1 = voodoo->set->voodoos[1]; + thread_wait_mutex(voodoo->swap_mutex); /*Only swap if both Voodoos are waiting for buffer swap*/ if (voodoo->swap_pending && (voodoo->retrace_count > voodoo->swap_interval) && voodoo_1->swap_pending && (voodoo_1->retrace_count > voodoo_1->swap_interval)) @@ -591,6 +592,7 @@ skip_draw: if (voodoo_1->swap_count > 0) voodoo_1->swap_count--; voodoo_1->swap_pending = 0; + thread_release_mutex(voodoo->swap_mutex); thread_set_event(voodoo->wake_fifo_thread); thread_set_event(voodoo_1->wake_fifo_thread); @@ -598,22 +600,28 @@ skip_draw: voodoo->frame_count++; voodoo_1->frame_count++; } + else + thread_release_mutex(voodoo->swap_mutex); } } else { + thread_wait_mutex(voodoo->swap_mutex); if (voodoo->swap_pending && (voodoo->retrace_count > voodoo->swap_interval)) { voodoo->front_offset = voodoo->swap_offset; if (voodoo->swap_count > 0) voodoo->swap_count--; voodoo->swap_pending = 0; + thread_release_mutex(voodoo->swap_mutex); memset(voodoo->dirty_line, 1, 1024); voodoo->retrace_count = 0; thread_set_event(voodoo->wake_fifo_thread); voodoo->frame_count++; } + else + thread_release_mutex(voodoo->swap_mutex); } voodoo->v_retrace = 1; } diff --git a/src/video/vid_voodoo_fifo.c b/src/video/vid_voodoo_fifo.c index c6e09ad37..597c45051 100644 --- a/src/video/vid_voodoo_fifo.c +++ b/src/video/vid_voodoo_fifo.c @@ -134,6 +134,7 @@ void voodoo_wait_for_swap_complete(voodoo_t *voodoo) thread_wait_event(voodoo->wake_fifo_thread, -1); thread_reset_event(voodoo->wake_fifo_thread); + thread_wait_mutex(voodoo->swap_mutex); if ((voodoo->swap_pending && voodoo->flush) || FIFO_FULL) { /*Main thread is waiting for FIFO to empty, so skip vsync wait and just swap*/ @@ -142,8 +143,11 @@ void voodoo_wait_for_swap_complete(voodoo_t *voodoo) if (voodoo->swap_count > 0) voodoo->swap_count--; voodoo->swap_pending = 0; + thread_release_mutex(voodoo->swap_mutex);; break; } + else + thread_release_mutex(voodoo->swap_mutex);; } } diff --git a/src/video/vid_voodoo_reg.c b/src/video/vid_voodoo_reg.c index 2daa3975c..2f3460e65 100644 --- a/src/video/vid_voodoo_reg.c +++ b/src/video/vid_voodoo_reg.c @@ -100,8 +100,10 @@ void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) if (!(val & 1)) { banshee_set_overlay_addr(voodoo->p, voodoo->leftOverlayBuf); + thread_wait_mutex(voodoo->swap_mutex); if (voodoo->swap_count > 0) voodoo->swap_count--; + thread_release_mutex(voodoo->swap_mutex); voodoo->frame_count++; } else if (TRIPLE_BUFFER) @@ -146,8 +148,10 @@ void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) { memset(voodoo->dirty_line, 1, sizeof(voodoo->dirty_line)); voodoo->front_offset = voodoo->params.front_offset; + thread_wait_mutex(voodoo->swap_mutex); if (voodoo->swap_count > 0) voodoo->swap_count--; + thread_release_mutex(voodoo->swap_mutex); } else if (TRIPLE_BUFFER) { From 5ce5685c1ab27ab7408a3ef5954bf913df0fdca1 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 18 Nov 2020 16:18:45 +0100 Subject: [PATCH 06/10] Fixed Banshee hardware cursor offset. --- src/video/vid_voodoo_banshee.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index bea894523..5676a64d2 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -656,7 +656,7 @@ static void banshee_ext_outl(uint16_t addr, uint32_t val, void *p) break; case Video_hwCurLoc: banshee->hwCurLoc = val; - svga->hwcursor.x = (val & 0x7ff) - 32; + svga->hwcursor.x = (val & 0x7ff) - 64; svga->hwcursor.y = ((val >> 16) & 0x7ff) - 64; if (svga->hwcursor.y < 0) { From e8266cd716aa9ef5fa690c93b6012e39f774b317 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 18 Nov 2020 16:21:09 +0100 Subject: [PATCH 07/10] Another Banshee cursor fix. --- src/video/vid_voodoo_banshee.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index 5676a64d2..1a94aaf2d 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -1604,7 +1604,7 @@ void banshee_hwcursor_draw(svga_t *svga, int displine) /*X11 mode*/ for (x = 0; x < 64; x += 8) { - if (x_off > (32-8)) + if (x_off > -8) { for (xx = 0; xx < 8; xx++) { @@ -1624,7 +1624,7 @@ void banshee_hwcursor_draw(svga_t *svga, int displine) /*Windows mode*/ for (x = 0; x < 64; x += 8) { - if (x_off > (32-8)) + if (x_off > -8) { for (xx = 0; xx < 8; xx++) { From 31c78fddf301b8c383c0ea17c5c3a6e8630ba0ec Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 18 Nov 2020 16:56:35 +0100 Subject: [PATCH 08/10] Fixed Voodoo 3D rendering. --- src/video/vid_voodoo_display.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/video/vid_voodoo_display.c b/src/video/vid_voodoo_display.c index a3548920a..3a7df1ab3 100644 --- a/src/video/vid_voodoo_display.c +++ b/src/video/vid_voodoo_display.c @@ -525,7 +525,7 @@ void voodoo_callback(void *p) if (draw_voodoo->dirty_line[draw_line]) { - uint32_t *p = &((uint32_t *)buffer32->line[voodoo->line])[32]; + uint32_t *p = &buffer32->line[voodoo->line + 8][8]; uint16_t *src = (uint16_t *)&draw_voodoo->fb_mem[draw_voodoo->front_offset + draw_line*draw_voodoo->row_width]; int x; @@ -539,6 +539,10 @@ void voodoo_callback(void *p) if (voodoo->line > voodoo->dirty_line_high) voodoo->dirty_line_high = voodoo->line; + /* Draw left overscan. */ + for (x = 0; x < 8; x++) + buffer32->line[voodoo->line + 8][x] = 0x00000000; + if (voodoo->scrfilter && voodoo->scrfilterEnabled) { uint8_t fil[(voodoo->h_disp) * 3]; /* interleaved 24-bit RGB */ @@ -560,6 +564,10 @@ void voodoo_callback(void *p) p[x] = draw_voodoo->video_16to32[src[x]]; } } + + /* Draw right overscan. */ + for (x = 0; x < 8; x++) + buffer32->line[voodoo->line + 8][voodoo->h_disp + x + 8] = 0x00000000; } } } From 9a2517c4153b7a1214899605225660a175af9470 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Wed, 18 Nov 2020 21:59:19 +0100 Subject: [PATCH 09/10] Ported the latest fixes from PCem about the Voodoo Banshee and 1/2. --- src/video/vid_voodoo.c | 2 ++ src/video/vid_voodoo_banshee.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/video/vid_voodoo.c b/src/video/vid_voodoo.c index 74dd5723b..d9929324a 100644 --- a/src/video/vid_voodoo.c +++ b/src/video/vid_voodoo.c @@ -139,7 +139,9 @@ void voodoo_recalc(voodoo_t *voodoo) if (voodoo->fbiInit1 & (1 << 24)) voodoo->block_width += 32; voodoo->row_width = voodoo->block_width * 32 * 2; + voodoo->params.row_width = voodoo->row_width; voodoo->aux_row_width = voodoo->row_width; + voodoo->params.aux_row_width = voodoo->aux_row_width; } diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index 1a94aaf2d..dcfdf8841 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -1673,10 +1673,11 @@ void banshee_hwcursor_draw(svga_t *svga, int displine) { \ int c; \ int wp = 0; \ + uint32_t base_addr = buf ? src_addr2 : src_addr; \ \ for (c = 0; c < voodoo->overlay.overlay_bytes; c += 2) \ { \ - uint16_t data = *(uint16_t *)&src[(c & 127) + (c >> 7)*128*32]; \ + uint16_t data = *(uint16_t *)&svga->vram[(base_addr + (c & 127) + (c >> 7)*128*32) & svga->vram_mask]; \ int r = data & 0x1f; \ int g = (data >> 5) & 0x3f; \ int b = data >> 11; \ @@ -1972,7 +1973,8 @@ static void banshee_overlay_draw(svga_t *svga, int displine) !(banshee->vidProcCfg & VIDPROCCFG_H_SCALE_ENABLE) && !(banshee->vidProcCfg & VIDPROCCFG_FILTER_MODE_DITHER_4X4) && !(banshee->vidProcCfg & VIDPROCCFG_FILTER_MODE_DITHER_2X2)); else - skip_filtering = ((banshee->vidProcCfg & VIDPROCCFG_FILTER_MODE_MASK) != VIDPROCCFG_FILTER_MODE_BILINEAR); + skip_filtering = ((banshee->vidProcCfg & VIDPROCCFG_FILTER_MODE_MASK) != VIDPROCCFG_FILTER_MODE_BILINEAR && + !(banshee->vidProcCfg & VIDPROCCFG_H_SCALE_ENABLE)); if (skip_filtering) { From f8744370093d2f03637ce6b7a9bf95aef597a7fe Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 18 Nov 2020 22:15:21 +0100 Subject: [PATCH 10/10] The Voodoo Banshee / 3 cards now inform video.c of their timings. --- src/video/vid_voodoo_banshee.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index dcfdf8841..bbe86cb73 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -43,6 +43,9 @@ #include <86box/vid_voodoo_render.h> +static video_timings_t timing_banshee = {VIDEO_BUS, 2, 2, 1, 20, 20, 21}; + + #ifdef CLAMP #undef CLAMP #endif @@ -2624,6 +2627,8 @@ static void *banshee_init_common(const device_t *info, wchar_t *fn, int has_sgra ddc_init(); + video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_banshee); + return banshee; }