Overhauled CD-ROM selection for SCSI and ATAPI, including model and vendor specific commands.

Fixed the Spock SCSI ID selection.
Fixed CD Audio on NCR 5380-based SCSI controllers.
Added a proprietary CD-ROM controller selection (not hooked up yet).
All on qt only.
This commit is contained in:
TC1995
2023-01-07 23:48:45 +01:00
parent d501a61dfb
commit e5496e2638
19 changed files with 1941 additions and 473 deletions

View File

@@ -20,6 +20,7 @@
extern "C" {
#include <86box/hdd.h>
#include <86box/cdrom.h>
}
#include <QAbstractItemModel>
@@ -48,14 +49,16 @@ void
Harddrives::populateRemovableBuses(QAbstractItemModel *model)
{
model->removeRows(0, model->rowCount());
model->insertRows(0, 3);
model->insertRows(0, 4);
model->setData(model->index(0, 0), QObject::tr("Disabled"));
model->setData(model->index(1, 0), QObject::tr("ATAPI"));
model->setData(model->index(2, 0), QObject::tr("SCSI"));
model->setData(model->index(3, 0), QObject::tr("Mitsumi"));
model->setData(model->index(0, 0), HDD_BUS_DISABLED, Qt::UserRole);
model->setData(model->index(1, 0), HDD_BUS_ATAPI, Qt::UserRole);
model->setData(model->index(2, 0), HDD_BUS_SCSI, Qt::UserRole);
model->setData(model->index(3, 0), CDROM_BUS_MITSUMI, Qt::UserRole);
}
void
@@ -143,6 +146,9 @@ Harddrives::BusChannelName(uint8_t bus, uint8_t channel)
case HDD_BUS_SCSI:
busName = QString("SCSI (%1:%2)").arg(channel >> 4).arg(channel & 15, 2, 10, QChar('0'));
break;
case CDROM_BUS_MITSUMI:
busName = QString("Mitsumi");
break;
}
return busName;

View File

@@ -29,6 +29,7 @@ extern uint64_t tsc;
#include <86box/cartridge.h>
#include <86box/cassette.h>
#include <86box/cdrom.h>
#include <86box/cdrom_interface.h>
#include <86box/fdd.h>
#include <86box/hdc.h>
#include <86box/scsi.h>
@@ -300,6 +301,8 @@ MachineStatus::iterateCDROM(const std::function<void(int)> &cb)
continue;
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && !hasSCSI() && (scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) && (scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
continue;
if ((cdrom[i].bus_type == CDROM_BUS_MITSUMI) && (cdrom_interface_current == 0))
continue;
if (cdrom[i].bus_type != 0) {
cb(i);
}

View File

@@ -593,6 +593,9 @@ MediaMenu::cdromUpdateMenu(int i)
case CDROM_BUS_SCSI:
busName = "SCSI";
break;
case CDROM_BUS_MITSUMI:
busName = "Mitsumi";
break;
}
// menu->setTitle(tr("CD-ROM %1 (%2): %3").arg(QString::number(i+1), busName, name.isEmpty() ? tr("(empty)") : name));

View File

