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

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

unix.superglobalmegacorp.com

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