From 276e43428e11a869b53a2792df822a5e0191c7c0 Mon Sep 17 00:00:00 2001 From: GreaseMonkey Date: Mon, 8 Jan 2024 13:48:33 +1300 Subject: [PATCH] Allow one to enable/disable unit tester exit Memo to self: Hardware renderers often exit in a silent segfault. Look into this at some point. --- src/device/unittester.c | 17 ++++++++++++++--- src/qt/qt_settingsotherperipherals.cpp | 7 +++++++ src/qt/qt_settingsotherperipherals.hpp | 1 + src/qt/qt_settingsotherperipherals.ui | 19 ++++++++++++++++++- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/device/unittester.c b/src/device/unittester.c index f8f7fa56e..0442d0695 100644 --- a/src/device/unittester.c +++ b/src/device/unittester.c @@ -114,10 +114,18 @@ static const struct unittester_state unittester_defaults = { .cmd_id = UT_CMD_NOOP, }; +static const device_config_t unittester_config[] = { + { .name = "exit_enabled", + .description = "Enable 0x04 \"Exit 86Box\" command", + .type = CONFIG_BINARY, + .default_int = 1, + .default_string = "" }, + { .type = CONFIG_END } +}; + /* Kept separate, as we will be reusing this object */ static bitmap_t *unittester_screen_buffer = NULL; -/* FIXME: This needs a config option! --GM */ static bool unittester_exit_enabled = true; #ifdef ENABLE_UNITTESTER_LOG @@ -572,10 +580,13 @@ unittester_trigger_write(UNUSED(uint16_t port), uint8_t val, UNUSED(void *priv)) static void * unittester_init(UNUSED(const device_t *info)) { + unittester = (struct unittester_state) unittester_defaults; + + unittester_exit_enabled = !!device_get_config_int("exit_enabled"); + if (unittester_screen_buffer == NULL) unittester_screen_buffer = create_bitmap(2048, 2048); - unittester = (struct unittester_state) unittester_defaults; io_sethandler(unittester.trigger_port, 1, NULL, NULL, NULL, unittester_trigger_write, NULL, NULL, NULL); unittester_log("[UT] 86Box Unit Tester initialised\n"); @@ -611,5 +622,5 @@ const device_t unittester_device = { { .available = NULL }, .speed_changed = NULL, .force_redraw = NULL, - .config = NULL + .config = unittester_config, }; diff --git a/src/qt/qt_settingsotherperipherals.cpp b/src/qt/qt_settingsotherperipherals.cpp index ad7a00bb4..beb484848 100644 --- a/src/qt/qt_settingsotherperipherals.cpp +++ b/src/qt/qt_settingsotherperipherals.cpp @@ -23,6 +23,7 @@ extern "C" { #include <86box/machine.h> #include <86box/isamem.h> #include <86box/isartc.h> +#include <86box/unittester.h> } #include "qt_deviceconfig.hpp" @@ -199,3 +200,9 @@ SettingsOtherPeripherals::on_pushButtonConfigureCard4_clicked() { DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard4->currentData().toInt()), 4, qobject_cast(Settings::settings)); } + +void +SettingsOtherPeripherals::on_pushButtonConfigureUT_clicked() +{ + DeviceConfig::ConfigureDevice(&unittester_device); +} diff --git a/src/qt/qt_settingsotherperipherals.hpp b/src/qt/qt_settingsotherperipherals.hpp index 97e47c90e..b521e7829 100644 --- a/src/qt/qt_settingsotherperipherals.hpp +++ b/src/qt/qt_settingsotherperipherals.hpp @@ -30,6 +30,7 @@ private slots: void on_comboBoxCard1_currentIndexChanged(int index); void on_pushButtonConfigureRTC_clicked(); void on_comboBoxRTC_currentIndexChanged(int index); + void on_pushButtonConfigureUT_clicked(); private: Ui::SettingsOtherPeripherals *ui; diff --git a/src/qt/qt_settingsotherperipherals.ui b/src/qt/qt_settingsotherperipherals.ui index 481d80ebe..af953a984 100644 --- a/src/qt/qt_settingsotherperipherals.ui +++ b/src/qt/qt_settingsotherperipherals.ui @@ -190,10 +190,27 @@ + + + + - 86Box unit tester + 86Box Unit Tester + + + + 0 + 0 + + + + + + + + Configure