@@ -20,6 +20,15 @@
#include "ui_qt_settingsfloppycdrom.h"
extern "C" {
#include <inttypes.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include <86box/86box.h>
#include <86box/timer.h>
#include <86box/fdd.h>
#include <86box/cdrom.h>
@@ -59,6 +68,7 @@ setCDROMBus(QAbstractItemModel *model, const QModelIndex &idx, uint8_t bus, uint
break;
case CDROM_BUS_ATAPI:
case CDROM_BUS_SCSI:
case CDROM_BUS_MITSUMI:
icon = ProgSettings::loadIcon("/cdrom.ico");
break;
}
@@ -88,6 +98,18 @@ setCDROMEarly(QAbstractItemModel *model, const QModelIndex &idx, bool early)
model->setData(i, early, Qt::UserRole);
}
static void
setCDROMType(QAbstractItemModel *model, const QModelIndex &idx, int type)
{
auto i = idx.siblingAtColumn(2);
if (idx.siblingAtColumn(0).data(Qt::UserRole).toUInt() == CDROM_BUS_DISABLED) {
model->setData(i, QCoreApplication::translate("", "None"));
} else if (idx.siblingAtColumn(0).data(Qt::UserRole).toUInt() != CDROM_BUS_MITSUMI) {
model->setData(i, QObject::tr(cdrom_getname(type)));
}
model->setData(i, type, Qt::UserRole);
}
SettingsFloppyCDROM::SettingsFloppyCDROM(QWidget *parent)
: QWidget(parent)
, ui(new Ui::SettingsFloppyCDROM)
@@ -134,18 +156,36 @@ SettingsFloppyCDROM::SettingsFloppyCDROM(QWidget *parent)
Models::AddEntry(model, QString("%1x").arg(i + 1), i + 1);
}
model = ui->comboBoxCDROMType->model();
i = 0;
while (true) {
QString name = tr(cdrom_getname(i));
if (name.isEmpty()) {
break;
}
Models::AddEntry(model, name, i);
++i;
}
model = new QStandardItemModel(0, 3, this);
ui->tableViewCDROM->setModel(model);
model->setHeaderData(0, Qt::Horizontal, tr("Bus"));
model->setHeaderData(1, Qt::Horizontal, tr("Speed"));
model->setHeaderData(2, Qt::Horizontal, tr("Earlier drive"));
model->setHeaderData(2, Qt::Horizontal, tr("Type"));
model->insertRows(0, CDROM_NUM);
for (int i = 0; i < CDROM_NUM; i++) {
auto idx = model->index(i, 0);
int type = cdrom_get_type(i);
setCDROMBus(model, idx, cdrom[i].bus_type, cdrom[i].res);
setCDROMSpeed(model, idx.siblingAtColumn(1), cdrom[i].speed);
setCDROMEarly(model, idx.siblingAtColumn(2), cdrom[i].early);
Harddrives::busTrackClass->device_track(1, DEV_CDROM, cdrom[i].bus_type, cdrom[i].bus_type == CDROM_BUS_ATAPI ? cdrom[i].ide_channel : cdrom[i].scsi_device_id);
setCDROMType(model, idx.siblingAtColumn(2), type);
if (cdrom[i].bus_type == CDROM_BUS_ATAPI)
Harddrives::busTrackClass->device_track(1, DEV_CDROM, cdrom[i].bus_type, cdrom[i].ide_channel);
else if (cdrom[i].bus_type == CDROM_BUS_SCSI)
Harddrives::busTrackClass->device_track(1, DEV_CDROM, cdrom[i].bus_type, cdrom[i].scsi_device_id);
else if (cdrom[i].bus_type == CDROM_BUS_MITSUMI)
Harddrives::busTrackClass->device_track(1, DEV_CDROM, cdrom[i].bus_type, 0);
}
ui->tableViewCDROM->resizeColumnsToContents();
ui->tableViewCDROM->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
@@ -172,18 +212,18 @@ SettingsFloppyCDROM::save()
/* Removable devices category */
model = ui->tableViewCDROM->model();
for (int i = 0; i < CDROM_NUM; i++) {
cdrom[i].is_dir = 0;
cdrom[i].priv = NULL;
cdrom[i].ops = NULL;
cdrom[i].image = NULL;
cdrom[i].insert = NULL;
cdrom[i].close = NULL;
cdrom[i].get_volume = NULL;
cdrom[i].is_dir = 0;
cdrom[i].priv = NULL;
cdrom[i].ops = NULL;
cdrom[i].image = NULL;
cdrom[i].insert = NULL;
cdrom[i].close = NULL;
cdrom[i].get_volume = NULL;
cdrom[i].get_channel = NULL;
cdrom[i].bus_type = model->index(i, 0).data(Qt::UserRole).toUInt();
cdrom[i].res = model->index(i, 0).data(Qt::UserRole + 1).toUInt();
cdrom[i].speed = model->index(i, 1).data(Qt::UserRole).toUInt();
cdrom[i].early = model->index(i, 2).data(Qt::UserRole).toUInt();
cdrom[i].bus_type = model->index(i, 0).data(Qt::UserRole).toUInt();
cdrom[i].res = model->index(i, 0).data(Qt::UserRole + 1).toUInt();
cdrom[i].speed = model->index(i, 1).data(Qt::UserRole).toUInt();
cdrom_set_type(i, model->index(i, 2).data(Qt::UserRole).toInt());
}
}
@@ -202,12 +242,12 @@ SettingsFloppyCDROM::onCDROMRowChanged(const QModelIndex &current)
uint8_t bus = current.siblingAtColumn(0).data(Qt::UserRole).toUInt();
uint8_t channel = current.siblingAtColumn(0).data(Qt::UserRole + 1).toUInt();
uint8_t speed = current.siblingAtColumn(1).data(Qt::UserRole).toUInt();
bool early = current.siblingAtColumn(2).data(Qt::UserRole).toBool();
int type = current.siblingAtColumn(2).data(Qt::UserRole).toInt();
ui->comboBoxBus->setCurrentIndex(-1);
auto *model = ui->comboBoxBus->model();
auto match = model->match(model->index(0, 0), Qt::UserRole, bus);
if (!match.isEmpty()) {
auto* model = ui->comboBoxBus->model();
auto match = model->match(model->index(0, 0), Qt::UserRole, bus);
if (! match.isEmpty()) {
ui->comboBoxBus->setCurrentIndex(match.first().row());
}
@@ -218,7 +258,7 @@ SettingsFloppyCDROM::onCDROMRowChanged(const QModelIndex &current)
}
ui->comboBoxSpeed->setCurrentIndex(speed == 0 ? 7 : speed - 1);
ui->checkBoxEarlierDrive->setChecked(early);
ui->comboBoxCDROMType->setCurrentIndex(type);
}
void
@@ -250,9 +290,10 @@ SettingsFloppyCDROM::on_comboBoxBus_currentIndexChanged(int index)
int bus = ui->comboBoxBus->currentData().toInt();
bool enabled = (bus != CDROM_BUS_DISABLED);
ui->comboBoxChannel->setEnabled(enabled);
ui->comboBoxSpeed->setEnabled(enabled);
ui->checkBoxEarlierDrive->setEnabled(enabled);
ui->comboBoxChannel->setEnabled((bus == CDROM_BUS_MITSUMI) ? 0 : enabled);
ui->comboBoxSpeed->setEnabled((bus == CDROM_BUS_MITSUMI) ? 0 : enabled);
ui->comboBoxCDROMType->setEnabled((bus == CDROM_BUS_MITSUMI) ? 0 : enabled);
Harddrives::populateBusChannels(ui->comboBoxChannel->model(), bus);
}
@@ -266,14 +307,26 @@ SettingsFloppyCDROM::on_comboBoxSpeed_activated(int index)
void
SettingsFloppyCDROM::on_comboBoxBus_activated(int)
{
auto i = ui->tableViewCDROM->selectionModel()->currentIndex().siblingAtColumn(0);
auto i = ui->tableViewCDROM->selectionModel()->currentIndex().siblingAtColumn(0);
uint8_t bus_type = ui->comboBoxBus->currentData().toUInt();
Harddrives::busTrackClass->device_track(0, DEV_CDROM, ui->tableViewCDROM->model()->data(i, Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, Qt::UserRole + 1).toInt());
ui->comboBoxChannel->setCurrentIndex(ui->comboBoxBus->currentData().toUInt() == CDROM_BUS_ATAPI ? Harddrives::busTrackClass->next_free_ide_channel() : Harddrives::busTrackClass->next_free_scsi_id());
if (bus_type == CDROM_BUS_ATAPI)
ui->comboBoxChannel->setCurrentIndex(Harddrives::busTrackClass->next_free_ide_channel());
else if (bus_type == CDROM_BUS_SCSI)
ui->comboBoxChannel->setCurrentIndex(Harddrives::busTrackClass->next_free_scsi_id());
else if (bus_type == CDROM_BUS_MITSUMI)
ui->comboBoxChannel->setCurrentIndex(0);
setCDROMBus(
ui->tableViewCDROM->model(),
ui->tableViewCDROM->selectionModel()->currentIndex(),
ui->comboBoxBus->currentData().toUInt(),
bus_type,
ui->comboBoxChannel->currentData().toUInt());
setCDROMType(
ui->tableViewCDROM->model(),
ui->tableViewCDROM->selectionModel()->currentIndex(),
ui->comboBoxCDROMType->currentData().toUInt());
Harddrives::busTrackClass->device_track(1, DEV_CDROM, ui->tableViewCDROM->model()->data(i, Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, Qt::UserRole + 1).toInt());
}
@@ -291,8 +344,12 @@ SettingsFloppyCDROM::on_comboBoxChannel_activated(int)
}
void
SettingsFloppyCDROM::on_checkBoxEarlierDrive_stateChanged(int arg1)
SettingsFloppyCDROM::on_comboBoxCDROMType_activated(int)
{
auto idx = ui->tableViewCDROM->selectionModel()->currentIndex();
setCDROMEarly(ui->tableViewCDROM->model(), idx.siblingAtColumn(2), (arg1 == Qt::Checked) ? true : false);
setCDROMType(
ui->tableViewCDROM->model(),
ui->tableViewCDROM->selectionModel()->currentIndex(),
ui->comboBoxCDROMType->currentData().toUInt());
ui->tableViewCDROM->resizeColumnsToContents();
ui->tableViewCDROM->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
}

