Annotation of uae/src/main.c, revision 1.1.1.14

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 "config.h"
                     14: #include "options.h"
1.1.1.3   root       15: #include "threaddep/penguin.h"
1.1.1.2   root       16: #include "uae.h"
1.1.1.3   root       17: #include "gensound.h"
1.1.1.13  root       18: #include "audio.h"
1.1.1.3   root       19: #include "sounddep/sound.h"
1.1.1.2   root       20: #include "events.h"
1.1       root       21: #include "memory.h"
                     22: #include "custom.h"
                     23: #include "serial.h"
                     24: #include "newcpu.h"
                     25: #include "disk.h"
                     26: #include "debug.h"
                     27: #include "xwin.h"
1.1.1.3   root       28: #include "joystick.h"
1.1       root       29: #include "keybuf.h"
                     30: #include "gui.h"
                     31: #include "zfile.h"
                     32: #include "autoconf.h"
1.1.1.2   root       33: #include "osemu.h"
1.1.1.3   root       34: #include "osdep/exectasks.h"
1.1       root       35: #include "compiler.h"
1.1.1.3   root       36: #include "picasso96.h"
1.1.1.6   root       37: #include "bsdsocket.h"
1.1.1.3   root       38: #include "uaeexe.h"
1.1.1.8   root       39: #include "native2amiga.h"
                     40: #include "scsidev.h"
1.1       root       41: 
1.1.1.4   root       42: long int version = 256*65536L*UAEMAJOR + 65536L*UAEMINOR + UAESUBREV;
1.1.1.3   root       43: 
1.1.1.6   root       44: struct uae_prefs currprefs, changed_prefs;
1.1.1.4   root       45: 
1.1.1.6   root       46: int no_gui = 0;
1.1.1.4   root       47: int joystickpresent = 0;
                     48: int cloanto_rom = 0;
                     49: 
1.1.1.11  root       50: struct gui_info gui_data;
                     51: 
1.1.1.4   root       52: char warning_buffer[256];
                     53: 
                     54: char optionsfile[256];
                     55: 
                     56: /* If you want to pipe printer output to a file, put something like
                     57:  * "cat >>printerfile.tmp" above.
                     58:  * The printer support was only tested with the driver "PostScript" on
                     59:  * Amiga side, using apsfilter for linux to print ps-data.
                     60:  *
                     61:  * Under DOS it ought to be -p LPT1: or -p PRN: but you'll need a
                     62:  * PostScript printer or ghostscript -=SR=-
                     63:  */
                     64: 
                     65: /* People must provide their own name for this */
                     66: char sername[256] = "";
                     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.6   root       79: void discard_prefs (struct uae_prefs *p)
