From 9f4ae7030ec8ee7768a77d7239041ce81d3cba5d Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 10 Aug 2023 16:10:59 +0200 Subject: [PATCH 01/13] ACPI and Vodoo 3/Banshee PCI/AGP card adding fixes, fixes #3535. --- src/acpi.c | 14 ++++---------- src/video/vid_voodoo_banshee.c | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/acpi.c b/src/acpi.c index 91d84be60..614deaa8c 100644 --- a/src/acpi.c +++ b/src/acpi.c @@ -141,12 +141,12 @@ acpi_update_irq(acpi_t *dev) acpi_timer_update(dev, (dev->regs.pmen & TMROF_EN) && !(dev->regs.pmsts & TMROF_STS)); } -static void -acpi_do_raise_smi(void *priv, int do_smi, int is_apm) +void +acpi_raise_smi(void *priv, int do_smi) { acpi_t *dev = (acpi_t *) priv; - if (is_apm || (dev->regs.glbctl & 0x01)) { + if (dev->regs.glbctl & 0x01) { if ((dev->vendor == VEN_VIA) || (dev->vendor == VEN_VIA_596B)) { if (!dev->regs.smi_lock || !dev->regs.smi_active) { if (do_smi) @@ -168,12 +168,6 @@ acpi_do_raise_smi(void *priv, int do_smi, int is_apm) } } -void -acpi_raise_smi(void *priv, int do_smi) -{ - acpi_do_raise_smi(priv, do_smi, 0); -} - static uint32_t acpi_reg_read_common_regs(UNUSED(int size), uint16_t addr, void *priv) { @@ -1588,7 +1582,7 @@ acpi_apm_out(uint16_t port, uint8_t val, void *priv) dev->apm->cmd = val; if (dev->vendor == VEN_INTEL) dev->regs.glbsts |= 0x20; - acpi_do_raise_smi(dev, dev->apm->do_smi, 1); + acpi_raise_smi(dev, dev->apm->do_smi); } else dev->apm->stat = val; } diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index e2c59b5a7..a73f2d3e8 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -3164,9 +3164,9 @@ banshee_init_common(const device_t *info, char *fn, int has_sgram, int type, int banshee->svga.decode_mask = 0x1ffffff; if (banshee->has_bios) - pci_add_card(banshee->agp ? PCI_ADD_AGP : PCI_ADD_VIDEO, banshee_pci_read, banshee_pci_write, banshee, &banshee->pci_slot); - else pci_add_card(banshee->agp ? PCI_ADD_AGP : PCI_ADD_NORMAL, banshee_pci_read, banshee_pci_write, banshee, &banshee->pci_slot); + else + pci_add_card(banshee->agp ? PCI_ADD_AGP : PCI_ADD_VIDEO, banshee_pci_read, banshee_pci_write, banshee, &banshee->pci_slot); banshee->voodoo = voodoo_2d3d_card_init(voodoo_type); banshee->voodoo->p = banshee; From 9474c02aec1c41eef753d56f549dd30f917f949d Mon Sep 17 00:00:00 2001 From: cold-brewed <47337035+cold-brewed@users.noreply.github.com> Date: Thu, 10 Aug 2023 10:40:19 -0400 Subject: [PATCH 02/13] qt: use QRegularExpression instead of QRegExp for qt6 compatibility (#3536) Co-authored-by: cold-brewed --- src/qt/qt_platform.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index cd43c6730..bddcd295c 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -712,7 +713,7 @@ plat_get_cpu_string(char *outbuf, uint8_t len) { if (line.isNull()) { break; } - if(line.contains(QRegExp("model name.*:"))) { + if(QRegularExpression("model name.*:").match(line).hasMatch()) { auto list = line.split(": "); if(!list.last().isEmpty()) { cpu_string = list.last(); From a2b7a175a9873b4ac7f2a9e5f0c527c00179519e Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 10 Aug 2023 16:47:12 +0200 Subject: [PATCH 03/13] Fixed Hercules InColor text mode wraparound, fixes #3520. --- src/video/vid_incolor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/vid_incolor.c b/src/video/vid_incolor.c index 7a3b416fc..1b10def46 100644 --- a/src/video/vid_incolor.c +++ b/src/video/vid_incolor.c @@ -749,8 +749,8 @@ text_line(incolor_t *dev, uint16_t ca) for (uint8_t x = 0; x < dev->crtc[1]; x++) { if (dev->ctrl & 8) { - chr = dev->vram[(dev->ma << 1) & 0xfff]; - attr = dev->vram[((dev->ma << 1) + 1) & 0xfff]; + chr = dev->vram[(dev->ma << 1) & 0x3fff]; + attr = dev->vram[((dev->ma << 1) + 1) & 0x3fff]; } else chr = attr = 0; From 785b61aaac70c663680e4d5373139ad6781a2027 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 10 Aug 2023 16:48:39 +0200 Subject: [PATCH 04/13] Fixed the conditions for mouse button click registration on platforms other than Windows. --- src/qt/qt_rendererstack.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index 88e5a7aa6..7618327c4 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -177,7 +177,17 @@ RendererStack::mouseReleaseEvent(QMouseEvent *event) return; } if (mouse_capture || (mouse_mode >= 1)) { - if ((mouse_mode >= 1) && ((m_monitor_index < 1) || mousedata.mouse_tablet_in_proximity)) +#ifdef Q_OS_WINDOWS + if (((m_monitor_index >= 1) && (mouse_mode >= 1) && mousedata.mouse_tablet_in_proximity) || + ((m_monitor_index < 1) && (mouse_mode >= 1))) +#else +#ifndef __APPLE__ + if (((m_monitor_index >= 1) && (mouse_mode >= 1) && mousedata.mouse_tablet_in_proximity) || + (m_monitor_index < 1)) +#else + if ((m_monitor_index >= 1) && (mouse_mode >= 1) && mousedata.mouse_tablet_in_proximity) +#endif +#endif mouse_set_buttons_ex(mouse_get_buttons_ex() & ~event->button()); } isMouseDown &= ~1; @@ -188,7 +198,17 @@ RendererStack::mousePressEvent(QMouseEvent *event) { isMouseDown |= 1; if (mouse_capture || (mouse_mode >= 1)) { - if ((mouse_mode >= 1) && ((m_monitor_index < 1) || mousedata.mouse_tablet_in_proximity)) +#ifdef Q_OS_WINDOWS + if (((m_monitor_index >= 1) && (mouse_mode >= 1) && mousedata.mouse_tablet_in_proximity) || + ((m_monitor_index < 1) && (mouse_mode >= 1))) +#else +#ifndef __APPLE__ + if (((m_monitor_index >= 1) && (mouse_mode >= 1) && mousedata.mouse_tablet_in_proximity) || + (m_monitor_index < 1)) +#else + if ((m_monitor_index >= 1) && (mouse_mode >= 1) && mousedata.mouse_tablet_in_proximity) +#endif +#endif mouse_set_buttons_ex(mouse_get_buttons_ex() | event->button()); } event->accept(); From 291dab233470f7a796b7e7bd6d378557aa4e3ff0 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 10 Aug 2023 17:24:08 +0200 Subject: [PATCH 05/13] Commented out an excess Resize log in qt/qt_mainwindow.cpp. --- src/qt/qt_mainwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index c49e93648..4bb30c56f 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -293,7 +293,9 @@ MainWindow::MainWindow(QWidget *parent) connect(this, &MainWindow::resizeContentsMonitor, this, [this](int w, int h, int monitor_index) { if (!QApplication::platformName().contains("eglfs") && vid_resize != 1) { +#ifdef QT_RESIZE_DEBUG qDebug() << "Resize"; +#endif w = (w / (!dpi_scale ? util::screenOfWidget(renderers[monitor_index].get())->devicePixelRatio() : 1.)); int modifiedHeight = (h / (!dpi_scale ? util::screenOfWidget(renderers[monitor_index].get())->devicePixelRatio() : 1.)); From 782015a92350b4665488705e0a31cf78e1ff55e5 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 11 Aug 2023 04:45:32 +0200 Subject: [PATCH 06/13] More mouse and PIC fixes and the mouse now takes of the ration between guest resolution and actual render area size, multiplied by the DPI, when returning coordinate deltas, also unified the delta return function across the various emulated mice. --- src/device/mouse.c | 171 ++++++++++++++++++++++++++++++++--- src/device/mouse_bus.c | 49 ++-------- src/device/mouse_ps2.c | 40 +++----- src/device/mouse_serial.c | 92 ++----------------- src/include/86box/86box.h | 6 +- src/include/86box/mouse.h | 11 ++- src/include/86box/plat.h | 1 + src/pic.c | 17 ++-- src/qt/qt_platform.cpp | 13 ++- src/qt/qt_renderercommon.cpp | 110 ++++++++++++---------- src/qt/qt_renderercommon.hpp | 4 +- src/qt/qt_rendererstack.cpp | 16 ++++ src/qt/qt_rendererstack.hpp | 12 +-- 13 files changed, 299 insertions(+), 243 deletions(-) diff --git a/src/device/mouse.c b/src/device/mouse.c index 46ecceec1..7a90e2c3f 100644 --- a/src/device/mouse.c +++ b/src/device/mouse.c @@ -32,6 +32,8 @@ #include <86box/timer.h> #include <86box/gdbstub.h> #include <86box/mouse.h> +#include <86box/video.h> +#include <86box/plat.h> #include <86box/plat_unused.h> typedef struct mouse_t { @@ -43,6 +45,8 @@ atomic_int mouse_x; atomic_int mouse_y; atomic_int mouse_z; atomic_int mouse_buttons; +atomic_int old_mouse_x; +atomic_int old_mouse_y; int mouse_mode; int mouse_timed = 1; int mouse_tablet_in_proximity = 0; @@ -52,8 +56,10 @@ double mouse_x_abs; double mouse_y_abs; double mouse_sensitivity = 1.0; -double mouse_x_error = 0.0; -double mouse_y_error = 0.0; +_Atomic double mouse_x_error = 0.0; +_Atomic double mouse_y_error = 0.0; +_Atomic double mouse_x_raw = 0.0; +_Atomic double mouse_y_raw = 0.0; pc_timer_t mouse_timer; /* mouse event timer */ @@ -130,12 +136,21 @@ mouse_log(const char *fmt, ...) # define mouse_log(fmt, ...) #endif +void +mouse_clear_coords(void) +{ + mouse_x = mouse_y = mouse_z = 0; + old_mouse_x = old_mouse_y = 0; + mouse_x_error = mouse_y_error = 0.0; + mouse_x_raw = mouse_y_raw = 0.0; +} + /* Initialize the mouse module. */ void mouse_init(void) { /* Initialize local data. */ - mouse_x = mouse_y = mouse_z = 0; + mouse_clear_coords(); mouse_buttons = 0x00; mouse_type = MOUSE_TYPE_NONE; @@ -159,6 +174,132 @@ mouse_close(void) timer_stop(&mouse_timer); } +static int +mouse_scale_coord_x(int x, int mul) +{ + double temp_x = (double) x; + double ratio = (double) monitors[0].mon_unscaled_size_x / (double) monitors[0].mon_res_x; + + if (mul) + temp_x *= ratio; + else + temp_x /= ratio; + + return (int) temp_x; +} + +static int +mouse_scale_coord_y(int y, int mul) +{ + double temp_y = (double) y; + double ratio = (double) monitors[0].mon_efscrnsz_y / (double) monitors[0].mon_res_y; + + if (mul) + temp_y *= ratio; + else + temp_y /= ratio; + + return (int) temp_y; +} + +/* It appears all host platforms give us y in the Microsoft format + (positive to the south), so for all non-Microsoft report formsts, + we have to invenrt that. */ +void +mouse_subtract_coords(int *delta_x, int *delta_y, int *o_x, int *o_y, + int min, int max, int invert, int abs) +{ + int real_x = mouse_x; + int real_y = mouse_y; + int smax_x; + int smax_y; + int rsmin_x; + int rsmin_y; + int smin_x; + int smin_y; + + if (invert) + real_y = -real_y; + + rsmin_x = mouse_scale_coord_x(min, 0); + rsmin_y = mouse_scale_coord_y(min, 0); + if (abs) { + smax_x = mouse_scale_coord_x(max, 0) + ABS(rsmin_x); + smax_y = mouse_scale_coord_y(max, 0) + ABS(rsmin_y); + max += ABS(min); + real_x += rsmin_x; + real_y += rsmin_y; + smin_x = 0; + smin_y = 0; + } else { + smax_x = mouse_scale_coord_x(max, 0); + smax_y = mouse_scale_coord_y(max, 0); + smin_x = rsmin_x; + smin_y = rsmin_y; + } + + /* Default the X and Y overflows to 1. */ + if (o_x != NULL) + *o_x = 1; + if (o_y != NULL) + *o_y = 1; + + if (real_x > smax_x) { + if (abs) + *delta_x = mouse_scale_coord_x(real_x, 1); + else + *delta_x = max; + real_x -= smax_x; + } else if (real_x < smin_x) { + if (abs) + *delta_x = mouse_scale_coord_x(real_x, 1); + else + *delta_x = min; + real_x += ABS(smin_x); + } else { + if (abs) + *delta_x = mouse_scale_coord_x(real_x, 1); + else + *delta_x = mouse_scale_coord_x(real_x, 1); + real_x = 0; + if (o_x != NULL) + *o_x = 0; + } + + if (real_y > smax_y) { + if (abs) + *delta_y = mouse_scale_coord_y(real_y, 1); + else + *delta_y = max; + real_y -= smax_y; + } else if (real_y < smin_y) { + if (abs) + *delta_y = mouse_scale_coord_y(real_y, 1); + else + *delta_y = min; + real_y += ABS(smin_y); + } else { + if (abs) + *delta_y = mouse_scale_coord_y(real_y, 1); + else + *delta_y = mouse_scale_coord_y(real_y, 1); + real_y = 0; + if (o_y != NULL) + *o_y = 0; + } + + if (abs) { + real_x -= rsmin_x; + real_y -= rsmin_y; + } + + if (invert) + real_y = -real_y; + + mouse_x = real_x; + mouse_y = real_y; +} + static void mouse_timer_poll(UNUSED(void *priv)) { @@ -178,8 +319,11 @@ mouse_timer_poll(UNUSED(void *priv)) void mouse_scale(int x, int y) { - double scaled_x = (((double) x) * mouse_sensitivity) + mouse_x_error; - double scaled_y = (((double) y) * mouse_sensitivity) + mouse_y_error; + double scaled_x = (((double) x) * mouse_sensitivity); + double scaled_y = (((double) y) * mouse_sensitivity); + + scaled_x += mouse_x_error; + scaled_y += mouse_y_error; mouse_x += (int) scaled_x; mouse_y += (int) scaled_y; @@ -191,21 +335,25 @@ mouse_scale(int x, int y) void mouse_scale_x(int x) { - double scaled_x = ((double) x) * mouse_sensitivity + mouse_x_error; + double scaled_x = (((double) x) * mouse_sensitivity); + + scaled_x += mouse_x_error; mouse_x += (int) scaled_x; - mouse_x_error = scaled_x - ((double) mouse_x); + mouse_x_error = scaled_x - floor(scaled_x); } void mouse_scale_y(int y) { - double scaled_y = ((double) y) * mouse_sensitivity + mouse_y_error; + double scaled_y = (((double) y) * mouse_sensitivity); + + scaled_y += mouse_y_error; mouse_y += (int) scaled_y; - mouse_y_error = scaled_y - ((double) mouse_y); + mouse_y_error = scaled_y - floor(scaled_y); } void @@ -248,7 +396,7 @@ mouse_reset(void) mouse_type, mouse_devices[mouse_type].device->name); /* Clear local data. */ - mouse_x = mouse_y = mouse_z = 0; + mouse_clear_coords(); mouse_buttons = 0x00; mouse_mode = 0; mouse_timed = 1; @@ -292,8 +440,7 @@ mouse_process(void) if ((mouse_mode >= 1) && mouse_poll_ex) mouse_poll_ex(); - - if ((mouse_dev_poll != NULL) || (mouse_curr->poll != NULL)) { + else if ((mouse_mode == 0) && ((mouse_dev_poll != NULL) || (mouse_curr->poll != NULL))) { if (mouse_curr->poll != NULL) mouse_curr->poll(mouse_x, mouse_y, mouse_z, mouse_buttons, mouse_x_abs, mouse_y_abs, mouse_priv); else diff --git a/src/device/mouse_bus.c b/src/device/mouse_bus.c index 33ac2ded3..e6229caef 100644 --- a/src/device/mouse_bus.c +++ b/src/device/mouse_bus.c @@ -478,7 +478,9 @@ static int bm_poll(int x, int y, UNUSED(int z), int b, UNUSED(double abs_x), UNUSED(double abs_y), void *priv) { mouse_t *dev = (mouse_t *) priv; - int xor ; + int delta_x; + int delta_y; + int xor; if (!mouse_capture && !video_fullscreen) return 1; @@ -514,27 +516,10 @@ bm_poll(int x, int y, UNUSED(int z), int b, UNUSED(double abs_x), UNUSED(double if (!dev->timer_enabled) { /* If the counters are not frozen, update them. */ if (!(dev->flags & FLAG_HOLD)) { - if (mouse_x > 127) { - dev->current_x = 127; - mouse_x -= 127; - } else if (mouse_x < 1-128) { - dev->current_x = -128; - mouse_x += 128; - } else { - dev->current_x = mouse_x; - mouse_x = 0; - } + mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 0, 0); - if (mouse_y > 127) { - dev->current_y = 127; - mouse_y -= 127; - } else if (mouse_y < 1-128) { - dev->current_y = -128; - mouse_y += 128; - } else { - dev->current_y = mouse_y; - mouse_y = 0; - } + dev->current_x = (int8_t) delta_x; + dev->current_y = (int8_t) delta_y; dev->current_b = dev->mouse_buttons; } @@ -561,27 +546,7 @@ bm_update_data(mouse_t *dev) /* If the counters are not frozen, update them. */ if ((mouse_capture || video_fullscreen) && !(dev->flags & FLAG_HOLD)) { /* Update the deltas and the delays. */ - if (mouse_x > 127) { - delta_x = 127; - mouse_x -= 127; - } else if (mouse_x < -128) { - delta_x = -128; - mouse_x += 128; - } else { - delta_x = mouse_x; - mouse_x = 0; - } - - if (mouse_y > 127) { - delta_y = 127; - mouse_y -= 127; - } else if (mouse_y < -128) { - delta_y = -128; - mouse_y += 128; - } else { - delta_y = mouse_y; - mouse_y = 0; - } + mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 0, 0); dev->current_x = (int8_t) delta_x; dev->current_y = (int8_t) delta_y; diff --git a/src/device/mouse_ps2.c b/src/device/mouse_ps2.c index f78fc55c4..048092f4c 100644 --- a/src/device/mouse_ps2.c +++ b/src/device/mouse_ps2.c @@ -75,35 +75,19 @@ static void ps2_report_coordinates(atkbc_dev_t *dev, int main) { uint8_t buff[3] = { 0x08, 0x00, 0x00 }; + int delta_x; + int delta_y; + int overflow_x; + int overflow_y; int temp_z; - if (mouse_x > 255) { - buff[0] |= 0x40; - buff[1] = 255; - mouse_x -= 255; - } else if (mouse_x < -256) { - buff[0] |= (0x40 | 0x10); - mouse_x += 256; - } else { - if (mouse_x < 0) - buff[0] |= 0x10; - buff[1] = mouse_x; - mouse_x = 0; - } - - if (mouse_y < -255) { - buff[0] |= 0x80; - buff[2] = 255; - mouse_y += 255; - } else if (mouse_y > 256) { - buff[0] |= (0x80 | 0x20); - mouse_y -= 256; - } else { - if (mouse_y > 0) - buff[0] |= 0x20; - buff[2] = -mouse_y; - mouse_y = 0; - } + mouse_subtract_coords(&delta_x, &delta_y, &overflow_x, &overflow_y, + -256, 255, 1, 0); + buff[0] = (overflow_y << 7) | (overflow_x << 6) | + ((delta_y & 0x0100) >> 3) | ((delta_x & 0x0100) >> 4) | + (mouse_buttons & ((dev->flags & FLAG_INTELLI) ? 0x07 : 0x03)); + buff[1] = (delta_x & 0x00ff); + buff[2] = (delta_y & 0x00ff); if (dev->z < -7) { temp_z = 7; @@ -116,8 +100,6 @@ ps2_report_coordinates(atkbc_dev_t *dev, int main) mouse_z = 0; } - buff[0] |= (mouse_buttons & ((dev->flags & FLAG_INTELLI) ? 0x07 : 0x03)); - kbc_at_dev_queue_add(dev, buff[0], main); kbc_at_dev_queue_add(dev, buff[1], main); kbc_at_dev_queue_add(dev, buff[2], main); diff --git a/src/device/mouse_serial.c b/src/device/mouse_serial.c index 09df1e409..986d18b74 100644 --- a/src/device/mouse_serial.c +++ b/src/device/mouse_serial.c @@ -82,8 +82,6 @@ typedef struct mouse_t { int8_t type; /* type of this device */ int8_t port; - int abs_x; - int abs_y; int old_buttons; int state; int bps; @@ -177,89 +175,13 @@ sermouse_transmit(mouse_t *dev, int len, int from_report, int to_report) sermouse_set_period(dev, dev->transmit_period); } -/* It appears all host platforms give us y in the Microsoft format - (positive to the south), so for all non-Microsoft report formsts, - we have to invenrt that. */ -static void -sermouse_subtract_coords(mouse_t *dev, int *delta_x, int *delta_y, int min, int max, int invert, int abs) -{ - int real_y = mouse_y; - int abs_max = max + ABS(min); - - if (invert) - real_y = -real_y; - - if (mouse_x > max) { - if (abs) { - dev->abs_x += max; - *delta_x = dev->abs_x; - } else - *delta_x = max; - mouse_x -= max; - } else if (mouse_x < min) { - if (abs) { - dev->abs_x += min; - *delta_x = dev->abs_x; - } else - *delta_x = min; - mouse_x += ABS(min); - } else { - if (abs) { - dev->abs_x += mouse_x; - *delta_x = dev->abs_x; - } else - *delta_x = mouse_x; - mouse_x = 0; - } - - if (real_y > max) { - if (abs) { - dev->abs_y += max; - *delta_y = dev->abs_y; - } else - *delta_y = max; - real_y -= max; - } else if (real_y < min) { - if (abs) { - dev->abs_y += min; - *delta_y = dev->abs_y; - } else - *delta_y = min; - real_y += ABS(min); - } else { - if (abs) { - dev->abs_y += real_y; - *delta_y = dev->abs_y; - } else - *delta_y = real_y; - real_y = 0; - } - - if (abs) { - if (dev->abs_x < 0) - *delta_x = 0; - else if (dev->abs_x > abs_max) - *delta_x = abs_max; - - if (dev->abs_y < 0) - *delta_y = 0; - else if (dev->abs_y > abs_max) - *delta_y = abs_max; - } - - if (invert) - real_y = -real_y; - - mouse_y = real_y; -} - static uint8_t sermouse_report_msystems(mouse_t *dev) { int delta_x = 0; int delta_y = 0; - sermouse_subtract_coords(dev, &delta_x, &delta_y, -128, 127, 1, 0); + mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 1, 0); dev->buf[0] = 0x80; dev->buf[0] |= (mouse_buttons & 0x01) ? 0x00 : 0x04; /* left button */ @@ -282,7 +204,7 @@ sermouse_report_3bp(mouse_t *dev) int delta_x = 0; int delta_y = 0; - sermouse_subtract_coords(dev, &delta_x, &delta_y, -128, 127, 1, 0); + mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 1, 0); dev->buf[0] = 0x80; dev->buf[0] |= (mouse_buttons & 0x01) ? 0x04 : 0x00; /* left button */ @@ -303,7 +225,7 @@ sermouse_report_mmseries(mouse_t *dev) int delta_x = 0; int delta_y = 0; - sermouse_subtract_coords(dev, &delta_x, &delta_y, -127, 127, 1, 0); + mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -127, 127, 1, 0); dev->buf[0] = 0x80; if (delta_x >= 0) @@ -328,7 +250,7 @@ sermouse_report_bp1(mouse_t *dev, int abs) int delta_x = 0; int delta_y = 0; - sermouse_subtract_coords(dev, &delta_x, &delta_y, -2048, 2047, 1, abs); + mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -2048, 2047, 1, abs); dev->buf[0] = 0x80; dev->buf[0] |= (mouse_buttons & 0x01) ? 0x10 : 0x00; /* left button */ @@ -351,7 +273,7 @@ sermouse_report_ms(mouse_t *dev) int delta_y = 0; int delta_z = 0; - sermouse_subtract_coords(dev, &delta_x, &delta_y, -128, 127, 0, 0); + mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 0, 0); dev->buf[0] = 0x40; dev->buf[0] |= (((delta_y >> 6) & 0x03) << 2); @@ -409,7 +331,7 @@ sermouse_report_hex(mouse_t *dev) int delta_x = 0; int delta_y = 0; - sermouse_subtract_coords(dev, &delta_x, &delta_y, -128, 127, 1, 0); + mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 1, 0); but |= (mouse_buttons & 0x01) ? 0x04 : 0x00; /* left button */ if (dev->but >= 3) @@ -669,7 +591,7 @@ ltsermouse_process_command(mouse_t *dev) case 0x41: /* Absolute Bit Pad One Packed Binary Format */ - dev->abs_x = dev->abs_y = 0; + mouse_clear_coords(); fallthrough; case 0x42: /* Relative Bit Pad One Packed Binary Format */ case 0x53: /* MM Series Data Format */ diff --git a/src/include/86box/86box.h b/src/include/86box/86box.h index 2f16c92d7..f65f58f63 100644 --- a/src/include/86box/86box.h +++ b/src/include/86box/86box.h @@ -143,8 +143,10 @@ extern int is_pentium; /* TODO: Move back to cpu/cpu.h when it's figured out, extern int fixed_size_x; extern int fixed_size_y; extern double mouse_sensitivity; /* (C) Mouse sensitivity scale */ -extern double mouse_x_error; /* Mouse error accumulator - Y */ -extern double mouse_y_error; /* Mouse error accumulator - Y */ +#ifdef _Atomic +extern _Atomic double mouse_x_error; /* Mouse error accumulator - Y */ +extern _Atomic double mouse_y_error; /* Mouse error accumulator - Y */ +#endif extern int pit_mode; /* (C) force setting PIT mode */ extern int fm_driver; /* (C) select FM sound driver */ diff --git a/src/include/86box/mouse.h b/src/include/86box/mouse.h index d8d609fbb..6bc125623 100644 --- a/src/include/86box/mouse.h +++ b/src/include/86box/mouse.h @@ -26,7 +26,7 @@ #endif #define MOUSE_TYPE_NONE 0 /* no mouse configured */ -#define MOUSE_TYPE_INTERNAL 1 /* machine has internal mouse */ +#define MOUSE_TYPE_INTERNAL 1 /* achine has internal mouse */ #define MOUSE_TYPE_LOGIBUS 2 /* Logitech/ATI Bus Mouse */ #define MOUSE_TYPE_INPORT 3 /* Microsoft InPort Mouse */ #if 0 @@ -62,8 +62,10 @@ extern double mouse_x_abs; extern double mouse_y_abs; extern int tablet_tool_type; extern double mouse_sensitivity; -extern double mouse_x_error; -extern double mouse_y_error; +#ifdef _Atomic +extern _Atomic double mouse_x_error; +extern _Atomic double mouse_y_error; +#endif #ifdef EMU_DEVICE_H extern const device_t *mouse_get_device(int mouse); @@ -83,8 +85,11 @@ extern const device_t mouse_wacom_device; extern const device_t mouse_wacom_artpad_device; #endif +extern void mouse_clear_coords(void); extern void mouse_init(void); extern void mouse_close(void); +extern void mouse_subtract_coords(int *delta_x, int *delta_y, int *o_x, int *o_y, + int min, int max, int invert, int abs); extern void mouse_reset(void); extern void mouse_set_buttons(int buttons); extern void mouse_set_poll_ex(void (*poll_ex)(void)); diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index 03f5584c1..44b0c691f 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -143,6 +143,7 @@ extern void plat_vid_reload_options(void); extern uint32_t plat_language_code(char *langcode); extern void plat_language_code_r(uint32_t lcid, char *outbuf, int len); extern void plat_get_cpu_string(char *outbuf, uint8_t len); +extern double plat_get_dpi(void); /* Resource management. */ extern void set_language(uint32_t id); diff --git a/src/pic.c b/src/pic.c index fdfed7d26..6999aa6d8 100644 --- a/src/pic.c +++ b/src/pic.c @@ -236,7 +236,12 @@ pic_update_pending_at(void) if (!(pic2.flags & PIC_FREEZE)) { pic2.int_pending = (find_best_interrupt(&pic2) != -1); - pic_cascade(pic2.int_pending); + // pic_cascade(pic2.int_pending); + + if (pic2.int_pending) + pic.irr |= (1 << pic2.icw3); + else + pic.irr &= ~(1 << pic2.icw3); } if (!(pic.flags & PIC_FREEZE)) @@ -375,6 +380,7 @@ pic_action(pic_t *dev, uint8_t irq, uint8_t eoi, uint8_t rotate) if (rotate) dev->priority = (irq + 1) & 7; + pic_update_request(dev, irq); update_pending(); } } @@ -414,13 +420,10 @@ pic_latch_read(UNUSED(uint16_t addr), UNUSED(void *priv)) { uint8_t ret = 0xff; - pic_log("pic_latch_read(%04X): %02X%02X\n", enabled_latches, latched_irqs & 0x10, latched_irqs & 0x02); + pic_log("pic_latch_read(%04X): %04X\n", enabled_latches, latched_irqs & 0x1002); - if ((latched_irqs & enabled_latches) & 0x0002) - picintc(0x0002); - - if ((latched_irqs & enabled_latches) & 0x1000) - picintc(0x1000); + if (latched_irqs & 0x1002) + picintc(latched_irqs & 0x1002); /* Return FF - we just lower IRQ 1 and IRQ 12. */ return ret; diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index bddcd295c..7a028bfac 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -42,9 +42,12 @@ #include #include +#include + #include "qt_rendererstack.hpp" #include "qt_mainwindow.hpp" #include "qt_progsettings.hpp" +#include "qt_util.hpp" #ifdef Q_OS_UNIX # include @@ -641,7 +644,7 @@ plat_get_global_config_dir(char* strptr) } void -plat_init_rom_paths() +plat_init_rom_paths(void) { auto paths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); @@ -727,4 +730,10 @@ plat_get_cpu_string(char *outbuf, uint8_t len) { qstrncpy(outbuf, cpu_string.toUtf8().constData(), len); -} \ No newline at end of file +} + +double +plat_get_dpi(void) +{ + return util::screenOfWidget(main_window)->devicePixelRatio(); +} diff --git a/src/qt/qt_renderercommon.cpp b/src/qt/qt_renderercommon.cpp index c2b38cd52..0f16257d7 100644 --- a/src/qt/qt_renderercommon.cpp +++ b/src/qt/qt_renderercommon.cpp @@ -27,6 +27,7 @@ extern "C" { #include <86box/86box.h> +#include <86box/plat.h> #include <86box/video.h> } @@ -51,62 +52,71 @@ integer_scale(double *d, double *g) void RendererCommon::onResize(int width, int height) { - if ((video_fullscreen == 0) && (video_fullscreen_scale_maximized ? ((parentWidget->isMaximized() == false) && (main_window->isAncestorOf(parentWidget) && main_window->isMaximized() == false)) : 1)) { + /* This is needed so that the if below does not take like, 5 lines. */ + bool is_fs = (video_fullscreen == 0); + bool parent_max = (parentWidget->isMaximized() == false); + bool main_is_ancestor = main_window->isAncestorOf(parentWidget); + bool main_max = main_window->isMaximized(); + bool main_is_max = (main_is_ancestor && main_max == false); + + if (is_fs && (video_fullscreen_scale_maximized ? (parent_max && main_is_max) : 1)) destination.setRect(0, 0, width, height); - return; - } - double dx; - double dy; - double dw; - double dh; - double gsr; + else { + double dx; + double dy; + double dw; + double dh; + double gsr; - double hw = width; - double hh = height; - double gw = source.width(); - double gh = source.height(); - double hsr = hw / hh; + double hw = width; + double hh = height; + double gw = source.width(); + double gh = source.height(); + double hsr = hw / hh; - switch (video_fullscreen_scale) { - case FULLSCR_SCALE_INT: - gsr = gw / gh; - if (gsr <= hsr) { - dw = hh * gsr; - dh = hh; - } else { - dw = hw; - dh = hw / gsr; - } - integer_scale(&dw, &gw); - integer_scale(&dh, &gh); - dx = (hw - dw) / 2.0; - dy = (hh - dh) / 2.0; - destination.setRect(dx, dy, dw, dh); - break; - case FULLSCR_SCALE_43: - case FULLSCR_SCALE_KEEPRATIO: - if (video_fullscreen_scale == FULLSCR_SCALE_43) { - gsr = 4.0 / 3.0; - } else { + switch (video_fullscreen_scale) { + case FULLSCR_SCALE_INT: gsr = gw / gh; - } + if (gsr <= hsr) { + dw = hh * gsr; + dh = hh; + } else { + dw = hw; + dh = hw / gsr; + } + integer_scale(&dw, &gw); + integer_scale(&dh, &gh); + dx = (hw - dw) / 2.0; + dy = (hh - dh) / 2.0; + destination.setRect((int) dx, (int) dy, (int) dw, (int) dh); + break; + case FULLSCR_SCALE_43: + case FULLSCR_SCALE_KEEPRATIO: + if (video_fullscreen_scale == FULLSCR_SCALE_43) + gsr = 4.0 / 3.0; + else + gsr = gw / gh; - if (gsr <= hsr) { - dw = hh * gsr; - dh = hh; - } else { - dw = hw; - dh = hw / gsr; - } - dx = (hw - dw) / 2.0; - dy = (hh - dh) / 2.0; - destination.setRect(dx, dy, dw, dh); - break; - case FULLSCR_SCALE_FULL: - default: - destination.setRect(0, 0, hw, hh); - break; + if (gsr <= hsr) { + dw = hh * gsr; + dh = hh; + } else { + dw = hw; + dh = hw / gsr; + } + dx = (hw - dw) / 2.0; + dy = (hh - dh) / 2.0; + destination.setRect((int) dx, (int) dy, (int) dw, (int) dh); + break; + case FULLSCR_SCALE_FULL: + default: + destination.setRect(0, 0, (int) hw, (int) hh); + break; + } } + + monitors[r_monitor_index].mon_res_x = (int) ((double) destination.width() * plat_get_dpi()); + monitors[r_monitor_index].mon_res_y = (int) ((double) destination.height() * plat_get_dpi()); } bool diff --git a/src/qt/qt_renderercommon.hpp b/src/qt/qt_renderercommon.hpp index 34b28fb30..4385a0b73 100644 --- a/src/qt/qt_renderercommon.hpp +++ b/src/qt/qt_renderercommon.hpp @@ -38,8 +38,10 @@ public: virtual bool hasBlitFunc() { return false; } virtual void blit(int x, int y, int w, int h) { } + int r_monitor_index = 0; + protected: - bool eventDelegate(QEvent *event, bool &result); + bool eventDelegate(QEvent *event, bool &result); QRect source { 0, 0, 0, 0 }; QRect destination; diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index 7618327c4..54f81d80c 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -552,3 +552,19 @@ RendererStack::event(QEvent* event) } return QStackedWidget::event(event); } + +void +RendererStack::setFocusRenderer() +{ + if (current) + current->setFocus(); +} + +void +RendererStack::onResize(int width, int height) +{ + if (rendererWindow) { + rendererWindow->r_monitor_index = m_monitor_index; + rendererWindow->onResize(width, height); + } +} diff --git a/src/qt/qt_rendererstack.hpp b/src/qt/qt_rendererstack.hpp index 7c0820190..f59849dda 100644 --- a/src/qt/qt_rendererstack.hpp +++ b/src/qt/qt_rendererstack.hpp @@ -71,16 +71,8 @@ public: /* Returns options dialog for current renderer */ QDialog *getOptions(QWidget *parent) { return rendererWindow ? rendererWindow->getOptions(parent) : nullptr; } - void setFocusRenderer() - { - if (current) - current->setFocus(); - } - void onResize(int width, int height) - { - if (rendererWindow) - rendererWindow->onResize(width, height); - } + void setFocusRenderer(); + void onResize(int width, int height); void (*mouse_capture_func)(QWindow *window) = nullptr; void (*mouse_uncapture_func)() = nullptr; From 4e9d208ce75e68a42b1bbcb0b8a4f057a2bd93ea Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 11 Aug 2023 05:03:26 +0200 Subject: [PATCH 07/13] Fixed text mode wrapping on the Hercules Plus. --- src/video/vid_herculesplus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/vid_herculesplus.c b/src/video/vid_herculesplus.c index 6ae13ba3f..5c210777e 100644 --- a/src/video/vid_herculesplus.c +++ b/src/video/vid_herculesplus.c @@ -459,8 +459,8 @@ text_line(herculesplus_t *dev, uint16_t ca) for (uint8_t x = 0; x < dev->crtc[1]; x++) { if (dev->ctrl & 8) { - chr = dev->vram[(dev->ma << 1) & 0xfff]; - attr = dev->vram[((dev->ma << 1) + 1) & 0xfff]; + chr = dev->vram[(dev->ma << 1) & 0x3fff]; + attr = dev->vram[((dev->ma << 1) + 1) & 0x3fff]; } else chr = attr = 0; From 6a022039bd11e6ca718de5dd533ab2a580a8428a Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 11 Aug 2023 05:42:08 +0200 Subject: [PATCH 08/13] More Hercules Plus and InColor fixes. --- src/video/vid_herculesplus.c | 6 ++++-- src/video/vid_incolor.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/video/vid_herculesplus.c b/src/video/vid_herculesplus.c index 5c210777e..a70182b90 100644 --- a/src/video/vid_herculesplus.c +++ b/src/video/vid_herculesplus.c @@ -139,6 +139,7 @@ herculesplus_out(uint16_t port, uint8_t val, void *priv) return; old = dev->crtc[dev->crtcreg]; dev->crtc[dev->crtcreg] = val; + if (dev->crtc[10] == 6 && dev->crtc[11] == 7) { /*Fix for Generic Turbo XT BIOS, *which sets up cursor registers wrong*/ @@ -535,6 +536,7 @@ herculesplus_poll(void *priv) int x; int oldvc; int oldsc; + int cw = HERCULESPLUS_CW; VIDEO_MONITOR_PROLOGUE(); if (!dev->linepos) { @@ -558,7 +560,7 @@ herculesplus_poll(void *priv) if ((dev->ctrl & HERCULESPLUS_CTRL_GRAPH) && (dev->ctrl2 & HERCULESPLUS_CTRL2_GRAPH)) x = dev->crtc[1] << 4; else - x = dev->crtc[1] * 9; + x = dev->crtc[1] * cw; video_process_8(x, dev->displine); } @@ -621,7 +623,7 @@ herculesplus_poll(void *priv) if ((dev->ctrl & HERCULESPLUS_CTRL_GRAPH) && (dev->ctrl2 & HERCULESPLUS_CTRL2_GRAPH)) x = dev->crtc[1] << 4; else - x = dev->crtc[1] * 9; + x = dev->crtc[1] * cw; dev->lastline++; if ((dev->ctrl & 8) && ((x != xsize) || ((dev->lastline - dev->firstline) != ysize) || video_force_resize_get())) { xsize = x; diff --git a/src/video/vid_incolor.c b/src/video/vid_incolor.c index 1b10def46..3ff511394 100644 --- a/src/video/vid_incolor.c +++ b/src/video/vid_incolor.c @@ -850,6 +850,7 @@ incolor_poll(void *priv) int x; int oldvc; int oldsc; + int cw = INCOLOR_CW; if (!dev->linepos) { timer_advance_u64(&dev->timer, dev->dispofftime); @@ -931,7 +932,7 @@ incolor_poll(void *priv) if ((dev->ctrl & INCOLOR_CTRL_GRAPH) && (dev->ctrl2 & INCOLOR_CTRL2_GRAPH)) x = dev->crtc[1] << 4; else - x = dev->crtc[1] * 9; + x = dev->crtc[1] * cw; dev->lastline++; if ((dev->ctrl & 8) && ((x != xsize) || ((dev->lastline - dev->firstline) != ysize) || video_force_resize_get())) { xsize = x; From f9335ae5945002a996de2f49ab095e2f5f5c1f6b Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Fri, 11 Aug 2023 12:16:59 -0300 Subject: [PATCH 09/13] Jenkins: Catch more MacPorts activation errors --- .ci/build.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.ci/build.sh b/.ci/build.sh index 0aa6a499d..6d4d9697d 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -540,12 +540,25 @@ then # Attempt to install dependencies. sudo "$macports/bin/port" install $(cat .ci/dependencies_macports.txt) 2>&1 | tee macports.log - # Stop if no port version activation errors were found. + # Check for port activation errors. stuck_dep=$(grep " cannot be built while another version of " macports.log | cut -d" " -f10) - [ -z $stuck_dep ] && break + if [ -n "$stuck_dep" ] + then + # Deactivate the stuck dependency and try again. + sudo "$macports/bin/port" -f deactivate "$stuck_dep" + continue + fi - # Deactivate the stuck dependency and try again. - sudo "$macports/bin/port" -f deactivate $stuck_dep + stuck_dep=$(grep " Please deactivate this port first, or " macports.log | cut -d" " -f5 | tr -d :) + if [ -n "$stuck_dep" ] + then + # Activate the stuck dependency and try again. + sudo "$macports/bin/port" -f activate "$stuck_dep" + continue + fi + + # Stop if no errors were found. + break done # Remove MacPorts error detection log. From 0e37602fe7a6b4c4dd7d525d51bcfc25c3e17b5a Mon Sep 17 00:00:00 2001 From: cold-brewed <47337035+cold-brewed@users.noreply.github.com> Date: Fri, 11 Aug 2023 14:24:05 -0400 Subject: [PATCH 10/13] ymfm: Clean up numerous warnings (#3539) Co-authored-by: cold-brewed --- src/sound/snd_opl_ymfm.cpp | 26 ++++++++++++++++---------- src/sound/ymfm/ymfm.h | 4 +++- src/sound/ymfm/ymfm_fm.ipp | 7 +++++-- src/sound/ymfm/ymfm_opl.cpp | 30 +++++++++++++++--------------- src/sound/ymfm/ymfm_opm.cpp | 10 +++++----- src/sound/ymfm/ymfm_opn.cpp | 14 +++++++------- src/sound/ymfm/ymfm_opq.cpp | 10 +++++----- src/sound/ymfm/ymfm_opz.cpp | 28 ++++++++++++++-------------- 8 files changed, 70 insertions(+), 59 deletions(-) diff --git a/src/sound/snd_opl_ymfm.cpp b/src/sound/snd_opl_ymfm.cpp index c6cf13a33..7558a65ba 100644 --- a/src/sound/snd_opl_ymfm.cpp +++ b/src/sound/snd_opl_ymfm.cpp @@ -150,12 +150,15 @@ public: { for (uint32_t i = 0; i < num_samples; i++) { m_chip.generate(&m_output); - if (ChipType::OUTPUTS == 1) { - *data++ = m_output.data[(m_type == FM_YMF278B) ? 4 : 0]; - *data++ = m_output.data[(m_type == FM_YMF278B) ? 4 : 0]; + if(m_type == FM_YMF278B) { + *data++ += m_output.data[4 % ChipType::OUTPUTS]; + *data++ += m_output.data[5 % ChipType::OUTPUTS]; + } else if (ChipType::OUTPUTS == 1) { + *data++ = m_output.data[0]; + *data++ = m_output.data[0]; } else { - *data++ = m_output.data[(m_type == FM_YMF278B) ? 4 : 0]; - *data++ = m_output.data[(m_type == FM_YMF278B) ? 5 : (1 % ChipType::OUTPUTS)]; + *data++ = m_output.data[0]; + *data++ = m_output.data[1 % ChipType::OUTPUTS]; } } } @@ -167,12 +170,15 @@ public: m_oldsamples[0] = m_samples[0]; m_oldsamples[1] = m_samples[1]; m_chip.generate(&m_output); - if (ChipType::OUTPUTS == 1) { - m_samples[0] = m_output.data[(m_type == FM_YMF278B) ? 4 : 0]; - m_samples[1] = m_output.data[(m_type == FM_YMF278B) ? 4 : 0]; + if(m_type == FM_YMF278B) { + m_samples[0] += m_output.data[4 % ChipType::OUTPUTS]; + m_samples[1] += m_output.data[5 % ChipType::OUTPUTS]; + } else if (ChipType::OUTPUTS == 1) { + m_samples[0] = m_output.data[0]; + m_samples[1] = m_output.data[0]; } else { - m_samples[0] = m_output.data[(m_type == FM_YMF278B) ? 4 : 0]; - m_samples[1] = m_output.data[(m_type == FM_YMF278B) ? 5 : (1 % ChipType::OUTPUTS)]; + m_samples[0] = m_output.data[0]; + m_samples[1] = m_output.data[1 % ChipType::OUTPUTS]; } m_samplecnt -= m_rateratio; } diff --git a/src/sound/ymfm/ymfm.h b/src/sound/ymfm/ymfm.h index bc0cf8b6c..4f8ba1243 100644 --- a/src/sound/ymfm/ymfm.h +++ b/src/sound/ymfm/ymfm.h @@ -46,6 +46,8 @@ #include #include +#define SNPRINTF_BUFFER_SIZE_CALC (256 - (end - &buffer[0])) + namespace ymfm { @@ -350,7 +352,7 @@ public: { // create file char name[20]; - sprintf(name, "wavlog-%02d.wav", m_index); + snprintf(name, sizeof(name), "wavlog-%02d.wav", m_index); FILE *out = fopen(name, "wb"); // make the wav file header diff --git a/src/sound/ymfm/ymfm_fm.ipp b/src/sound/ymfm/ymfm_fm.ipp index 14c1aa965..6e8d39e3e 100644 --- a/src/sound/ymfm/ymfm_fm.ipp +++ b/src/sound/ymfm/ymfm_fm.ipp @@ -1522,8 +1522,11 @@ void fm_engine_base::engine_timer_expired(uint32_t tnum) m_modified_channels |= 1 << chnum; } - // reset - m_timer_running[tnum] = false; + // Make sure the array does not go out of bounds to keep gcc happy + if(tnum < 2) { + // reset + m_timer_running[tnum] = false; + } update_timer(tnum, 1, 0); } diff --git a/src/sound/ymfm/ymfm_opl.cpp b/src/sound/ymfm/ymfm_opl.cpp index 499bfceef..bb91c5dc0 100644 --- a/src/sound/ymfm/ymfm_opl.cpp +++ b/src/sound/ymfm/ymfm_opl.cpp @@ -388,7 +388,7 @@ std::string opl_registers_base::log_keyon(uint32_t choffs, uint32_t op char buffer[256]; char *end = &buffer[0]; - end += sprintf(end, "%2u.%02u freq=%04X fb=%u alg=%X mul=%X tl=%02X ksr=%u ns=%u ksl=%u adr=%X/%X/%X sl=%X sus=%u", + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, "%2u.%02u freq=%04X fb=%u alg=%X mul=%X tl=%02X ksr=%u ns=%u ksl=%u adr=%X/%X/%X sl=%X sus=%u", chnum, opnum, ch_block_freq(choffs), ch_feedback(choffs), @@ -405,25 +405,25 @@ std::string opl_registers_base::log_keyon(uint32_t choffs, uint32_t op op_eg_sustain(opoffs)); if (OUTPUTS > 1) - end += sprintf(end, " out=%c%c%c%c", + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " out=%c%c%c%c", ch_output_0(choffs) ? 'L' : '-', ch_output_1(choffs) ? 'R' : '-', ch_output_2(choffs) ? '0' : '-', ch_output_3(choffs) ? '1' : '-'); if (op_lfo_am_enable(opoffs) != 0) - end += sprintf(end, " am=%u", lfo_am_depth()); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " am=%u", lfo_am_depth()); if (op_lfo_pm_enable(opoffs) != 0) - end += sprintf(end, " pm=%u", lfo_pm_depth()); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " pm=%u", lfo_pm_depth()); if (waveform_enable() && op_waveform(opoffs) != 0) - end += sprintf(end, " wf=%u", op_waveform(opoffs)); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " wf=%u", op_waveform(opoffs)); if (is_rhythm(choffs)) - end += sprintf(end, " rhy=1"); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " rhy=1"); if (DYNAMIC_OPS) { operator_mapping map; operator_map(map); if (bitfield(map.chan[chnum], 16, 8) != 0xff) - end += sprintf(end, " 4op"); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " 4op"); } return buffer; @@ -687,7 +687,7 @@ std::string opll_registers::log_keyon(uint32_t choffs, uint32_t opoffs) char buffer[256]; char *end = &buffer[0]; - end += sprintf(end, "%u.%02u freq=%04X inst=%X fb=%u mul=%X", + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, "%u.%02u freq=%04X inst=%X fb=%u mul=%X", chnum, opnum, ch_block_freq(choffs), ch_instrument(choffs), @@ -695,11 +695,11 @@ std::string opll_registers::log_keyon(uint32_t choffs, uint32_t opoffs) op_multiple(opoffs)); if (bitfield(opoffs, 0) == 1 || (is_rhythm(choffs) && choffs >= 6)) - end += sprintf(end, " vol=%X", op_volume(opoffs)); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " vol=%X", op_volume(opoffs)); else - end += sprintf(end, " tl=%02X", ch_total_level(choffs)); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " tl=%02X", ch_total_level(choffs)); - end += sprintf(end, " ksr=%u ksl=%u adr=%X/%X/%X sl=%X sus=%u/%u", + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " ksr=%u ksl=%u adr=%X/%X/%X sl=%X sus=%u/%u", op_ksr(opoffs), op_ksl(opoffs), op_attack_rate(opoffs), @@ -710,13 +710,13 @@ std::string opll_registers::log_keyon(uint32_t choffs, uint32_t opoffs) ch_sustain(choffs)); if (op_lfo_am_enable(opoffs)) - end += sprintf(end, " am=1"); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " am=1"); if (op_lfo_pm_enable(opoffs)) - end += sprintf(end, " pm=1"); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " pm=1"); if (op_waveform(opoffs) != 0) - end += sprintf(end, " wf=1"); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " wf=1"); if (is_rhythm(choffs)) - end += sprintf(end, " rhy=1"); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " rhy=1"); return buffer; } diff --git a/src/sound/ymfm/ymfm_opm.cpp b/src/sound/ymfm/ymfm_opm.cpp index 544bbe89a..c72badb57 100644 --- a/src/sound/ymfm/ymfm_opm.cpp +++ b/src/sound/ymfm/ymfm_opm.cpp @@ -356,7 +356,7 @@ std::string opm_registers::log_keyon(uint32_t choffs, uint32_t opoffs) char buffer[256]; char *end = &buffer[0]; - end += sprintf(end, "%u.%02u freq=%04X dt2=%u dt=%u fb=%u alg=%X mul=%X tl=%02X ksr=%u adsr=%02X/%02X/%02X/%X sl=%X out=%c%c", + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, "%u.%02u freq=%04X dt2=%u dt=%u fb=%u alg=%X mul=%X tl=%02X ksr=%u adsr=%02X/%02X/%02X/%X sl=%X out=%c%c", chnum, opnum, ch_block_freq(choffs), op_detune2(opoffs), @@ -376,14 +376,14 @@ std::string opm_registers::log_keyon(uint32_t choffs, uint32_t opoffs) bool am = (lfo_am_depth() != 0 && ch_lfo_am_sens(choffs) != 0 && op_lfo_am_enable(opoffs) != 0); if (am) - end += sprintf(end, " am=%u/%02X", ch_lfo_am_sens(choffs), lfo_am_depth()); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " am=%u/%02X", ch_lfo_am_sens(choffs), lfo_am_depth()); bool pm = (lfo_pm_depth() != 0 && ch_lfo_pm_sens(choffs) != 0); if (pm) - end += sprintf(end, " pm=%u/%02X", ch_lfo_pm_sens(choffs), lfo_pm_depth()); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " pm=%u/%02X", ch_lfo_pm_sens(choffs), lfo_pm_depth()); if (am || pm) - end += sprintf(end, " lfo=%02X/%c", lfo_rate(), "WQTN"[lfo_waveform()]); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " lfo=%02X/%c", lfo_rate(), "WQTN"[lfo_waveform()]); if (noise_enable() && opoffs == 31) - end += sprintf(end, " noise=1"); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " noise=1"); return buffer; } diff --git a/src/sound/ymfm/ymfm_opn.cpp b/src/sound/ymfm/ymfm_opn.cpp index 053ad9770..388162dfe 100644 --- a/src/sound/ymfm/ymfm_opn.cpp +++ b/src/sound/ymfm/ymfm_opn.cpp @@ -411,7 +411,7 @@ std::string opn_registers_base::log_keyon(uint32_t choffs, uint32_t opof char buffer[256]; char *end = &buffer[0]; - end += sprintf(end, "%u.%02u freq=%04X dt=%u fb=%u alg=%X mul=%X tl=%02X ksr=%u adsr=%02X/%02X/%02X/%X sl=%X", + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, "%u.%02u freq=%04X dt=%u fb=%u alg=%X mul=%X tl=%02X ksr=%u adsr=%02X/%02X/%02X/%X sl=%X", chnum, opnum, block_freq, op_detune(opoffs), @@ -427,21 +427,21 @@ std::string opn_registers_base::log_keyon(uint32_t choffs, uint32_t opof op_sustain_level(opoffs)); if (OUTPUTS > 1) - end += sprintf(end, " out=%c%c", + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " out=%c%c", ch_output_0(choffs) ? 'L' : '-', ch_output_1(choffs) ? 'R' : '-'); if (op_ssg_eg_enable(opoffs)) - end += sprintf(end, " ssg=%X", op_ssg_eg_mode(opoffs)); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " ssg=%X", op_ssg_eg_mode(opoffs)); bool am = (op_lfo_am_enable(opoffs) && ch_lfo_am_sens(choffs) != 0); if (am) - end += sprintf(end, " am=%u", ch_lfo_am_sens(choffs)); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " am=%u", ch_lfo_am_sens(choffs)); bool pm = (ch_lfo_pm_sens(choffs) != 0); if (pm) - end += sprintf(end, " pm=%u", ch_lfo_pm_sens(choffs)); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " pm=%u", ch_lfo_pm_sens(choffs)); if (am || pm) - end += sprintf(end, " lfo=%02X", lfo_rate()); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " lfo=%02X", lfo_rate()); if (multi_freq() && choffs == 2) - end += sprintf(end, " multi=1"); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " multi=1"); return buffer; } diff --git a/src/sound/ymfm/ymfm_opq.cpp b/src/sound/ymfm/ymfm_opq.cpp index 3467c0ddf..e6f6fa5ea 100644 --- a/src/sound/ymfm/ymfm_opq.cpp +++ b/src/sound/ymfm/ymfm_opq.cpp @@ -341,7 +341,7 @@ std::string opq_registers::log_keyon(uint32_t choffs, uint32_t opoffs) char buffer[256]; char *end = &buffer[0]; - end += sprintf(end, "%u.%02u freq=%04X dt=%+2d fb=%u alg=%X mul=%X tl=%02X ksr=%u adsr=%02X/%02X/%02X/%X sl=%X out=%c%c", + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, "%u.%02u freq=%04X dt=%+2d fb=%u alg=%X mul=%X tl=%02X ksr=%u adsr=%02X/%02X/%02X/%X sl=%X out=%c%c", chnum, opnum, (opoffs & 1) ? ch_block_freq_24(choffs) : ch_block_freq_13(choffs), int32_t(op_detune(opoffs)) - 0x20, @@ -360,14 +360,14 @@ std::string opq_registers::log_keyon(uint32_t choffs, uint32_t opoffs) bool am = (lfo_enable() && op_lfo_am_enable(opoffs) && ch_lfo_am_sens(choffs) != 0); if (am) - end += sprintf(end, " am=%u", ch_lfo_am_sens(choffs)); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " am=%u", ch_lfo_am_sens(choffs)); bool pm = (lfo_enable() && ch_lfo_pm_sens(choffs) != 0); if (pm) - end += sprintf(end, " pm=%u", ch_lfo_pm_sens(choffs)); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " pm=%u", ch_lfo_pm_sens(choffs)); if (am || pm) - end += sprintf(end, " lfo=%02X", lfo_rate()); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " lfo=%02X", lfo_rate()); if (ch_reverb(choffs)) - end += sprintf(end, " reverb"); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " reverb"); return buffer; } diff --git a/src/sound/ymfm/ymfm_opz.cpp b/src/sound/ymfm/ymfm_opz.cpp index adeefd79f..a5ec912aa 100644 --- a/src/sound/ymfm/ymfm_opz.cpp +++ b/src/sound/ymfm/ymfm_opz.cpp @@ -557,14 +557,14 @@ std::string opz_registers::log_keyon(uint32_t choffs, uint32_t opoffs) char buffer[256]; char *end = &buffer[0]; - end += sprintf(end, "%u.%02u", chnum, opnum); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, "%u.%02u", chnum, opnum); if (op_fix_mode(opoffs)) - end += sprintf(end, " fixfreq=%X fine=%X shift=%X", op_fix_frequency(opoffs), op_fine(opoffs), op_fix_range(opoffs)); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " fixfreq=%X fine=%X shift=%X", op_fix_frequency(opoffs), op_fine(opoffs), op_fix_range(opoffs)); else - end += sprintf(end, " freq=%04X dt2=%u fine=%X", ch_block_freq(choffs), op_detune2(opoffs), op_fine(opoffs)); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " freq=%04X dt2=%u fine=%X", ch_block_freq(choffs), op_detune2(opoffs), op_fine(opoffs)); - end += sprintf(end, " dt=%u fb=%u alg=%X mul=%X tl=%02X ksr=%u adsr=%02X/%02X/%02X/%X sl=%X out=%c%c", + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " dt=%u fb=%u alg=%X mul=%X tl=%02X ksr=%u adsr=%02X/%02X/%02X/%X sl=%X out=%c%c", op_detune(opoffs), ch_feedback(choffs), ch_algorithm(choffs), @@ -580,32 +580,32 @@ std::string opz_registers::log_keyon(uint32_t choffs, uint32_t opoffs) ch_output_1(choffs) ? 'R' : '-'); if (op_eg_shift(opoffs) != 0) - end += sprintf(end, " egshift=%u", op_eg_shift(opoffs)); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " egshift=%u", op_eg_shift(opoffs)); bool am = (lfo_am_depth() != 0 && ch_lfo_am_sens(choffs) != 0 && op_lfo_am_enable(opoffs) != 0); if (am) - end += sprintf(end, " am=%u/%02X", ch_lfo_am_sens(choffs), lfo_am_depth()); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " am=%u/%02X", ch_lfo_am_sens(choffs), lfo_am_depth()); bool pm = (lfo_pm_depth() != 0 && ch_lfo_pm_sens(choffs) != 0); if (pm) - end += sprintf(end, " pm=%u/%02X", ch_lfo_pm_sens(choffs), lfo_pm_depth()); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " pm=%u/%02X", ch_lfo_pm_sens(choffs), lfo_pm_depth()); if (am || pm) - end += sprintf(end, " lfo=%02X/%c", lfo_rate(), "WQTN"[lfo_waveform()]); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " lfo=%02X/%c", lfo_rate(), "WQTN"[lfo_waveform()]); bool am2 = (lfo2_am_depth() != 0 && ch_lfo2_am_sens(choffs) != 0 && op_lfo_am_enable(opoffs) != 0); if (am2) - end += sprintf(end, " am2=%u/%02X", ch_lfo2_am_sens(choffs), lfo2_am_depth()); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " am2=%u/%02X", ch_lfo2_am_sens(choffs), lfo2_am_depth()); bool pm2 = (lfo2_pm_depth() != 0 && ch_lfo2_pm_sens(choffs) != 0); if (pm2) - end += sprintf(end, " pm2=%u/%02X", ch_lfo2_pm_sens(choffs), lfo2_pm_depth()); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " pm2=%u/%02X", ch_lfo2_pm_sens(choffs), lfo2_pm_depth()); if (am2 || pm2) - end += sprintf(end, " lfo2=%02X/%c", lfo2_rate(), "WQTN"[lfo2_waveform()]); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " lfo2=%02X/%c", lfo2_rate(), "WQTN"[lfo2_waveform()]); if (op_reverb_rate(opoffs) != 0) - end += sprintf(end, " rev=%u", op_reverb_rate(opoffs)); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " rev=%u", op_reverb_rate(opoffs)); if (op_waveform(opoffs) != 0) - end += sprintf(end, " wf=%u", op_waveform(opoffs)); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " wf=%u", op_waveform(opoffs)); if (noise_enable() && opoffs == 31) - end += sprintf(end, " noise=1"); + end += snprintf(end, SNPRINTF_BUFFER_SIZE_CALC, " noise=1"); return buffer; } From edf5c2bb5d23cad2e798df5ecebf4399661fc24d Mon Sep 17 00:00:00 2001 From: pankozaC++ <77279607+pankoza2-pl@users.noreply.github.com> Date: Fri, 11 Aug 2023 20:42:01 +0200 Subject: [PATCH 11/13] Add Dell OEM version of Intel Premiere PCI/II (part 1) --- src/include/86box/machine.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 7e17c270f..a2f824619 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -572,6 +572,7 @@ extern int machine_at_p5sp4_init(const machine_t *); /* m_at_socket5.c */ extern int machine_at_plato_init(const machine_t *); +extern int machine_at_dellplato_init(const machine_t *); extern int machine_at_ambradp90_init(const machine_t *); extern int machine_at_430nx_init(const machine_t *); From cced8a66c96b0c593ad824c2ce7b9dcb75fc64d4 Mon Sep 17 00:00:00 2001 From: pankozaC++ <77279607+pankoza2-pl@users.noreply.github.com> Date: Fri, 11 Aug 2023 20:44:33 +0200 Subject: [PATCH 12/13] Add Dell OEM Version of Intel Premiere PCI/II (part 2) --- src/machine/m_at_socket5.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/machine/m_at_socket5.c b/src/machine/m_at_socket5.c index 9a45e71bf..acaff764e 100644 --- a/src/machine/m_at_socket5.c +++ b/src/machine/m_at_socket5.c @@ -61,6 +61,25 @@ machine_at_plato_init(const machine_t *model) return ret; } +int +machine_at_dellplato_init(const machine_t *model) +{ + int ret; + + ret = bios_load_linear_combined("roms/machines/dellplato/1016AX1J.bio", + "roms/machines/dellplato/1016AX1J.bi1", + 0x1d000, 128); + + if (bios_only || !ret) + return ret; + + machine_at_premiere_common_init(model, PCI_CAN_SWITCH_TYPE); + + device_add(&i430nx_device); + + return ret; +} + int machine_at_ambradp90_init(const machine_t *model) { From 3bf6478b71b4f87c6076c02b5ae7938f900fedf5 Mon Sep 17 00:00:00 2001 From: pankozaC++ <77279607+pankoza2-pl@users.noreply.github.com> Date: Fri, 11 Aug 2023 20:47:01 +0200 Subject: [PATCH 13/13] Add Dell OEM version of Intel Premiere PCI/II (part 3) --- src/machine/machine_table.c | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index d16713e6c..f19e7c9ef 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -8094,6 +8094,45 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, + /* Same as Intel Premiere PCI/II, but with a Dell OEM BIOS */ + { + .name = "[i430NX] Dell Dimension XPS Pxxx", + .internal_name = "dellplato", + .type = MACHINE_TYPE_SOCKET5, + .chipset = MACHINE_CHIPSET_INTEL_430NX, + .init = machine_at_dellplato_init, + .pad = 0, + .pad0 = 0, + .pad1 = MACHINE_AVAILABLE, + .pad2 = 0, + .cpu = { + .package = CPU_PKG_SOCKET5_7, + .block = CPU_BLOCK_NONE, + .min_bus = 50000000, + .max_bus = 66666667, + .min_voltage = 3520, + .max_voltage = 3520, + .min_multi = 1.5, + .max_multi = 1.5 + }, + .bus_flags = MACHINE_PS2_PCI, + .flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_ACPI, + .ram = { + .min = 2048, + .max = 131072, + .step = 2048 + }, + .nvrmask = 127, + .kbc_device = NULL, + .kbc_p1 = 0, + .gpio = 0, + .device = NULL, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = NULL, + .snd_device = NULL, + .net_device = NULL + }, /* This has the Phoenix MultiKey KBC firmware. This is basically an Intel Premiere/PCI II with a fancier POST screen. */ {