X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Fconfig.c;h=f4d25463aaad476e30b8296613d682f49a09af2c;hb=dd5fd4778d797a1ef4767604b1c57c924ed0f64b;hp=534fb4000dea7abad9d5df987933a38f3fc32f86;hpb=367b6f1f939dcd7930d372aee0ca900b0b8790b1;p=libpicofe.git diff --git a/common/config.c b/common/config.c index 534fb40..f4d2546 100644 --- a/common/config.c +++ b/common/config.c @@ -21,10 +21,10 @@ extern const int cdopt_entry_count; static menu_entry *cfg_opts[] = { opt_entries, opt2_entries, cdopt_entries }; static const int *cfg_opt_counts[] = { &opt_entry_count, &opt2_entry_count, &cdopt_entry_count }; -#define NL "\n" +#define NL "\r\n" -static void mystrip(char *str) +static char *mystrip(char *str) { int i, len; @@ -32,10 +32,13 @@ static void mystrip(char *str) for (i = 0; i < len; i++) if (str[i] != ' ') break; if (i > 0) memmove(str, str + i, len - i + 1); + len = strlen(str); for (i = len - 1; i >= 0; i--) if (str[i] != ' ') break; str[i+1] = 0; + + return str; } @@ -67,9 +70,9 @@ static void custom_write(FILE *f, const menu_entry *me, int no_def) switch (me->id) { case MA_OPT_RENDERER: - if (no_def && !((defaultConfig.s_PicoOpt^PicoOpt)&0x10) && + if (no_def && !((defaultConfig.s_PicoOpt^PicoOpt)&POPT_ALT_RENDERER) && !((defaultConfig.EmuOpt^currentConfig.EmuOpt)&0x80)) return; - if (PicoOpt&0x10) + if (PicoOpt&POPT_ALT_RENDERER) str = "8bit fast"; else if (currentConfig.EmuOpt&0x80) str = "16bit accurate"; @@ -96,9 +99,9 @@ static void custom_write(FILE *f, const menu_entry *me, int no_def) fprintf(f, "Frameskip = %s", str24); break; case MA_OPT_SOUND_QUALITY: - if (no_def && !((defaultConfig.s_PicoOpt^PicoOpt)&8) && + if (no_def && !((defaultConfig.s_PicoOpt^PicoOpt)&POPT_EN_STEREO) && defaultConfig.s_PsndRate == PsndRate) return; - str = (PicoOpt&0x08)?"stereo":"mono"; + str = (PicoOpt&POPT_EN_STEREO)?"stereo":"mono"; fprintf(f, "Sound Quality = %i %s", PsndRate, str); break; case MA_OPT_REGION: @@ -167,22 +170,18 @@ static void keys_write(FILE *fn, const char *bind_str, const int binds[32], #endif for (i = 0; i < sizeof(me_ctrl_actions) / sizeof(me_ctrl_actions[0]); i++) { if (me_ctrl_actions[i].mask & binds[t]) { - sprintf(act, "player%i ", ((binds[t]>>16)&1)+1); - strncpy(act + 8, me_ctrl_actions[i].name, 31); - break; + strncpy(act, me_ctrl_actions[i].name, 31); + fprintf(fn, "%s %s = player%i %s" NL, bind_str, names[t], + ((binds[t]>>16)&1)+1, mystrip(act)); } } - if (act[0] == 0) - { - for (i = 0; emuctrl_actions[i].name != NULL; i++) - if (emuctrl_actions[i].mask & binds[t]) { - strncpy(act, emuctrl_actions[i].name, 31); - break; - } - } - mystrip(act); - fprintf(fn, "%s %s = %s" NL, bind_str, names[t], act); + for (i = 0; emuctrl_actions[i].name != NULL; i++) { + if (emuctrl_actions[i].mask & binds[t]) { + strncpy(act, emuctrl_actions[i].name, 31); + fprintf(fn, "%s %s = %s" NL, bind_str, names[t], mystrip(act)); + } + } } } @@ -323,6 +322,9 @@ write: keys_write(fn, "bind_joy2", currentConfig.JoyBinds[2], defaultConfig.JoyBinds[2], joyKeyNames, 1); keys_write(fn, "bind_joy3", currentConfig.JoyBinds[3], defaultConfig.JoyBinds[3], joyKeyNames, 1); + if (section == NULL) + fprintf(fn, "Sound Volume = %i" NL, currentConfig.volume); + fprintf(fn, NL); if (fo != NULL) @@ -351,7 +353,7 @@ int config_writelrom(const char *fname) int size; FILE *f; - if (strlen(lastRomFile) == 0) return 0; + if (strlen(lastRomFile) == 0) return -1; f = fopen(fname, "r"); if (f != NULL) @@ -436,14 +438,14 @@ static int custom_read(menu_entry *me, const char *var, const char *val) case MA_OPT_RENDERER: if (strcasecmp(var, "Renderer") != 0) return 0; if (strcasecmp(val, "8bit fast") == 0) { - PicoOpt |= 0x10; + PicoOpt |= POPT_ALT_RENDERER; } else if (strcasecmp(val, "16bit accurate") == 0) { - PicoOpt &= ~0x10; + PicoOpt &= ~POPT_ALT_RENDERER; currentConfig.EmuOpt |= 0x80; } else if (strcasecmp(val, "8bit accurate") == 0) { - PicoOpt &= ~0x10; + PicoOpt &= ~POPT_ALT_RENDERER; currentConfig.EmuOpt &= ~0x80; } else @@ -478,9 +480,9 @@ static int custom_read(menu_entry *me, const char *var, const char *val) PsndRate = 22050; while (*tmp == ' ') tmp++; if (strcasecmp(tmp, "stereo") == 0) { - PicoOpt |= 8; + PicoOpt |= POPT_EN_STEREO; } else if (strcasecmp(tmp, "mono") == 0) { - PicoOpt &= ~8; + PicoOpt &= ~POPT_EN_STEREO; } else return 0; return 1; @@ -566,9 +568,11 @@ static int custom_read(menu_entry *me, const char *var, const char *val) } +static unsigned int keys_encountered = 0; + static void keys_parse(const char *var, const char *val, int binds[32], const char *names[32]) { - int t, i, keys_encountered = 0; + int t, i; unsigned int player; for (t = 0; t < 32; t++) @@ -580,7 +584,7 @@ static void keys_parse(const char *var, const char *val, int binds[32], const ch return; } - if (!(keys_encountered & (1<