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