Store sound card in config file as name rather than number.

This commit is contained in:
SarahW 2017-03-08 20:03:32 +00:00
commit 7d6028a619
3 changed files with 42 additions and 16 deletions

View file

@ -600,7 +600,11 @@ void loadconfig(char *fn)
else else
gfxcard = 0; gfxcard = 0;
video_speed = config_get_int(NULL, "video_speed", 3); video_speed = config_get_int(NULL, "video_speed", 3);
sound_card_current = config_get_int(NULL, "sndcard", SB2); p = (char *)config_get_string(NULL, "sndcard", "");
if (p)
sound_card_current = sound_card_get_from_internal_name(p);
else
sound_card_current = 0;
p = (char *)config_get_string(NULL, "disc_a", ""); p = (char *)config_get_string(NULL, "disc_a", "");
if (p) strcpy(discfns[0], p); if (p) strcpy(discfns[0], p);
@ -711,7 +715,7 @@ void saveconfig()
config_set_string(NULL, "gfxcard", video_get_internal_name(video_old_to_new(gfxcard))); config_set_string(NULL, "gfxcard", video_get_internal_name(video_old_to_new(gfxcard)));
config_set_int(NULL, "video_speed", video_speed); config_set_int(NULL, "video_speed", video_speed);
config_set_int(NULL, "sndcard", sound_card_current); config_set_string(NULL, "sndcard", sound_card_get_internal_name(sound_card_current));
config_set_int(NULL, "cpu_speed", cpuspeed); config_set_int(NULL, "cpu_speed", cpuspeed);
config_set_int(NULL, "has_fpu", hasfpu); config_set_int(NULL, "has_fpu", hasfpu);
config_set_string(NULL, "disc_a", discfns[0]); config_set_string(NULL, "disc_a", discfns[0]);

View file

@ -23,25 +23,26 @@ static int sound_card_last = 0;
typedef struct typedef struct
{ {
char name[32]; char name[64];
char internal_name[24];
device_t *device; device_t *device;
} SOUND_CARD; } SOUND_CARD;
static SOUND_CARD sound_cards[] = static SOUND_CARD sound_cards[] =
{ {
{"None", NULL}, {"None", "none", NULL},
{"Adlib", &adlib_device}, {"Adlib", "adlib", &adlib_device},
{"Sound Blaster 1.0", &sb_1_device}, {"Sound Blaster 1.0", "sb", &sb_1_device},
{"Sound Blaster 1.5", &sb_15_device}, {"Sound Blaster 1.5", "sb1.5", &sb_15_device},
{"Sound Blaster 2.0", &sb_2_device}, {"Sound Blaster 2.0", "sb2.0", &sb_2_device},
{"Sound Blaster Pro v1", &sb_pro_v1_device}, {"Sound Blaster Pro v1", "sbprov1", &sb_pro_v1_device},
{"Sound Blaster Pro v2", &sb_pro_v2_device}, {"Sound Blaster Pro v2", "sbprov2", &sb_pro_v2_device},
{"Sound Blaster 16", &sb_16_device}, {"Sound Blaster 16", "sb16", &sb_16_device},
{"Sound Blaster AWE32", &sb_awe32_device}, {"Sound Blaster AWE32", "sbawe32", &sb_awe32_device},
{"Adlib Gold", &adgold_device}, {"Adlib Gold", "adlibgold", &adgold_device},
{"Windows Sound System", &wss_device}, {"Windows Sound System", "wss", &wss_device},
{"Pro Audio Spectrum 16", &pas16_device}, {"Pro Audio Spectrum 16", "pas16", &pas16_device},
{"", NULL} {"", "", NULL}
}; };
int sound_card_available(int card) int sound_card_available(int card)
@ -69,6 +70,25 @@ int sound_card_has_config(int card)
return sound_cards[card].device->config ? 1 : 0; return sound_cards[card].device->config ? 1 : 0;
} }
char *sound_card_get_internal_name(int card)
{
return sound_cards[card].internal_name;
}
int sound_card_get_from_internal_name(char *s)
{
int c = 0;
while (strlen(sound_cards[c].internal_name))
{
if (!strcmp(sound_cards[c].internal_name, s))
return c;
c++;
}
return 0;
}
void sound_card_init() void sound_card_init()
{ {
if (sound_cards[sound_card_current].device) if (sound_cards[sound_card_current].device)

View file

@ -8,6 +8,8 @@ int sound_card_available(int card);
char *sound_card_getname(int card); char *sound_card_getname(int card);
struct device_t *sound_card_getdevice(int card); struct device_t *sound_card_getdevice(int card);
int sound_card_has_config(int card); int sound_card_has_config(int card);
char *sound_card_get_internal_name(int card);
int sound_card_get_from_internal_name(char *s);
void sound_card_init(); void sound_card_init();
void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r); void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r);