View File

@@ -17,6 +17,7 @@ public:
void save();
private slots:
void on_comboBoxCDROMType_activated(int index);
void on_comboBoxChannel_activated(int index);
void on_comboBoxBus_activated(int index);
void on_comboBoxSpeed_activated(int index);
@@ -27,8 +28,6 @@ private slots:
void onFloppyRowChanged(const QModelIndex &current);
void onCDROMRowChanged(const QModelIndex &current);
void on_checkBoxEarlierDrive_stateChanged(int arg1);
private:
Ui::SettingsFloppyCDROM *ui;
};

View File

@@ -115,16 +115,20 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Bus:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Channel:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxBus"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
@@ -132,25 +136,24 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Bus:</string>
<string>Type:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxBus"/>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="comboBoxChannel"/>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxSpeed"/>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="checkBoxEarlierDrive">
<property name="text">
<string>Earlier drive</string>
</property>
</widget>
<item row="2" column="1" colspan="3">
<widget class="QComboBox" name="comboBoxCDROMType"/>
</item>
</layout>
</item>

View File

@@ -25,6 +25,7 @@ extern "C" {
#include <86box/hdc.h>
#include <86box/hdc_ide.h>
#include <86box/fdc_ext.h>
#include <86box/cdrom_interface.h>
#include <86box/scsi.h>
#include <86box/scsi_device.h>
#include <86box/cassette.h>
@@ -57,11 +58,12 @@ SettingsStorageControllers::save()
auto *cbox = findChild<QComboBox *>(QString("comboBoxSCSI%1").arg(i + 1));
scsi_card_current[i] = cbox->currentData().toInt();
}
hdc_current = ui->comboBoxHD->currentData().toInt();
fdc_type = ui->comboBoxFD->currentData().toInt();
ide_ter_enabled = ui->checkBoxTertiaryIDE->isChecked() ? 1 : 0;
ide_qua_enabled = ui->checkBoxQuaternaryIDE->isChecked() ? 1 : 0;
cassette_enable = ui->checkBoxCassette->isChecked() ? 1 : 0;
hdc_current = ui->comboBoxHD->currentData().toInt();
fdc_type = ui->comboBoxFD->currentData().toInt();
cdrom_interface_current = ui->comboBoxCDInterface->currentData().toInt();
ide_ter_enabled = ui->checkBoxTertiaryIDE->isChecked() ? 1 : 0;
ide_qua_enabled = ui->checkBoxQuaternaryIDE->isChecked() ? 1 : 0;
cassette_enable = ui->checkBoxCassette->isChecked() ? 1 : 0;
}
void
@@ -131,6 +133,35 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId)
ui->comboBoxFD->setCurrentIndex(-1);
ui->comboBoxFD->setCurrentIndex(selectedRow);
/*CD interface controller config*/
model = ui->comboBoxCDInterface->model();
removeRows = model->rowCount();
c = 0;
selectedRow = 0;
while (true) {
/* Skip "internal" if machine doesn't have it. */
QString name = DeviceConfig::DeviceName(cdrom_interface_get_device(c), cdrom_interface_get_internal_name(c), 1);
if (name.isEmpty()) {
break;
}
if (cdrom_interface_available(c)) {
auto *cdrom_interface_dev = cdrom_interface_get_device(c);
if (device_is_valid(cdrom_interface_dev, machineId)) {
int row = Models::AddEntry(model, name, c);
if (c == cdrom_interface_current) {
selectedRow = row - removeRows;
}
}
}
c++;
}
model->removeRows(0, removeRows);
ui->comboBoxCDInterface->setEnabled(model->rowCount() > 0);
ui->comboBoxCDInterface->setCurrentIndex(-1);
ui->comboBoxCDInterface->setCurrentIndex(selectedRow);
for (int i = 0; i < SCSI_BUS_MAX; ++i) {
auto *cbox = findChild<QComboBox *>(QString("comboBoxSCSI%1").arg(i + 1));
model = cbox->model();
@@ -187,6 +218,14 @@ SettingsStorageControllers::on_comboBoxFD_currentIndexChanged(int index)
ui->pushButtonFD->setEnabled(hdc_has_config(ui->comboBoxFD->currentData().toInt()) > 0);
}
void SettingsStorageControllers::on_comboBoxCDInterface_currentIndexChanged(int index)
{
if (index < 0) {
return;
}
ui->pushButtonCDInterface->setEnabled(cdrom_interface_has_config(ui->comboBoxCDInterface->currentData().toInt()) > 0);
}
void
SettingsStorageControllers::on_checkBoxTertiaryIDE_stateChanged(int arg1)
{

View File

@@ -32,10 +32,12 @@ private slots:
void on_pushButtonTertiaryIDE_clicked();
void on_pushButtonFD_clicked();
void on_pushButtonHD_clicked();
void on_pushButtonCDInterface_clicked();
void on_checkBoxQuaternaryIDE_stateChanged(int arg1);
void on_checkBoxTertiaryIDE_stateChanged(int arg1);
void on_comboBoxFD_currentIndexChanged(int index);
void on_comboBoxHD_currentIndexChanged(int index);
void on_comboBoxCDInterface_currentIndexChanged(int index);
private:
Ui::SettingsStorageControllers *ui;

View File

@@ -49,6 +49,23 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>CD-ROM Controller:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxCDInterface"/>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButtonCDInterface">
<property name="text">
<string>Configure</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxHD">
<property name="sizePolicy">
@@ -69,21 +86,21 @@
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxFD"/>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxTertiaryIDE">
<property name="text">
<string>Tertiary IDE Controller</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QCheckBox" name="checkBoxQuaternaryIDE">
<property name="text">
<string>Quaternary IDE Controller</string>
</property>
</widget>
</item>
<item row="2" column="2">
<item row="3" column="2">
<widget class="QPushButton" name="pushButtonTertiaryIDE">
<property name="enabled">
<bool>false</bool>
@@ -93,7 +110,7 @@
</property>
</widget>
</item>
<item row="3" column="2">
<item row="4" column="2">
<widget class="QPushButton" name="pushButtonQuaternaryIDE">
<property name="enabled">
<bool>false</bool>