1.1.1.3   root       80: {
1.1.1.6   root       81:     struct strlist **ps = &p->unknown_lines;
                     82:     while (*ps) {
                     83:        struct strlist *s = *ps;
                     84:        *ps = s->next;
                     85:        free (s->str);
                     86:        free (s);
                     87:     }
                     88:     free_mountinfo (p->mountinfo);
                     89: }
                     90: 
                     91: void default_prefs (struct uae_prefs *p)
                     92: {
                     93:     strcpy (p->description, "UAE default configuration");
                     94: 
                     95:     p->start_gui = 1;
                     96:     p->start_debugger = 0;
                     97: 
                     98:     p->unknown_lines = 0;
1.1.1.4   root       99:     /* Note to porters: please don't change any of these options! UAE is supposed
                    100:      * to behave identically on all platforms if possible. */
1.1.1.6   root      101:     p->illegal_mem = 0;
                    102:     p->no_xhair = 0;
                    103:     p->use_serial = 0;
                    104:     p->serial_demand = 0;
                    105:     p->parallel_demand = 0;
                    106: 
                    107:     p->jport0 = 2;
                    108:     p->jport1 = 0;
                    109:     p->keyboard_lang = KBD_LANG_US;
                    110:     p->emul_accuracy = 2;
                    111:     p->test_drawing_speed = 0;
                    112: 
                    113:     p->produce_sound = 0;
                    114:     p->stereo = 0;
                    115:     p->sound_bits = DEFAULT_SOUND_BITS;
                    116:     p->sound_freq = DEFAULT_SOUND_FREQ;
                    117:     p->sound_minbsiz = DEFAULT_SOUND_MINB;
                    118:     p->sound_maxbsiz = DEFAULT_SOUND_MAXB;
1.1.1.9   root      119:     p->sound_interpol = 0;
1.1.1.6   root      120: 
1.1.1.8   root      121:     p->gfx_framerate = 1;
1.1.1.6   root      122:     p->gfx_width = 800;
                    123:     p->gfx_height = 600;
                    124:     p->gfx_lores = 0;
                    125:     p->gfx_linedbl = 0;
                    126:     p->gfx_afullscreen = 0;
                    127:     p->gfx_pfullscreen = 0;
                    128:     p->gfx_correct_aspect = 0;
                    129:     p->gfx_xcenter = 0;
                    130:     p->gfx_ycenter = 0;
                    131:     p->color_mode = 0;
                    132: 
                    133:     p->x11_use_low_bandwidth = 0;
                    134:     p->x11_use_mitshm = 0;
                    135:     p->x11_hide_cursor = 1;
                    136: 
1.1.1.8   root      137:     p->svga_no_linear = 0;
                    138: 
1.1.1.10  root      139:     p->curses_reverse_video = 0;
                    140: 
1.1.1.8   root      141:     p->win32_middle_mouse = 0;
                    142:     p->win32_sound_style = 0;
                    143:     p->win32_sound_tweak = 0;
                    144:     p->win32_logfile = 0;
                    145:     p->win32_iconified_nospeed = 0;
                    146:     p->win32_iconified_nosound = 0;
                    147: 
1.1.1.6   root      148:     p->immediate_blits = 0;
                    149:     p->blits_32bit_enabled = 0;
1.1.1.14! root      150:     p->collision_level = 1;
        !           151:     p->fast_copper = 1;
1.1.1.6   root      152: 
                    153:     strcpy (p->df[0], "df0.adf");
                    154:     strcpy (p->df[1], "df1.adf");
                    155:     strcpy (p->df[2], "df2.adf");
                    156:     strcpy (p->df[3], "df3.adf");
                    157: 
                    158:     strcpy (p->romfile, "kick.rom");
                    159:     strcpy (p->keyfile, "");
                    160:     strcpy (p->prtname, DEFPRTNAME);
                    161: 
                    162:     strcpy (p->path_rom, "./");
                    163:     strcpy (p->path_floppy, "./");
                    164:     strcpy (p->path_hardfile, "./");
                    165: 
1.1.1.11  root      166:     p->m68k_speed = 0;
1.1.1.6   root      167:     p->cpu_level = 2;
                    168:     p->cpu_compatible = 0;
                    169:     p->address_space_24 = 0;
                    170: 
                    171:     p->fastmem_size = 0x00000000;
                    172:     p->a3000mem_size = 0x00000000;
                    173:     p->z3fastmem_size = 0x00000000;
                    174:     p->chipmem_size = 0x00200000;
                    175:     p->bogomem_size = 0x00000000;
                    176:     p->gfxmem_size = 0x00000000;
1.1       root      177: 
1.1.1.11  root      178:     p->nr_floppies = 4;
                    179: 
1.1.1.6   root      180:     p->mountinfo = alloc_mountinfo ();
1.1.1.4   root      181: }
1.1       root      182: 
1.1.1.4   root      183: void fixup_prefs_dimensions (struct uae_prefs *prefs)
                    184: {
                    185:     if (prefs->gfx_width < 320)
                    186:        prefs->gfx_width = 320;
                    187:     if (prefs->gfx_height < 200)
                    188:        prefs->gfx_height = 200;
                    189:     if (prefs->gfx_height > 300 && ! prefs->gfx_linedbl)
                    190:        prefs->gfx_height = 300;
                    191:     if (prefs->gfx_height > 600)
                    192:        prefs->gfx_height = 600;
1.1       root      193: 
1.1.1.4   root      194:     prefs->gfx_width += 7; /* X86.S wants multiples of 4 bytes, might be 8 in the future. */
                    195:     prefs->gfx_width &= ~7;
                    196: }
