|
|
1.1 root 1: /*
2: * UAE - The Un*x Amiga Emulator
1.1.1.3 root 3: *
4: * Main program
5: *
6: * Copyright 1995 Ed Hanway
7: * Copyright 1995, 1996, 1997 Bernd Schmidt
1.1 root 8: */
9: #include "sysconfig.h"
10: #include "sysdeps.h"
11: #include <assert.h>
12:
13: #include "options.h"
1.1.1.15 root 14: #include "threaddep/thread.h"
1.1.1.2 root 15: #include "uae.h"
1.1.1.3 root 16: #include "gensound.h"
1.1.1.13 root 17: #include "audio.h"
1.1.1.3 root 18: #include "sounddep/sound.h"
1.1.1.2 root 19: #include "events.h"
1.1 root 20: #include "memory.h"
21: #include "custom.h"
22: #include "serial.h"
23: #include "newcpu.h"
24: #include "disk.h"
25: #include "debug.h"
26: #include "xwin.h"
1.1.1.20 root 27: #include "inputdevice.h"
1.1 root 28: #include "keybuf.h"
29: #include "gui.h"
30: #include "zfile.h"
31: #include "autoconf.h"
1.1.1.22 root 32: #include "filesys.h"
1.1.1.2 root 33: #include "osemu.h"
1.1.1.3 root 34: #include "picasso96.h"
1.1.1.22 root 35: #include "traps.h"
1.1.1.6 root 36: #include "bsdsocket.h"
1.1.1.3 root 37: #include "uaeexe.h"
1.1.1.8 root 38: #include "native2amiga.h"
39: #include "scsidev.h"
1.1.1.22 root 40: #include "romlist.h"
1.1 root 41:
1.1.1.15 root 42: #ifdef USE_SDL
43: #include "SDL.h"
44: #endif
45:
1.1.1.6 root 46: struct uae_prefs currprefs, changed_prefs;
1.1.1.21 root 47: struct gfx_params *curr_gfx;
1.1.1.4 root 48:
1.1.1.6 root 49: int no_gui = 0;
1.1.1.4 root 50: int joystickpresent = 0;
51: int cloanto_rom = 0;
52:
1.1.1.11 root 53: struct gui_info gui_data;
54:
1.1.1.4 root 55: char warning_buffer[256];
56:
57: char optionsfile[256];
58:
59: /* If you want to pipe printer output to a file, put something like
60: * "cat >>printerfile.tmp" above.
61: * The printer support was only tested with the driver "PostScript" on
62: * Amiga side, using apsfilter for linux to print ps-data.
63: *
64: * Under DOS it ought to be -p LPT1: or -p PRN: but you'll need a
65: * PostScript printer or ghostscript -=SR=-
66: */
67:
68: /* Slightly stupid place for this... */
69: /* ncurses.c might use quite a few of those. */
70: char *colormodes[] = { "256 colors", "32768 colors", "65536 colors",
71: "256 colors dithered", "16 colors dithered", "16 million colors",
72: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
73: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
74: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
75: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
76: "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
77: };
78:
1.1.1.22 root 79: struct uae_rect *gfx_fullscreen_modes, *gfx_windowed_modes;
80: int n_fullscreen_modes, n_windowed_modes;
1.1.1.21 root 81:
1.1.1.22 root 82: static struct uae_rect default_windowed_modes[] =
1.1.1.21 root 83: {
1.1.1.22 root 84: { 320, 256 },
85: { 400, 300 },
86: { 640, 512 },
87: { 800, 600 }
88: };
89:
90: struct config_list *predef_configs;
91: int n_predef_configs;
92: int predef_configs_space;
1.1.1.21 root 93:
1.1.1.22 root 94: static int sortfn (const void *a, const void *b)
95: {
96: struct config_list *pa = (struct config_list *)a;
97: struct config_list *pb = (struct config_list *)b;
98: return strcmp (pa->sortstr, pb->sortstr);
99: }
100:
101: static void scan_configs (const char *path)
102: {
103: DIR *dir;
104: int pathlen = strlen (path);
105: int bufsz = pathlen + 256;
106: char *buffer;
107: uae_u8 *data;
108:
109: predef_configs_space = 20;
110: predef_configs = malloc (sizeof (struct config_list) * 20);
111: n_predef_configs = 0;
112:
113: dir = opendir (path);
114: if (!dir)
115: return;
116:
117: buffer = malloc (bufsz);
118: if (!buffer)
119: goto out;
120: data = malloc (1024 * 1024);
121: if (!data)
122: goto out1;
123:
124: strcpy (buffer, path);
125: buffer[pathlen++] = '/';
126: buffer[pathlen] = '\0';
127: for (;;) {
128: struct uae_prefs p;
129: struct zfile *f;
130: struct dirent *ent = readdir (dir);
131: int len;
132: struct romdata *rd;
133: long size;
134:
135: if (!ent)
136: break;
137:
138: len = strlen (ent->d_name);
139: if (len + pathlen + 1 >= bufsz) {
140: bufsz = len + pathlen + 200;
141: buffer = realloc (buffer, bufsz);
142: if (!buffer) {
143: free (data);
144: goto out;
145: }
146: }
147: strcpy (buffer + pathlen, ent->d_name);
148:
149: if (n_predef_configs >= predef_configs_space) {
150: predef_configs_space += 20;
151: predef_configs = realloc (predef_configs,
152: sizeof (struct config_list) * predef_configs_space);
153: }
154: default_prefs (&p);
155: strcpy (p.description, "");
156: strcpy (p.sortstr, "");
157: cfgfile_load (&p, buffer);
158: if (strlen (p.description) > 0) {
159: predef_configs[n_predef_configs].filename = strdup (buffer);
160: predef_configs[n_predef_configs].description = strdup (p.description);
161: predef_configs[n_predef_configs++].sortstr = strdup (p.sortstr);
162: }
163: }
164: qsort (predef_configs, n_predef_configs, sizeof *predef_configs, sortfn);
165: free (data);
166: out1:
167: free (buffer);
168: out:
169: closedir (dir);
1.1.1.21 root 170: }
171:
1.1.1.6 root 172: void discard_prefs (struct uae_prefs *p)
1.1.1.3 root 173: {
1.1.1.6 root 174: struct strlist **ps = &p->unknown_lines;
175: while (*ps) {
176: struct strlist *s = *ps;
177: *ps = s->next;
178: free (s->str);
179: free (s);
180: }
181: free_mountinfo (p->mountinfo);
182: }
183:
184: void default_prefs (struct uae_prefs *p)
185: {
186: strcpy (p->description, "UAE default configuration");
187:
188: p->start_gui = 1;
189: p->start_debugger = 0;
190:
191: p->unknown_lines = 0;
1.1.1.4 root 192: /* Note to porters: please don't change any of these options! UAE is supposed
193: * to behave identically on all platforms if possible. */
1.1.1.6 root 194: p->illegal_mem = 0;
195: p->use_serial = 0;
196: p->serial_demand = 0;
197: p->parallel_demand = 0;
198:
1.1.1.20 root 199: p->jport0 = JSEM_MICE;
200: p->jport1 = JSEM_JOYS;
201:
1.1.1.6 root 202: p->keyboard_lang = KBD_LANG_US;
203: p->emul_accuracy = 2;
204: p->test_drawing_speed = 0;
205:
1.1.1.22 root 206: p->produce_sound = 3;
1.1.1.18 root 207: p->sound_stereo = 0;
1.1.1.22 root 208: p->sound_stereo_separation = 7;
209: p->sound_mixed_stereo_delay = 0;
1.1.1.6 root 210: p->sound_freq = DEFAULT_SOUND_FREQ;
211: p->sound_maxbsiz = DEFAULT_SOUND_MAXB;
1.1.1.23! root 212: p->sound_interpol = 2;
1.1.1.22 root 213: p->sound_filter = FILTER_SOUND_OFF;
214: p->sound_filter_type = FILTER_SOUND_TYPE_A500;
1.1.1.6 root 215:
1.1.1.8 root 216: p->gfx_framerate = 1;
1.1.1.21 root 217: p->gfx_w.width = 800;
218: p->gfx_w.height = 600;
219: p->gfx_w.lores = 0;
220: p->gfx_w.linedbl = 2;
221: p->gfx_w.correct_aspect = 0;
222: p->gfx_w.xcenter = 0;
223: p->gfx_w.ycenter = 0;
224: p->gfx_f = p->gfx_w;
1.1.1.22 root 225: p->gfx_w.leds_on_screen = 0;
226: p->gfx_f.leds_on_screen = 1;
1.1.1.6 root 227: p->gfx_afullscreen = 0;
228: p->gfx_pfullscreen = 0;
229: p->color_mode = 0;
230:
231: p->x11_use_low_bandwidth = 0;
232: p->x11_use_mitshm = 0;
233: p->x11_hide_cursor = 1;
234:
1.1.1.8 root 235: p->svga_no_linear = 0;
236:
1.1.1.10 root 237: p->curses_reverse_video = 0;
238:
1.1.1.8 root 239: p->win32_middle_mouse = 0;
240: p->win32_logfile = 0;
241: p->win32_iconified_nospeed = 0;
242: p->win32_iconified_nosound = 0;
1.1.1.16 root 243: p->win32_no_overlay = 0;
1.1.1.8 root 244:
1.1.1.6 root 245: p->immediate_blits = 0;
1.1.1.14 root 246: p->collision_level = 1;
1.1.1.22 root 247:
248: p->chipset_mask = CSMASK_ECS_AGNUS;
249: p->cs_rtc = 2;
250: p->cs_a1000ram = 0;
251: p->cs_fatgaryrev = -1;
252: p->cs_ramseyrev = -1;
253: p->cs_ide = 0;
1.1.1.6 root 254:
255: strcpy (p->df[0], "df0.adf");
256: strcpy (p->df[1], "df1.adf");
257: strcpy (p->df[2], "df2.adf");
258: strcpy (p->df[3], "df3.adf");
259:
260: strcpy (p->romfile, "kick.rom");
261: strcpy (p->keyfile, "");
262: strcpy (p->prtname, DEFPRTNAME);
1.1.1.22 root 263: p->rom_crc32 = 0;
1.1.1.6 root 264:
265: strcpy (p->path_rom, "./");
266: strcpy (p->path_floppy, "./");
267: strcpy (p->path_hardfile, "./");
268:
1.1.1.15 root 269: strcpy (p->prtname, "");
270: strcpy (p->sername, "");
271:
1.1.1.22 root 272: p->nr_floppies = 2;
273: p->dfxtype[0] = DRV_35_DD;
274: p->dfxtype[1] = DRV_35_DD;
275: p->dfxtype[2] = DRV_NONE;
276: p->dfxtype[3] = DRV_NONE;
277:
1.1.1.11 root 278: p->m68k_speed = 0;
1.1.1.22 root 279: p->cpu_model = 68020;
280: p->fpu_model = 0;
1.1.1.6 root 281: p->address_space_24 = 0;
282:
283: p->fastmem_size = 0x00000000;
1.1.1.22 root 284: p->mbresmem_low_size = 0x00000000;
285: p->mbresmem_high_size = 0x00000000;
1.1.1.6 root 286: p->z3fastmem_size = 0x00000000;
287: p->chipmem_size = 0x00200000;
288: p->bogomem_size = 0x00000000;
289: p->gfxmem_size = 0x00000000;
1.1 root 290:
1.1.1.6 root 291: p->mountinfo = alloc_mountinfo ();
1.1.1.20 root 292: inputdevice_default_prefs (p);
1.1.1.22 root 293: p->bootrom = 1;
1.1.1.4 root 294: }
1.1 root 295:
1.1.1.22 root 296: int fixup_prefs_dimensions (struct gfx_params *p, struct uae_rect *modes, int n_modes)
1.1.1.4 root 297: {
1.1.1.22 root 298: int i;
1.1.1.21 root 299: if (p->width < 320)
300: p->width = 320;
301: if (p->height < 200)
302: p->height = 200;
1.1.1.22 root 303: for (i = 0; i < n_modes; i++) {
304: if ((modes[i].w >= p->width && modes[i].h >= p->height)
305: || i == n_modes - 1)
306: {
307: p->width = modes[i].w;
308: p->height = modes[i].h;
309: p->lores = p->width <= 512;
310: if (p->height > 300 && !p->linedbl)
311: p->linedbl = 1;
312: return i;
313: }
314: }
315: return n_modes - 1;
316: }
317:
318: void fixup_cpu (struct uae_prefs *p)
319: {
320: }
1.1 root 321:
1.1.1.22 root 322: void fixup_sound (struct uae_prefs *p)
323: {
324: if (p->sound_stereo_separation < 0)
325: p->sound_stereo_separation = 0;
326: if (p->sound_stereo_separation > MIXED_STEREO_MAX)
327: p->sound_stereo_separation = MIXED_STEREO_MAX;
1.1.1.4 root 328: }
1.1.1.3 root 329:
1.1.1.22 root 330: static void fixup_prefs (struct uae_prefs *p)
1.1.1.2 root 331: {
1.1.1.3 root 332: int err = 0;
333:
1.1.1.22 root 334: if ((p->chipmem_size & (p->chipmem_size - 1)) != 0
335: || p->chipmem_size < 0x80000
336: || p->chipmem_size > 0x800000)
1.1.1.3 root 337: {
1.1.1.22 root 338: p->chipmem_size = 0x200000;
1.1.1.16 root 339: write_log ("Unsupported chipmem size!\n");
1.1.1.3 root 340: err = 1;
341: }
1.1.1.22 root 342: if ((p->fastmem_size & (p->fastmem_size - 1)) != 0
343: || (p->fastmem_size != 0 && (p->fastmem_size < 0x100000 || p->fastmem_size > 0x800000)))
1.1.1.3 root 344: {
1.1.1.22 root 345: p->fastmem_size = 0;
1.1.1.16 root 346: write_log ("Unsupported fastmem size!\n");
1.1.1.3 root 347: err = 1;
348: }
1.1.1.22 root 349: if ((p->gfxmem_size & (p->gfxmem_size - 1)) != 0
350: || (p->gfxmem_size != 0 && (p->gfxmem_size < 0x100000 || p->gfxmem_size > 0x2000000)))
1.1.1.3 root 351: {
1.1.1.22 root 352: write_log ("Unsupported graphics card memory size %lx!\n", p->gfxmem_size);
353: p->gfxmem_size = 0;
1.1.1.3 root 354: err = 1;
355: }
1.1.1.22 root 356: if ((p->z3fastmem_size & (p->z3fastmem_size - 1)) != 0
357: || (p->z3fastmem_size != 0 && (p->z3fastmem_size < 0x100000 || p->z3fastmem_size > 0x4000000)))
1.1.1.3 root 358: {
1.1.1.22 root 359: p->z3fastmem_size = 0;
1.1.1.16 root 360: write_log ("Unsupported Zorro III fastmem size!\n");
1.1.1.3 root 361: err = 1;
362: }
1.1.1.22 root 363: if (p->address_space_24 && (p->gfxmem_size != 0 || p->z3fastmem_size != 0)) {
364: p->z3fastmem_size = p->gfxmem_size = 0;
1.1.1.16 root 365: write_log ("Can't use a graphics card or Zorro III fastmem when using a 24 bit\n"
1.1.1.3 root 366: "address space - sorry.\n");
367: }
1.1.1.22 root 368: if ((p->bogomem_size & (p->bogomem_size - 1)) != 0
369: || (p->bogomem_size != 0 && (p->bogomem_size < 0x80000 || p->bogomem_size > 0x100000)))
1.1.1.3 root 370: {
1.1.1.22 root 371: p->bogomem_size = 0;
1.1.1.16 root 372: write_log ("Unsupported bogomem size!\n");
1.1.1.3 root 373: err = 1;
374: }
375:
1.1.1.22 root 376: if (p->chipmem_size > 0x200000 && p->fastmem_size != 0) {
1.1.1.16 root 377: write_log ("You can't use fastmem and more than 2MB chip at the same time!\n");
1.1.1.22 root 378: p->fastmem_size = 0;
1.1.1.3 root 379: err = 1;
380: }
1.1.1.13 root 381: #if 0
1.1.1.22 root 382: if (p->m68k_speed < -1 || p->m68k_speed > 20) {
1.1.1.16 root 383: write_log ("Bad value for -w parameter: must be -1, 0, or within 1..20.\n");
1.1.1.22 root 384: p->m68k_speed = 4;
1.1.1.3 root 385: err = 1;
386: }
1.1.1.13 root 387: #endif
1.1.1.20 root 388:
1.1.1.22 root 389: if (p->produce_sound < 0 || p->produce_sound > 3) {
1.1.1.16 root 390: write_log ("Bad value for -S parameter: enable value must be within 0..3\n");
1.1.1.22 root 391: p->produce_sound = 0;
1.1.1.3 root 392: err = 1;
393: }
1.1.1.22 root 394: if (p->cpu_model < 68020 && p->z3fastmem_size > 0) {
1.1.1.16 root 395: write_log ("Z3 fast memory can't be used with a 68000/68010 emulation. It\n"
1.1.1.3 root 396: "requires a 68020 emulation. Turning off Z3 fast memory.\n");
1.1.1.22 root 397: p->z3fastmem_size = 0;
1.1.1.3 root 398: err = 1;
399: }
1.1.1.22 root 400: if (p->gfxmem_size > 0 && (p->cpu_model < 68020 || p->address_space_24)) {
1.1.1.16 root 401: write_log ("Picasso96 can't be used with a 68000/68010 or 68EC020 emulation. It\n"
1.1.1.3 root 402: "requires a 68020 emulation. Turning off Picasso96.\n");
1.1.1.22 root 403: p->gfxmem_size = 0;
1.1.1.3 root 404: err = 1;
405: }
1.1.1.22 root 406: #ifndef BSDSOCKET
407: if (p->socket_emu) {
1.1.1.16 root 408: write_log ("Compile-time option of BSDSOCKET_SUPPORTED was not enabled. You can't use bsd-socket emulation.\n");
1.1.1.22 root 409: p->socket_emu = 0;
1.1.1.8 root 410: err = 1;
411: }
412: #endif
1.1.1.3 root 413:
1.1.1.22 root 414: if (p->nr_floppies < 1 || p->nr_floppies > 4) {
1.1.1.16 root 415: write_log ("Invalid number of floppies. Using 4.\n");
1.1.1.22 root 416: p->nr_floppies = 4;
1.1.1.11 root 417: err = 1;
418: }
1.1.1.22 root 419: if (p->collision_level < 0 || p->collision_level > 3) {
1.1.1.16 root 420: write_log ("Invalid collision support level. Using 1.\n");
1.1.1.22 root 421: p->collision_level = 1;
1.1.1.14 root 422: err = 1;
423: }
1.1.1.11 root 424:
1.1.1.22 root 425: fixup_sound (p);
426:
1.1.1.3 root 427: if (err)
1.1.1.16 root 428: write_log ("Please use \"uae -h\" to get usage information.\n");
1.1.1.3 root 429: }
430:
431: int quit_program = 0;
432:
1.1.1.20 root 433: void uae_reset (int hardreset)
1.1.1.3 root 434: {
1.1.1.20 root 435: if (quit_program == 0) {
1.1.1.3 root 436: quit_program = -2;
1.1.1.20 root 437: if (hardreset)
438: quit_program = -3;
439: }
1.1.1.3 root 440: }
441:
442: void uae_quit (void)
443: {
444: if (quit_program != -1)
445: quit_program = -1;
1.1.1.2 root 446: }
1.1 root 447:
1.1.1.6 root 448: #ifndef DONT_PARSE_CMDLINE
1.1.1.3 root 449:
1.1.1.6 root 450: void usage (void)
451: {
1.1.1.3 root 452: }
453:
1.1.1.6 root 454: void parse_cmdline (int argc, char **argv)
455: {
1.1.1.8 root 456: int i;
457: for (i = 1; i < argc; i++) {
458: if (strncmp (argv[i], "-config=", 8) == 0)
459: cfgfile_load (&currprefs, argv[i] + 8);
460: /* Check for new-style "-f xxx" argument, where xxx is config-file */
461: else if (strcmp (argv[i], "-f") == 0) {
462: if (i + 1 == argc)
1.1.1.17 root 463: write_log ("Missing argument for '-f' option.\n");
1.1.1.8 root 464: else
465: cfgfile_load (&currprefs, argv[++i]);
466: } else if (strcmp (argv[i], "-s") == 0) {
467: if (i + 1 == argc)
1.1.1.17 root 468: write_log ("Missing argument for '-s' option.\n");
1.1.1.8 root 469: else
470: cfgfile_parse_line (&currprefs, argv[++i]);
471: } else if (strcmp (argv[i], "-h") == 0 || strcmp (argv[i], "-help") == 0) {
1.1.1.6 root 472: usage ();
473: exit (0);
1.1.1.9 root 474: } else {
475: if (argv[i][0] == '-' && argv[i][1] != '\0') {
476: const char *arg = argv[i] + 2;
1.1.1.10 root 477: int extra_arg = *arg == '\0';
478: if (extra_arg)
1.1.1.9 root 479: arg = i + 1 < argc ? argv[i + 1] : 0;
1.1.1.22 root 480: if (parse_cmdline_option (&currprefs, argv[i][1], arg) && extra_arg)
1.1.1.10 root 481: i++;
1.1.1.9 root 482: }
1.1.1.3 root 483: }
1.1 root 484: }
485: }
486: #endif
487:
1.1.1.4 root 488: static void parse_cmdline_and_init_file (int argc, char **argv)
1.1 root 489: {
1.1.1.3 root 490: char *home;
1.1 root 491:
1.1.1.6 root 492: strcpy (optionsfile, "");
1.1 root 493:
1.1.1.3 root 494: #ifdef OPTIONS_IN_HOME
1.1.1.4 root 495: home = getenv ("HOME");
496: if (home != NULL && strlen (home) < 240)
1.1 root 497: {
1.1.1.4 root 498: strcpy (optionsfile, home);
499: strcat (optionsfile, "/");
1.1 root 500: }
501: #endif
502:
1.1.1.4 root 503: strcat (optionsfile, OPTIONSFILENAME);
1.1 root 504:
1.1.1.6 root 505: if (! cfgfile_load (&currprefs, optionsfile)) {
1.1.1.3 root 506: #ifdef OPTIONS_IN_HOME
1.1.1.22 root 507: /* If not found in $HOME then look in current directory. However,
508: * don't use the optionsfile variable, so that we will save changes
509: * to the home directory. */
510: char pwd_optionsfile[256];
1.1.1.3 root 511: strcpy (optionsfile, OPTIONSFILENAME);
1.1.1.6 root 512: cfgfile_load (&currprefs, optionsfile);
1.1.1.2 root 513: #endif
1.1.1.17 root 514: }
1.1.1.2 root 515:
1.1.1.6 root 516: parse_cmdline (argc, argv);
1.1 root 517: }
518:
1.1.1.4 root 519: void reset_all_systems (void)
520: {
1.1.1.14 root 521: init_eventtab ();
522:
523: memory_reset ();
1.1.1.6 root 524: bsdlib_reset ();
1.1.1.4 root 525: filesys_reset ();
526: filesys_start_threads ();
1.1.1.8 root 527: scsidev_reset ();
528: scsidev_start_threads ();
1.1.1.4 root 529: }
530:
1.1.1.2 root 531: /* Okay, this stuff looks strange, but it is here to encourage people who
532: * port UAE to re-use as much of this code as possible. Functions that you
533: * should be using are do_start_program() and do_leave_program(), as well
534: * as real_main(). Some OSes don't call main() (which is braindamaged IMHO,
535: * but unfortunately very common), so you need to call real_main() from
536: * whatever entry point you have. You may want to write your own versions
537: * of start_program() and leave_program() if you need to do anything special.
538: * Add #ifdefs around these as appropriate.
539: */
540:
1.1.1.4 root 541: void do_start_program (void)
1.1.1.2 root 542: {
1.1.1.20 root 543: if (quit_program == -1)
544: return;
545: inputdevice_updateconfig (&currprefs);
546:
1.1.1.3 root 547: /* Do a reset on startup. Whether this is elegant is debatable. */
1.1.1.20 root 548: if (quit_program >= 0)
549: quit_program = 2;
1.1.1.4 root 550: m68k_go (1);
1.1.1.2 root 551: }
552:
1.1.1.4 root 553: void do_leave_program (void)
1.1.1.2 root 554: {
1.1.1.4 root 555: graphics_leave ();
1.1.1.20 root 556: inputdevice_close ();
1.1.1.4 root 557: close_sound ();
558: dump_counts ();
559: serial_exit ();
560: zfile_exit ();
561: if (! no_gui)
562: gui_exit ();
1.1.1.15 root 563: #ifdef USE_SDL
564: SDL_Quit ();
565: #endif
566: expansion_cleanup ();
567: memory_cleanup ();
1.1.1.2 root 568: }
569:
1.1.1.4 root 570: void start_program (void)
1.1.1.2 root 571: {
1.1.1.4 root 572: do_start_program ();
1.1.1.2 root 573: }
574:
1.1.1.4 root 575: void leave_program (void)
1.1.1.2 root 576: {
1.1.1.4 root 577: do_leave_program ();
1.1.1.2 root 578: }
579:
1.1.1.4 root 580: void real_main (int argc, char **argv)
1.1 root 581: {
582: FILE *hf;
583:
1.1.1.15 root 584: #ifdef USE_SDL
585: SDL_Init (SDL_INIT_EVERYTHING | SDL_INIT_NOPARACHUTE);
586: #endif
587:
1.1.1.6 root 588: default_prefs (&currprefs);
1.1.1.20 root 589:
1.1.1.22 root 590: #ifdef SYSTEM_CFGDIR
591: scan_configs (SYSTEM_CFGDIR);
592: #endif
593:
594: /* Can be overriden in graphics_setup, although there's not much of a
595: point. Fullscreen modes are filled in by graphics_setup. */
596: gfx_windowed_modes = default_windowed_modes;
597: n_windowed_modes = sizeof default_windowed_modes / sizeof *default_windowed_modes;
598:
1.1.1.4 root 599: if (! graphics_setup ()) {
600: exit (1);
1.1 root 601: }
1.1.1.2 root 602:
1.1 root 603: rtarea_init ();
604: hardfile_install ();
1.1.1.8 root 605: scsidev_install ();
1.1 root 606:
1.1.1.4 root 607: parse_cmdline_and_init_file (argc, argv);
1.1.1.2 root 608:
1.1.1.4 root 609: machdep_init ();
1.1.1.21 root 610: init_gtod ();
1.1.1.3 root 611:
1.1.1.4 root 612: if (! setup_sound ()) {
1.1.1.16 root 613: write_log ("Sound driver unavailable: Sound output disabled\n");
1.1.1.3 root 614: currprefs.produce_sound = 0;
1.1 root 615: }
1.1.1.20 root 616: inputdevice_init ();
1.1 root 617:
1.1.1.15 root 618: changed_prefs = currprefs;
1.1.1.6 root 619: no_gui = ! currprefs.start_gui;
1.1.1.4 root 620: if (! no_gui) {
1.1.1.22 root 621: int err = gui_init (1);
1.1.1.15 root 622: currprefs = changed_prefs;
1.1.1.2 root 623: if (err == -1) {
1.1.1.16 root 624: write_log ("Failed to initialize the GUI\n");
1.1.1.2 root 625: } else if (err == -2) {
1.1.1.4 root 626: exit (0);
1.1.1.2 root 627: }
1.1 root 628: }
1.1.1.13 root 629: if (sound_available && currprefs.produce_sound > 1 && ! init_audio ()) {
1.1.1.16 root 630: write_log ("Sound driver unavailable: Sound output disabled\n");
1.1.1.3 root 631: currprefs.produce_sound = 0;
632: }
1.1.1.2 root 633:
1.1.1.22 root 634: fixup_prefs (&currprefs);
1.1.1.3 root 635: changed_prefs = currprefs;
636:
1.1.1.22 root 637: #ifdef SYSTEM_ROMDIR
638: scan_roms (SYSTEM_ROMDIR, ROMLOC_SYSTEM);
639: #endif
640: scan_roms (currprefs.path_rom, ROMLOC_USER);
1.1.1.2 root 641: /* Install resident module to get 8MB chipmem, if requested */
1.1.1.4 root 642: rtarea_setup ();
1.1.1.3 root 643:
1.1.1.4 root 644: keybuf_init (); /* Must come after init_joystick */
1.1.1.3 root 645:
1.1 root 646: expansion_init ();
1.1.1.4 root 647: memory_init ();
648:
649: filesys_install ();
1.1.1.22 root 650: bsdlib_install ();
1.1.1.4 root 651: emulib_install ();
652: uaeexe_install ();
1.1.1.8 root 653: native2amiga_install ();
1.1.1.4 root 654:
655: custom_init (); /* Must come after memory_init */
656: serial_init ();
657: DISK_init ();
658:
659: reset_frame_rate_hack ();
660: init_m68k(); /* must come after reset_frame_rate_hack (); */
1.1 root 661:
1.1.1.4 root 662: gui_update ();
1.1.1.2 root 663:
1.1.1.3 root 664: if (graphics_init ()) {
1.1.1.22 root 665: reset_drawing ();
1.1.1.3 root 666: setup_brkhandler ();
1.1.1.6 root 667: if (currprefs.start_debugger && debuggable ())
1.1.1.3 root 668: activate_debugger ();
669:
670: start_program ();
1.1 root 671: }
1.1.1.3 root 672: leave_program ();
1.1.1.2 root 673: }
674:
1.1.1.21 root 675: void uae_abort (const char *msg)
676: {
677: write_log ("%s", msg);
678: abort ();
679: }
680:
1.1.1.3 root 681: #ifndef NO_MAIN_IN_MAIN_C
1.1.1.4 root 682: int main (int argc, char **argv)
1.1.1.2 root 683: {
1.1.1.4 root 684: real_main (argc, argv);
1.1 root 685: return 0;
686: }
1.1.1.3 root 687: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.