|
|
1.1 root 1: /*
2: * UAE - The Un*x Amiga Emulator
3: *
4: * Config file handling
5: * This still needs some thought before it's complete...
6: *
7: * Copyright 1998 Brian King, Bernd Schmidt
8: */
9:
10: #include "sysconfig.h"
11: #include "sysdeps.h"
12:
13: #include <ctype.h>
14:
15: #include "options.h"
1.1.1.10 root 16: #include "threaddep/thread.h"
1.1 root 17: #include "uae.h"
18: #include "autoconf.h"
1.1.1.8 root 19: #include "events.h"
1.1.1.3 root 20: #include "custom.h"
1.1.1.16 root 21: #include "inputdevice.h"
22:
23: #define cfgfile_write fprintf
1.1 root 24:
25: /* @@@ need to get rid of this... just cut part of the manual and print that
26: * as a help text. */
27: struct cfg_lines
28: {
29: const char *config_label, *config_help;
30: };
31:
32: static struct cfg_lines opttable[] =
33: {
34: {"help", "Prints this help" },
35: {"config_description", "" },
36: {"use_gui", "Enable the GUI? If no, then goes straight to emulator" },
37: {"use_debugger", "Enable the debugger?" },
38: {"cpu_speed", "can be max, real, or a number between 1 and 20" },
39: {"cpu_type", "Can be 68000, 68010, 68020, 68020/68881" },
40: {"cpu_compatible", "yes enables compatibility-mode" },
41: {"cpu_24bit_addressing", "must be set to 'no' in order for Z3mem or P96mem to work" },
42: {"autoconfig", "yes = add filesystems and extra ram" },
43: {"accuracy", "emulation accuracy, default is 2" },
44: {"log_illegal_mem", "print illegal memory access by Amiga software?" },
45: {"fastmem_size", "Size in megabytes of fast-memory" },
46: {"chipmem_size", "Size in megabytes of chip-memory" },
47: {"bogomem_size", "Size in megabytes of bogo-memory at 0xC00000" },
48: {"a3000mem_size", "Size in megabytes of A3000 memory" },
49: {"gfxcard_size", "Size in megabytes of Picasso96 graphics-card memory" },
50: {"z3mem_size", "Size in megabytes of Zorro-III expansion memory" },
51: {"gfx_test_speed", "Test graphics speed?" },
52: {"framerate", "Print every nth frame" },
53: {"gfx_width", "Screen width" },
54: {"gfx_height", "Screen height" },
55: {"gfx_lores", "Treat display as lo-res?" },
56: {"gfx_linemode", "Can be none, double, or scanlines" },
57: {"gfx_fullscreen_amiga", "Amiga screens are fullscreen?" },
58: {"gfx_fullscreen_picasso", "Picasso screens are fullscreen?" },
59: {"gfx_correct_aspect", "Correct aspect ratio?" },
60: {"gfx_center_horizontal", "Center display horizontally?" },
61: {"gfx_center_vertical", "Center display vertically?" },
62: {"gfx_colour_mode", "" },
63: {"32bit_blits", "Enable 32 bit blitter emulation" },
64: {"immediate_blits", "Perform blits immediately" },
1.1.1.15 root 65: {"show_leds", "LED display" },
1.1 root 66: {"gfxlib_replacement", "Use graphics.library replacement?" },
67: {"sound_output", "" },
68: {"sound_frequency", "" },
69: {"sound_bits", "" },
70: {"sound_channels", "" },
71: {"sound_min_buff", "" },
72: {"sound_max_buff", "" },
73: {"parallel_on_demand", "" },
74: {"serial_on_demand", "" },
75: {"joyport0", "" },
76: {"joyport1", "" },
77: {"kickstart_rom_file", "Kickstart ROM image, (C) Copyright Amiga, Inc." },
1.1.1.12 root 78: {"kickstart_ext_rom_file", "Extended Kickstart ROM image, (C) Copyright Amiga, Inc." },
1.1 root 79: {"kickstart_key_file", "Key-file for encrypted ROM images (from Cloanto's Amiga Forever)" },
80: {"floppy0", "Diskfile for drive 0" },
81: {"floppy1", "Diskfile for drive 1" },
82: {"floppy2", "Diskfile for drive 2" },
83: {"floppy3", "Diskfile for drive 3" },
84: {"hardfile", "access,sectors, surfaces, reserved, blocksize, path format" },
85: {"filesystem", "access,'Amiga volume-name':'host directory path' - where 'access' can be 'read-only' or 'read-write'" }
86: };
87:
1.1.1.10 root 88: static const char *guimode1[] = { "no", "yes", "nowait", 0 };
89: static const char *guimode2[] = { "false", "true", "nowait", 0 };
90: static const char *guimode3[] = { "0", "1", "nowait", 0 };
91: static const char *csmode[] = { "ocs", "ecs_agnus", "ecs_denise", "ecs", "aga", 0 };
1.1 root 92: static const char *linemode1[] = { "none", "double", "scanlines", 0 };
93: static const char *linemode2[] = { "n", "d", "s", 0 };
94: static const char *speedmode[] = { "max", "real", 0 };
1.1.1.7 root 95: static const char *cpumode[] = {
96: "68000", "68000", "68010", "68010", "68ec020", "68020", "68ec020/68881", "68020/68881",
1.1.1.9 root 97: "68040", "68040", 0
1.1.1.7 root 98: };
1.1 root 99: static const char *colormode1[] = { "8bit", "15bit", "16bit", "8bit_dither", "4bit_dither", "32bit", 0 };
100: static const char *colormode2[] = { "8", "15", "16", "8d", "4d", "32", 0 };
101: static const char *soundmode[] = { "none", "interrupts", "normal", "exact", 0 };
1.1.1.2 root 102: static const char *centermode1[] = { "none", "simple", "smart", 0 };
103: static const char *centermode2[] = { "false", "true", "smart", 0 };
1.1.1.8 root 104: static const char *stereomode1[] = { "mono", "stereo", "mixed", 0 };
105: static const char *stereomode2[] = { "m", "s", "x", 0 };
106: static const char *stereomode3[] = { "1", "2", "3", 0 };
1.1.1.17! root 107: static const char *interpolmode[] = { "none", "rh", "crux", "sinc", 0 };
1.1.1.9 root 108: static const char *collmode[] = { "none", "sprites", "playfields", "full", 0 };
1.1 root 109:
110: #define UNEXPANDED "$(FILE_PATH)"
111:
112: static int match_string (const char *table[], const char *str)
113: {
114: int i;
115: for (i = 0; table[i] != 0; i++)
116: if (strcasecmp (table[i], str) == 0)
117: return i;
118: return -1;
119: }
120:
121: char *cfgfile_subst_path (const char *path, const char *subst, const char *file)
122: {
123: /* @@@ use strcasecmp for some targets. */
124: if (strlen (path) > 0 && strncmp (file, path, strlen (path)) == 0) {
125: int l;
126: char *p = xmalloc (strlen (file) + strlen (subst) + 2);
127: strcpy (p, subst);
128: l = strlen (p);
129: while (l > 0 && p[l - 1] == '/')
130: p[--l] = '\0';
131: l = strlen (path);
132: while (file[l] == '/')
133: l++;
134: strcat (p, "/"); strcat (p, file + l);
135: return p;
136: }
137: return my_strdup (file);
138: }
139:
1.1.1.17! root 140: static void write_gfx_params (FILE *f, struct gfx_params *p, char *suffix)
! 141: {
! 142: cfgfile_write (f, "gfx_width_%s=%d\n", suffix, p->width);
! 143: cfgfile_write (f, "gfx_height_%s=%d\n", suffix, p->height);
! 144: cfgfile_write (f, "gfx_lores_%s=%s\n", suffix, p->lores ? "true" : "false");
! 145: cfgfile_write (f, "gfx_linemode_%s=%s\n", suffix, linemode1[p->linedbl]);
! 146: cfgfile_write (f, "gfx_correct_aspect_%s=%s\n", suffix, p->correct_aspect ? "true" : "false");
! 147: cfgfile_write (f, "gfx_center_horizontal_%s=%s\n", suffix, centermode1[p->xcenter]);
! 148: cfgfile_write (f, "gfx_center_vertical_%s=%s\n", suffix, centermode1[p->ycenter]);
! 149: }
! 150:
1.1 root 151: void save_options (FILE *f, struct uae_prefs *p)
152: {
153: struct strlist *sl;
154: char *str;
155: int i;
156:
1.1.1.16 root 157: cfgfile_write (f, "config_description=%s\n", p->description);
1.1 root 158:
159: for (sl = p->unknown_lines; sl; sl = sl->next)
1.1.1.16 root 160: cfgfile_write (f, "%s\n", sl->str);
1.1 root 161:
1.1.1.16 root 162: cfgfile_write (f, "%s.rom_path=%s\n", TARGET_NAME, p->path_rom);
163: cfgfile_write (f, "%s.floppy_path=%s\n", TARGET_NAME, p->path_floppy);
164: cfgfile_write (f, "%s.hardfile_path=%s\n", TARGET_NAME, p->path_hardfile);
1.1 root 165:
1.1.1.2 root 166: target_save_options (f, p);
167:
1.1.1.16 root 168: cfgfile_write (f, "use_gui=%s\n", guimode1[p->start_gui]);
169: cfgfile_write (f, "use_debugger=%s\n", p->start_debugger ? "true" : "false");
1.1 root 170: str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->romfile);
1.1.1.16 root 171: cfgfile_write (f, "kickstart_rom_file=%s\n", str);
1.1 root 172: free (str);
1.1.1.12 root 173: str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->romextfile);
1.1.1.16 root 174: cfgfile_write (f, "kickstart_ext_rom_file=%s\n", str);
1.1.1.12 root 175: free (str);
1.1 root 176: str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->keyfile);
1.1.1.16 root 177: cfgfile_write (f, "kickstart_key_file=%s\n", str);
1.1 root 178: free (str);
1.1.1.16 root 179: cfgfile_write (f, "kickshifter=%s\n", p->kickshifter ? "true" : "false");
1.1 root 180:
181: for (i = 0; i < 4; i++) {
182: str = cfgfile_subst_path (p->path_floppy, UNEXPANDED, p->df[i]);
1.1.1.16 root 183: cfgfile_write (f, "floppy%d=%s\n", i, str);
1.1 root 184: free (str);
185: }
1.1.1.16 root 186: cfgfile_write (f, "nr_floppies=%d\n", p->nr_floppies);
187: cfgfile_write (f, "parallel_on_demand=%s\n", p->parallel_demand ? "true" : "false");
188: cfgfile_write (f, "serial_on_demand=%s\n", p->serial_demand ? "true" : "false");
189:
190: cfgfile_write (f, "sound_output=%s\n", soundmode[p->produce_sound]);
191: cfgfile_write (f, "sound_channels=%s\n", stereomode1[p->sound_stereo + p->mixed_stereo]);
192: cfgfile_write (f, "sound_bits=%d\n", p->sound_bits);
193: cfgfile_write (f, "sound_min_buff=%d\n", p->sound_minbsiz);
194: cfgfile_write (f, "sound_max_buff=%d\n", p->sound_maxbsiz);
195: cfgfile_write (f, "sound_frequency=%d\n", p->sound_freq);
196: cfgfile_write (f, "sound_interpol=%s\n", interpolmode[p->sound_interpol]);
197:
198: cfgfile_write (f, "sound_pri_time=%d\n", p->sound_pri_time);
199: cfgfile_write (f, "sound_pri_cutoff=%d\n", p->sound_pri_cutoff);
200:
201: for (i = 0; i < 2; i++) {
202: int v = i == 0 ? p->jport0 : p->jport1;
203: char tmp1[100], tmp2[50];
204: if (v < JSEM_JOYS) {
205: sprintf (tmp2, "kbd%d", v + 1);
206: } else if (v < JSEM_MICE) {
207: sprintf (tmp2, "joy%d", v - JSEM_JOYS);
208: } else {
209: strcpy (tmp2, "mouse");
210: if (v - JSEM_MICE > 0)
211: sprintf (tmp2, "mouse%d", v - JSEM_MICE);
212: }
213: sprintf (tmp1, "joyport%d=%s\n", i, tmp2);
214: cfgfile_write (f, tmp1);
215: }
216:
217: cfgfile_write (f, "bsdsocket_emu=%s\n", p->socket_emu ? "true" : "false");
218:
219: cfgfile_write (f, "gfx_framerate=%d\n", p->gfx_framerate);
1.1.1.17! root 220: write_gfx_params (f, &p->gfx_w, "windowed");
! 221: write_gfx_params (f, &p->gfx_f, "fullscreen");
1.1.1.16 root 222: cfgfile_write (f, "gfx_fullscreen_amiga=%s\n", p->gfx_afullscreen ? "true" : "false");
223: cfgfile_write (f, "gfx_fullscreen_picasso=%s\n", p->gfx_pfullscreen ? "true" : "false");
224: cfgfile_write (f, "gfx_colour_mode=%s\n", colormode1[p->color_mode]);
225:
226: cfgfile_write (f, "immediate_blits=%s\n", p->immediate_blits ? "true" : "false");
227: cfgfile_write (f, "ntsc=%s\n", p->ntscmode ? "true" : "false");
228: cfgfile_write (f, "show_leds=%s\n", p->leds_on_screen ? "true" : "false");
1.1.1.3 root 229: if (p->chipset_mask & CSMASK_AGA)
1.1.1.16 root 230: cfgfile_write (f, "chipset=aga\n");
1.1.1.3 root 231: else if ((p->chipset_mask & CSMASK_ECS_AGNUS) && (p->chipset_mask & CSMASK_ECS_AGNUS))
1.1.1.16 root 232: cfgfile_write (f, "chipset=ecs\n");
1.1.1.3 root 233: else if (p->chipset_mask & CSMASK_ECS_AGNUS)
1.1.1.16 root 234: cfgfile_write (f, "chipset=ecs_agnus\n");
1.1.1.3 root 235: else if (p->chipset_mask & CSMASK_ECS_DENISE)
1.1.1.16 root 236: cfgfile_write (f, "chipset=ecs_denise\n");
1.1.1.3 root 237: else
1.1.1.16 root 238: cfgfile_write (f, "chipset=ocs\n");
239: cfgfile_write (f, "collision_level=%s\n", collmode[p->collision_level]);
1.1 root 240:
1.1.1.16 root 241: cfgfile_write (f, "fastmem_size=%d\n", p->fastmem_size / 0x100000);
242: cfgfile_write (f, "a3000mem_size=%d\n", p->a3000mem_size / 0x100000);
243: cfgfile_write (f, "z3mem_size=%d\n", p->z3fastmem_size / 0x100000);
244: cfgfile_write (f, "bogomem_size=%d\n", p->bogomem_size / 0x40000);
245: cfgfile_write (f, "gfxcard_size=%d\n", p->gfxmem_size / 0x100000);
246: cfgfile_write (f, "chipmem_size=%d\n", p->chipmem_size / 0x80000);
1.1 root 247:
1.1.1.3 root 248: if (p->m68k_speed > 0)
1.1.1.16 root 249: cfgfile_write (f, "finegrain_cpu_speed=%d\n", p->m68k_speed);
1.1 root 250: else
1.1.1.16 root 251: cfgfile_write (f, "cpu_speed=%s\n", p->m68k_speed == -1 ? "max" : "real");
1.1 root 252:
1.1.1.16 root 253: cfgfile_write (f, "cpu_type=%s\n", cpumode[p->cpu_level * 2 + !p->address_space_24]);
254: cfgfile_write (f, "cpu_compatible=%s\n", p->cpu_compatible ? "true" : "false");
1.1 root 255:
1.1.1.16 root 256: cfgfile_write (f, "accuracy=%d\n", p->emul_accuracy);
257: cfgfile_write (f, "log_illegal_mem=%s\n", p->illegal_mem ? "true" : "false");
1.1 root 258:
1.1.1.16 root 259: cfgfile_write (f, "kbd_lang=%s\n", (p->keyboard_lang == KBD_LANG_DE ? "de"
1.1.1.9 root 260: : p->keyboard_lang == KBD_LANG_DK ? "dk"
1.1 root 261: : p->keyboard_lang == KBD_LANG_ES ? "es"
262: : p->keyboard_lang == KBD_LANG_US ? "us"
263: : p->keyboard_lang == KBD_LANG_SE ? "se"
264: : p->keyboard_lang == KBD_LANG_FR ? "fr"
265: : p->keyboard_lang == KBD_LANG_IT ? "it"
266: : "FOO"));
267:
268: write_filesys_config (p->mountinfo, UNEXPANDED, p->path_hardfile, f);
269:
270: /* Don't write gfxlib/gfx_test_speed options. */
271: }
272:
273: int cfgfile_yesno (char *option, char *value, char *name, int *location)
274: {
275: if (strcmp (option, name) != 0)
276: return 0;
277: if (strcasecmp (value, "yes") == 0 || strcasecmp (value, "y") == 0
278: || strcasecmp (value, "true") == 0 || strcasecmp (value, "t") == 0)
279: *location = 1;
280: else if (strcasecmp (value, "no") == 0 || strcasecmp (value, "n") == 0
281: || strcasecmp (value, "false") == 0 || strcasecmp (value, "f") == 0)
282: *location = 0;
283: else
284: write_log ("Option `%s' requires a value of either `yes' or `no'.\n", option);
285: return 1;
286: }
287:
288: int cfgfile_intval (char *option, char *value, char *name, int *location, int scale)
289: {
290: int base = 10;
291: char *endptr;
292: if (strcmp (option, name) != 0)
293: return 0;
294: /* I guess octal isn't popular enough to worry about here... */
295: if (value[0] == '0' && value[1] == 'x')
296: value += 2, base = 16;
297: *location = strtol (value, &endptr, base) * scale;
298:
299: if (*endptr != '\0' || *value == '\0')
300: write_log ("Option `%s' requires a numeric argument.\n", option);
301: return 1;
302: }
303:
304: int cfgfile_strval (char *option, char *value, char *name, int *location, const char *table[], int more)
305: {
306: int val;
307: if (strcmp (option, name) != 0)
308: return 0;
309: val = match_string (table, value);
310: if (val == -1) {
1.1.1.6 root 311: if (more)
312: return 0;
313:
314: write_log ("Unknown value for option `%s'.\n", option);
1.1 root 315: return 1;
316: }
317: *location = val;
318: return 1;
319: }
320:
321: int cfgfile_string (char *option, char *value, char *name, char *location, int maxsz)
322: {
323: if (strcmp (option, name) != 0)
324: return 0;
325: strncpy (location, value, maxsz - 1);
326: location[maxsz - 1] = '\0';
327: return 1;
328: }
329:
330: static int getintval (char **p, int *result, int delim)
331: {
332: char *value = *p;
333: int base = 10;
334: char *endptr;
335: char *p2 = strchr (*p, delim);
336:
337: if (p2 == 0)
338: return 0;
339:
340: *p2++ = '\0';
341:
342: if (value[0] == '0' && value[1] == 'x')
343: value += 2, base = 16;
344: *result = strtol (value, &endptr, base);
345: *p = p2;
346:
347: if (*endptr != '\0' || *value == '\0')
348: return 0;
349:
350: return 1;
351: }
352:
1.1.1.8 root 353: static void set_chipset_mask (struct uae_prefs *p, int val)
1.1.1.5 root 354: {
355: p->chipset_mask = (val == 0 ? 0
356: : val == 1 ? CSMASK_ECS_AGNUS
357: : val == 2 ? CSMASK_ECS_DENISE
358: : val == 3 ? CSMASK_ECS_DENISE | CSMASK_ECS_AGNUS
359: : CSMASK_AGA | CSMASK_ECS_DENISE | CSMASK_ECS_AGNUS);
360: }
361:
1.1.1.2 root 362: int cfgfile_parse_option (struct uae_prefs *p, char *option, char *value)
1.1 root 363: {
1.1.1.3 root 364: int tmpval;
1.1.1.9 root 365: int dummy;
1.1 root 366: char *section = 0;
367: char *tmpp;
1.1.1.3 root 368:
1.1.1.17! root 369: if (memcmp (option, "input.", 6) == 0) {
! 370: read_inputdevice_config (p, option, value);
! 371: return 1;
! 372: }
! 373:
1.1 root 374: for (tmpp = option; *tmpp != '\0'; tmpp++)
375: if (isupper (*tmpp))
376: *tmpp = tolower (*tmpp);
377: tmpp = strchr (option, '.');
378: if (tmpp) {
379: section = option;
380: option = tmpp + 1;
381: *tmpp = '\0';
382: if (strcmp (section, TARGET_NAME) == 0) {
383: /* We special case the various path options here. */
384: if (cfgfile_string (option, value, "rom_path", p->path_rom, 256)
385: || cfgfile_string (option, value, "floppy_path", p->path_floppy, 256)
386: || cfgfile_string (option, value, "hardfile_path", p->path_hardfile, 256))
387: return 1;
388: return target_parse_option (p, option, value);
389: }
390: return 0;
391: }
392: if (cfgfile_yesno (option, value, "use_debugger", &p->start_debugger)
1.1.1.3 root 393: || cfgfile_yesno (option, value, "bsdsocket_emu", &p->socket_emu)
1.1 root 394: || cfgfile_yesno (option, value, "immediate_blits", &p->immediate_blits)
1.1.1.11 root 395: || cfgfile_yesno (option, value, "kickshifter", &p->kickshifter)
1.1.1.17! root 396: || (cfgfile_yesno (option, value, "gfx_lores", &p->gfx_w.lores)
! 397: && cfgfile_yesno (option, value, "gfx_lores", &p->gfx_f.lores))
! 398: || cfgfile_yesno (option, value, "gfx_lores_windowed", &p->gfx_w.lores)
! 399: || cfgfile_yesno (option, value, "gfx_lores_fullscreen", &p->gfx_f.lores)
! 400: || (cfgfile_yesno (option, value, "gfx_correct_aspect", &p->gfx_w.correct_aspect)
! 401: && cfgfile_yesno (option, value, "gfx_correct_aspect", &p->gfx_f.correct_aspect))
! 402: || cfgfile_yesno (option, value, "gfx_correct_aspect_windowed", &p->gfx_w.correct_aspect)
! 403: || cfgfile_yesno (option, value, "gfx_correct_aspect_fullscreen", &p->gfx_f.correct_aspect)
1.1 root 404: || cfgfile_yesno (option, value, "gfx_fullscreen_amiga", &p->gfx_afullscreen)
405: || cfgfile_yesno (option, value, "gfx_fullscreen_picasso", &p->gfx_pfullscreen)
1.1.1.3 root 406: || cfgfile_yesno (option, value, "ntsc", &p->ntscmode)
1.1 root 407: || cfgfile_yesno (option, value, "cpu_compatible", &p->cpu_compatible)
408: || cfgfile_yesno (option, value, "cpu_24bit_addressing", &p->address_space_24)
1.1.1.9 root 409: /* For backward compatibility. */
410: || cfgfile_yesno (option, value, "autoconfig", &dummy)
1.1 root 411: || cfgfile_yesno (option, value, "parallel_on_demand", &p->parallel_demand)
412: || cfgfile_yesno (option, value, "serial_on_demand", &p->serial_demand)
413: || cfgfile_yesno (option, value, "log_illegal_mem", &p->illegal_mem))
414: return 1;
415: if (cfgfile_intval (option, value, "accuracy", &p->emul_accuracy, 1)
416: || cfgfile_intval (option, value, "sound_min_buff", &p->sound_minbsiz, 1)
417: || cfgfile_intval (option, value, "sound_max_buff", &p->sound_maxbsiz, 1)
418: || cfgfile_intval (option, value, "sound_frequency", &p->sound_freq, 1)
419: || cfgfile_intval (option, value, "sound_bits", &p->sound_bits, 1)
420: || cfgfile_intval (option, value, "sound_pri_cutoff", &p->sound_pri_cutoff, 1)
421: || cfgfile_intval (option, value, "sound_pri_time", &p->sound_pri_time, 1)
1.1.1.3 root 422: || cfgfile_intval (option, value, "gfx_framerate", &p->gfx_framerate, 1)
1.1.1.17! root 423: || (cfgfile_intval (option, value, "gfx_width", &p->gfx_w.width, 1)
! 424: && cfgfile_intval (option, value, "gfx_width", &p->gfx_f.width, 1))
! 425: || cfgfile_intval (option, value, "gfx_width_windowed", &p->gfx_w.width, 1)
! 426: || cfgfile_intval (option, value, "gfx_width_fullscreen", &p->gfx_f.width, 1)
! 427: || (cfgfile_intval (option, value, "gfx_height", &p->gfx_w.height, 1)
! 428: && cfgfile_intval (option, value, "gfx_height", &p->gfx_f.height, 1))
! 429: || cfgfile_intval (option, value, "gfx_height_windowed", &p->gfx_w.height, 1)
! 430: || cfgfile_intval (option, value, "gfx_height_fullscreen", &p->gfx_f.height, 1)
1.1 root 431: || cfgfile_intval (option, value, "fastmem_size", &p->fastmem_size, 0x100000)
432: || cfgfile_intval (option, value, "a3000mem_size", &p->a3000mem_size, 0x100000)
433: || cfgfile_intval (option, value, "z3mem_size", &p->z3fastmem_size, 0x100000)
434: || cfgfile_intval (option, value, "bogomem_size", &p->bogomem_size, 0x40000)
435: || cfgfile_intval (option, value, "gfxcard_size", &p->gfxmem_size, 0x100000)
1.1.1.6 root 436: || cfgfile_intval (option, value, "chipmem_size", &p->chipmem_size, 0x80000)
437: || cfgfile_intval (option, value, "nr_floppies", &p->nr_floppies, 1))
1.1 root 438: return 1;
439: if (cfgfile_strval (option, value, "sound_output", &p->produce_sound, soundmode, 0)
1.1.1.4 root 440: || cfgfile_strval (option, value, "sound_interpol", &p->sound_interpol, interpolmode, 0)
1.1.1.10 root 441: || cfgfile_strval (option, value, "use_gui", &p->start_gui, guimode1, 1)
442: || cfgfile_strval (option, value, "use_gui", &p->start_gui, guimode2, 1)
443: || cfgfile_strval (option, value, "use_gui", &p->start_gui, guimode3, 0)
1.1.1.8 root 444: || cfgfile_strval (option, value, "collision_level", &p->collision_level, collmode, 0)
1.1.1.17! root 445: || (cfgfile_strval (option, value, "gfx_linemode", &p->gfx_w.linedbl, linemode1, 1)
! 446: && cfgfile_strval (option, value, "gfx_linemode", &p->gfx_f.linedbl, linemode1, 1))
! 447: || (cfgfile_strval (option, value, "gfx_linemode", &p->gfx_w.linedbl, linemode2, 0)
! 448: && cfgfile_strval (option, value, "gfx_linemode", &p->gfx_f.linedbl, linemode2, 0))
! 449: || cfgfile_strval (option, value, "gfx_linemode_windowed", &p->gfx_w.linedbl, linemode1, 1)
! 450: || cfgfile_strval (option, value, "gfx_linemode_windowed", &p->gfx_w.linedbl, linemode2, 0)
! 451: || cfgfile_strval (option, value, "gfx_linemode_fullscreen", &p->gfx_f.linedbl, linemode1, 1)
! 452: || cfgfile_strval (option, value, "gfx_linemode_fullscreen", &p->gfx_f.linedbl, linemode2, 0)
! 453: || (cfgfile_strval (option, value, "gfx_center_horizontal", &p->gfx_w.xcenter, centermode1, 1)
! 454: && cfgfile_strval (option, value, "gfx_center_horizontal", &p->gfx_f.xcenter, centermode1, 1))
! 455: || (cfgfile_strval (option, value, "gfx_center_horizontal", &p->gfx_w.xcenter, centermode2, 0)
! 456: && cfgfile_strval (option, value, "gfx_center_horizontal", &p->gfx_f.xcenter, centermode2, 0))
! 457: || cfgfile_strval (option, value, "gfx_center_horizontal_windowed", &p->gfx_w.xcenter, centermode1, 1)
! 458: || cfgfile_strval (option, value, "gfx_center_horizontal_windowed", &p->gfx_w.xcenter, centermode2, 0)
! 459: || cfgfile_strval (option, value, "gfx_center_horizontal_fullscreen", &p->gfx_f.xcenter, centermode1, 1)
! 460: || cfgfile_strval (option, value, "gfx_center_horizontal_fullscreen", &p->gfx_f.xcenter, centermode2, 0)
! 461: || (cfgfile_strval (option, value, "gfx_center_vertical", &p->gfx_w.ycenter, centermode1, 1)
! 462: && cfgfile_strval (option, value, "gfx_center_vertical", &p->gfx_f.ycenter, centermode1, 1))
! 463: || (cfgfile_strval (option, value, "gfx_center_vertical", &p->gfx_w.ycenter, centermode2, 0)
! 464: && cfgfile_strval (option, value, "gfx_center_vertical", &p->gfx_f.ycenter, centermode2, 0))
! 465: || cfgfile_strval (option, value, "gfx_center_vertical_windowed", &p->gfx_w.ycenter, centermode1, 1)
! 466: || cfgfile_strval (option, value, "gfx_center_vertical_windowed", &p->gfx_w.ycenter, centermode2, 0)
! 467: || cfgfile_strval (option, value, "gfx_center_vertical_fullscreen", &p->gfx_f.ycenter, centermode1, 1)
! 468: || cfgfile_strval (option, value, "gfx_center_vertical_fullscreen", &p->gfx_f.ycenter, centermode2, 0)
1.1 root 469: || cfgfile_strval (option, value, "gfx_colour_mode", &p->color_mode, colormode1, 1)
470: || cfgfile_strval (option, value, "gfx_colour_mode", &p->color_mode, colormode2, 0)
471: || cfgfile_strval (option, value, "gfx_color_mode", &p->color_mode, colormode1, 1)
472: || cfgfile_strval (option, value, "gfx_color_mode", &p->color_mode, colormode2, 0))
473: return 1;
1.1.1.16 root 474:
475: if (strcmp (option, "joyport0") == 0 || strcmp (option, "joyport1") == 0) {
476: int port = strcmp (option, "joyport0") == 0 ? 0 : 1;
477: int start = -1;
478: char *pp = 0;
479: if (strncmp (value, "kbd", 3) == 0) {
480: start = JSEM_KBDLAYOUT;
481: pp = value + 3;
482: } else if (strncmp (value, "joy", 3) == 0) {
483: start = JSEM_JOYS;
484: pp = value + 3;
485: } else if (strncmp (value, "mouse", 5) == 0) {
486: start = JSEM_MICE;
487: pp = value + 5;
488: }
489: if (pp) {
490: int v = atol (pp);
491: if (start >= 0) {
492: if (start == JSEM_KBDLAYOUT)
493: v--;
494: if (v >= 0) {
495: start += v;
496: if (port)
497: p->jport1 = start;
498: else
499: p->jport0 = start;
500: }
501: }
502: }
503: return 1;
504: }
505:
1.1 root 506: if (cfgfile_string (option, value, "floppy0", p->df[0], 256)
507: || cfgfile_string (option, value, "floppy1", p->df[1], 256)
508: || cfgfile_string (option, value, "floppy2", p->df[2], 256)
509: || cfgfile_string (option, value, "floppy3", p->df[3], 256)
510: || cfgfile_string (option, value, "kickstart_rom_file", p->romfile, 256)
1.1.1.12 root 511: || cfgfile_string (option, value, "kickstart_ext_rom_file", p->romextfile, 256)
1.1 root 512: || cfgfile_string (option, value, "kickstart_key_file", p->keyfile, 256)
1.1.1.2 root 513: || cfgfile_string (option, value, "config_description", p->description, 256))
1.1 root 514: return 1;
515:
516: /* Tricky ones... */
1.1.1.3 root 517: if (cfgfile_strval (option, value, "chipset", &tmpval, csmode, 0)) {
1.1.1.5 root 518: set_chipset_mask (p, tmpval);
1.1.1.3 root 519: return 1;
520: }
1.1.1.7 root 521:
1.1.1.14 root 522: if (cfgfile_strval (option, value, "sound_channels", &p->sound_stereo, stereomode1, 1)
523: || cfgfile_strval (option, value, "sound_channels", &p->sound_stereo, stereomode2, 1)
524: || cfgfile_strval (option, value, "sound_channels", &p->sound_stereo, stereomode3, 0))
1.1.1.8 root 525: {
526: p->mixed_stereo = 0;
1.1.1.14 root 527: if (p->sound_stereo == 2) {
528: p->sound_stereo = 1;
1.1.1.8 root 529: p->mixed_stereo = 1;
530: }
1.1.1.13 root 531: return 1;
1.1.1.8 root 532: }
533:
1.1 root 534: if (cfgfile_strval (option, value, "cpu_type", &p->cpu_level, cpumode, 0)) {
1.1.1.7 root 535: p->address_space_24 = p->cpu_level < 8 && !(p->cpu_level & 1);
1.1 root 536: p->cpu_level >>= 1;
537: return 1;
538: }
1.1.1.11 root 539: if (cfgfile_strval (option, value, "cpu_speed", &p->m68k_speed, speedmode, 1)
540: /* Broken earlier versions used to write this out as a string. */
541: || cfgfile_strval (option, value, "finegraincpu_speed", &p->m68k_speed, speedmode, 1))
542: {
1.1 root 543: p->m68k_speed--;
544: return 1;
545: }
1.1.1.8 root 546: if (cfgfile_intval (option, value, "cpu_speed", &p->m68k_speed, 1)) {
1.1.1.16 root 547: p->m68k_speed *= CYCLE_UNIT;
1.1.1.8 root 548: return 1;
549: }
1.1.1.9 root 550: if (cfgfile_intval (option, value, "finegrain_cpu_speed", &p->m68k_speed, 1)) {
551: if (OFFICIAL_CYCLE_UNIT > CYCLE_UNIT) {
552: int factor = OFFICIAL_CYCLE_UNIT / CYCLE_UNIT;
553: p->m68k_speed = (p->m68k_speed + factor - 1) / factor;
554: }
1.1 root 555: return 1;
1.1.1.9 root 556: }
1.1 root 557:
558: if (strcmp (option, "kbd_lang") == 0) {
559: KbdLang l;
560: if ((l = KBD_LANG_DE, strcasecmp (value, "de") == 0)
1.1.1.9 root 561: || (l = KBD_LANG_DK, strcasecmp (value, "dk") == 0)
1.1 root 562: || (l = KBD_LANG_SE, strcasecmp (value, "se") == 0)
563: || (l = KBD_LANG_US, strcasecmp (value, "us") == 0)
564: || (l = KBD_LANG_FR, strcasecmp (value, "fr") == 0)
565: || (l = KBD_LANG_IT, strcasecmp (value, "it") == 0)
566: || (l = KBD_LANG_ES, strcasecmp (value, "es") == 0))
567: p->keyboard_lang = l;
568: else
569: write_log ("Unknown keyboard language\n");
570: return 1;
571: }
572:
573: if (strcmp (option, "filesystem") == 0
574: || strcmp (option, "hardfile") == 0)
575: {
1.1.1.2 root 576: int secs, heads, reserved, bs, ro;
577: char *aname, *root;
1.1 root 578: char *tmpp = strchr (value, ',');
1.1.1.2 root 579: char *str;
1.1 root 580: if (tmpp == 0)
581: goto invalid_fs;
582:
583: *tmpp++ = '\0';
584: if (strcmp (value, "0") == 0 || strcasecmp (value, "ro") == 0
585: || strcasecmp (value, "readonly") == 0
586: || strcasecmp (value, "read-only") == 0)
1.1.1.2 root 587: ro = 1;
1.1 root 588: else if (strcmp (value, "1") == 0 || strcasecmp (value, "rw") == 0
589: || strcasecmp (value, "readwrite") == 0
590: || strcasecmp (value, "read-write") == 0)
1.1.1.2 root 591: ro = 0;
1.1 root 592: else
593: goto invalid_fs;
1.1.1.2 root 594: secs = 0; heads = 0; reserved = 0; bs = 0;
1.1 root 595:
596: value = tmpp;
597: if (strcmp (option, "filesystem") == 0) {
598: tmpp = strchr (value, ':');
599: if (tmpp == 0)
600: goto invalid_fs;
601: *tmpp++ = '\0';
1.1.1.2 root 602: aname = value;
603: root = tmpp;
1.1 root 604: } else {
1.1.1.2 root 605: if (! getintval (&value, &secs, ',')
606: || ! getintval (&value, &heads, ',')
607: || ! getintval (&value, &reserved, ',')
608: || ! getintval (&value, &bs, ','))
1.1 root 609: goto invalid_fs;
1.1.1.2 root 610: root = value;
611: aname = 0;
1.1 root 612: }
1.1.1.2 root 613: str = cfgfile_subst_path (UNEXPANDED, p->path_hardfile, root);
614: tmpp = add_filesys_unit (p->mountinfo, aname, str, ro, secs,
615: heads, reserved, bs);
616: free (str);
617: if (tmpp)
618: write_log ("Error: %s\n", tmpp);
1.1 root 619: return 1;
620:
621: invalid_fs:
622: write_log ("Invalid filesystem/hardfile specification.\n");
623: return 1;
624: }
625:
626: return 0;
627: }
628:
1.1.1.2 root 629: void cfgfile_parse_line (struct uae_prefs *p, char *line)
1.1 root 630: {
631: int i;
632: char *orig_line = my_strdup (line);
633: char *line1, *line2;
634:
635: line1 = line;
636: line2 = strchr (line, '=');
637: if (! line2) {
638: write_log ("CFGFILE: line was incomplete with only %s\n", line1);
639: return;
640: }
641:
642: *line2++ = '\0';
643:
644: /* Get rid of whitespace. */
1.1.1.2 root 645: i = strlen (line2);
646: while (i > 0 && (line2[i - 1] == '\t' || line2[i - 1] == ' '
647: || line2[i - 1] == '\r' || line2[i - 1] == '\n'))
648: line2[--i] = '\0';
1.1 root 649: line2 += strspn (line2, "\t \r\n");
1.1.1.2 root 650: i = strlen (line);
651: while (i > 0 && (line[i - 1] == '\t' || line[i - 1] == ' '
652: || line[i - 1] == '\r' || line[i - 1] == '\n'))
653: line[--i] = '\0';
1.1 root 654: line += strspn (line, "\t \r\n");
655:
1.1.1.2 root 656: if (! cfgfile_parse_option (p, line, line2)) {
1.1 root 657: struct strlist *u = xmalloc (sizeof (struct strlist));
658: u->str = orig_line;
659: u->next = p->unknown_lines;
660: p->unknown_lines = u;
661: } else
662: free (orig_line);
663: }
664:
665: static void subst (char *p, char *f, int n)
666: {
667: char *str = cfgfile_subst_path (UNEXPANDED, p, f);
668: strncpy (f, str, n - 1);
669: f[n - 1] = '\0';
670: free (str);
671: }
672:
673: int cfgfile_load (struct uae_prefs *p, const char *filename)
674: {
675: int i;
676:
677: FILE *fh;
678: char line[256];
679:
1.1.1.4 root 680: fh = fopen (filename, "r");
1.1 root 681: if (! fh)
682: return 0;
683:
684: while (fgets (line, 256, fh) != 0) {
1.1.1.13 root 685: int len = strlen (line);
686: /* Delete trailing whitespace. */
687: while (len > 0 && strcspn (line + len - 1, "\t \r\n") == 0) {
688: line[--len] = '\0';
689: }
1.1 root 690: if (strlen (line) > 0)
1.1.1.2 root 691: cfgfile_parse_line (p, line);
1.1 root 692: }
693: fclose (fh);
694:
695: for (i = 0; i < 4; i++)
696: subst (p->path_floppy, p->df[i], sizeof p->df[i]);
697: subst (p->path_rom, p->romfile, sizeof p->romfile);
1.1.1.12 root 698: subst (p->path_rom, p->romextfile, sizeof p->romextfile);
1.1 root 699: subst (p->path_rom, p->keyfile, sizeof p->keyfile);
700:
701: return 1;
702: }
703:
704: int cfgfile_save (struct uae_prefs *p, const char *filename)
705: {
706: FILE *fh = fopen (filename, "w");
707: if (! fh)
708: return 0;
709:
710: save_options (fh, p);
711: fclose (fh);
712: return 1;
713: }
714:
715: int cfgfile_get_description (const char *filename, char *description)
716: {
717: int result = 0;
718: struct uae_prefs p;
719: default_prefs (&p);
720: strcpy (p.description, "");
1.1.1.12 root 721: if (cfgfile_load (&p, filename)) {
1.1 root 722: result = 1;
723: strcpy (description, p.description);
724: }
725: discard_prefs (&p);
726: return result;
727: }
728:
729: void cfgfile_show_usage (void)
730: {
731: int i;
732: fprintf (stderr, "UAE Configuration Help:\n" \
733: "=======================\n");
734: for (i = 0; i < sizeof opttable / sizeof *opttable; i++)
735: fprintf (stderr, "%s: %s\n", opttable[i].config_label, opttable[i].config_help);
736: }
1.1.1.4 root 737:
738: /* This implements the old commandline option parsing. I've re-added this
739: because the new way of doing things is painful for me (it requires me
740: to type a couple hundred characters when invoking UAE). The following
741: is far less annoying to use. */
1.1.1.16 root 742: static void parse_gfx_specs (struct uae_prefs *p, char *spec)
1.1.1.4 root 743: {
744: char *x0 = my_strdup (spec);
745: char *x1, *x2;
746:
747: x1 = strchr (x0, ':');
748: if (x1 == 0)
749: goto argh;
750: x2 = strchr (x1+1, ':');
751: if (x2 == 0)
752: goto argh;
753: *x1++ = 0; *x2++ = 0;
754:
1.1.1.17! root 755: p->gfx_w.width = atoi (x0);
! 756: p->gfx_w.height = atoi (x1);
! 757: p->gfx_w.lores = strchr (x2, 'l') != 0;
! 758: p->gfx_w.xcenter = strchr (x2, 'x') != 0 ? 1 : strchr (x2, 'X') != 0 ? 2 : 0;
! 759: p->gfx_w.ycenter = strchr (x2, 'y') != 0 ? 1 : strchr (x2, 'Y') != 0 ? 2 : 0;
! 760: p->gfx_w.linedbl = strchr (x2, 'd') != 0;
! 761: p->gfx_w.linedbl += 2 * (strchr (x2, 'D') != 0);
! 762: p->gfx_w.correct_aspect = strchr (x2, 'c') != 0;
! 763:
! 764: p->gfx_f = p->gfx_w;
! 765:
1.1.1.16 root 766: p->gfx_afullscreen = strchr (x2, 'a') != 0;
767: p->gfx_pfullscreen = strchr (x2, 'p') != 0;
1.1.1.4 root 768:
1.1.1.17! root 769: if (p->gfx_w.linedbl == 3) {
1.1.1.4 root 770: fprintf (stderr, "You can't use both 'd' and 'D' modifiers in the display mode specification.\n");
771: }
1.1.1.16 root 772:
1.1.1.4 root 773: free (x0);
774: return;
775:
776: argh:
777: fprintf (stderr, "Bad display mode specification.\n");
778: fprintf (stderr, "The format to use is: \"width:height:modifiers\"\n");
779: fprintf (stderr, "Type \"uae -h\" for detailed help.\n");
780: free (x0);
781: }
782:
1.1.1.16 root 783: static void parse_sound_spec (struct uae_prefs *p, char *spec)
1.1.1.4 root 784: {
785: char *x0 = my_strdup (spec);
786: char *x1, *x2 = NULL, *x3 = NULL, *x4 = NULL, *x5 = NULL;
787:
788: x1 = strchr (x0, ':');
789: if (x1 != NULL) {
790: *x1++ = '\0';
791: x2 = strchr (x1 + 1, ':');
792: if (x2 != NULL) {
793: *x2++ = '\0';
794: x3 = strchr (x2 + 1, ':');
795: if (x3 != NULL) {
796: *x3++ = '\0';
797: x4 = strchr (x3 + 1, ':');
798: if (x4 != NULL) {
799: *x4++ = '\0';
800: x5 = strchr (x4 + 1, ':');
801: }
802: }
803: }
804: }
1.1.1.16 root 805: p->produce_sound = atoi (x0);
1.1.1.4 root 806: if (x1) {
1.1.1.16 root 807: p->mixed_stereo = 0;
1.1.1.8 root 808: if (*x1 == 'S')
1.1.1.16 root 809: p->sound_stereo = p->mixed_stereo = 1;
1.1.1.8 root 810: else if (*x1 == 's')
1.1.1.16 root 811: p->sound_stereo = 1;
1.1.1.4 root 812: else
1.1.1.16 root 813: p->sound_stereo = 0;
1.1.1.4 root 814: }
815: if (x2)
1.1.1.16 root 816: p->sound_bits = atoi (x2);
1.1.1.4 root 817: if (x3)
1.1.1.16 root 818: p->sound_freq = atoi (x3);
1.1.1.4 root 819: if (x4)
1.1.1.16 root 820: p->sound_maxbsiz = p->sound_minbsiz = atoi (x4);
1.1.1.4 root 821: if (x5)
1.1.1.16 root 822: p->sound_minbsiz = atoi (x5);
1.1.1.4 root 823: free (x0);
824: return;
825: }
826:
827:
1.1.1.16 root 828: static void parse_joy_spec (struct uae_prefs *p, char *spec)
1.1.1.4 root 829: {
830: int v0 = 2, v1 = 0;
831: if (strlen(spec) != 2)
832: goto bad;
833:
834: switch (spec[0]) {
1.1.1.16 root 835: case '0': v0 = JSEM_JOYS; break;
836: case '1': v0 = JSEM_JOYS + 1; break;
837: case 'M': case 'm': v0 = JSEM_MICE; break;
838: case 'A': case 'a': v0 = JSEM_KBDLAYOUT; break;
839: case 'B': case 'b': v0 = JSEM_KBDLAYOUT + 1; break;
840: case 'C': case 'c': v0 = JSEM_KBDLAYOUT + 2; break;
1.1.1.4 root 841: default: goto bad;
842: }
843:
844: switch (spec[1]) {
1.1.1.16 root 845: case '0': v1 = JSEM_JOYS; break;
846: case '1': v1 = JSEM_JOYS + 1; break;
847: case 'M': case 'm': v1 = JSEM_MICE; break;
848: case 'A': case 'a': v1 = JSEM_KBDLAYOUT; break;
849: case 'B': case 'b': v1 = JSEM_KBDLAYOUT + 1; break;
850: case 'C': case 'c': v1 = JSEM_KBDLAYOUT + 2; break;
1.1.1.4 root 851: default: goto bad;
852: }
853: if (v0 == v1)
854: goto bad;
855: /* Let's scare Pascal programmers */
856: if (0)
857: bad:
1.1.1.16 root 858: write_log ("Bad joystick mode specification. Use -J xy, where x and y\n"
1.1.1.4 root 859: "can be 0 for joystick 0, 1 for joystick 1, M for mouse, and\n"
860: "a, b or c for different keyboard settings.\n");
861:
1.1.1.16 root 862: p->jport0 = v0;
863: p->jport1 = v1;
1.1.1.4 root 864: }
865:
866: static void parse_filesys_spec (int readonly, char *spec)
867: {
868: char buf[256];
869: char *s2;
870:
871: strncpy (buf, spec, 255); buf[255] = 0;
872: s2 = strchr (buf, ':');
873: if (s2) {
874: *s2++ = '\0';
875: #ifdef __DOS__
876: {
877: char *tmp;
1.1.1.16 root 878:
1.1.1.4 root 879: while ((tmp = strchr (s2, '\\')))
880: *tmp = '/';
881: }
882: #endif
883: s2 = add_filesys_unit (currprefs.mountinfo, buf, s2, readonly, 0, 0, 0, 0);
884: if (s2)
885: fprintf (stderr, "%s\n", s2);
886: } else {
887: fprintf (stderr, "Usage: [-m | -M] VOLNAME:mount_point\n");
888: }
889: }
1.1.1.16 root 890:
1.1.1.4 root 891: static void parse_hardfile_spec (char *spec)
892: {
893: char *x0 = my_strdup (spec);
894: char *x1, *x2, *x3, *x4;
895:
896: x1 = strchr (x0, ':');
897: if (x1 == NULL)
898: goto argh;
899: *x1++ = '\0';
900: x2 = strchr (x1 + 1, ':');
901: if (x2 == NULL)
902: goto argh;
903: *x2++ = '\0';
904: x3 = strchr (x2 + 1, ':');
905: if (x3 == NULL)
906: goto argh;
907: *x3++ = '\0';
908: x4 = strchr (x3 + 1, ':');
909: if (x4 == NULL)
910: goto argh;
911: *x4++ = '\0';
912: x4 = add_filesys_unit (currprefs.mountinfo, 0, x4, 0, atoi (x0), atoi (x1), atoi (x2), atoi (x3));
913: if (x4)
914: fprintf (stderr, "%s\n", x4);
915:
916: free (x0);
917: return;
918:
919: argh:
920: free (x0);
921: fprintf (stderr, "Bad hardfile parameter specified - type \"uae -h\" for help.\n");
922: return;
923: }
924:
925: static void parse_cpu_specs (char *spec)
926: {
1.1.1.7 root 927: if (*spec < '0' || *spec > '4') {
928: fprintf (stderr, "CPU parameter string must begin with '0', '1', '2', '3' or '4'.\n");
1.1.1.4 root 929: return;
930: }
1.1.1.16 root 931:
1.1.1.4 root 932: currprefs.cpu_level = *spec++ - '0';
933: currprefs.address_space_24 = currprefs.cpu_level < 2;
934: currprefs.cpu_compatible = 0;
935: while (*spec != '\0') {
936: switch (*spec) {
937: case 'a':
938: if (currprefs.cpu_level < 2)
939: fprintf (stderr, "In 68000/68010 emulation, the address space is always 24 bit.\n");
1.1.1.7 root 940: else if (currprefs.cpu_level >= 4)
941: fprintf (stderr, "In 68040 emulation, the address space is always 32 bit.\n");
1.1.1.4 root 942: else
943: currprefs.address_space_24 = 1;
944: break;
945: case 'c':
946: if (currprefs.cpu_level != 0)
947: fprintf (stderr, "The more compatible CPU emulation is only available for 68000\n"
948: "emulation, not for 68010 upwards.\n");
949: else
950: currprefs.cpu_compatible = 1;
951: break;
952: default:
953: fprintf (stderr, "Bad CPU parameter specified - type \"uae -h\" for help.\n");
954: break;
955: }
956: spec++;
957: }
958: }
959:
960: /* Returns the number of args used up (0 or 1). */
961: int parse_cmdline_option (char c, char *arg)
962: {
1.1.1.5 root 963: const char arg_required[] = "0123rKpImWSAJwNCZUFcblOdHRv";
1.1.1.4 root 964:
965: if (strchr (arg_required, c) && ! arg) {
966: fprintf (stderr, "Missing argument for option `-%c'!\n", c);
967: return 0;
968: }
969:
970: switch (c) {
1.1.1.5 root 971: case 'h': usage (); exit (0);
1.1.1.4 root 972:
1.1.1.5 root 973: case '0': strncpy (currprefs.df[0], arg, 255); currprefs.df[0][255] = 0; break;
974: case '1': strncpy (currprefs.df[1], arg, 255); currprefs.df[1][255] = 0; break;
975: case '2': strncpy (currprefs.df[2], arg, 255); currprefs.df[2][255] = 0; break;
976: case '3': strncpy (currprefs.df[3], arg, 255); currprefs.df[3][255] = 0; break;
977: case 'r': strncpy (currprefs.romfile, arg, 255); currprefs.romfile[255] = 0; break;
978: case 'K': strncpy (currprefs.keyfile, arg, 255); currprefs.keyfile[255] = 0; break;
979: case 'p': strncpy (currprefs.prtname, arg, 255); currprefs.prtname[255] = 0; break;
1.1.1.4 root 980: /* case 'I': strncpy (currprefs.sername, arg, 255); currprefs.sername[255] = 0; currprefs.use_serial = 1; break; */
1.1.1.5 root 981: case 'm': case 'M': parse_filesys_spec (c == 'M', arg); break;
982: case 'W': parse_hardfile_spec (arg); break;
1.1.1.16 root 983: case 'S': parse_sound_spec (&currprefs, arg); break;
1.1.1.5 root 984: case 'R': currprefs.gfx_framerate = atoi (arg); break;
985: case 'A': currprefs.emul_accuracy = atoi (arg); break;
986: case 'x': currprefs.no_xhair = 1; break;
987: case 'i': currprefs.illegal_mem = 1; break;
1.1.1.16 root 988: case 'J': parse_joy_spec (&currprefs, arg); break;
1.1.1.5 root 989:
990: case 't': currprefs.test_drawing_speed = 1; break;
991: case 'L': currprefs.x11_use_low_bandwidth = 1; break;
992: case 'T': currprefs.x11_use_mitshm = 1; break;
993: case 'w': currprefs.m68k_speed = atoi (arg); break;
1.1.1.4 root 994:
995: /* case 'g': currprefs.use_gfxlib = 1; break; */
1.1.1.5 root 996: case 'G': currprefs.start_gui = 0; break;
997: case 'D': currprefs.start_debugger = 1; break;
1.1.1.4 root 998:
1.1.1.5 root 999: case 'n':
1.1.1.4 root 1000: if (strchr (arg, '3') != 0)
1001: currprefs.blits_32bit_enabled = 1;
1002: if (strchr (arg, 'i') != 0)
1003: currprefs.immediate_blits = 1;
1004: break;
1005:
1.1.1.5 root 1006: case 'v':
1007: set_chipset_mask (&currprefs, atoi (arg));
1008: break;
1009:
1010: case 'C':
1.1.1.4 root 1011: parse_cpu_specs (arg);
1012: break;
1013:
1.1.1.5 root 1014: case 'Z':
1.1.1.4 root 1015: currprefs.z3fastmem_size = atoi (arg) * 0x100000;
1016: break;
1017:
1.1.1.5 root 1018: case 'U':
1.1.1.4 root 1019: currprefs.gfxmem_size = atoi (arg) * 0x100000;
1020: break;
1021:
1.1.1.5 root 1022: case 'F':
1.1.1.4 root 1023: currprefs.fastmem_size = atoi (arg) * 0x100000;
1024: break;
1025:
1.1.1.5 root 1026: case 'b':
1.1.1.4 root 1027: currprefs.bogomem_size = atoi (arg) * 0x40000;
1028: break;
1029:
1.1.1.5 root 1030: case 'c':
1.1.1.4 root 1031: currprefs.chipmem_size = atoi (arg) * 0x80000;
1032: break;
1033:
1.1.1.5 root 1034: case 'l':
1.1.1.4 root 1035: if (0 == strcasecmp(arg, "de"))
1036: currprefs.keyboard_lang = KBD_LANG_DE;
1.1.1.9 root 1037: else if (0 == strcasecmp(arg, "dk"))
1038: currprefs.keyboard_lang = KBD_LANG_DK;
1.1.1.4 root 1039: else if (0 == strcasecmp(arg, "us"))
1040: currprefs.keyboard_lang = KBD_LANG_US;
1041: else if (0 == strcasecmp(arg, "se"))
1042: currprefs.keyboard_lang = KBD_LANG_SE;
1043: else if (0 == strcasecmp(arg, "fr"))
1044: currprefs.keyboard_lang = KBD_LANG_FR;
1045: else if (0 == strcasecmp(arg, "it"))
1046: currprefs.keyboard_lang = KBD_LANG_IT;
1047: else if (0 == strcasecmp(arg, "es"))
1048: currprefs.keyboard_lang = KBD_LANG_ES;
1049: break;
1050:
1.1.1.16 root 1051: case 'O': parse_gfx_specs (&currprefs, arg); break;
1.1.1.5 root 1052: case 'd':
1.1.1.4 root 1053: if (strchr (arg, 'S') != NULL || strchr (arg, 's')) {
1054: write_log (" Serial on demand.\n");
1055: currprefs.serial_demand = 1;
1056: }
1057: if (strchr (arg, 'P') != NULL || strchr (arg, 'p')) {
1058: write_log (" Parallel on demand.\n");
1059: currprefs.parallel_demand = 1;
1060: }
1061:
1062: break;
1063:
1.1.1.5 root 1064: case 'H':
1.1.1.4 root 1065: currprefs.color_mode = atoi (arg);
1066: if (currprefs.color_mode < 0) {
1067: fprintf (stderr, "Bad color mode selected. Using default.\n");
1068: currprefs.color_mode = 0;
1069: }
1070: break;
1.1.1.5 root 1071: default:
1.1.1.4 root 1072: fprintf (stderr, "Unknown option `-%c'!\n", c);
1073: break;
1074: }
1075: return !! strchr (arg_required, c);
1076: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.