From 42d49564b7108211d647fef4b6da10b5d00f620c Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 30 Jul 2021 01:39:33 +0200 Subject: [PATCH 01/15] 32 kB raw cartridges are now loaded at the correct offset. --- src/device/cartridge.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/device/cartridge.c b/src/device/cartridge.c index 894262aa3..25e8beac7 100644 --- a/src/device/cartridge.c +++ b/src/device/cartridge.c @@ -128,6 +128,8 @@ cart_image_load(int drive, char *fn) fclose(f); } else { base = drive ? 0xe0000 : 0xd0000; + if (size == 32768) + base += 0x8000; fseek(f, 0x00000000, SEEK_SET); carts[drive].buf = (uint8_t *) malloc(size); memset(carts[drive].buf, 0x00, size); From 24002d1882ab2e5260ea3e6e2bc2f147fdc74530 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 30 Jul 2021 02:08:07 +0200 Subject: [PATCH 02/15] More cartridge-related fixes. --- src/win/win_media_menu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/win/win_media_menu.c b/src/win/win_media_menu.c index f72c2aae1..cb50a418f 100644 --- a/src/win/win_media_menu.c +++ b/src/win/win_media_menu.c @@ -103,11 +103,11 @@ media_menu_set_name_cartridge(int drive) wchar_t name[512], fn[512]; MENUITEMINFO mii = { 0 }; - if (strlen(floppyfns[drive]) == 0) { + if (strlen(cart_fns[drive]) == 0) { _swprintf(name, plat_get_string(IDS_2150), drive + 1, plat_get_string(IDS_2057)); } else { - mbstoc16s(fn, floppyfns[drive], sizeof_w(fn)); + mbstoc16s(fn, cart_fns[drive], sizeof_w(fn)); _swprintf(name, plat_get_string(IDS_2150), drive + 1, fn); } @@ -608,7 +608,7 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case IDM_CARTRIDGE_IMAGE: - ret = file_dlg_st(hwnd, IDS_2151, floppyfns[id], NULL, 0); + ret = file_dlg_st(hwnd, IDS_2151, cart_fns[id], NULL, 0); if (! ret) cartridge_mount(id, openfilestring, wp); break; From 3c64da96bd8b76413cd8a08bc99bc4bc0e03cc4f Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 30 Jul 2021 03:41:32 +0200 Subject: [PATCH 03/15] More Hercules fixes, closes #1566. --- src/video/vid_hercules.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/video/vid_hercules.c b/src/video/vid_hercules.c index 05f126110..49a860835 100644 --- a/src/video/vid_hercules.c +++ b/src/video/vid_hercules.c @@ -63,6 +63,8 @@ typedef struct { int vsynctime; int vadj; + int lp_ff; + int cols[256][2][2]; uint8_t *vram; @@ -148,6 +150,11 @@ hercules_out(uint16_t addr, uint8_t val, void *priv) recalc_timings(dev); break; + case 0x03b9: + case 0x03bb: + dev->lp_ff = !(addr & 0x0002); + break; + case 0x03bf: old = dev->ctrl2; dev->ctrl2 = val; @@ -183,7 +190,9 @@ hercules_in(uint16_t addr, void *priv) break; case 0x03ba: - ret = 0x72; /* Hercules ident */ + // ret = 0x72; /* Hercules ident */ + ret = 0x70; /* Hercules ident */ + ret |= (dev->lp_ff ? 2 : 0); #if 0 if (dev->stat & 0x08) ret |= 0x88; @@ -221,10 +230,15 @@ hercules_write(uint32_t addr, uint8_t val, void *priv) { hercules_t *dev = (hercules_t *)priv; - if (dev->ctrl2 & 0x01) - dev->vram[addr & 0xffff] = val; - else - dev->vram[addr & 0x0fff] = val; + /* According to the Programmer's guide to the Hercules graphics cars + by David B. Doty from 1988, the CTRL2 modes (bits 1,0) are as follow: + - 00: DIAG: Text mode only, only page 0 accessible; + - 01: HALF: Graphics mode allowed, only page 0 accessible; + - 11: FULL: Graphics mode allowed, both pages accessible. */ + if ((addr >= 0xb8000) && ((dev->ctrl2 & 0x03) != 0x03)) + return; + + dev->vram[addr & 0xffff] = val; hercules_waitstates(dev); } @@ -235,10 +249,10 @@ hercules_read(uint32_t addr, void *priv) { hercules_t *dev = (hercules_t *)priv; - if (dev->ctrl2 & 0x01) - return(dev->vram[addr & 0xffff]); - else - return(dev->vram[addr & 0x0fff]); + if ((addr >= 0xb8000) && ((dev->ctrl2 & 0x03) != 0x03)) + return 0xff; + + return(dev->vram[addr & 0xffff]); hercules_waitstates(dev); } From d1991ac763c3d4f4241cd8de03787ddebc8c5093 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 30 Jul 2021 04:01:46 +0200 Subject: [PATCH 04/15] Added the ability to hide the status bar, closes #1530. --- src/config.c | 8 +++++++ src/include/86box/plat.h | 2 +- src/include/86box/resource.h | 3 +-- src/win/86Box.rc | 2 ++ src/win/win.c | 10 +++++++-- src/win/win_ui.c | 43 +++++++++++++++++++++++++++++++----- 6 files changed, 57 insertions(+), 11 deletions(-) diff --git a/src/config.c b/src/config.c index 08969bc3f..9525dc7e2 100644 --- a/src/config.c +++ b/src/config.c @@ -532,7 +532,9 @@ load_general(void) } sound_gain = config_get_int(cat, "sound_gain", 0); + kbd_req_capture = config_get_int(cat, "kbd_req_capture", 0); + hide_status_bar = config_get_int(cat, "hide_status_bar", 0); confirm_reset = config_get_int(cat, "confirm_reset", 1); confirm_exit = config_get_int(cat, "confirm_exit", 1); @@ -1972,6 +1974,7 @@ config_load(void) plat_langid = 0x0409; #endif kbd_req_capture = 0; + hide_status_bar = 0; scale = 1; machine = machine_get_machine_from_internal_name("ibmpc"); @@ -2150,6 +2153,11 @@ save_general(void) else config_delete_var(cat, "kbd_req_capture"); + if (hide_status_bar != 0) + config_set_int(cat, "hide_status_bar", hide_status_bar); + else + config_delete_var(cat, "hide_status_bar"); + if (confirm_reset != 1) config_set_int(cat, "confirm_reset", confirm_reset); else diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index 208d7d3bd..301d9a4ef 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -80,7 +80,7 @@ extern int update_icons; extern int unscaled_size_x, /* current unscaled size X */ unscaled_size_y; /* current unscaled size Y */ -extern int kbd_req_capture; +extern int kbd_req_capture, hide_status_bar; /* System-related functions. */ extern char *fix_exe_path(char *str); diff --git a/src/include/86box/resource.h b/src/include/86box/resource.h index 91291dfd8..7ce6edd18 100644 --- a/src/include/86box/resource.h +++ b/src/include/86box/resource.h @@ -307,8 +307,7 @@ #define IDM_ACTION_TRACE 40020 #endif #define IDM_CONFIG 40020 -#define IDM_CONFIG_LOAD 40021 -#define IDM_CONFIG_SAVE 40022 +#define IDM_VID_HIDE_STATUS_BAR 40021 #define IDM_UPDATE_ICONS 40030 #define IDM_VID_RESIZE 40040 #define IDM_VID_REMEMBER 40041 diff --git a/src/win/86Box.rc b/src/win/86Box.rc index c5205f85f..2ee41aec1 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -59,6 +59,8 @@ BEGIN END POPUP "&View" BEGIN + MENUITEM "&Hide status bar", IDM_VID_HIDE_STATUS_BAR + MENUITEM SEPARATOR MENUITEM "&Resizeable window", IDM_VID_RESIZE MENUITEM "R&emember size && position", IDM_VID_REMEMBER MENUITEM SEPARATOR diff --git a/src/win/win.c b/src/win/win.c index 12655373e..ff7726459 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -1075,7 +1075,10 @@ plat_setfullscreen(int on) GetClientRect(hwndMain, &rect); temp_x = rect.right - rect.left + 1; - temp_y = rect.bottom - rect.top + 1 - sbar_height; + if (hide_status_bar) + temp_y = rect.bottom - rect.top + 1; + else + temp_y = rect.bottom - rect.top + 1 - sbar_height; } else { if (dpi_scale) { temp_x = MulDiv((vid_resize & 2) ? fixed_size_x : unscaled_size_x, dpi, 96); @@ -1086,7 +1089,10 @@ plat_setfullscreen(int on) } /* Main Window. */ - ResizeWindowByClientArea(hwndMain, temp_x, temp_y + sbar_height); + if (hide_status_bar) + ResizeWindowByClientArea(hwndMain, temp_x, temp_y); + else + ResizeWindowByClientArea(hwndMain, temp_x, temp_y + sbar_height); } /* Render window. */ diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 237324d0b..251892832 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -68,6 +68,7 @@ int rctrl_is_lalt = 0; int user_resize = 0; int fixed_size_x = 0, fixed_size_y = 0; int kbd_req_capture = 0; +int hide_status_bar = 0; extern char openfilestring[512]; extern WCHAR wopenfilestring[512]; @@ -705,6 +706,18 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) config_save(); break; + case IDM_VID_HIDE_STATUS_BAR: + hide_status_bar ^= 1; + CheckMenuItem(hmenu, IDM_VID_HIDE_STATUS_BAR, hide_status_bar ? MF_CHECKED : MF_UNCHECKED); + ShowWindow(hwndSBAR, hide_status_bar ? SW_HIDE : SW_SHOW); + GetWindowRect(hwnd, &rect); + if (hide_status_bar) + MoveWindow(hwnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top - sbar_height, TRUE); + else + MoveWindow(hwnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top + sbar_height, TRUE); + config_save(); + break; + case IDM_VID_RESIZE: vid_resize ^= 1; CheckMenuItem(hmenu, IDM_VID_RESIZE, (vid_resize & 1) ? MF_CHECKED : MF_UNCHECKED); @@ -723,7 +736,10 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) temp_y = unscaled_size_y; } - ResizeWindowByClientArea(hwnd, temp_x, temp_y + sbar_height); + if (hide_status_bar) + ResizeWindowByClientArea(hwnd, temp_x, temp_y); + else + ResizeWindowByClientArea(hwnd, temp_x, temp_y + sbar_height); if (mouse_capture) { ClipCursor(&rect); @@ -1009,7 +1025,10 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } /* Main Window. */ - ResizeWindowByClientArea(hwndMain, temp_x, temp_y + sbar_height); + if (hide_status_bar) + ResizeWindowByClientArea(hwndMain, temp_x, temp_y); + else + ResizeWindowByClientArea(hwndMain, temp_x, temp_y + sbar_height); } else if (!user_resize) doresize = 1; break; @@ -1039,8 +1058,12 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (!(pos->flags & SWP_NOSIZE) || !user_resize) { plat_vidapi_enable(0); - MoveWindow(hwndSBAR, 0, rect.bottom - sbar_height, sbar_height, rect.right, TRUE); - MoveWindow(hwndRender, 0, 0, rect.right, rect.bottom - sbar_height, TRUE); + if (hide_status_bar) + MoveWindow(hwndRender, 0, 0, rect.right, rect.bottom, TRUE); + else { + MoveWindow(hwndSBAR, 0, rect.bottom - sbar_height, sbar_height, rect.right, TRUE); + MoveWindow(hwndRender, 0, 0, rect.right, rect.bottom - sbar_height, TRUE); + } GetClientRect(hwndRender, &rect); if (dpi_scale) { @@ -1423,6 +1446,8 @@ ui_init(int nCmdShow) /* Get the actual height of the status bar */ GetWindowRect(hwndSBAR, &sbar_rect); sbar_height = sbar_rect.bottom - sbar_rect.top; + if (hide_status_bar) + ShowWindow(hwndSBAR, SW_HIDE); /* Set up main window for resizing if configured. */ if (vid_resize == 1) @@ -1445,7 +1470,10 @@ ui_init(int nCmdShow) scrnsz_x = fixed_size_x; scrnsz_y = fixed_size_y; } - ResizeWindowByClientArea(hwndMain, scrnsz_x, scrnsz_y + sbar_height); + if (hide_status_bar) + ResizeWindowByClientArea(hwndMain, scrnsz_x, scrnsz_y); + else + ResizeWindowByClientArea(hwndMain, scrnsz_x, scrnsz_y + sbar_height); } /* Reset all menus to their defaults. */ @@ -1689,7 +1717,10 @@ plat_resize(int x, int y) x = MulDiv(x, dpi, 96); y = MulDiv(y, dpi, 96); } - ResizeWindowByClientArea(hwndMain, x, y + sbar_height); + if (hide_status_bar) + ResizeWindowByClientArea(hwndMain, x, y); + else + ResizeWindowByClientArea(hwndMain, x, y + sbar_height); } } From 03068f9ee31a7d5dd51c393c41c719c1d8e096b6 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 30 Jul 2021 04:45:05 +0200 Subject: [PATCH 05/15] Removed the last leftovers of IDM_CONFIG_LOAD and IDM_CONFIG_SAVE, should fix compile. --- src/win/win_ui.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 251892832..8ee6e16ba 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -258,12 +258,6 @@ video_set_filter_menu(HMENU menu) static void ResetAllMenus(void) { -#ifndef DEV_BRANCH - /* FIXME: until we fix these.. --FvK */ - EnableMenuItem(menuMain, IDM_CONFIG_LOAD, MF_DISABLED); - EnableMenuItem(menuMain, IDM_CONFIG_SAVE, MF_DISABLED); -#endif - CheckMenuItem(menuMain, IDM_ACTION_RCTRL_IS_LALT, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_ACTION_KBD_REQ_CAPTURE, MF_UNCHECKED); From 36821c2fc8bf4d450e117d5af308015e7a69f0c0 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 30 Jul 2021 06:27:21 +0200 Subject: [PATCH 06/15] Small VIA NVR fix. --- src/nvr_at.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvr_at.c b/src/nvr_at.c index 733eac250..bf188dbbf 100644 --- a/src/nvr_at.c +++ b/src/nvr_at.c @@ -604,7 +604,7 @@ nvr_reg_write(uint16_t reg, uint8_t val, void *priv) /*FALLTHROUGH*/ case 0x32: - if ((local->cent == RTC_CENTURY_VIA) && local->wp_32) + if ((reg == 0x32) && (local->cent == RTC_CENTURY_VIA) && local->wp_32) break; /* FALLTHROUGH */ From 79f83cc928801a51572bd3efd5f36973023f478a Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 30 Jul 2021 19:17:46 +0200 Subject: [PATCH 07/15] Fixed "Hide status bar" check mark, fixes #1569. --- src/win/win_ui.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 8ee6e16ba..7000a4402 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -287,6 +287,7 @@ ResetAllMenus(void) # endif #endif + CheckMenuItem(menuMain, IDM_VID_HIDE_STATUS_BAR, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_FORCE43, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_OVERSCAN, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_INVERT, MF_UNCHECKED); @@ -353,6 +354,7 @@ ResetAllMenus(void) # endif #endif + CheckMenuItem(menuMain, IDM_VID_HIDE_STATUS_BAR, hide_statu_bar ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_FORCE43, force_43?MF_CHECKED:MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_OVERSCAN, enable_overscan?MF_CHECKED:MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_INVERT, invert_display ? MF_CHECKED : MF_UNCHECKED); From 9050fb3a08c4559aec3b5955855ec91d8c6b0bb7 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 30 Jul 2021 19:33:23 +0200 Subject: [PATCH 08/15] If the graphics card is automatically set to "None", the configure button is now disabled, closes #850. --- src/win/win_settings.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/win/win_settings.c b/src/win/win_settings.c index edba0f0b1..aa27346b9 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -1070,6 +1070,7 @@ static BOOL CALLBACK win_settings_video_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { int c = 0, d = 0; + int e; switch (message) { case WM_INITDIALOG: @@ -1107,7 +1108,8 @@ win_settings_video_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } settings_enable_window(hdlg, IDC_COMBO_VIDEO, !(machines[temp_machine].flags & MACHINE_VIDEO_ONLY)); - settings_enable_window(hdlg, IDC_CONFIGURE_VID, video_card_has_config(temp_gfxcard)); + e = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_VIDEO)]; + settings_enable_window(hdlg, IDC_CONFIGURE_VID, video_card_has_config(e)); settings_enable_window(hdlg, IDC_CHECK_VOODOO, (machines[temp_machine].flags & MACHINE_BUS_PCI)); settings_set_check(hdlg, IDC_CHECK_VOODOO, temp_voodoo); settings_enable_window(hdlg, IDC_BUTTON_VOODOO, (machines[temp_machine].flags & MACHINE_BUS_PCI) && temp_voodoo); From 43aed39016cac18f1657593018c6d7f6a786889a Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 30 Jul 2021 19:37:50 +0200 Subject: [PATCH 09/15] Fixed a compile-breaking typo in win/win_ui.c . --- src/win/win_ui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 7000a4402..6f884a916 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -354,7 +354,7 @@ ResetAllMenus(void) # endif #endif - CheckMenuItem(menuMain, IDM_VID_HIDE_STATUS_BAR, hide_statu_bar ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_HIDE_STATUS_BAR, hide_status_bar ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_FORCE43, force_43?MF_CHECKED:MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_OVERSCAN, enable_overscan?MF_CHECKED:MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_INVERT, invert_display ? MF_CHECKED : MF_UNCHECKED); From 4af2177c664aa4b7d926c670f89e09d248360c64 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 30 Jul 2021 19:48:46 +0200 Subject: [PATCH 10/15] Fixed Tandy text mode to properly support 8x9 mode, closes #1305. --- src/machine/m_tandy.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/machine/m_tandy.c b/src/machine/m_tandy.c index ab01241a0..75aa7cbeb 100644 --- a/src/machine/m_tandy.c +++ b/src/machine/m_tandy.c @@ -811,8 +811,13 @@ vid_poll(void *priv) } } else { for (c = 0; c < 8; c++) { - buffer32->line[(vid->displine << 1)][(x << 3) + c + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 3) + c + 8] = - cols[(fontdat[chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + if (vid->sc == 8) { + buffer32->line[(vid->displine << 1)][(x << 3) + c + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 3) + c + 8] = + cols[(fontdat[chr][7] & (1 << (c ^ 7))) ? 1 : 0]; + } else { + buffer32->line[(vid->displine << 1)][(x << 3) + c + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 3) + c + 8] = + cols[(fontdat[chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + } } } if (drawcursor) { @@ -844,9 +849,15 @@ vid_poll(void *priv) cols[0]; } else { for (c = 0; c < 8; c++) { - buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = - buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = - cols[(fontdat[chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + if (vid->sc == 8) { + buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = + buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = + cols[(fontdat[chr][7] & (1 << (c ^ 7))) ? 1 : 0]; + } else { + buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 8] = + buffer32->line[(vid->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(vid->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = + cols[(fontdat[chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + } } } if (drawcursor) { From 07e7c1dd9e041f786f686c3aa4b415c8edb4e6a7 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 2 Aug 2021 04:24:23 +0200 Subject: [PATCH 11/15] More Hercules fixes. --- src/video/vid_hercules.c | 148 ++++++++++++++++++++++++--------------- 1 file changed, 91 insertions(+), 57 deletions(-) diff --git a/src/video/vid_hercules.c b/src/video/vid_hercules.c index 49a860835..5ff73287a 100644 --- a/src/video/vid_hercules.c +++ b/src/video/vid_hercules.c @@ -36,7 +36,7 @@ typedef struct { mem_mapping_t mapping; - uint8_t crtc[32]; + uint8_t crtc[32], charbuffer[4096]; int crtcreg; uint8_t ctrl, @@ -125,27 +125,31 @@ hercules_out(uint16_t addr, uint8_t val, void *priv) dev->crtc[10] = 0xb; dev->crtc[11] = 0xc; } -#if 0 - if (old ^ val) - recalc_timings(dev); -#else + if (old != val) { if ((dev->crtcreg < 0xe) || (dev->crtcreg > 0x10)) { fullchange = changeframecount; recalc_timings(dev); } } -#endif break; case 0x03b8: old = dev->ctrl; - /* Prevent settings of bits if they are disabled in CTRL2. */ - if (!(dev->ctrl2 & 0x01) && (val & 0x02)) - val &= 0xfd; - if (!(dev->ctrl2 & 0x02) && (val & 0x80)) - val &= 0x7f; - dev->ctrl = val; + + /* Prevent setting of bits if they are disabled in CTRL2. */ + if ((old & 0x02) && !(val & 0x02)) + dev->ctrl &= 0xfd; + else if ((val & 0x02) && (dev->ctrl2 & 0x01)) + dev->ctrl |= 0x02; + + if ((old & 0x80) && !(val & 0x80)) + dev->ctrl &= 0x7f; + else if ((val & 0x80) && (dev->ctrl2 & 0x02)) + dev->ctrl |= 0x80; + + dev->ctrl = (dev->ctrl & 0x82) | (val & 0x7d); + if (old ^ val) recalc_timings(dev); break; @@ -158,6 +162,19 @@ hercules_out(uint16_t addr, uint8_t val, void *priv) case 0x03bf: old = dev->ctrl2; dev->ctrl2 = val; + /* According to the Programmer's guide to the Hercules graphics cars + by David B. Doty from 1988, the CTRL2 modes (bits 1,0) are as follow: + - 00: DIAG: Text mode only, only page 0 accessible; + - 01: HALF: Graphics mode allowed, only page 0 accessible; + - 11: FULL: Graphics mode allowed, both pages accessible. */ + if (val & 0x01) + mem_mapping_set_exec(&dev->mapping, dev->vram); + else + mem_mapping_set_exec(&dev->mapping, NULL); + if (val & 0x02) + mem_mapping_set_addr(&dev->mapping, 0xb0000, 0x10000); + else + mem_mapping_set_addr(&dev->mapping, 0xb0000, 0x08000); if (old ^ val) recalc_timings(dev); break; @@ -187,21 +204,18 @@ hercules_in(uint16_t addr, void *priv) case 0x03b5: case 0x03b7: ret = dev->crtc[dev->crtcreg]; + if (dev->crtcreg == 12) + ret = (dev->ma >> 8) & 0x3f; + else + ret = dev->ma & 0xff; break; case 0x03ba: - // ret = 0x72; /* Hercules ident */ ret = 0x70; /* Hercules ident */ ret |= (dev->lp_ff ? 2 : 0); -#if 0 - if (dev->stat & 0x08) - ret |= 0x88; -#else + ret |= (dev->stat & 0x01); if (dev->stat & 0x08) ret |= 0x80; -#endif - if ((dev->stat & 0x09) == 0x01) - ret |= (dev->stat & 0x01); if ((ret & 0x81) == 0x80) ret |= 0x08; break; @@ -230,15 +244,12 @@ hercules_write(uint32_t addr, uint8_t val, void *priv) { hercules_t *dev = (hercules_t *)priv; - /* According to the Programmer's guide to the Hercules graphics cars - by David B. Doty from 1988, the CTRL2 modes (bits 1,0) are as follow: - - 00: DIAG: Text mode only, only page 0 accessible; - - 01: HALF: Graphics mode allowed, only page 0 accessible; - - 11: FULL: Graphics mode allowed, both pages accessible. */ - if ((addr >= 0xb8000) && ((dev->ctrl2 & 0x03) != 0x03)) - return; + if (dev->ctrl2 & 0x01) + addr &= 0xffff; + else + addr &= 0x0fff; - dev->vram[addr & 0xffff] = val; + dev->vram[addr] = val; hercules_waitstates(dev); } @@ -248,13 +259,18 @@ static uint8_t hercules_read(uint32_t addr, void *priv) { hercules_t *dev = (hercules_t *)priv; + uint8_t ret = 0xff; - if ((addr >= 0xb8000) && ((dev->ctrl2 & 0x03) != 0x03)) - return 0xff; - - return(dev->vram[addr & 0xffff]); + if (dev->ctrl2 & 0x01) + addr &= 0xffff; + else + addr &= 0x0fff; hercules_waitstates(dev); + + ret = dev->vram[addr]; + + return ret; } @@ -282,14 +298,14 @@ hercules_poll(void *priv) if (dev->dispon) { if (dev->displine < dev->firstline) { - dev->firstline = dev->displine; - video_wait_for_buffer(); + dev->firstline = dev->displine; + video_wait_for_buffer(); } dev->lastline = dev->displine; - if ((dev->ctrl & 0x02) && (dev->ctrl2 & 0x01)) { + if (dev->ctrl & 0x02) { ca = (dev->sc & 3) * 0x2000; - if ((dev->ctrl & 0x80) && (dev->ctrl2 & 0x02)) + if (dev->ctrl & 0x80) ca += 0x8000; for (x = 0; x < dev->crtc[1]; x++) { @@ -304,13 +320,12 @@ hercules_poll(void *priv) video_blend((x << 4) + c, dev->displine); } } else { - pa = ((dev->ctrl & 0x80) && (dev->ctrl2 & 0x02)) ? 0x8000 : 0x0000; for (x = 0; x < dev->crtc[1]; x++) { if (dev->ctrl & 8) { /* Undocumented behavior: page 1 in text mode means characters are read from page 1 and attributes from page 0. */ - chr = dev->vram[((dev->ma << 1) & 0xfff) + pa]; - attr = dev->vram[((dev->ma << 1) + 1) & 0xfff]; + chr = dev->charbuffer[x << 1]; + attr = dev->charbuffer[(x << 1) + 1]; } else chr = attr = 0; drawcursor = ((dev->ma == ca) && dev->con && dev->cursoron); @@ -328,7 +343,10 @@ hercules_poll(void *priv) else buffer32->line[dev->displine][(x * 9) + 8] = dev->cols[attr][blink][0]; } - dev->ma++; + if (dev->ctrl2 & 0x01) + dev->ma = (dev->ma + 1) & 0x3fff; + else + dev->ma = (dev->ma + 1) & 0x7ff; if (drawcursor) { for (c = 0; c < 9; c++) @@ -347,6 +365,9 @@ hercules_poll(void *priv) } else { timer_advance_u64(&dev->timer, dev->dispontime); + if (dev->dispon) + dev->stat &= ~1; + dev->linepos = 0; if (dev->vsynctime) { dev->vsynctime--; @@ -364,42 +385,51 @@ hercules_poll(void *priv) dev->sc++; dev->sc &= 31; dev->ma = dev->maback; - dev->vadj--; if (! dev->vadj) { dev->dispon = 1; dev->ma = dev->maback = (dev->crtc[13] | (dev->crtc[12] << 8)) & 0x3fff; dev->sc = 0; } - } else if (dev->sc == dev->crtc[9] || ((dev->crtc[8] & 3) == 3 && dev->sc == (dev->crtc[9] >> 1))) { + } else if (((dev->crtc[8] & 3) != 3 && dev->sc == dev->crtc[9]) || ((dev->crtc[8] & 3) == 3 && dev->sc == (dev->crtc[9] >> 1))) { dev->maback = dev->ma; dev->sc = 0; oldvc = dev->vc; dev->vc++; dev->vc &= 127; + if (dev->vc == dev->crtc[6]) dev->dispon = 0; if (oldvc == dev->crtc[4]) { dev->vc = 0; dev->vadj = dev->crtc[5]; - if (! dev->vadj) + if (! dev->vadj) { dev->dispon = 1; - if (! dev->vadj) dev->ma = dev->maback = (dev->crtc[13] | (dev->crtc[12] << 8)) & 0x3fff; - if ((dev->crtc[10] & 0x60) == 0x20) - dev->cursoron = 0; - else - dev->cursoron = dev->blink & 16; + } + switch (dev->crtc[10] & 0x60) { + case 0x20: + dev->cursoron = 0; + break; + case 0x60: + dev->cursoron = dev->blink & 0x10; + break; + default: + dev->cursoron = dev->blink & 0x08; + break; + } } if (dev->vc == dev->crtc[7]) { dev->dispon = 0; dev->displine = 0; - dev->vsynctime = 16;//(crtcm[3]>>4)+1; + if ((dev->crtc[8] & 3) == 3) + dev->vsynctime = ((int32_t)dev->crtc[4] * ((dev->crtc[9] >> 1) + 1)) + dev->crtc[5] - dev->crtc[7] + 1; + else + dev->vsynctime = ((int32_t)dev->crtc[4] * (dev->crtc[9] + 1)) + dev->crtc[5] - dev->crtc[7] + 1; if (dev->crtc[7]) { - // if ((dev->ctrl & 2) && (dev->ctrl2 & 1)) - if (dev->ctrl & 2) + if (dev->ctrl & 0x02) x = dev->crtc[1] << 4; else x = dev->crtc[1] * 9; @@ -419,7 +449,8 @@ hercules_poll(void *priv) video_blit_memtoscreen_8(0, dev->firstline, 0, ysize, xsize, ysize); frames++; - if ((dev->ctrl & 2) && (dev->ctrl2 & 1)) { + // if ((dev->ctrl & 2) && (dev->ctrl2 & 1)) { + if (dev->ctrl & 0x02) { video_res_x = dev->crtc[1] * 16; video_res_y = dev->crtc[6] * 4; video_bpp = 1; @@ -439,12 +470,15 @@ hercules_poll(void *priv) dev->ma = dev->maback; } - if (dev->dispon) - dev->stat &= ~1; - if ((dev->sc == (dev->crtc[10] & 31) || ((dev->crtc[8] & 3)==3 && dev->sc == ((dev->crtc[10] & 31) >> 1)))) dev->con = 1; + if (dev->dispon && !(dev->ctrl & 0x02)) { + for (x = 0; x < (dev->crtc[1] << 1); x++) { + pa = (dev->ctrl & 0x80) ? ((x & 1) ? 0x0000 : 0x8000) : 0x0000; + dev->charbuffer[x] = dev->vram[(((dev->ma << 1) + x) & 0x3fff) + pa]; + } + } } } @@ -462,9 +496,9 @@ hercules_init(const device_t *info) timer_add(&dev->timer, hercules_poll, dev, 1); - mem_mapping_add(&dev->mapping, 0xb0000, 0x10000, + mem_mapping_add(&dev->mapping, 0xb0000, 0x08000, hercules_read,NULL,NULL, hercules_write,NULL,NULL, - dev->vram, MEM_MAPPING_EXTERNAL, dev); + NULL /*dev->vram*/, MEM_MAPPING_EXTERNAL, dev); io_sethandler(0x03b0, 16, hercules_in,NULL,NULL, hercules_out,NULL,NULL, dev); From 6b8d4a21b6dbd1abb847f792475824238a498471 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 2 Aug 2021 20:32:35 +0200 Subject: [PATCH 12/15] Fixed a SCSI-related bug in win/win_settings.c . --- src/win/win_settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win/win_settings.c b/src/win/win_settings.c index aa27346b9..5f67b8225 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -2154,7 +2154,7 @@ win_settings_hard_disks_update_item(HWND hdlg, int i, int column) wsprintf(szText, plat_get_string(IDS_4612), temp_hdd[i].ide_channel >> 1, temp_hdd[i].ide_channel & 1); break; case HDD_BUS_SCSI: - wsprintf(szText, plat_get_string(IDS_4613), temp_hdd[i].scsi_id >> 4, temp_hdd[i].scsi_id >> 4 & 15); + wsprintf(szText, plat_get_string(IDS_4613), temp_hdd[i].scsi_id >> 4, temp_hdd[i].scsi_id & 15); break; } lvI.pszText = szText; From 2cdd6fec56ae672062c5e4c97d67c21c3f5d1496 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 2 Aug 2021 22:14:29 +0200 Subject: [PATCH 13/15] And another typo fix in win/win_settings.c, reported by lemondrops. --- src/win/win_settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 5f67b8225..811493a6a 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -2228,7 +2228,7 @@ win_settings_hard_disks_recalc_list(HWND hdlg) wsprintf(szText, plat_get_string(IDS_4612), temp_hdd[i].ide_channel >> 1, temp_hdd[i].ide_channel & 1); break; case HDD_BUS_SCSI: - wsprintf(szText, plat_get_string(IDS_4613), temp_hdd[i].scsi_id >> 4, temp_hdd[i].scsi_id >> 4 & 15); + wsprintf(szText, plat_get_string(IDS_4613), temp_hdd[i].scsi_id >> 4, temp_hdd[i].scsi_id & 15); break; } lvI.pszText = szText; From 1d57246ee84d739efb57cf9aa68255b43f42947d Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Tue, 3 Aug 2021 02:46:09 -0400 Subject: [PATCH 14/15] Added correct AWE64 Gold RAM amounts Corrected AWE64 Gold RAM amounts based on formulas seen here - https://www.vogons.org/viewtopic.php?p=988235#p988235 --- src/sound/snd_sb.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 3d8e51806..f7914a46d 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -2560,21 +2560,18 @@ static const device_config_t sb_awe64_gold_config[] = { "onboard_ram", "Onboard RAM", CONFIG_SELECTION, "", 4096, "", { 0 }, { - { - "None", 0 - }, - { - "512 KB", 512 - }, - { - "2 MB", 2048 - }, { "4 MB", 4096 }, { "8 MB", 8192 }, + { + "12 MB", 12288 + }, + { + "16 MB", 16384 + }, { "28 MB", 28*1024 }, From d2d5906e2fb9accdd08bf55569a8d97437ae7a40 Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Tue, 3 Aug 2021 02:57:54 -0400 Subject: [PATCH 15/15] Added correct SB 32 PnP RAM amounts Corrected Sound Blaster 32 PnP RAM amounts based on formulas seen here - https://www.vogons.org/viewtopic.php?p=988235#p988235 --- src/sound/snd_sb.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index f7914a46d..7361d90cd 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -2341,9 +2341,6 @@ static const device_config_t sb_32_pnp_config[] = { "None", 0 }, - { - "512 KB", 512 - }, { "2 MB", 2048 },