1.1.1.3   root      197: 
1.1.1.4   root      198: static void fix_options (void)
1.1.1.2   root      199: {
1.1.1.3   root      200:     int err = 0;
                    201: 
1.1.1.4   root      202:     if ((currprefs.chipmem_size & (currprefs.chipmem_size - 1)) != 0
                    203:        || currprefs.chipmem_size < 0x80000
                    204:        || currprefs.chipmem_size > 0x800000)
1.1.1.3   root      205:     {
1.1.1.4   root      206:        currprefs.chipmem_size = 0x200000;
1.1.1.3   root      207:        fprintf (stderr, "Unsupported chipmem size!\n");
                    208:        err = 1;
                    209:     }
1.1.1.4   root      210:     if ((currprefs.fastmem_size & (currprefs.fastmem_size - 1)) != 0
                    211:        || (currprefs.fastmem_size != 0 && (currprefs.fastmem_size < 0x100000 || currprefs.fastmem_size > 0x800000)))
1.1.1.3   root      212:     {
1.1.1.4   root      213:        currprefs.fastmem_size = 0;
1.1.1.3   root      214:        fprintf (stderr, "Unsupported fastmem size!\n");
                    215:        err = 1;
                    216:     }
1.1.1.4   root      217:     if ((currprefs.gfxmem_size & (currprefs.gfxmem_size - 1)) != 0
                    218:        || (currprefs.gfxmem_size != 0 && (currprefs.gfxmem_size < 0x100000 || currprefs.gfxmem_size > 0x800000)))
1.1.1.3   root      219:     {
1.1.1.4   root      220:        currprefs.gfxmem_size = 0;
1.1.1.3   root      221:        fprintf (stderr, "Unsupported graphics card memory size!\n");
                    222:        err = 1;
                    223:     }
1.1.1.4   root      224:     if ((currprefs.z3fastmem_size & (currprefs.z3fastmem_size - 1)) != 0
                    225:        || (currprefs.z3fastmem_size != 0 && (currprefs.z3fastmem_size < 0x100000 || currprefs.z3fastmem_size > 0x4000000)))
1.1.1.3   root      226:     {
1.1.1.4   root      227:        currprefs.z3fastmem_size = 0;
1.1.1.3   root      228:        fprintf (stderr, "Unsupported Zorro III fastmem size!\n");
                    229:        err = 1;
                    230:     }
1.1.1.4   root      231:     if (currprefs.address_space_24 && (currprefs.gfxmem_size != 0 || currprefs.z3fastmem_size != 0)) {
                    232:        currprefs.z3fastmem_size = currprefs.gfxmem_size = 0;
1.1.1.3   root      233:        fprintf (stderr, "Can't use a graphics card or Zorro III fastmem when using a 24 bit\n"
                    234:                 "address space - sorry.\n");
                    235:     }
1.1.1.4   root      236:     if ((currprefs.bogomem_size & (currprefs.bogomem_size - 1)) != 0
                    237:        || (currprefs.bogomem_size != 0 && (currprefs.bogomem_size < 0x80000 || currprefs.bogomem_size > 0x100000)))
1.1.1.3   root      238:     {
1.1.1.4   root      239:        currprefs.bogomem_size = 0;
1.1.1.3   root      240:        fprintf (stderr, "Unsupported bogomem size!\n");
                    241:        err = 1;
                    242:     }
                    243: 
1.1.1.4   root      244:     if (currprefs.chipmem_size > 0x200000 && currprefs.fastmem_size != 0) {
1.1.1.3   root      245:        fprintf (stderr, "You can't use fastmem and more than 2MB chip at the same time!\n");
1.1.1.4   root      246:        currprefs.fastmem_size = 0;
1.1.1.3   root      247:        err = 1;
                    248:     }
1.1.1.13  root      249: #if 0
1.1.1.4   root      250:     if (currprefs.m68k_speed < -1 || currprefs.m68k_speed > 20) {
                    251:        fprintf (stderr, "Bad value for -w parameter: must be -1, 0, or within 1..20.\n");
1.1.1.3   root      252:        currprefs.m68k_speed = 4;
                    253:        err = 1;
                    254:     }
1.1.1.13  root      255: #endif
                    256:   
1.1.1.3   root      257:     if (currprefs.produce_sound < 0 || currprefs.produce_sound > 3) {
                    258:        fprintf (stderr, "Bad value for -S parameter: enable value must be within 0..3\n");
                    259:        currprefs.produce_sound = 0;
                    260:        err = 1;
                    261:     }
1.1.1.4   root      262:     if (currprefs.cpu_level < 2 && currprefs.z3fastmem_size > 0) {
1.1.1.3   root      263:        fprintf (stderr, "Z3 fast memory can't be used with a 68000/68010 emulation. It\n"
                    264:                 "requires a 68020 emulation. Turning off Z3 fast memory.\n");
1.1.1.4   root      265:        currprefs.z3fastmem_size = 0;
1.1.1.3   root      266:        err = 1;
                    267:     }
1.1.1.8   root      268:     if (currprefs.gfxmem_size > 0 && (currprefs.cpu_level < 2 || currprefs.address_space_24)) {
                    269:        fprintf (stderr, "Picasso96 can't be used with a 68000/68010 or 68EC020 emulation. It\n"
1.1.1.3   root      270:                 "requires a 68020 emulation. Turning off Picasso96.\n");
1.1.1.4   root      271:        currprefs.gfxmem_size = 0;
1.1.1.3   root      272:        err = 1;
                    273:     }
1.1.1.8   root      274: #ifndef BSDSOCKET_SUPPORTED
                    275:     if (currprefs.socket_emu) {
                    276:        fprintf (stderr, "Compile-time option of BSDSOCKET_SUPPORTED was not enabled.  You can't use bsd-socket emulation.\n");
                    277:        currprefs.socket_emu = 0;
                    278:        err = 1;
                    279:     }
                    280: #endif
1.1.1.3   root      281: 
1.1.1.11  root      282:     if (currprefs.nr_floppies < 1 || currprefs.nr_floppies > 4) {
                    283:        fprintf (stderr, "Invalid number of floppies.  Using 4.\n");
                    284:        currprefs.nr_floppies = 4;
                    285:        err = 1;
                    286:     }
1.1.1.14! root      287:     if (currprefs.collision_level < 0 || currprefs.collision_level > 3) {
        !           288:        fprintf (stderr, "Invalid collision support level.  Using 1.\n");
        !           289:        currprefs.collision_level = 1;
        !           290:        err = 1;
        !           291:     }
1.1.1.11  root      292: 
1.1.1.3   root      293:     if (err)
                    294:        fprintf (stderr, "Please use \"uae -h\" to get usage information.\n");
                    295: }
                    296: 
                    297: int quit_program = 0;
                    298: 
                    299: void uae_reset (void)
                    300: {
1.1.1.4   root      301:     if (quit_program == 0)
1.1.1.3   root      302:        quit_program = -2;
                    303: }
                    304: 
                    305: void uae_quit (void)
                    306: {
                    307:     if (quit_program != -1)
                    308:        quit_program = -1;
1.1.1.2   root      309: }
1.1       root      310: 
1.1.1.3   root      311: const char *gameport_state (int nr)
1.1       root      312: {
1.1.1.6   root      313:     if (JSEM_ISJOY0 (nr, &currprefs) && nr_joysticks > 0)
1.1.1.3   root      314:        return "using joystick #0";
1.1.1.6   root      315:     else if (JSEM_ISJOY1 (nr, &currprefs) && nr_joysticks > 1)
1.1.1.3   root      316:        return "using joystick #1";
1.1.1.6   root      317:     else if (JSEM_ISMOUSE (nr, &currprefs))
1.1.1.3   root      318:        return "using mouse";
1.1.1.6   root      319:     else if (JSEM_ISNUMPAD (nr, &currprefs))
1.1.1.3   root      320:        return "using numeric pad as joystick";
1.1.1.6   root      321:     else if (JSEM_ISCURSOR (nr, &currprefs))
1.1.1.3   root      322:        return "using cursor keys as joystick";
1.1.1.6   root      323:     else if (JSEM_ISSOMEWHEREELSE (nr, &currprefs))
1.1.1.3   root      324:        return "using T/F/H/B/Alt as joystick";
                    325: 
                    326:     return "not connected";
                    327: }
                    328: 
