--- uae/src/cfgfile.c 2018/04/24 16:44:54 1.1 +++ uae/src/cfgfile.c 2018/04/24 16:46:16 1.1.1.2 @@ -18,12 +18,6 @@ #include "uae.h" #include "autoconf.h" -struct mount_data { - struct mount_data *next; - int secs, heads, reserved, bs, ro; - char *aname, *root; -}; - /* @@@ need to get rid of this... just cut part of the manual and print that * as a help text. */ struct cfg_lines @@ -94,6 +88,8 @@ static const char *portmode[] = { "joy0" static const char *colormode1[] = { "8bit", "15bit", "16bit", "8bit_dither", "4bit_dither", "32bit", 0 }; static const char *colormode2[] = { "8", "15", "16", "8d", "4d", "32", 0 }; static const char *soundmode[] = { "none", "interrupts", "normal", "exact", 0 }; +static const char *centermode1[] = { "none", "simple", "smart", 0 }; +static const char *centermode2[] = { "false", "true", "smart", 0 }; static const char *stereomode1[] = { "mono", "stereo", 0 }; static const char *stereomode2[] = { "m", "s", 0 }; static const char *stereomode3[] = { "1", "2", 0 }; @@ -143,6 +139,8 @@ void save_options (FILE *f, struct uae_p fprintf (f, "%s.floppy_path=%s\n", TARGET_NAME, p->path_floppy); fprintf (f, "%s.hardfile_path=%s\n", TARGET_NAME, p->path_hardfile); + target_save_options (f, p); + fprintf (f, "use_gui=%s\n", p->start_gui ? "true" : "false"); fprintf (f, "use_debugger=%s\n", p->start_debugger ? "true" : "false"); str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->romfile); @@ -182,8 +180,8 @@ void save_options (FILE *f, struct uae_p fprintf (f, "gfx_correct_aspect=%s\n", p->gfx_correct_aspect ? "true" : "false"); fprintf (f, "gfx_fullscreen_amiga=%s\n", p->gfx_afullscreen ? "true" : "false"); fprintf (f, "gfx_fullscreen_picasso=%s\n", p->gfx_pfullscreen ? "true" : "false"); - fprintf (f, "gfx_center_horizontal=%s\n", p->gfx_xcenter ? "true" : "false"); - fprintf (f, "gfx_center_vertical=%s\n", p->gfx_ycenter ? "true" : "false"); + fprintf (f, "gfx_center_horizontal=%s\n", centermode1[p->gfx_xcenter]); + fprintf (f, "gfx_center_vertical=%s\n", centermode1[p->gfx_ycenter]); fprintf (f, "gfx_colour_mode=%s\n", colormode1[p->color_mode]); fprintf (f, "32bit_blits=%s\n", p->blits_32bit_enabled ? "true" : "false"); @@ -299,8 +297,7 @@ static int getintval (char **p, int *res return 1; } -int cfgfile_parse_option (struct uae_prefs *p, char *option, char *value, - struct mount_data **pmqueue) +int cfgfile_parse_option (struct uae_prefs *p, char *option, char *value) { char *section = 0; char *tmpp; @@ -330,8 +327,6 @@ int cfgfile_parse_option (struct uae_pre || cfgfile_yesno (option, value, "gfx_correct_aspect", &p->gfx_correct_aspect) || cfgfile_yesno (option, value, "gfx_fullscreen_amiga", &p->gfx_afullscreen) || cfgfile_yesno (option, value, "gfx_fullscreen_picasso", &p->gfx_pfullscreen) - || cfgfile_yesno (option, value, "gfx_center_horizontal", &p->gfx_xcenter) - || cfgfile_yesno (option, value, "gfx_center_vertical", &p->gfx_ycenter) || cfgfile_yesno (option, value, "cpu_compatible", &p->cpu_compatible) || cfgfile_yesno (option, value, "cpu_24bit_addressing", &p->address_space_24) || cfgfile_yesno (option, value, "autoconfig", &p->automount_uaedev) @@ -364,6 +359,10 @@ int cfgfile_parse_option (struct uae_pre || cfgfile_strval (option, value, "joyport1", &p->jport1, portmode, 0) || cfgfile_strval (option, value, "gfx_linemode", &p->gfx_linedbl, linemode1, 1) || cfgfile_strval (option, value, "gfx_linemode", &p->gfx_linedbl, linemode2, 0) + || cfgfile_strval (option, value, "gfx_center_horizontal", &p->gfx_xcenter, centermode1, 1) + || cfgfile_strval (option, value, "gfx_center_vertical", &p->gfx_ycenter, centermode1, 1) + || cfgfile_strval (option, value, "gfx_center_horizontal", &p->gfx_xcenter, centermode2, 0) + || cfgfile_strval (option, value, "gfx_center_vertical", &p->gfx_ycenter, centermode2, 0) || cfgfile_strval (option, value, "gfx_colour_mode", &p->color_mode, colormode1, 1) || cfgfile_strval (option, value, "gfx_colour_mode", &p->color_mode, colormode2, 0) || cfgfile_strval (option, value, "gfx_color_mode", &p->color_mode, colormode1, 1) @@ -375,7 +374,7 @@ int cfgfile_parse_option (struct uae_pre || cfgfile_string (option, value, "floppy3", p->df[3], 256) || cfgfile_string (option, value, "kickstart_rom_file", p->romfile, 256) || cfgfile_string (option, value, "kickstart_key_file", p->keyfile, 256) - || cfgfile_string (option, value, "description", p->description, 256)) + || cfgfile_string (option, value, "config_description", p->description, 256)) return 1; /* Tricky ones... */ @@ -408,9 +407,10 @@ int cfgfile_parse_option (struct uae_pre if (strcmp (option, "filesystem") == 0 || strcmp (option, "hardfile") == 0) { - struct mount_data *data = xmalloc (sizeof (struct mount_data)); + int secs, heads, reserved, bs, ro; + char *aname, *root; char *tmpp = strchr (value, ','); - + char *str; if (tmpp == 0) goto invalid_fs; @@ -418,14 +418,14 @@ int cfgfile_parse_option (struct uae_pre if (strcmp (value, "0") == 0 || strcasecmp (value, "ro") == 0 || strcasecmp (value, "readonly") == 0 || strcasecmp (value, "read-only") == 0) - data->ro = 1; + ro = 1; else if (strcmp (value, "1") == 0 || strcasecmp (value, "rw") == 0 || strcasecmp (value, "readwrite") == 0 || strcasecmp (value, "read-write") == 0) - data->ro = 0; + ro = 0; else goto invalid_fs; - data->secs = 0; data->heads = 0; data->reserved = 0; data->bs = 0; + secs = 0; heads = 0; reserved = 0; bs = 0; value = tmpp; if (strcmp (option, "filesystem") == 0) { @@ -433,36 +433,26 @@ int cfgfile_parse_option (struct uae_pre if (tmpp == 0) goto invalid_fs; *tmpp++ = '\0'; - data->aname = my_strdup (value); - data->root = my_strdup (tmpp); + aname = value; + root = tmpp; } else { - if (! getintval (&value, &data->secs, ',') - || ! getintval (&value, &data->heads, ',') - || ! getintval (&value, &data->reserved, ',') - || ! getintval (&value, &data->bs, ',')) + if (! getintval (&value, &secs, ',') + || ! getintval (&value, &heads, ',') + || ! getintval (&value, &reserved, ',') + || ! getintval (&value, &bs, ',')) goto invalid_fs; - data->root = my_strdup (value); - data->aname = 0; - } - if (pmqueue == 0) { - char *str = cfgfile_subst_path (UNEXPANDED, p->path_hardfile, data->root); - tmpp = add_filesys_unit (p->mountinfo, data->aname, str, data->ro, data->secs, - data->heads, data->reserved, data->bs); - free (str); - if (tmpp) - write_log ("Error: %s\n", tmpp); - free (data->root); - if (data->aname) - free (data->aname); - free (data); - } else { - data->next = *pmqueue; - *pmqueue = data; + root = value; + aname = 0; } + str = cfgfile_subst_path (UNEXPANDED, p->path_hardfile, root); + tmpp = add_filesys_unit (p->mountinfo, aname, str, ro, secs, + heads, reserved, bs); + free (str); + if (tmpp) + write_log ("Error: %s\n", tmpp); return 1; invalid_fs: - free (data); write_log ("Invalid filesystem/hardfile specification.\n"); return 1; } @@ -470,7 +460,7 @@ int cfgfile_parse_option (struct uae_pre return 0; } -void cfgfile_parse_line (struct uae_prefs *p, char *line, struct mount_data **pmqueue) +void cfgfile_parse_line (struct uae_prefs *p, char *line) { int i; char *orig_line = my_strdup (line); @@ -486,12 +476,18 @@ void cfgfile_parse_line (struct uae_pref *line2++ = '\0'; /* Get rid of whitespace. */ - line2[strcspn (line2, "\t \r\n")] = '\0'; + i = strlen (line2); + while (i > 0 && (line2[i - 1] == '\t' || line2[i - 1] == ' ' + || line2[i - 1] == '\r' || line2[i - 1] == '\n')) + line2[--i] = '\0'; line2 += strspn (line2, "\t \r\n"); - line[strcspn (line, "\t \r\n")] = '\0'; + i = strlen (line); + while (i > 0 && (line[i - 1] == '\t' || line[i - 1] == ' ' + || line[i - 1] == '\r' || line[i - 1] == '\n')) + line[--i] = '\0'; line += strspn (line, "\t \r\n"); - if (! cfgfile_parse_option (p, line, line2, pmqueue)) { + if (! cfgfile_parse_option (p, line, line2)) { struct strlist *u = xmalloc (sizeof (struct strlist)); u->str = orig_line; u->next = p->unknown_lines; @@ -510,7 +506,6 @@ static void subst (char *p, char *f, int int cfgfile_load (struct uae_prefs *p, const char *filename) { - struct mount_data *q = 0; char *str; int i; @@ -524,7 +519,7 @@ int cfgfile_load (struct uae_prefs *p, c while (fgets (line, 256, fh) != 0) { line[strcspn (line, "\t \r\n")] = '\0'; if (strlen (line) > 0) - cfgfile_parse_line (p, line, &q); + cfgfile_parse_line (p, line); } fclose (fh); @@ -533,24 +528,6 @@ int cfgfile_load (struct uae_prefs *p, c subst (p->path_rom, p->romfile, sizeof p->romfile); subst (p->path_rom, p->keyfile, sizeof p->keyfile); - while (q != 0) { - const char *errstr; - struct mount_data *data = q; - - str = cfgfile_subst_path (UNEXPANDED, p->path_hardfile, data->root); - errstr = add_filesys_unit (p->mountinfo, data->aname, str, data->ro, data->secs, - data->heads, data->reserved, data->bs); - free (str); - - if (errstr) - write_log ("Error: %s\n", errstr); - q = data->next; - free (data->root); - if (data->aname) - free (data->aname); - free (data); - } - return 1; }