This commit is contained in:
OBattler
2023-04-19 23:34:43 +02:00
6 changed files with 102 additions and 53 deletions

View File

@@ -718,6 +718,24 @@ load_sound(void)
mpu401_standalone_enable = !!ini_section_get_int(cat, "mpu401_standalone", 0);
/* Backwards compatibility for standalone SSI-2001, CMS and GUS from v3.11 and older. */
const char *legacy_cards[][2] = {
{"ssi2001", "ssi2001"},
{ "gameblaster", "cms" },
{ "gus", "gus" }
};
for (int i = 0, j = 0; i < (sizeof(legacy_cards) / sizeof(legacy_cards[0])); i++) {
if (ini_section_get_int(cat, legacy_cards[i][0], 0) == 1) {
/* Migrate to the first available sound card slot. */
for (; j < (sizeof(sound_card_current) / sizeof(sound_card_current[0])); j++) {
if (!sound_card_current[j]) {
sound_card_current[j] = sound_card_get_from_internal_name(legacy_cards[i][1]);
break;
}
}
}
}
memset(temp, '\0', sizeof(temp));
p = ini_section_get_string(cat, "sound_type", "float");
if (strlen(p) > 511)
@@ -2159,7 +2177,7 @@ save_machine(void)
else
ini_section_delete_var(cat, "cpu_override");
/* Forwards compatibility with the previous CPU model system. */
/* Downgrade compatibility with the previous CPU model system. */
ini_section_delete_var(cat, "cpu_manufacturer");
ini_section_delete_var(cat, "cpu");
@@ -2390,6 +2408,27 @@ save_sound(void)
else
ini_section_set_int(cat, "mpu401_standalone", mpu401_standalone_enable);
/* Downgrade compatibility for standalone SSI-2001, CMS and GUS from v3.11 and older. */
const char *legacy_cards[][2] = {
{"ssi2001", "ssi2001"},
{ "gameblaster", "cms" },
{ "gus", "gus" }
};
for (int i = 0; i < (sizeof(legacy_cards) / sizeof(legacy_cards[0])); i++) {
int card_id = sound_card_get_from_internal_name(legacy_cards[i][1]);
for (int j = 0; j < (sizeof(sound_card_current) / sizeof(sound_card_current[0])); j++) {
if (sound_card_current[j] == card_id) {
/* A special value of 2 still enables the cards on older versions,
but lets newer versions know that they've already been migrated. */
ini_section_set_int(cat, legacy_cards[i][0], 2);
card_id = 0; /* mark as found */
break;
}
}
if (card_id > 0) /* not found */
ini_section_delete_var(cat, legacy_cards[i][0]);
}
if (sound_is_float == 1)
ini_section_delete_var(cat, "sound_type");
else

View File

@@ -30,26 +30,26 @@ typedef void *ini_t;
typedef void *ini_section_t;
extern ini_t ini_new(void);
extern ini_t ini_read(char *fn);
extern void ini_write(ini_t ini, char *fn);
extern ini_t ini_read(const char *fn);
extern void ini_write(ini_t ini, const char *fn);
extern void ini_dump(ini_t ini);
extern void ini_close(ini_t ini);
extern void ini_section_delete_var(ini_section_t section, char *name);
extern int ini_section_get_int(ini_section_t section, char *name, int def);
extern double ini_section_get_double(ini_section_t section, char *name, double def);
extern int ini_section_get_hex16(ini_section_t section, char *name, int def);
extern int ini_section_get_hex20(ini_section_t section, char *name, int def);
extern int ini_section_get_mac(ini_section_t section, char *name, int def);
extern char *ini_section_get_string(ini_section_t section, char *name, char *def);
extern wchar_t *ini_section_get_wstring(ini_section_t section, char *name, wchar_t *def);
extern void ini_section_set_int(ini_section_t section, char *name, int val);
extern void ini_section_set_double(ini_section_t section, char *name, double val);
extern void ini_section_set_hex16(ini_section_t section, char *name, int val);
extern void ini_section_set_hex20(ini_section_t section, char *name, int val);
extern void ini_section_set_mac(ini_section_t section, char *name, int val);
extern void ini_section_delete_var(ini_section_t section, const char *name);
extern int ini_section_get_int(ini_section_t section, const char *name, int def);
extern double ini_section_get_double(ini_section_t section, const char *name, double def);
extern int ini_section_get_hex16(ini_section_t section, const char *name, int def);
extern int ini_section_get_hex20(ini_section_t section, const char *name, int def);
extern int ini_section_get_mac(ini_section_t section, const char *name, int def);
extern char *ini_section_get_string(ini_section_t section, const char *name, char *def);
extern wchar_t *ini_section_get_wstring(ini_section_t section, const char *name, wchar_t *def);
extern void ini_section_set_int(ini_section_t section, const char *name, int val);
extern void ini_section_set_double(ini_section_t section, const char *name, double val);
extern void ini_section_set_hex16(ini_section_t section, const char *name, int val);
extern void ini_section_set_hex20(ini_section_t section, const char *name, int val);
extern void ini_section_set_mac(ini_section_t section, const char *name, int val);
extern void ini_section_set_string(ini_section_t section, const char *name, const char *val);
extern void ini_section_set_wstring(ini_section_t section, char *name, wchar_t *val);
extern void ini_section_set_wstring(ini_section_t section, const char *name, wchar_t *val);
#define ini_delete_var(ini, head, name) ini_section_delete_var(ini_find_section(ini, head), name)
@@ -69,13 +69,13 @@ extern void ini_section_set_wstring(ini_section_t section, char *name, wchar
#define ini_set_string(ini, head, name, val) ini_section_set_string(ini_find_or_create_section(ini, head), name, val)
#define ini_set_wstring(ini, head, name, val) ini_section_set_wstring(ini_find_or_create_section(ini, head), name, val)
extern ini_section_t ini_find_section(ini_t ini, char *name);
extern ini_section_t ini_find_or_create_section(ini_t ini, char *name);
extern void ini_rename_section(ini_section_t section, char *name);
extern ini_section_t ini_find_section(ini_t ini, const char *name);
extern ini_section_t ini_find_or_create_section(ini_t ini, const char *name);
extern void ini_rename_section(ini_section_t section, const char *name);
extern void ini_delete_section_if_empty(ini_t ini, ini_section_t section);
#ifdef __cplusplus
}
#endif
#endif
#endif

