The great CD-ROM clean-up and rewrite, fixes #5134.
This commit is contained in:
@@ -17,16 +17,18 @@
|
||||
* Copyright 2023 Miran Grca.
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
#ifdef ENABLE_IOCTL_LOG
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <86box/86box.h>
|
||||
#include <86box/scsi_device.h>
|
||||
#include <86box/cdrom.h>
|
||||
#include <86box/log.h>
|
||||
#include <86box/plat_unused.h>
|
||||
#include <86box/plat_cdrom.h>
|
||||
|
||||
@@ -35,223 +37,203 @@
|
||||
of the audio while audio still plays. With an absolute conversion, the counter is fine. */
|
||||
#define MSFtoLBA(m, s, f) ((((m * 60) + s) * 75) + f)
|
||||
|
||||
typedef struct dummy_cdrom_ioctl_t {
|
||||
typedef struct ioctl_t {
|
||||
cdrom_t *dev;
|
||||
void *log;
|
||||
int toc_valid;
|
||||
} dummy_cdrom_ioctl_t;
|
||||
} ioctl_t;
|
||||
|
||||
#ifdef ENABLE_DUMMY_CDROM_IOCTL_LOG
|
||||
int dummy_cdrom_ioctl_do_log = ENABLE_DUMMY_CDROM_IOCTL_LOG;
|
||||
#ifdef ENABLE_IOCTL_LOG
|
||||
int ioctl_do_log = ENABLE_IOCTL_LOG;
|
||||
|
||||
void
|
||||
dummy_cdrom_ioctl_log(const char *fmt, ...)
|
||||
ioctl_log(void *priv, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (dummy_cdrom_ioctl_do_log) {
|
||||
if (ioctl_do_log) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
pclog_ex(fmt, ap);
|
||||
log_out(priv, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define dummy_cdrom_ioctl_log(fmt, ...)
|
||||
# define ioctl_log(priv, fmt, ...)
|
||||
#endif
|
||||
|
||||
static int
|
||||
plat_cdrom_open(void *local)
|
||||
/* Internal functions. */
|
||||
static void
|
||||
ioctl_close_handle(UNUSED(const ioctl_t *ioctl))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
plat_cdrom_load(void *local)
|
||||
ioctl_open_handle(UNUSED(ioctl_t *ioctl))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
plat_cdrom_read_toc(void *local)
|
||||
ioctl_read_toc(ioctl_t *ioctl)
|
||||
{
|
||||
dummy_cdrom_ioctl_t *ioctl = (dummy_cdrom_ioctl_t *) local;
|
||||
if (!ioctl->toc_valid) {
|
||||
ioctl->toc_valid = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Shared functions. */
|
||||
static int
|
||||
ioctl_get_track_info(UNUSED(const void *local), UNUSED(const uint32_t track),
|
||||
UNUSED(int end), UNUSED(track_info_t *ti))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ioctl_get_raw_track_info(const void *local, UNUSED(int *num), UNUSED(uint8_t *rti))
|
||||
{
|
||||
ioctl_t *ioctl = (ioctl_t *) local;
|
||||
|
||||
if (!ioctl->toc_valid)
|
||||
ioctl->toc_valid = 1;
|
||||
}
|
||||
|
||||
void
|
||||
plat_cdrom_get_raw_track_info(UNUSED(void *local), int *num, raw_track_info_t *rti)
|
||||
static void
|
||||
ioctl_get_raw_track_info(UNUSED(const void *local), int *num, uint8_t *rti)
|
||||
{
|
||||
*num = 1;
|
||||
memset(rti, 0x00, 11);
|
||||
}
|
||||
|
||||
int
|
||||
plat_cdrom_is_track_audio(void *local, uint32_t sector)
|
||||
static int
|
||||
ioctl_is_track_pre(const void *local, const uint32_t sector)
|
||||
{
|
||||
dummy_cdrom_ioctl_t *ioctl = (dummy_cdrom_ioctl_t *) local;
|
||||
|
||||
plat_cdrom_read_toc(ioctl);
|
||||
|
||||
const int ret = 0;
|
||||
|
||||
dummy_cdrom_ioctl_log("plat_cdrom_is_track_audio(%08X): %i\n", sector, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
plat_cdrom_is_track_pre(void *local, uint32_t sector)
|
||||
{
|
||||
dummy_cdrom_ioctl_t *ioctl = (dummy_cdrom_ioctl_t *) local;
|
||||
ioctl_t *ioctl = (ioctl_t *) local;
|
||||
|
||||
plat_cdrom_read_toc(ioctl);
|
||||
|
||||
const int ret = 0;
|
||||
|
||||
dummy_cdrom_ioctl_log("plat_cdrom_is_track_audio(%08X): %i\n", sector, ret);
|
||||
ioctl_log("plat_cdrom_is_track_audio(%08X): %i\n", sector, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
plat_cdrom_get_track_start(void *local, uint32_t sector, uint8_t *attr, uint8_t *track)
|
||||
static int
|
||||
ioctl_read_sector(const void *local, uint8_t *buffer, uint32_t const sector)
|
||||
{
|
||||
dummy_cdrom_ioctl_t *ioctl = (dummy_cdrom_ioctl_t *) local;
|
||||
|
||||
plat_cdrom_read_toc(ioctl);
|
||||
|
||||
return 0x00000000;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
plat_cdrom_get_last_block(void *local)
|
||||
{
|
||||
dummy_cdrom_ioctl_t *ioctl = (dummy_cdrom_ioctl_t *) local;
|
||||
|
||||
plat_cdrom_read_toc(ioctl);
|
||||
|
||||
return 0x00000000;
|
||||
}
|
||||
|
||||
int
|
||||
plat_cdrom_ext_medium_changed(UNUSED(void *local))
|
||||
{
|
||||
#if 0
|
||||
dummy_cdrom_ioctl_t *ioctl = (dummy_cdrom_ioctl_t *) local;
|
||||
|
||||
plat_cdrom_read_toc(ioctl);
|
||||
#endif
|
||||
|
||||
int ret = 0;
|
||||
|
||||
dummy_cdrom_ioctl_log("plat_cdrom_ext_medium_changed(): %i\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* This replaces both Info and EndInfo, they are specified by a variable. */
|
||||
int
|
||||
plat_cdrom_get_audio_track_info(void *local, UNUSED(int end), int track, int *track_num, TMSF *start, uint8_t *attr)
|
||||
{
|
||||
dummy_cdrom_ioctl_t *ioctl = (dummy_cdrom_ioctl_t *) local;
|
||||
|
||||
plat_cdrom_read_toc(ioctl);
|
||||
|
||||
if ((track < 1) || (track == 0xaa)) {
|
||||
dummy_cdrom_ioctl_log("plat_cdrom_get_audio_track_info(%02i)\n", track);
|
||||
return 0;
|
||||
}
|
||||
|
||||
start->min = 0;
|
||||
start->sec = 0;
|
||||
start->fr = 2;
|
||||
|
||||
*track_num = 1;
|
||||
*attr = 0x14;
|
||||
|
||||
dummy_cdrom_ioctl_log("plat_cdrom_get_audio_track_info(%02i): %02i:%02i:%02i, %02i, %02X\n",
|
||||
track, start->min, start->sec, start->fr, *track_num, *attr);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* TODO: See if track start is adjusted by 150 or not. */
|
||||
int
|
||||
plat_cdrom_get_audio_sub(UNUSED(void *local), UNUSED(uint32_t sector), uint8_t *attr, uint8_t *track, uint8_t *index,
|
||||
TMSF *rel_pos, TMSF *abs_pos)
|
||||
{
|
||||
*track = 1;
|
||||
*attr = 0x14;
|
||||
*index = 1;
|
||||
|
||||
rel_pos->min = 0;
|
||||
rel_pos->sec = 0;
|
||||
rel_pos->fr = 0;
|
||||
abs_pos->min = 0;
|
||||
abs_pos->sec = 0;
|
||||
abs_pos->fr = 2;
|
||||
|
||||
dummy_cdrom_ioctl_log("plat_cdrom_get_audio_sub(): %02i, %02X, %02i, %02i:%02i:%02i, %02i:%02i:%02i\n",
|
||||
*track, *attr, *index, rel_pos->min, rel_pos->sec, rel_pos->fr, abs_pos->min, abs_pos->sec, abs_pos->fr);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
plat_cdrom_get_sector_size(UNUSED(void *local), UNUSED(uint32_t sector))
|
||||
{
|
||||
dummy_cdrom_ioctl_log("BytesPerSector=2048\n");
|
||||
|
||||
return 2048;
|
||||
}
|
||||
|
||||
int
|
||||
plat_cdrom_read_sector(void *local, uint8_t *buffer, uint32_t sector)
|
||||
{
|
||||
dummy_cdrom_ioctl_t *ioctl = (dummy_cdrom_ioctl_t *) local;
|
||||
ioctl_t *ioctl = (ioctl_t *) local;
|
||||
|
||||
plat_cdrom_open(ioctl);
|
||||
|
||||
/* Raw */
|
||||
dummy_cdrom_ioctl_log("Raw\n");
|
||||
ioctl_log("Raw\n");
|
||||
|
||||
plat_cdrom_close(ioctl);
|
||||
|
||||
dummy_cdrom_ioctl_log("ReadSector sector=%d.\n", sector);
|
||||
ioctl_log("ReadSector sector=%d.\n", sector);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
plat_cdrom_eject(void *local)
|
||||
static uint8_t
|
||||
ioctl_get_track_type(UNUSED(const void *local), UNUSED(const uint32_t sector))
|
||||
{
|
||||
dummy_cdrom_ioctl_t *ioctl = (dummy_cdrom_ioctl_t *) local;
|
||||
|
||||
plat_cdrom_open(ioctl);
|
||||
plat_cdrom_close(ioctl);
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
void
|
||||
plat_cdrom_close(UNUSED(void *local))
|
||||
static uint32_t
|
||||
ioctl_get_last_block(const void *local)
|
||||
{
|
||||
ioctl_t *ioctl = (ioctl_t *) local;
|
||||
|
||||
ioctl_read_toc(ioctl);
|
||||
|
||||
return 0x00000000;
|
||||
}
|
||||
|
||||
int
|
||||
plat_cdrom_set_drive(void *local, const char *drv)
|
||||
static int
|
||||
ioctl_read_dvd_structure(UNUSED(const void *local), UNUSED(const uint8_t layer), UNUSED(const uint8_t format),
|
||||
UNUSED(uint8_t *buffer), UNUSED(uint32_t *info))
|
||||
{
|
||||
dummy_cdrom_ioctl_t *ioctl = (dummy_cdrom_ioctl_t *) local;
|
||||
|
||||
plat_cdrom_close(ioctl);
|
||||
|
||||
ioctl->toc_valid = 0;
|
||||
|
||||
plat_cdrom_load(ioctl);
|
||||
|
||||
return 1;
|
||||
return -0x00052100;
|
||||
}
|
||||
|
||||
int
|
||||
plat_cdrom_get_local_size(void)
|
||||
static int
|
||||
ioctl_is_dvd(UNUSED(const void *local))
|
||||
{
|
||||
return sizeof(dummy_cdrom_ioctl_t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ioctl_has_audio(UNUSED(const void *local))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ioctl_ext_medium_changed(UNUSED(void *local))
|
||||
{
|
||||
#if 0
|
||||
ioctl_t *ioctl = (ioctl_t *) local;
|
||||
#endif
|
||||
int ret = 0;
|
||||
|
||||
ioctl_log("ioctl_ext_medium_changed(): %i\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
ioctl_close(void *local)
|
||||
{
|
||||
ioctl_t *ioctl = (ioctl_t *) local;
|
||||
|
||||
ioctl_close_handle(ioctl);
|
||||
ioctl->handle = NULL;
|
||||
|
||||
ioctl_log(ioctl->log, "Log closed\n");
|
||||
|
||||
log_close(ioctl->log);
|
||||
ioctl->log = NULL;
|
||||
}
|
||||
|
||||
static const cdrom_ops_t ioctl_ops = {
|
||||
ioctl_get_track_info,
|
||||
ioctl_get_raw_track_info,
|
||||
ioctl_is_track_pre,
|
||||
ioctl_read_sector,
|
||||
ioctl_get_track_type,
|
||||
ioctl_get_last_block,
|
||||
ioctl_read_dvd_structure,
|
||||
ioctl_is_dvd,
|
||||
ioctl_has_audio,
|
||||
ioctl_ext_medium_changed,
|
||||
ioctl_close
|
||||
};
|
||||
|
||||
/* Public functions. */
|
||||
void *
|
||||
ioctl_open(cdrom_t *dev, const char *drv)
|
||||
{
|
||||
ioctl_t *ioctl = (ioctl_t *) calloc(1, sizeof(ioctl_t));
|
||||
|
||||
if (ioctl != NULL) {
|
||||
char n[1024] = { 0 };
|
||||
|
||||
sprintf(n, "CD-ROM %i IOCtl", dev->id + 1);
|
||||
ioctl->log = log_open(n);
|
||||
|
||||
memset(ioctl->path, 0x00, sizeof(ioctl->path));
|
||||
|
||||
wsprintf(ioctl->path, L"%S", &(drv[8]));
|
||||
ioctl_log(ioctl->log, "Path is %S\n", ioctl->path);
|
||||
|
||||
ioctl->dev = dev;
|
||||
ioctl->toc_valid = 0;
|
||||
|
||||
dev->ops = &ioctl_ops;
|
||||
}
|
||||
|
||||
return ioctl;
|
||||
}
|
||||
|
||||
@@ -369,12 +369,12 @@ MachineStatus::iterateNIC(const std::function<void(int)> &cb)
|
||||
}
|
||||
|
||||
static int
|
||||
hdd_count(int bus)
|
||||
hdd_count(const int bus_type)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
for (uint8_t i = 0; i < HDD_NUM; i++) {
|
||||
if (hdd[i].bus == bus) {
|
||||
if (hdd[i].bus_type == bus_type) {
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,10 +537,7 @@ MediaMenu::cdromMount(int i, const QString &filename)
|
||||
if ((fn.data() != NULL) && (strlen(fn.data()) >= 1) && (fn.data()[strlen(fn.data()) - 1] == '\\'))
|
||||
fn.data()[strlen(fn.data()) - 1] = '/';
|
||||
#endif
|
||||
if ((fn.data() != nullptr) && fn.contains("ioctl://"))
|
||||
cdrom_ioctl_open(&(cdrom[i]), fn.data());
|
||||
else
|
||||
cdrom_image_open(&(cdrom[i]), fn.data());
|
||||
cdrom_load(&(cdrom[i]), fn.data(), 1);
|
||||
|
||||
/* Signal media change to the emulated machine. */
|
||||
if (cdrom[i].insert) {
|
||||
@@ -806,14 +803,21 @@ MediaMenu::zipSelectImage(int i, bool wp)
|
||||
void
|
||||
MediaMenu::zipMount(int i, const QString &filename, bool wp)
|
||||
{
|
||||
const auto dev = static_cast<zip_t *>(zip_drives[i].priv);
|
||||
const auto dev = static_cast<zip_t *>(zip_drives[i].priv);
|
||||
int was_empty = zip_is_empty(i);
|
||||
|
||||
zip_disk_close(dev);
|
||||
zip_drives[i].read_only = wp;
|
||||
if (!filename.isEmpty()) {
|
||||
QByteArray filenameBytes = filename.toUtf8();
|
||||
zip_load(dev, filenameBytes.data());
|
||||
zip_load(dev, filenameBytes.data(), 1);
|
||||
|
||||
/* Signal media change to the emulated machine. */
|
||||
zip_insert(dev);
|
||||
|
||||
/* The drive was previously empty, transition directly to UNIT ATTENTION. */
|
||||
if (was_empty)
|
||||
zip_insert(dev);
|
||||
}
|
||||
mhm.addImageToHistory(i, ui::MediaType::Zip, zip_drives[i].prev_image_path, zip_drives[i].image_path);
|
||||
|
||||
@@ -935,14 +939,21 @@ MediaMenu::moSelectImage(int i, bool wp)
|
||||
void
|
||||
MediaMenu::moMount(int i, const QString &filename, bool wp)
|
||||
{
|
||||
const auto dev = static_cast<mo_t *>(mo_drives[i].priv);
|
||||
const auto dev = static_cast<mo_t *>(mo_drives[i].priv);
|
||||
int was_empty = mo_is_empty(i);
|
||||
|
||||
mo_disk_close(dev);
|
||||
mo_drives[i].read_only = wp;
|
||||
if (!filename.isEmpty()) {
|
||||
QByteArray filenameBytes = filename.toUtf8();
|
||||
mo_load(dev, filenameBytes.data());
|
||||
mo_load(dev, filenameBytes.data(), 1);
|
||||
|
||||
/* Signal media change to the emulated machine. */
|
||||
mo_insert(dev);
|
||||
|
||||
/* The drive was previously empty, transition directly to UNIT ATTENTION. */
|
||||
if (was_empty)
|
||||
mo_insert(dev);
|
||||
}
|
||||
mhm.addImageToHistory(i, ui::MediaType::Mo, mo_drives[i].prev_image_path, mo_drives[i].image_path);
|
||||
|
||||
|
||||
@@ -90,6 +90,14 @@ setCDROMSpeed(QAbstractItemModel *model, const QModelIndex &idx, uint8_t speed)
|
||||
model->setData(i, speed, Qt::UserRole);
|
||||
}
|
||||
|
||||
static QString
|
||||
CDROMName(int type)
|
||||
{
|
||||
char temp[512];
|
||||
cdrom_get_name(type, temp);
|
||||
return QObject::tr((const char *) temp);
|
||||
}
|
||||
|
||||
static void
|
||||
setCDROMType(QAbstractItemModel *model, const QModelIndex &idx, int type)
|
||||
{
|
||||
@@ -97,7 +105,7 @@ setCDROMType(QAbstractItemModel *model, const QModelIndex &idx, int type)
|
||||
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, CDROMName(type));
|
||||
model->setData(i, type, Qt::UserRole);
|
||||
}
|
||||
|
||||
@@ -156,8 +164,12 @@ SettingsFloppyCDROM::SettingsFloppyCDROM(QWidget *parent)
|
||||
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);
|
||||
setCDROMType(model, idx.siblingAtColumn(2), type);
|
||||
int speed = cdrom_get_speed(type);
|
||||
if (speed == -1)
|
||||
setCDROMSpeed(model, idx.siblingAtColumn(1), cdrom[i].speed);
|
||||
else
|
||||
setCDROMSpeed(model, idx.siblingAtColumn(1), speed);
|
||||
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)
|
||||
@@ -186,7 +198,7 @@ SettingsFloppyCDROM::SettingsFloppyCDROM(QWidget *parent)
|
||||
if (((bus_type == CDROM_BUS_ATAPI) || (bus_type == CDROM_BUS_SCSI)) &&
|
||||
((cdrom_drive_types[j].bus_type == bus_type) ||
|
||||
(cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH))) {
|
||||
QString name = tr(cdrom_getname(j));
|
||||
QString name = CDROMName(j);
|
||||
Models::AddEntry(modelType, name, j);
|
||||
if ((cdrom[cdromIdx].bus_type == bus_type) && (cdrom[cdromIdx].type == j))
|
||||
selectedTypeRow = eligibleRows;
|
||||
@@ -246,7 +258,6 @@ SettingsFloppyCDROM::onCDROMRowChanged(const QModelIndex ¤t)
|
||||
{
|
||||
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();
|
||||
int type = current.siblingAtColumn(2).data(Qt::UserRole).toInt();
|
||||
|
||||
ui->comboBoxBus->setCurrentIndex(-1);
|
||||
@@ -260,7 +271,14 @@ SettingsFloppyCDROM::onCDROMRowChanged(const QModelIndex ¤t)
|
||||
if (!match.isEmpty())
|
||||
ui->comboBoxChannel->setCurrentIndex(match.first().row());
|
||||
|
||||
int speed = cdrom_get_speed(type);
|
||||
if (speed == -1) {
|
||||
speed = current.siblingAtColumn(1).data(Qt::UserRole).toUInt();
|
||||
ui->comboBoxSpeed->setEnabled(true);
|
||||
} else
|
||||
ui->comboBoxSpeed->setEnabled(false);
|
||||
ui->comboBoxSpeed->setCurrentIndex(speed == 0 ? 7 : speed - 1);
|
||||
|
||||
ui->comboBoxCDROMType->setCurrentIndex(type);
|
||||
enableCurrentlySelectedChannel();
|
||||
}
|
||||
@@ -351,7 +369,7 @@ SettingsFloppyCDROM::on_comboBoxBus_activated(int)
|
||||
if (((bus_type == CDROM_BUS_ATAPI) || (bus_type == CDROM_BUS_SCSI)) &&
|
||||
((cdrom_drive_types[j].bus_type == bus_type) ||
|
||||
(cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH))) {
|
||||
QString name = tr(cdrom_getname(j));
|
||||
QString name = CDROMName(j);
|
||||
Models::AddEntry(modelType, name, j);
|
||||
if ((cdrom[cdromIdx].bus_type == bus_type) && (cdrom[cdromIdx].type == j))
|
||||
selectedTypeRow = eligibleRows;
|
||||
@@ -401,9 +419,22 @@ SettingsFloppyCDROM::on_comboBoxChannel_activated(int)
|
||||
void
|
||||
SettingsFloppyCDROM::on_comboBoxCDROMType_activated(int)
|
||||
{
|
||||
int type = ui->comboBoxCDROMType->currentData().toUInt();
|
||||
|
||||
setCDROMType(ui->tableViewCDROM->model(),
|
||||
ui->tableViewCDROM->selectionModel()->currentIndex(),
|
||||
ui->comboBoxCDROMType->currentData().toUInt());
|
||||
type);
|
||||
ui->tableViewCDROM->resizeColumnsToContents();
|
||||
ui->tableViewCDROM->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
|
||||
int speed = cdrom_get_speed(type);
|
||||
if (speed == -1) {
|
||||
speed = ui->comboBoxSpeed->currentData().toUInt();
|
||||
ui->comboBoxSpeed->setEnabled(true);
|
||||
} else
|
||||
ui->comboBoxSpeed->setEnabled(false);
|
||||
ui->comboBoxSpeed->setCurrentIndex(speed == 0 ? 7 : speed - 1);
|
||||
|
||||
auto idx = ui->tableViewCDROM->selectionModel()->currentIndex();
|
||||
setCDROMSpeed(ui->tableViewCDROM->model(), idx.siblingAtColumn(1), speed);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ normalize_hd_list()
|
||||
memset(ihdd, 0x00, HDD_NUM * sizeof(hard_disk_t));
|
||||
|
||||
for (uint8_t i = 0; i < HDD_NUM; i++) {
|
||||
if (temp_hdd[i].bus != HDD_BUS_DISABLED) {
|
||||
if (temp_hdd[i].bus_type != HDD_BUS_DISABLED) {
|
||||
memcpy(&(ihdd[j]), &(temp_hdd[i]), sizeof(hard_disk_t));
|
||||
j++;
|
||||
}
|
||||
@@ -79,14 +79,14 @@ addRow(QAbstractItemModel *model, hard_disk_t *hd)
|
||||
int row = model->rowCount();
|
||||
model->insertRow(row);
|
||||
|
||||
QString busName = Harddrives::BusChannelName(hd->bus, hd->channel);
|
||||
QString busName = Harddrives::BusChannelName(hd->bus_type, hd->channel);
|
||||
model->setData(model->index(row, ColumnBus), busName);
|
||||
model->setData(model->index(row, ColumnBus), ProgSettings::loadIcon("/hard_disk.ico"), Qt::DecorationRole);
|
||||
model->setData(model->index(row, ColumnBus), hd->bus, DataBus);
|
||||
model->setData(model->index(row, ColumnBus), hd->bus, DataBusPrevious);
|
||||
model->setData(model->index(row, ColumnBus), hd->bus_type, DataBus);
|
||||
model->setData(model->index(row, ColumnBus), hd->bus_type, DataBusPrevious);
|
||||
model->setData(model->index(row, ColumnBus), hd->channel, DataBusChannel);
|
||||
model->setData(model->index(row, ColumnBus), hd->channel, DataBusChannelPrevious);
|
||||
Harddrives::busTrackClass->device_track(1, DEV_HDD, hd->bus, hd->channel);
|
||||
Harddrives::busTrackClass->device_track(1, DEV_HDD, hd->bus_type, hd->channel);
|
||||
QString fileName = hd->fn;
|
||||
if (fileName.startsWith(userPath, Qt::CaseInsensitive)) {
|
||||
model->setData(model->index(row, ColumnFilename), fileName.mid(userPath.size()));
|
||||
@@ -120,7 +120,7 @@ SettingsHarddisks::SettingsHarddisks(QWidget *parent)
|
||||
ui->tableView->setModel(model);
|
||||
|
||||
for (int i = 0; i < HDD_NUM; i++) {
|
||||
if (hdd[i].bus > 0) {
|
||||
if (hdd[i].bus_type > 0) {
|
||||
addRow(model, &hdd[i]);
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ SettingsHarddisks::save()
|
||||
int rows = model->rowCount();
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
auto idx = model->index(i, ColumnBus);
|
||||
hdd[i].bus = idx.data(DataBus).toUInt();
|
||||
hdd[i].bus_type = idx.data(DataBus).toUInt();
|
||||
hdd[i].channel = idx.data(DataBusChannel).toUInt();
|
||||
hdd[i].tracks = idx.siblingAtColumn(ColumnCylinders).data().toUInt();
|
||||
hdd[i].hpc = idx.siblingAtColumn(ColumnHeads).data().toUInt();
|
||||
@@ -313,11 +313,11 @@ addDriveFromDialog(Ui::SettingsHarddisks *ui, const HarddiskDialog &dlg)
|
||||
hard_disk_t hd;
|
||||
memset(&hd, 0, sizeof(hd));
|
||||
|
||||
hd.bus = dlg.bus();
|
||||
hd.channel = dlg.channel();
|
||||
hd.tracks = dlg.cylinders();
|
||||
hd.hpc = dlg.heads();
|
||||
hd.spt = dlg.sectors();
|
||||
hd.bus_type = dlg.bus();
|
||||
hd.channel = dlg.channel();
|
||||
hd.tracks = dlg.cylinders();
|
||||
hd.hpc = dlg.heads();
|
||||
hd.spt = dlg.sectors();
|
||||
strncpy(hd.fn, fn.data(), sizeof(hd.fn) - 1);
|
||||
hd.speed_preset = dlg.speed();
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user