Make DosBeep volume configurable.
This commit is contained in:
1 parent
1fd6bab8eb
commit
b8f67643dc
3 files changed
+19
-1
No files matched your search
@@ -384,6 +384,17 @@ static void cfgProcessBoolString(const char *fname, const int lineno, int *outpu
|
||||
cfgWarn(fname, lineno, "\"%s\" is not valid for this setting. Try 1 or 0.", val);
|
||||
}
|
||||
|
||||
static void cfgProcessFloatString(const char *fname, const int lineno, float *output, const char *val)
|
||||
{
|
||||
errno = 0;
|
||||
const float converted = strtof(val, NULL);
|
||||
if (!errno) {
|
||||
*output = converted;
|
||||
} else {
|
||||
cfgWarn(fname, lineno, "\"%s\" is not valid for this setting. Try a number.", val);
|
||||
}
|
||||
}
|
||||
|
||||
static void cfgProcessMountPoint(const char *fname, const int lineno, const char *var, const char *val)
|
||||
{
|
||||
char letter = var[0];
|
||||
@@ -426,6 +437,8 @@ static void cfgProcessSystem(const char *fname, const int lineno, const char *va
|
||||
cfgProcessBoolString(fname, lineno, &GLoaderState.trace_native, val);
|
||||
} else if (strcmp(var, "trace_events") == 0) {
|
||||
cfgProcessBoolString(fname, lineno, &GLoaderState.trace_events, val);
|
||||
} else if (strcmp(var, "beep_volume") == 0) {
|
||||
cfgProcessFloatString(fname, lineno, &GLoaderState.beep_volume, val);
|
||||
} else {
|
||||
cfgWarn(fname, lineno, "Unknown variable system.%s", var);
|
||||
}
|
||||
@@ -818,6 +831,9 @@ LX_NATIVE_CONSTRUCTOR(lib2ine)
|
||||
GLoaderState.registerAudioGenerator = registerAudioGenerator_lib2ine;
|
||||
GLoaderState.lib2ine_shutdown = lib2ine_shutdown;
|
||||
|
||||
// VMware emulates the PC Speaker on a sound card _really_ quietly.
|
||||
GLoaderState.beep_volume = 0.05f;
|
||||
|
||||
cfgLoadFiles();
|
||||
prepOs2Drives();
|
||||
|
||||
|
||||
@@ -299,6 +299,7 @@ typedef struct LxLoaderState
|
||||
char *current_dir[26]; // current directory, per-disk, A: through Z: ... NULL if unmounted.
|
||||
int current_disk; // 1==A:\\, 2==B:\\, etc.
|
||||
uint32 diskmap; // 1<<0==drive A mounted, 1<<1==drive B mounted, etc.
|
||||
float beep_volume;
|
||||
uint8 main_tib_selector;
|
||||
uint32 mainstacksize;
|
||||
uint16 original_cs;
|
||||
|
||||
+2
-1
@@ -3151,6 +3151,7 @@ static DosBeepGeneratorInfo dos_beep_info;
|
||||
|
||||
static int DosBeepGenerator(void *userdata, float *stream, int samples, int freq)
|
||||
{
|
||||
const float beep_volume = GLoaderState.beep_volume;
|
||||
DosBeepGeneratorInfo *info = &dos_beep_info;
|
||||
assert(userdata == &dos_beep_info);
|
||||
|
||||
@@ -3177,7 +3178,7 @@ static int DosBeepGenerator(void *userdata, float *stream, int samples, int freq
|
||||
}
|
||||
} else { // still generating the current piece of the square wave, mix it into the stream.
|
||||
// VMware emulates the PC Speaker on a sound card _really_ quietly.
|
||||
const float val = info->positive ? 0.05f : -0.05f;
|
||||
const float val = info->positive ? beep_volume : -beep_volume;
|
||||
int total = info->square_remaining;
|
||||
if (info->samples_remaining < total) total = info->samples_remaining;
|
||||
if (samples < total) total = samples;
|
||||
|
||||
Reference in new issue
Block a user