View File

@@ -24,13 +24,13 @@
extern int sound_gain;
#define FREQ_44100 44100
#define FREQ_48000 48000
#define FREQ_49716 49716
#define FREQ_88200 88200
#define FREQ_96000 96000
#define FREQ_44100 44100
#define FREQ_48000 48000
#define FREQ_49716 49716
#define FREQ_88200 88200
#define FREQ_96000 96000
#define SOUND_FREQ FREQ_48000
#define SOUND_FREQ FREQ_48000
#define SOUNDBUFLEN (SOUND_FREQ / 50)
#define CD_FREQ FREQ_44100
@@ -62,7 +62,7 @@ extern const device_t *sound_card_getdevice(int card);
#endif
extern int sound_card_has_config(int card);
extern char *sound_card_get_internal_name(int card);
extern int sound_card_get_from_internal_name(char *s);
extern int sound_card_get_from_internal_name(const char *s);
extern void sound_card_init(void);
extern void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r);

View File

@@ -101,10 +101,10 @@ ini_log(const char *fmt, ...)
#endif
static section_t *
find_section(list_t *head, char *name)
find_section(list_t *head, const char *name)
{
section_t *sec = (section_t *) head->next;
char blank[] = "";
const char blank[] = "";
if (name == NULL)
name = blank;
@@ -120,7 +120,7 @@ find_section(list_t *head, char *name)
}
ini_section_t
ini_find_section(ini_t ini, char *name)
ini_find_section(ini_t ini, const char *name)
{
if (ini == NULL)
return NULL;
@@ -129,7 +129,7 @@ ini_find_section(ini_t ini, char *name)
}
void
ini_rename_section(ini_section_t section, char *name)
ini_rename_section(ini_section_t section, const char *name)
{
section_t *sec = (section_t *) section;
@@ -197,7 +197,7 @@ ini_delete_section_if_empty(ini_t ini, ini_section_t section)
}
static section_t *
create_section(list_t *head, char *name)
create_section(list_t *head, const char *name)
{
section_t *ns = malloc(sizeof(section_t));
@@ -209,7 +209,7 @@ create_section(list_t *head, char *name)
}
ini_section_t
ini_find_or_create_section(ini_t ini, char *name)
ini_find_or_create_section(ini_t ini, const char *name)
{
if (ini == NULL)
return NULL;
@@ -263,7 +263,7 @@ ini_close(ini_t ini)
}
static int
ini_detect_bom(char *fn)
ini_detect_bom(const char *fn)
{
FILE *f;
unsigned char bom[4] = { 0, 0, 0, 0 };
@@ -311,7 +311,7 @@ ini_fgetws(wchar_t *str, int count, FILE *stream)
/* Read and parse the configuration file into memory. */
ini_t
ini_read(char *fn)
ini_read(const char *fn)
{
char sname[128], ename[128];
wchar_t buff[1024];
@@ -438,7 +438,7 @@ ini_read(char *fn)
/* Write the in-memory configuration to disk. */
void
ini_write(ini_t ini, char *fn)
ini_write(ini_t ini, const char *fn)
{
wchar_t wtemp[512];
list_t *list = (list_t *) ini;
@@ -521,7 +521,7 @@ ini_dump(ini_t ini)
}
void
ini_section_delete_var(ini_section_t self, char *name)
ini_section_delete_var(ini_section_t self, const char *name)
{
section_t *section = (section_t *) self;
entry_t *entry;
@@ -537,7 +537,7 @@ ini_section_delete_var(ini_section_t self, char *name)
}
int
ini_section_get_int(ini_section_t self, char *name, int def)
ini_section_get_int(ini_section_t self, const char *name, int def)
{
section_t *section = (section_t *) self;
entry_t *entry;
@@ -556,7 +556,7 @@ ini_section_get_int(ini_section_t self, char *name, int def)
}
double
ini_section_get_double(ini_section_t self, char *name, double def)
ini_section_get_double(ini_section_t self, const char *name, double def)
{
section_t *section = (section_t *) self;
entry_t *entry;
@@ -575,7 +575,7 @@ ini_section_get_double(ini_section_t self, char *name, double def)
}
int
ini_section_get_hex16(ini_section_t self, char *name, int def)
ini_section_get_hex16(ini_section_t self, const char *name, int def)
{
section_t *section = (section_t *) self;
entry_t *entry;
@@ -594,7 +594,7 @@ ini_section_get_hex16(ini_section_t self, char *name, int def)
}
int
ini_section_get_hex20(ini_section_t self, char *name, int def)
ini_section_get_hex20(ini_section_t self, const char *name, int def)
{
section_t *section = (section_t *) self;
entry_t *entry;
@@ -613,7 +613,7 @@ ini_section_get_hex20(ini_section_t self, char *name, int def)
}
int
ini_section_get_mac(ini_section_t self, char *name, int def)
ini_section_get_mac(ini_section_t self, const char *name, int def)
{
section_t *section = (section_t *) self;
entry_t *entry;
@@ -632,7 +632,7 @@ ini_section_get_mac(ini_section_t self, char *name, int def)
}
char *
ini_section_get_string(ini_section_t self, char *name, char *def)
ini_section_get_string(ini_section_t self, const char *name, char *def)
{
section_t *section = (section_t *) self;
entry_t *entry;
@@ -648,7 +648,7 @@ ini_section_get_string(ini_section_t self, char *name, char *def)
}
wchar_t *
ini_section_get_wstring(ini_section_t self, char *name, wchar_t *def)
ini_section_get_wstring(ini_section_t self, const char *name, wchar_t *def)
{
section_t *section = (section_t *) self;
entry_t *entry;
@@ -664,7 +664,7 @@ ini_section_get_wstring(ini_section_t self, char *name, wchar_t *def)
}
void
ini_section_set_int(ini_section_t self, char *name, int val)
ini_section_set_int(ini_section_t self, const char *name, int val)
{
section_t *section = (section_t *) self;
entry_t *ent;
@@ -681,7 +681,7 @@ ini_section_set_int(ini_section_t self, char *name, int val)
}
void
ini_section_set_double(ini_section_t self, char *name, double val)
ini_section_set_double(ini_section_t self, const char *name, double val)
{
section_t *section = (section_t *) self;
entry_t *ent;
@@ -698,7 +698,7 @@ ini_section_set_double(ini_section_t self, char *name, double val)
}
void
ini_section_set_hex16(ini_section_t self, char *name, int val)
ini_section_set_hex16(ini_section_t self, const char *name, int val)
{
section_t *section = (section_t *) self;
entry_t *ent;
@@ -715,7 +715,7 @@ ini_section_set_hex16(ini_section_t self, char *name, int val)
}
void
ini_section_set_hex20(ini_section_t self, char *name, int val)
ini_section_set_hex20(ini_section_t self, const char *name, int val)
{
section_t *section = (section_t *) self;
entry_t *ent;
@@ -732,7 +732,7 @@ ini_section_set_hex20(ini_section_t self, char *name, int val)
}
void
ini_section_set_mac(ini_section_t self, char *name, int val)
ini_section_set_mac(ini_section_t self, const char *name, int val)
{
section_t *section = (section_t *) self;
entry_t *ent;
@@ -774,7 +774,7 @@ ini_section_set_string(ini_section_t self, const char *name, const char *val)
}
void
ini_section_set_wstring(ini_section_t self, char *name, wchar_t *val)
ini_section_set_wstring(ini_section_t self, const char *name, wchar_t *val)
{
section_t *section = (section_t *) self;
entry_t *ent;

View File

@@ -54,16 +54,26 @@
<property name="text">
<string>CD-ROM Controller:</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxCDInterface"/>
<widget class="QComboBox" name="comboBoxCDInterface">
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButtonCDInterface">
<property name="text">
<string>Configure</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">

View File

@@ -202,7 +202,7 @@ sound_card_get_internal_name(int card)
}
int
sound_card_get_from_internal_name(char *s)
sound_card_get_from_internal_name(const char *s)
{
int c = 0;