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

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

unix.superglobalmegacorp.com

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