2022-02-07 15:00:02 +06:00
|
|
|
/*
|
2023-01-06 15:36:05 -05:00
|
|
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
|
|
|
|
* running old operating systems and software designed for IBM
|
|
|
|
|
* PC systems and compatibles from 1981 through fairly recent
|
|
|
|
|
* system designs based on the PCI bus.
|
2022-02-07 15:00:02 +06:00
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* This file is part of the 86Box distribution.
|
2022-02-07 15:00:02 +06:00
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* Display settings UI module.
|
2022-02-07 15:00:02 +06:00
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* Authors: Joakim L. Gilje <jgilje@jgilje.net>
|
2022-02-07 15:00:02 +06:00
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* Copyright 2021 Joakim L. Gilje
|
2022-02-07 15:00:02 +06:00
|
|
|
*/
|
2021-11-25 10:20:56 +01:00
|
|
|
#include "qt_settingsdisplay.hpp"
|
|
|
|
|
#include "ui_qt_settingsdisplay.h"
|
|
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
#include <86box/86box.h>
|
|
|
|
|
#include <86box/device.h>
|
|
|
|
|
#include <86box/machine.h>
|
|
|
|
|
#include <86box/video.h>
|
2022-07-03 23:01:46 +02:00
|
|
|
#include <86box/vid_xga_device.h>
|
2021-11-25 10:20:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include "qt_deviceconfig.hpp"
|
|
|
|
|
#include "qt_models_common.hpp"
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
SettingsDisplay::SettingsDisplay(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
, ui(new Ui::SettingsDisplay)
|
2021-11-25 10:20:56 +01:00
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
2023-07-14 23:38:04 +02:00
|
|
|
videoCard[0] = gfxcard[0];
|
2023-02-06 04:12:46 -05:00
|
|
|
videoCard[1] = gfxcard[1];
|
2021-11-25 10:20:56 +01:00
|
|
|
onCurrentMachineChanged(machine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SettingsDisplay::~SettingsDisplay()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsDisplay::save()
|
|
|
|
|
{
|
2023-08-22 17:56:55 +05:00
|
|
|
gfxcard[0] = ui->comboBoxVideo->currentData().toInt();
|
|
|
|
|
gfxcard[1] = ui->comboBoxVideoSecondary->currentData().toInt();
|
|
|
|
|
voodoo_enabled = ui->checkBoxVoodoo->isChecked() ? 1 : 0;
|
|
|
|
|
ibm8514_standalone_enabled = ui->checkBox8514->isChecked() ? 1 : 0;
|
|
|
|
|
xga_standalone_enabled = ui->checkBoxXga->isChecked() ? 1 : 0;
|
2021-11-25 10:20:56 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsDisplay::onCurrentMachineChanged(int machineId)
|
|
|
|
|
{
|
2021-11-25 10:20:56 +01:00
|
|
|
// win_settings_video_proc, WM_INITDIALOG
|
|
|
|
|
this->machineId = machineId;
|
2023-02-06 04:12:46 -05:00
|
|
|
auto curVideoCard = videoCard[0];
|
2021-11-25 10:20:56 +01:00
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
auto *model = ui->comboBoxVideo->model();
|
|
|
|
|
auto removeRows = model->rowCount();
|
2021-11-25 10:20:56 +01:00
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
int c = 0;
|
2021-11-25 10:20:56 +01:00
|
|
|
int selectedRow = 0;
|
|
|
|
|
while (true) {
|
|
|
|
|
/* Skip "internal" if machine doesn't have it. */
|
2021-12-14 13:53:56 +01:00
|
|
|
if ((c == 1) && (machine_has_flags(machineId, MACHINE_VIDEO) == 0)) {
|
2021-11-25 10:20:56 +01:00
|
|
|
c++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
const device_t *video_dev = video_card_getdevice(c);
|
|
|
|
|
QString name = DeviceConfig::DeviceName(video_dev, video_get_internal_name(c), 1);
|
2021-11-25 10:20:56 +01:00
|
|
|
if (name.isEmpty()) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
if (video_card_available(c) && device_is_valid(video_dev, machineId)) {
|
2021-11-25 10:20:56 +01:00
|
|
|
int row = Models::AddEntry(model, name, c);
|
2022-12-23 20:49:13 +06:00
|
|
|
if (c == curVideoCard) {
|
2021-11-25 10:20:56 +01:00
|
|
|
selectedRow = row - removeRows;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c++;
|
|
|
|
|
}
|
|
|
|
|
model->removeRows(0, removeRows);
|
|
|
|
|
|
2021-12-14 13:53:56 +01:00
|
|
|
if (machine_has_flags(machineId, MACHINE_VIDEO_ONLY) > 0) {
|
2021-11-25 10:20:56 +01:00
|
|
|
ui->comboBoxVideo->setEnabled(false);
|
2022-07-07 14:34:59 +06:00
|
|
|
ui->comboBoxVideoSecondary->setEnabled(false);
|
|
|
|
|
ui->pushButtonConfigureSecondary->setEnabled(false);
|
2021-11-25 10:20:56 +01:00
|
|
|
selectedRow = 1;
|
|
|
|
|
} else {
|
|
|
|
|
ui->comboBoxVideo->setEnabled(true);
|
2022-07-07 14:34:59 +06:00
|
|
|
ui->comboBoxVideoSecondary->setEnabled(true);
|
|
|
|
|
ui->pushButtonConfigureSecondary->setEnabled(true);
|
2021-11-25 10:20:56 +01:00
|
|
|
}
|
|
|
|
|
ui->comboBoxVideo->setCurrentIndex(selectedRow);
|
2023-02-06 04:12:46 -05:00
|
|
|
if (gfxcard[1] == 0)
|
2022-11-19 08:49:04 -05:00
|
|
|
ui->pushButtonConfigureSecondary->setEnabled(false);
|
2021-11-25 10:20:56 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsDisplay::on_pushButtonConfigure_clicked()
|
|
|
|
|
{
|
2023-10-06 05:41:15 +02:00
|
|
|
int videoCard = ui->comboBoxVideo->currentData().toInt();
|
|
|
|
|
auto *device = video_card_getdevice(videoCard);
|
|
|
|
|
if (videoCard == VID_INTERNAL)
|
|
|
|
|
device = machine_get_vid_device(machineId);
|
2022-11-19 08:49:04 -05:00
|
|
|
DeviceConfig::ConfigureDevice(device, 0, qobject_cast<Settings *>(Settings::settings));
|
2021-11-25 10:20:56 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsDisplay::on_pushButtonConfigureVoodoo_clicked()
|
|
|
|
|
{
|
|
|
|
|
DeviceConfig::ConfigureDevice(&voodoo_device, 0, qobject_cast<Settings *>(Settings::settings));
|
2021-11-25 10:20:56 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsDisplay::on_pushButtonConfigureXga_clicked()
|
|
|
|
|
{
|
2023-08-22 17:56:55 +05:00
|
|
|
if (machine_has_bus(machineId, MACHINE_BUS_MCA) > 0) {
|
|
|
|
|
DeviceConfig::ConfigureDevice(&xga_device, 0, qobject_cast<Settings *>(Settings::settings));
|
|
|
|
|
} else {
|
|
|
|
|
DeviceConfig::ConfigureDevice(&xga_isa_device, 0, qobject_cast<Settings *>(Settings::settings));
|
2022-07-03 23:01:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index)
|
|
|
|
|
{
|
2021-11-25 10:20:56 +01:00
|
|
|
if (index < 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-02-06 04:12:46 -05:00
|
|
|
auto curVideoCard_2 = videoCard[1];
|
|
|
|
|
videoCard[0] = ui->comboBoxVideo->currentData().toInt();
|
2023-10-06 05:28:26 +02:00
|
|
|
if (videoCard[0] == VID_INTERNAL)
|
|
|
|
|
ui->pushButtonConfigure->setEnabled(machine_has_flags(machineId, MACHINE_VIDEO) &&
|
|
|
|
|
device_has_config(machine_get_vid_device(machineId)));
|
|
|
|
|
else
|
|
|
|
|
ui->pushButtonConfigure->setEnabled(video_card_has_config(videoCard[0]) > 0);
|
2021-12-14 13:53:56 +01:00
|
|
|
bool machineHasPci = machine_has_bus(machineId, MACHINE_BUS_PCI) > 0;
|
2021-11-25 10:20:56 +01:00
|
|
|
ui->checkBoxVoodoo->setEnabled(machineHasPci);
|
|
|
|
|
if (machineHasPci) {
|
|
|
|
|
ui->checkBoxVoodoo->setChecked(voodoo_enabled);
|
|
|
|
|
}
|
|
|
|
|
ui->pushButtonConfigureVoodoo->setEnabled(machineHasPci && ui->checkBoxVoodoo->isChecked());
|
2022-05-14 18:55:00 +02:00
|
|
|
|
2023-08-22 17:56:55 +05:00
|
|
|
bool machineHasIsa16 = machine_has_bus(machineId, MACHINE_BUS_ISA16) > 0;
|
|
|
|
|
bool machineHasMca = machine_has_bus(machineId, MACHINE_BUS_MCA) > 0;
|
|
|
|
|
|
|
|
|
|
bool videoCardHas8514 = ((videoCard[0] == VID_INTERNAL) ? machine_has_flags(machineId, MACHINE_VIDEO_8514A) : (video_card_get_flags(videoCard[0]) == VIDEO_FLAG_TYPE_8514));
|
|
|
|
|
bool videoCardHasXga = ((videoCard[0] == VID_INTERNAL) ? machine_has_flags(machineId, MACHINE_VIDEO_XGA) : (video_card_get_flags(videoCard[0]) == VIDEO_FLAG_TYPE_XGA));
|
|
|
|
|
|
2024-03-11 19:25:45 +05:00
|
|
|
bool machineSupports8514 = ((machineHasIsa16 || machineHasMca) && !videoCardHas8514);
|
|
|
|
|
bool machineSupportsXga = (((machineHasIsa16 && device_available(&xga_isa_device)) || (machineHasMca && device_available(&xga_device))) && !videoCardHasXga);
|
2022-06-17 21:26:26 +02:00
|
|
|
|
2024-03-11 19:25:45 +05:00
|
|
|
ui->checkBox8514->setEnabled(machineSupports8514);
|
|
|
|
|
ui->checkBox8514->setChecked(ibm8514_standalone_enabled && machineSupports8514);
|
2022-07-03 23:01:46 +02:00
|
|
|
|
2024-03-11 19:25:45 +05:00
|
|
|
ui->checkBoxXga->setEnabled(machineSupportsXga);
|
|
|
|
|
ui->checkBoxXga->setChecked(xga_standalone_enabled && machineSupportsXga);
|
|
|
|
|
|
|
|
|
|
ui->pushButtonConfigureXga->setEnabled(ui->checkBoxXga->isEnabled() && ui->checkBoxXga->isChecked());
|
2022-07-07 14:34:59 +06:00
|
|
|
|
|
|
|
|
int c = 2;
|
2022-07-07 18:16:15 +06:00
|
|
|
|
2022-07-07 14:34:59 +06:00
|
|
|
ui->comboBoxVideoSecondary->clear();
|
|
|
|
|
ui->comboBoxVideoSecondary->addItem(QObject::tr("None"), 0);
|
|
|
|
|
|
2022-07-08 14:21:41 +06:00
|
|
|
ui->comboBoxVideoSecondary->setCurrentIndex(0);
|
2022-07-07 18:16:15 +06:00
|
|
|
// TODO: Implement support for selecting non-MDA secondary cards properly when MDA cards are the primary ones.
|
2023-02-06 04:12:46 -05:00
|
|
|
if (video_card_get_flags(videoCard[0]) == VIDEO_FLAG_TYPE_MDA) {
|
2022-07-07 18:16:15 +06:00
|
|
|
ui->comboBoxVideoSecondary->setCurrentIndex(0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-07-07 14:34:59 +06:00
|
|
|
while (true) {
|
2022-11-19 08:49:04 -05:00
|
|
|
const device_t *video_dev = video_card_getdevice(c);
|
|
|
|
|
QString name = DeviceConfig::DeviceName(video_dev, video_get_internal_name(c), 1);
|
2022-07-07 14:34:59 +06:00
|
|
|
if (name.isEmpty()) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 17:56:55 +05:00
|
|
|
int primaryFlags = video_card_get_flags(videoCard[0]);
|
|
|
|
|
int secondaryFlags = video_card_get_flags(c);
|
|
|
|
|
if (video_card_available(c)
|
|
|
|
|
&& device_is_valid(video_dev, machineId)
|
|
|
|
|
&& !((secondaryFlags == primaryFlags) && (secondaryFlags != VIDEO_FLAG_TYPE_SPECIAL))
|
|
|
|
|
&& !(((primaryFlags == VIDEO_FLAG_TYPE_8514) || (primaryFlags == VIDEO_FLAG_TYPE_XGA)) && (secondaryFlags != VIDEO_FLAG_TYPE_MDA) && (secondaryFlags != VIDEO_FLAG_TYPE_SPECIAL))
|
|
|
|
|
&& !((primaryFlags != VIDEO_FLAG_TYPE_MDA) && (primaryFlags != VIDEO_FLAG_TYPE_SPECIAL) && ((secondaryFlags == VIDEO_FLAG_TYPE_8514) || (secondaryFlags == VIDEO_FLAG_TYPE_XGA)))) {
|
2022-11-19 08:49:04 -05:00
|
|
|
ui->comboBoxVideoSecondary->addItem(name, c);
|
2022-12-23 20:49:13 +06:00
|
|
|
if (c == curVideoCard_2)
|
2022-11-19 08:49:04 -05:00
|
|
|
ui->comboBoxVideoSecondary->setCurrentIndex(ui->comboBoxVideoSecondary->count() - 1);
|
2022-07-07 14:34:59 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c++;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-14 23:38:04 +02:00
|
|
|
if ((videoCard[1] == 0) || (machine_has_flags(machineId, MACHINE_VIDEO_ONLY) > 0)) {
|
2022-07-08 14:21:41 +06:00
|
|
|
ui->comboBoxVideoSecondary->setCurrentIndex(0);
|
|
|
|
|
ui->pushButtonConfigureSecondary->setEnabled(false);
|
|
|
|
|
}
|
2021-11-25 10:20:56 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsDisplay::on_checkBoxVoodoo_stateChanged(int state)
|
|
|
|
|
{
|
2021-11-25 10:20:56 +01:00
|
|
|
ui->pushButtonConfigureVoodoo->setEnabled(state == Qt::Checked);
|
|
|
|
|
}
|
2022-07-03 23:01:46 +02:00
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsDisplay::on_checkBoxXga_stateChanged(int state)
|
|
|
|
|
{
|
2023-08-22 17:56:55 +05:00
|
|
|
ui->pushButtonConfigureXga->setEnabled(state == Qt::Checked);
|
2022-07-03 23:01:46 +02:00
|
|
|
}
|
2022-07-07 14:34:59 +06:00
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsDisplay::on_comboBoxVideoSecondary_currentIndexChanged(int index)
|
2022-07-07 14:34:59 +06:00
|
|
|
{
|
|
|
|
|
if (index < 0) {
|
2022-07-08 14:21:41 +06:00
|
|
|
ui->pushButtonConfigureSecondary->setEnabled(false);
|
2022-07-07 14:34:59 +06:00
|
|
|
return;
|
|
|
|
|
}
|
2023-02-06 04:12:46 -05:00
|
|
|
videoCard[1] = ui->comboBoxVideoSecondary->currentData().toInt();
|
|
|
|
|
ui->pushButtonConfigureSecondary->setEnabled(index != 0 && video_card_has_config(videoCard[1]) > 0);
|
2022-07-07 14:34:59 +06:00
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
SettingsDisplay::on_pushButtonConfigureSecondary_clicked()
|
2022-07-07 14:34:59 +06:00
|
|
|
{
|
2022-11-19 08:49:04 -05:00
|
|
|
auto *device = video_card_getdevice(ui->comboBoxVideoSecondary->currentData().toInt());
|
|
|
|
|
DeviceConfig::ConfigureDevice(device, 0, qobject_cast<Settings *>(Settings::settings));
|
2022-07-07 14:34:59 +06:00
|
|
|
}
|