1.1.1.6   root      329: #ifndef DONT_PARSE_CMDLINE
1.1.1.3   root      330: 
1.1.1.6   root      331: void usage (void)
                    332: {
1.1.1.3   root      333: }
                    334: 
1.1.1.6   root      335: void parse_cmdline (int argc, char **argv)
                    336: {
1.1.1.8   root      337:     int i;
                    338:     for (i = 1; i < argc; i++) {
                    339:        if (strncmp (argv[i], "-config=", 8) == 0)
                    340:            cfgfile_load (&currprefs, argv[i] + 8);
                    341:        /* Check for new-style "-f xxx" argument, where xxx is config-file */
                    342:        else if (strcmp (argv[i], "-f") == 0) {
                    343:            if (i + 1 == argc)
                    344:                fprintf (stderr, "Missing argument for '-f' option.\n");
                    345:            else
                    346:                cfgfile_load (&currprefs, argv[++i]);
                    347:        } else if (strcmp (argv[i], "-s") == 0) {
                    348:            if (i + 1 == argc)
                    349:                fprintf (stderr, "Missing argument for '-s' option.\n");
                    350:            else
                    351:                cfgfile_parse_line (&currprefs, argv[++i]);
                    352:        } else if (strcmp (argv[i], "-h") == 0 || strcmp (argv[i], "-help") == 0) {
1.1.1.6   root      353:            usage ();
                    354:            exit (0);
1.1.1.9   root      355:        } else {
                    356:            if (argv[i][0] == '-' && argv[i][1] != '\0') {
                    357:                const char *arg = argv[i] + 2;
1.1.1.10  root      358:                int extra_arg = *arg == '\0';
                    359:                if (extra_arg)
1.1.1.9   root      360:                    arg = i + 1 < argc ? argv[i + 1] : 0;
1.1.1.10  root      361:                if (parse_cmdline_option (argv[i][1], arg) && extra_arg)
                    362:                    i++;
1.1.1.9   root      363:            }
1.1.1.3   root      364:        }
1.1       root      365:     }
                    366: }
                    367: #endif
                    368: 
