mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 01:25:33 -07:00
Menu options to enable / disable fdd sound for all drives.
DISABLE_FDD_AUDIO definition added, to disable the feature via cmake/build.
This commit is contained in:
@@ -237,6 +237,7 @@ char monitor_edid_path[1024] = { 0 }; /* (C) Path to
|
||||
double video_gl_input_scale = 1.0; /* (C) OpenGL 3.x input scale */
|
||||
int video_gl_input_scale_mode = FULLSCR_SCALE_FULL; /* (C) OpenGL 3.x input stretch mode */
|
||||
int color_scheme = 0; /* (C) Color scheme of UI (Windows-only) */
|
||||
int fdd_sounds_enabled = 1; /* (C) Floppy drive sounds enabled */
|
||||
|
||||
// Accelerator key array
|
||||
struct accelKey acc_keys[NUM_ACCELS];
|
||||
|
||||
@@ -265,6 +265,7 @@ load_general(void)
|
||||
|
||||
do_auto_pause = ini_section_get_int(cat, "do_auto_pause", 0);
|
||||
force_constant_mouse = ini_section_get_int(cat, "force_constant_mouse", 0);
|
||||
fdd_sounds_enabled = ini_section_get_int(cat, "fdd_sounds_enabled", 1);
|
||||
|
||||
p = ini_section_get_string(cat, "uuid", NULL);
|
||||
if (p != NULL)
|
||||
@@ -2479,6 +2480,11 @@ save_general(void)
|
||||
else
|
||||
ini_section_delete_var(cat, "force_constant_mouse");
|
||||
|
||||
if (fdd_sounds_enabled == 1)
|
||||
ini_section_delete_var(cat, "fdd_sounds_enabled");
|
||||
else
|
||||
ini_section_set_int(cat, "fdd_sounds_enabled", fdd_sounds_enabled);
|
||||
|
||||
char cpu_buf[128] = { 0 };
|
||||
plat_get_cpu_string(cpu_buf, 128);
|
||||
ini_section_set_string(cat, "host_cpu", cpu_buf);
|
||||
|
||||
@@ -13,9 +13,11 @@
|
||||
*
|
||||
* Authors: Sarah Walker, <https://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Toni Riikonen, <riikonen.toni@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2020 Sarah Walker.
|
||||
* Copyright 2016-2020 Miran Grca.
|
||||
* Copyright 2025 Toni Riikonen.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
* Authors: Sarah Walker, <https://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Toni Riikonen, <riikonen.toni@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2019 Sarah Walker.
|
||||
* Copyright 2016-2019 Miran Grca.
|
||||
* Copyright 2018-2019 Fred N. van Kempen.
|
||||
* Copyright 2025 Toni Riikonen.
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
@@ -752,7 +754,9 @@ fdd_init(void)
|
||||
fdd_load(i, floppyfns[i]);
|
||||
}
|
||||
|
||||
fdd_audio_init();
|
||||
if (fdd_sounds_enabled) {
|
||||
fdd_audio_init();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -32,8 +32,10 @@
|
||||
// OK 4. Single sector read/write sound emulation
|
||||
// OK 5. Multi-track seek sound emulation
|
||||
// OK 6. Volume control for drive sounds
|
||||
// 7. Limit sound emulation only for 3,5" 300 rpm drives, until we have sound samples for other rpm drives
|
||||
// 8. Configuration option to enable/disable drive sounds
|
||||
// OK 7. Multi drive support
|
||||
// OK 8. Configuration option to enable/disable drive sounds
|
||||
|
||||
#ifndef DISABLE_FDD_AUDIO
|
||||
|
||||
/* Audio sample structure */
|
||||
typedef struct {
|
||||
@@ -111,23 +113,6 @@ extern uint64_t motoron[FDD_NUM];
|
||||
/* Forward declaration */
|
||||
static int16_t *load_wav(const char *filename, int *sample_count);
|
||||
|
||||
const char *
|
||||
fdd_audio_motor_state_name(motor_state_t state)
|
||||
{
|
||||
switch (state) {
|
||||
case MOTOR_STATE_STOPPED:
|
||||
return "STOPPED";
|
||||
case MOTOR_STATE_STARTING:
|
||||
return "STARTING";
|
||||
case MOTOR_STATE_RUNNING:
|
||||
return "RUNNING";
|
||||
case MOTOR_STATE_STOPPING:
|
||||
return "STOPPING";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
static int16_t *
|
||||
load_wav(const char *filename, int *sample_count)
|
||||
{
|
||||
@@ -268,6 +253,9 @@ fdd_audio_close(void)
|
||||
void
|
||||
fdd_audio_set_motor_enable(int drive, int motor_enable)
|
||||
{
|
||||
if (!fdd_sounds_enabled)
|
||||
return;
|
||||
|
||||
if (motor_enable && !motoron[drive]) {
|
||||
/* Motor starting up */
|
||||
if (spindlemotor_state[drive] == MOTOR_STATE_STOPPING) {
|
||||
@@ -295,6 +283,9 @@ fdd_audio_set_motor_enable(int drive, int motor_enable)
|
||||
void
|
||||
fdd_audio_play_single_track_step(int drive, int from_track, int to_track)
|
||||
{
|
||||
if (!fdd_sounds_enabled)
|
||||
return;
|
||||
|
||||
if (drive < 0 || drive >= FDD_NUM)
|
||||
return;
|
||||
if (abs(from_track - to_track) != 1)
|
||||
@@ -307,6 +298,9 @@ fdd_audio_play_single_track_step(int drive, int from_track, int to_track)
|
||||
void
|
||||
fdd_audio_play_multi_track_seek(int drive, int from_track, int to_track)
|
||||
{
|
||||
if (!fdd_sounds_enabled)
|
||||
return;
|
||||
|
||||
if (drive < 0 || drive >= FDD_NUM)
|
||||
return;
|
||||
|
||||
@@ -345,7 +339,6 @@ fdd_audio_callback(int16_t *buffer, int length)
|
||||
{
|
||||
/* Clear buffer */
|
||||
memset(buffer, 0, length * sizeof(int16_t));
|
||||
|
||||
/* Check if any motor is running or transitioning, or any audio is active */
|
||||
int any_audio_active = 0;
|
||||
for (int drive = 0; drive < FDD_NUM; drive++) {
|
||||
@@ -495,4 +488,14 @@ fdd_audio_callback(int16_t *buffer, int length)
|
||||
float_buffer[i * 2 + 1] += right_sample;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
void fdd_audio_init(void) {}
|
||||
void fdd_audio_close(void) {}
|
||||
void fdd_audio_set_motor_enable(int drive, int motor_enable) { (void) drive; (void) motor_enable; }
|
||||
void fdd_audio_play_single_track_step(int drive, int from_track, int to_track) { (void) drive; (void) from_track; (void) to_track; }
|
||||
void fdd_audio_play_multi_track_seek(int drive, int from_track, int to_track) { (void) drive; (void) from_track; (void) to_track; }
|
||||
void fdd_audio_callback(int16_t *buffer, int length) { memset(buffer, 0, length * sizeof(int16_t)); }
|
||||
|
||||
#endif /* DISABLE_FDD_AUDIO */
|
||||
@@ -207,6 +207,7 @@ extern int monitor_edid; /* (C) Which EDID to use. 0=default,
|
||||
extern char monitor_edid_path[1024]; /* (C) Path to custom EDID */
|
||||
|
||||
extern int color_scheme; /* (C) Color scheme of UI (Windows-only) */
|
||||
extern int fdd_sounds_enabled; /* (C) Enable floppy drive sounds */
|
||||
|
||||
#ifndef USE_NEW_DYNAREC
|
||||
extern FILE *stdlog; /* file to log output to */
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
* Authors: Sarah Walker, <https://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Toni Riikonen, <riikonen.toni@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2020 Sarah Walker.
|
||||
* Copyright 2016-2020 Miran Grca.
|
||||
* Copyright 2018-2020 Fred N. van Kempen.
|
||||
* Copyright 2025 Toni Riikonen.
|
||||
*/
|
||||
#ifndef EMU_FDC_H
|
||||
#define EMU_FDC_H
|
||||
|
||||
@@ -11,10 +11,12 @@
|
||||
* Authors: Sarah Walker, <https://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Toni Riikonen, <riikonen.toni@gmail.com>
|
||||
*
|
||||
* Copyright 2008-2025 Sarah Walker.
|
||||
* Copyright 2016-2025 Miran Grca.
|
||||
* Copyright 2018-2025 Fred N. van Kempen.
|
||||
* Copyright 2025 Toni Riikonen.
|
||||
*/
|
||||
#ifndef EMU_FDD_H
|
||||
#define EMU_FDD_H
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_FDD_AUDIO
|
||||
|
||||
/* Motor sound states */
|
||||
typedef enum {
|
||||
MOTOR_STATE_STOPPED = 0,
|
||||
@@ -50,6 +52,14 @@ typedef struct {
|
||||
#define FADE_DURATION_MS 75
|
||||
#define FADE_SAMPLES (48000 * FADE_DURATION_MS / 1000)
|
||||
|
||||
#else
|
||||
|
||||
typedef enum {
|
||||
MOTOR_STATE_STOPPED = 0
|
||||
} motor_state_t;
|
||||
|
||||
#endif /* DISABLE_FDD_AUDIO */
|
||||
|
||||
/* FDD audio initialization and cleanup */
|
||||
extern void fdd_audio_init(void);
|
||||
extern void fdd_audio_close(void);
|
||||
|
||||
@@ -213,6 +213,12 @@ SettingsFloppyCDROM::SettingsFloppyCDROM(QWidget *parent)
|
||||
ui->comboBoxCDROMType->setEnabled(eligibleRows > 1);
|
||||
ui->comboBoxCDROMType->setCurrentIndex(-1);
|
||||
ui->comboBoxCDROMType->setCurrentIndex(selectedTypeRow);
|
||||
#ifndef DISABLE_FDD_AUDIO
|
||||
ui->checkBoxFloppySounds->setVisible(true);
|
||||
ui->checkBoxFloppySounds->setChecked(fdd_sounds_enabled > 0);
|
||||
#else
|
||||
ui->checkBoxFloppySounds->setVisible(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
SettingsFloppyCDROM::~SettingsFloppyCDROM()
|
||||
@@ -245,6 +251,12 @@ SettingsFloppyCDROM::save()
|
||||
cdrom[i].speed = model->index(i, 1).data(Qt::UserRole).toUInt();
|
||||
cdrom_set_type(i, model->index(i, 2).data(Qt::UserRole).toInt());
|
||||
}
|
||||
|
||||
#ifdef DISABLE_FDD_AUDIO
|
||||
fdd_sounds_enabled = 0;
|
||||
#else
|
||||
fdd_sounds_enabled = ui->checkBoxFloppySounds->isChecked() ? 1 : 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@@ -325,6 +337,12 @@ SettingsFloppyCDROM::on_checkBoxCheckBPB_stateChanged(int arg1)
|
||||
tr("On") : tr("Off"));
|
||||
}
|
||||
|
||||
void
|
||||
SettingsFloppyCDROM::on_checkBoxFloppySounds_stateChanged(int arg1)
|
||||
{
|
||||
fdd_sounds_enabled = (arg1 == Qt::Checked) ? 1 : 0;
|
||||
}
|
||||
|
||||
void
|
||||
SettingsFloppyCDROM::on_comboBoxFloppyType_activated(int index)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@ private slots:
|
||||
void on_comboBoxFloppyType_activated(int index);
|
||||
void on_checkBoxTurboTimings_stateChanged(int arg1);
|
||||
void on_checkBoxCheckBPB_stateChanged(int arg1);
|
||||
void on_checkBoxFloppySounds_stateChanged(int arg1);
|
||||
|
||||
void onCDROMRowChanged(const QModelIndex ¤t);
|
||||
void on_comboBoxBus_activated(int index);
|
||||
|
||||
@@ -66,32 +66,43 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="floppyControls" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QVBoxLayout" name="floppyVerticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFloppyType">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFloppyType">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxFloppyType">
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxTurboTimings">
|
||||
<property name="text">
|
||||
<string>Turbo timings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxCheckBPB">
|
||||
<property name="text">
|
||||
<string>Check BPB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxFloppyType">
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxTurboTimings">
|
||||
<widget class="QCheckBox" name="checkBoxFloppySounds">
|
||||
<property name="text">
|
||||
<string>Turbo timings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxCheckBPB">
|
||||
<property name="text">
|
||||
<string>Check BPB</string>
|
||||
<string>Enable floppy sounds for all drives</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -205,6 +216,7 @@
|
||||
<tabstop>comboBoxFloppyType</tabstop>
|
||||
<tabstop>checkBoxTurboTimings</tabstop>
|
||||
<tabstop>checkBoxCheckBPB</tabstop>
|
||||
<tabstop>checkBoxFloppySounds</tabstop>
|
||||
<tabstop>tableViewCDROM</tabstop>
|
||||
<tabstop>comboBoxBus</tabstop>
|
||||
<tabstop>comboBoxChannel</tabstop>
|
||||
|
||||
@@ -791,12 +791,6 @@ sound_cd_thread_reset(void)
|
||||
cd_thread_enable = available_cdrom_drives ? 1 : 0;
|
||||
}
|
||||
|
||||
static void
|
||||
sound_fdd_clean_buffers(void)
|
||||
{
|
||||
memset(fdd_out_buffer, 0, SOUNDBUFLEN * 2);
|
||||
}
|
||||
|
||||
static void
|
||||
sound_fdd_thread(UNUSED(void *param))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user