Limit audio profile selection to the identical tracks. 40 track audio profiles for 40 track drives, 80 track profiles to 80 track drives.

This commit is contained in:
Toni Riikonen
2025-11-03 21:48:11 +02:00
parent 56ffe0cab8
commit a2fe28e6df
3 changed files with 58 additions and 2 deletions

View File

@@ -430,6 +430,15 @@ fdd_track0(int drive)
return !fdd[drive].track;
}
int
fdd_get_type_max_track(int type)
{
if (type < 0 || type >= (sizeof(drive_types) / sizeof(drive_types[0])))
return 0;
return drive_types[type].max_track;
}
int
fdd_current_track(int drive)
{

View File

@@ -36,6 +36,7 @@ extern void fdd_do_seek(int drive, int track);
extern void fdd_forced_seek(int drive, int track_diff);
extern void fdd_seek(int drive, int track_diff);
extern int fdd_track0(int drive);
extern int fdd_get_type_max_track(int type);
extern int fdd_getrpm(int drive);
extern void fdd_set_densel(int densel);
extern int fdd_can_read_medium(int drive);

View File

@@ -309,8 +309,51 @@ SettingsFloppyCDROM::onFloppyRowChanged(const QModelIndex &current)
ui->checkBoxCheckBPB->setChecked(current.siblingAtColumn(2).data() == tr("On"));
int prof = current.siblingAtColumn(3).data(Qt::UserRole).toInt();
#ifndef DISABLE_FDD_AUDIO
// Rebuild audio profile combo box based on drive type
int row = current.row();
ui->comboBoxFloppyAudio->clear();
// Get drive type's track count to determine 40-track vs 80-track
int drive_max_tracks = fdd_get_type_max_track(type);
bool is_40_track = (drive_max_tracks <= 43);
int profile_count = fdd_audio_get_profile_count();
int currentProfileIndex = -1;
int comboIndex = 0;
for (int i = 0; i < profile_count; i++) {
const char *name = fdd_audio_get_profile_name(i);
if (name) {
const fdd_audio_profile_config_t *profile = fdd_audio_get_profile(i);
if (profile) {
// Only show profiles that match the drive type's track count
if ((is_40_track && profile->total_tracks == 40) || (!is_40_track && profile->total_tracks == 80) || profile->total_tracks == 0) { // Profile ID 0 is "None"
ui->comboBoxFloppyAudio->addItem(name, i);
if (i == prof) {
currentProfileIndex = comboIndex;
}
comboIndex++;
}
}
}
}
// If current profile is not compatible, select "None" (profile 0)
if (currentProfileIndex == -1) {
currentProfileIndex = ui->comboBoxFloppyAudio->findData(0);
// Update the model to reflect "None" profile
auto audioIdx = current.siblingAtColumn(3);
ui->tableViewFloppy->model()->setData(audioIdx, tr("None"));
ui->tableViewFloppy->model()->setData(audioIdx, 0, Qt::UserRole);
}
ui->comboBoxFloppyAudio->setCurrentIndex(currentProfileIndex);
#else
int comboIndex = ui->comboBoxFloppyAudio->findData(prof);
ui->comboBoxFloppyAudio->setCurrentIndex(comboIndex);
#endif
}
void
@@ -386,8 +429,11 @@ SettingsFloppyCDROM::on_checkBoxCheckBPB_stateChanged(int arg1)
void
SettingsFloppyCDROM::on_comboBoxFloppyType_activated(int index)
{
setFloppyType(ui->tableViewFloppy->model(),
ui->tableViewFloppy->selectionModel()->currentIndex(), index);
auto currentIndex = ui->tableViewFloppy->selectionModel()->currentIndex();
setFloppyType(ui->tableViewFloppy->model(), currentIndex, index);
// Trigger row changed to rebuild audio profile list
onFloppyRowChanged(currentIndex);
}
void