1.1.1.4   root      369: static void parse_cmdline_and_init_file (int argc, char **argv)
1.1       root      370: {
1.1.1.3   root      371:     char *home;
1.1       root      372: 
1.1.1.6   root      373:     strcpy (optionsfile, "");
1.1       root      374: 
1.1.1.3   root      375: #ifdef OPTIONS_IN_HOME
1.1.1.4   root      376:     home = getenv ("HOME");
                    377:     if (home != NULL && strlen (home) < 240)
1.1       root      378:     {
1.1.1.4   root      379:        strcpy (optionsfile, home);
                    380:        strcat (optionsfile, "/");
1.1       root      381:     }
                    382: #endif
                    383: 
1.1.1.4   root      384:     strcat (optionsfile, OPTIONSFILENAME);
1.1       root      385: 
1.1.1.6   root      386:     if (! cfgfile_load (&currprefs, optionsfile)) {
1.1.1.3   root      387: #ifdef OPTIONS_IN_HOME
1.1.1.6   root      388:        /* sam: if not found in $HOME then look in current directory */
1.1.1.3   root      389:        strcpy (optionsfile, OPTIONSFILENAME);
1.1.1.6   root      390:        cfgfile_load (&currprefs, optionsfile);
1.1.1.2   root      391:     }
                    392: #endif
                    393: 
1.1.1.6   root      394:     parse_cmdline (argc, argv);
1.1       root      395: }
                    396: 
