From 17a75137de0b57e3a1c4ee018a57682230ff4435 Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Thu, 16 Dec 2021 12:53:04 +0100 Subject: [PATCH 1/2] include for std::min --- src/qt/qt_settingsmachine.cpp | 2 ++ src/qt/sdl_joystick.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/qt/qt_settingsmachine.cpp b/src/qt/qt_settingsmachine.cpp index 267ea06ae..d278031cb 100644 --- a/src/qt/qt_settingsmachine.cpp +++ b/src/qt/qt_settingsmachine.cpp @@ -7,6 +7,8 @@ #include #include +#include + extern "C" { #include "../cpu/cpu.h" diff --git a/src/qt/sdl_joystick.cpp b/src/qt/sdl_joystick.cpp index 5a8100ee5..60d2dafad 100644 --- a/src/qt/sdl_joystick.cpp +++ b/src/qt/sdl_joystick.cpp @@ -2,6 +2,8 @@ #include +#include + extern "C" { #include <86box/device.h> #include <86box/gameport.h> From 92b7ea8536b6c2c665c08923ddcd39231eb5035e Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Thu, 16 Dec 2021 13:52:37 +0100 Subject: [PATCH 2/2] simplified (from @OBattler) --- src/qt/qt_settingsmachine.cpp | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/qt/qt_settingsmachine.cpp b/src/qt/qt_settingsmachine.cpp index d278031cb..959c53635 100644 --- a/src/qt/qt_settingsmachine.cpp +++ b/src/qt/qt_settingsmachine.cpp @@ -158,26 +158,18 @@ void SettingsMachine::on_comboBoxMachine_currentIndexChanged(int index) { ui->comboBoxCPU->setCurrentIndex(-1); ui->comboBoxCPU->setCurrentIndex(selectedCpuFamilyRow); - auto* machine = &machines[machineId]; - if ((machine->ram_granularity < 1024)) { - ui->spinBoxRAM->setMinimum(machine_get_min_ram(machineId)); - ui->spinBoxRAM->setMaximum(machine_get_max_ram(machineId)); - ui->spinBoxRAM->setSingleStep(machine_get_ram_granularity(machineId)); - ui->spinBoxRAM->setSuffix(" KiB"); - ui->spinBoxRAM->setValue(mem_size); + int divisor; + if ((machine_get_ram_granularity(machineId) < 1024)) { + divisor = 1; + ui->spinBoxRAM->setSuffix(" KB"); } else { - int maxram; -#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) - maxram = std::min(machine->max_ram, 2097152); -#else - maxram = std::min(machine_get_max_ram(machineId), 3145728); -#endif - ui->spinBoxRAM->setMinimum(machine_get_min_ram(machineId) / 1024); - ui->spinBoxRAM->setMaximum(maxram / 1024); - ui->spinBoxRAM->setSingleStep(machine_get_ram_granularity(machineId) / 1024); - ui->spinBoxRAM->setSuffix(" MiB"); - ui->spinBoxRAM->setValue(mem_size / 1024); + divisor = 1024; + ui->spinBoxRAM->setSuffix(" MB"); } + ui->spinBoxRAM->setMinimum(machine_get_min_ram(machineId) / divisor); + ui->spinBoxRAM->setMaximum(machine_get_max_ram(machineId) / divisor); + ui->spinBoxRAM->setSingleStep(machine_get_ram_granularity(machineId) / divisor); + ui->spinBoxRAM->setValue(mem_size / divisor); ui->spinBoxRAM->setEnabled(machine_get_min_ram(machineId) != machine_get_max_ram(machineId)); emit currentMachineChanged(machineId);