1.1.1.4   root      397: void write_log_standard (const char *fmt, ...)
                    398: {
                    399:     va_list ap;
                    400:     va_start (ap, fmt);
                    401: #ifdef HAVE_VFPRINTF
                    402:     vfprintf (stderr, fmt, ap);
                    403: #else
                    404:     /* Technique stolen from GCC.  */
                    405:     {
                    406:        int x1, x2, x3, x4, x5, x6, x7, x8;
                    407:        x1 = va_arg (ap, int);
                    408:        x2 = va_arg (ap, int);
                    409:        x3 = va_arg (ap, int);
                    410:        x4 = va_arg (ap, int);
                    411:        x5 = va_arg (ap, int);
                    412:        x6 = va_arg (ap, int);
                    413:        x7 = va_arg (ap, int);
                    414:        x8 = va_arg (ap, int);
                    415:        fprintf (stderr, fmt, x1, x2, x3, x4, x5, x6, x7, x8);
                    416:     }
                    417: #endif
                    418: }
                    419: 
                    420: void reset_all_systems (void)
                    421: {
1.1.1.14! root      422:     init_eventtab ();
        !           423: 
        !           424:     memory_reset ();
1.1.1.6   root      425:     bsdlib_reset ();
1.1.1.4   root      426:     filesys_reset ();
                    427:     filesys_start_threads ();
1.1.1.8   root      428:     scsidev_reset ();
                    429:     scsidev_start_threads ();
1.1.1.4   root      430: }
                    431: 
1.1.1.2   root      432: /* Okay, this stuff looks strange, but it is here to encourage people who
                    433:  * port UAE to re-use as much of this code as possible. Functions that you
                    434:  * should be using are do_start_program() and do_leave_program(), as well
                    435:  * as real_main(). Some OSes don't call main() (which is braindamaged IMHO,
                    436:  * but unfortunately very common), so you need to call real_main() from
                    437:  * whatever entry point you have. You may want to write your own versions
                    438:  * of start_program() and leave_program() if you need to do anything special.
                    439:  * Add #ifdefs around these as appropriate.
                    440:  */
                    441: 
1.1.1.4   root      442: void do_start_program (void)
1.1.1.2   root      443: {
1.1.1.3   root      444:     /* Do a reset on startup. Whether this is elegant is debatable. */
                    445:     quit_program = 2;
1.1.1.4   root      446:     m68k_go (1);
1.1.1.2   root      447: }
                    448: 
1.1.1.4   root      449: void do_leave_program (void)
1.1.1.2   root      450: {
1.1.1.4   root      451:     graphics_leave ();
                    452:     close_joystick ();
                    453:     close_sound ();
                    454:     dump_counts ();
                    455:     serial_exit ();
                    456:     zfile_exit ();
                    457:     if (! no_gui)
                    458:        gui_exit ();
1.1.1.2   root      459: }
                    460: 
1.1.1.4   root      461: void start_program (void)
1.1.1.2   root      462: {
1.1.1.4   root      463:     do_start_program ();
1.1.1.2   root      464: }
                    465: 
1.1.1.4   root      466: void leave_program (void)
1.1.1.2   root      467: {
1.1.1.4   root      468:     do_leave_program ();
1.1.1.2   root      469: }
                    470: 
1.1.1.4   root      471: void real_main (int argc, char **argv)
1.1       root      472: {
                    473:     FILE *hf;
                    474: 
1.1.1.6   root      475:     default_prefs (&currprefs);
1.1.1.3   root      476:     
1.1.1.4   root      477:     if (! graphics_setup ()) {
                    478:        exit (1);
1.1       root      479:     }
1.1.1.2   root      480: 
1.1       root      481:     rtarea_init ();
                    482:     hardfile_install ();
1.1.1.8   root      483:     scsidev_install ();
1.1.1.13  root      484:     ahi_install ();
1.1       root      485: 
1.1.1.4   root      486:     parse_cmdline_and_init_file (argc, argv);
1.1.1.2   root      487: 
1.1.1.4   root      488:     machdep_init ();
1.1.1.3   root      489: 
1.1.1.4   root      490:     if (! setup_sound ()) {
1.1.1.3   root      491:        fprintf (stderr, "Sound driver unavailable: Sound output disabled\n");
                    492:        currprefs.produce_sound = 0;
1.1       root      493:     }
1.1.1.4   root      494:     init_joystick ();
1.1       root      495: 
1.1.1.6   root      496:     no_gui = ! currprefs.start_gui;
1.1.1.4   root      497:     if (! no_gui) {
                    498:        int err = gui_init ();
1.1.1.2   root      499:        if (err == -1) {
1.1.1.3   root      500:            fprintf (stderr, "Failed to initialize the GUI\n");
1.1.1.2   root      501:        } else if (err == -2) {
1.1.1.4   root      502:            exit (0);
1.1.1.2   root      503:        }
1.1       root      504:     }
1.1.1.13  root      505:     if (sound_available && currprefs.produce_sound > 1 && ! init_audio ()) {
1.1.1.3   root      506:        fprintf (stderr, "Sound driver unavailable: Sound output disabled\n");
                    507:        currprefs.produce_sound = 0;
                    508:     }
1.1.1.2   root      509: 
1.1.1.4   root      510:     fix_options ();
1.1.1.3   root      511:     changed_prefs = currprefs;
                    512: 
1.1.1.2   root      513:     /* Install resident module to get 8MB chipmem, if requested */
1.1.1.4   root      514:     rtarea_setup ();
1.1.1.3   root      515: 
1.1.1.4   root      516:     keybuf_init (); /* Must come after init_joystick */
1.1.1.3   root      517: 
1.1       root      518:     expansion_init ();
1.1.1.4   root      519:     memory_init ();
                    520: 
                    521:     filesys_install ();
                    522:     gfxlib_install ();
                    523:     emulib_install ();
                    524:     uaeexe_install ();
1.1.1.8   root      525:     native2amiga_install ();
1.1.1.4   root      526: 
                    527:     custom_init (); /* Must come after memory_init */
                    528:     serial_init ();
                    529:     DISK_init ();
                    530: 
                    531:     reset_frame_rate_hack ();
                    532:     init_m68k(); /* must come after reset_frame_rate_hack (); */
1.1       root      533: 
1.1.1.4   root      534:     compiler_init ();
                    535:     gui_update ();
1.1.1.2   root      536: 
1.1.1.3   root      537:     if (graphics_init ()) {
                    538:        setup_brkhandler ();
1.1.1.6   root      539:        if (currprefs.start_debugger && debuggable ())
1.1.1.3   root      540:            activate_debugger ();
                    541: 
                    542:        start_program ();
1.1       root      543:     }
1.1.1.3   root      544:     leave_program ();
1.1.1.2   root      545: }
                    546: 
1.1.1.3   root      547: #ifndef NO_MAIN_IN_MAIN_C
1.1.1.4   root      548: int main (int argc, char **argv)
1.1.1.2   root      549: {
1.1.1.4   root      550:     real_main (argc, argv);
1.1       root      551:     return 0;
                    552: }
1.1.1.3   root      553: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.