--- uae/src/main.c 2018/04/24 17:00:05 1.1.1.14 +++ uae/src/main.c 2018/04/24 17:12:27 1.1.1.19 @@ -12,7 +12,7 @@ #include "config.h" #include "options.h" -#include "threaddep/penguin.h" +#include "threaddep/thread.h" #include "uae.h" #include "gensound.h" #include "audio.h" @@ -32,13 +32,16 @@ #include "autoconf.h" #include "osemu.h" #include "osdep/exectasks.h" -#include "compiler.h" #include "picasso96.h" #include "bsdsocket.h" #include "uaeexe.h" #include "native2amiga.h" #include "scsidev.h" +#ifdef USE_SDL +#include "SDL.h" +#endif + long int version = 256*65536L*UAEMAJOR + 65536L*UAEMINOR + UAESUBREV; struct uae_prefs currprefs, changed_prefs; @@ -62,9 +65,6 @@ char optionsfile[256]; * PostScript printer or ghostscript -=SR=- */ -/* People must provide their own name for this */ -char sername[256] = ""; - /* Slightly stupid place for this... */ /* ncurses.c might use quite a few of those. */ char *colormodes[] = { "256 colors", "32768 colors", "65536 colors", @@ -111,7 +111,7 @@ void default_prefs (struct uae_prefs *p) p->test_drawing_speed = 0; p->produce_sound = 0; - p->stereo = 0; + p->sound_stereo = 0; p->sound_bits = DEFAULT_SOUND_BITS; p->sound_freq = DEFAULT_SOUND_FREQ; p->sound_minbsiz = DEFAULT_SOUND_MINB; @@ -122,7 +122,7 @@ void default_prefs (struct uae_prefs *p) p->gfx_width = 800; p->gfx_height = 600; p->gfx_lores = 0; - p->gfx_linedbl = 0; + p->gfx_linedbl = 2; p->gfx_afullscreen = 0; p->gfx_pfullscreen = 0; p->gfx_correct_aspect = 0; @@ -139,16 +139,13 @@ void default_prefs (struct uae_prefs *p) p->curses_reverse_video = 0; p->win32_middle_mouse = 0; - p->win32_sound_style = 0; - p->win32_sound_tweak = 0; p->win32_logfile = 0; p->win32_iconified_nospeed = 0; p->win32_iconified_nosound = 0; + p->win32_no_overlay = 0; p->immediate_blits = 0; - p->blits_32bit_enabled = 0; p->collision_level = 1; - p->fast_copper = 1; strcpy (p->df[0], "df0.adf"); strcpy (p->df[1], "df1.adf"); @@ -163,6 +160,9 @@ void default_prefs (struct uae_prefs *p) strcpy (p->path_floppy, "./"); strcpy (p->path_hardfile, "./"); + strcpy (p->prtname, ""); + strcpy (p->sername, ""); + p->m68k_speed = 0; p->cpu_level = 2; p->cpu_compatible = 0; @@ -204,94 +204,94 @@ static void fix_options (void) || currprefs.chipmem_size > 0x800000) { currprefs.chipmem_size = 0x200000; - fprintf (stderr, "Unsupported chipmem size!\n"); + write_log ("Unsupported chipmem size!\n"); err = 1; } if ((currprefs.fastmem_size & (currprefs.fastmem_size - 1)) != 0 || (currprefs.fastmem_size != 0 && (currprefs.fastmem_size < 0x100000 || currprefs.fastmem_size > 0x800000))) { currprefs.fastmem_size = 0; - fprintf (stderr, "Unsupported fastmem size!\n"); + write_log ("Unsupported fastmem size!\n"); err = 1; } if ((currprefs.gfxmem_size & (currprefs.gfxmem_size - 1)) != 0 - || (currprefs.gfxmem_size != 0 && (currprefs.gfxmem_size < 0x100000 || currprefs.gfxmem_size > 0x800000))) + || (currprefs.gfxmem_size != 0 && (currprefs.gfxmem_size < 0x100000 || currprefs.gfxmem_size > 0x2000000))) { + write_log ("Unsupported graphics card memory size %lx!\n", currprefs.gfxmem_size); currprefs.gfxmem_size = 0; - fprintf (stderr, "Unsupported graphics card memory size!\n"); err = 1; } if ((currprefs.z3fastmem_size & (currprefs.z3fastmem_size - 1)) != 0 || (currprefs.z3fastmem_size != 0 && (currprefs.z3fastmem_size < 0x100000 || currprefs.z3fastmem_size > 0x4000000))) { currprefs.z3fastmem_size = 0; - fprintf (stderr, "Unsupported Zorro III fastmem size!\n"); + write_log ("Unsupported Zorro III fastmem size!\n"); err = 1; } if (currprefs.address_space_24 && (currprefs.gfxmem_size != 0 || currprefs.z3fastmem_size != 0)) { currprefs.z3fastmem_size = currprefs.gfxmem_size = 0; - fprintf (stderr, "Can't use a graphics card or Zorro III fastmem when using a 24 bit\n" + write_log ("Can't use a graphics card or Zorro III fastmem when using a 24 bit\n" "address space - sorry.\n"); } if ((currprefs.bogomem_size & (currprefs.bogomem_size - 1)) != 0 || (currprefs.bogomem_size != 0 && (currprefs.bogomem_size < 0x80000 || currprefs.bogomem_size > 0x100000))) { currprefs.bogomem_size = 0; - fprintf (stderr, "Unsupported bogomem size!\n"); + write_log ("Unsupported bogomem size!\n"); err = 1; } if (currprefs.chipmem_size > 0x200000 && currprefs.fastmem_size != 0) { - fprintf (stderr, "You can't use fastmem and more than 2MB chip at the same time!\n"); + write_log ("You can't use fastmem and more than 2MB chip at the same time!\n"); currprefs.fastmem_size = 0; err = 1; } #if 0 if (currprefs.m68k_speed < -1 || currprefs.m68k_speed > 20) { - fprintf (stderr, "Bad value for -w parameter: must be -1, 0, or within 1..20.\n"); + write_log ("Bad value for -w parameter: must be -1, 0, or within 1..20.\n"); currprefs.m68k_speed = 4; err = 1; } #endif if (currprefs.produce_sound < 0 || currprefs.produce_sound > 3) { - fprintf (stderr, "Bad value for -S parameter: enable value must be within 0..3\n"); + write_log ("Bad value for -S parameter: enable value must be within 0..3\n"); currprefs.produce_sound = 0; err = 1; } if (currprefs.cpu_level < 2 && currprefs.z3fastmem_size > 0) { - fprintf (stderr, "Z3 fast memory can't be used with a 68000/68010 emulation. It\n" + write_log ("Z3 fast memory can't be used with a 68000/68010 emulation. It\n" "requires a 68020 emulation. Turning off Z3 fast memory.\n"); currprefs.z3fastmem_size = 0; err = 1; } if (currprefs.gfxmem_size > 0 && (currprefs.cpu_level < 2 || currprefs.address_space_24)) { - fprintf (stderr, "Picasso96 can't be used with a 68000/68010 or 68EC020 emulation. It\n" + write_log ("Picasso96 can't be used with a 68000/68010 or 68EC020 emulation. It\n" "requires a 68020 emulation. Turning off Picasso96.\n"); currprefs.gfxmem_size = 0; err = 1; } #ifndef BSDSOCKET_SUPPORTED if (currprefs.socket_emu) { - fprintf (stderr, "Compile-time option of BSDSOCKET_SUPPORTED was not enabled. You can't use bsd-socket emulation.\n"); + write_log ("Compile-time option of BSDSOCKET_SUPPORTED was not enabled. You can't use bsd-socket emulation.\n"); currprefs.socket_emu = 0; err = 1; } #endif if (currprefs.nr_floppies < 1 || currprefs.nr_floppies > 4) { - fprintf (stderr, "Invalid number of floppies. Using 4.\n"); + write_log ("Invalid number of floppies. Using 4.\n"); currprefs.nr_floppies = 4; err = 1; } if (currprefs.collision_level < 0 || currprefs.collision_level > 3) { - fprintf (stderr, "Invalid collision support level. Using 1.\n"); + write_log ("Invalid collision support level. Using 1.\n"); currprefs.collision_level = 1; err = 1; } if (err) - fprintf (stderr, "Please use \"uae -h\" to get usage information.\n"); + write_log ("Please use \"uae -h\" to get usage information.\n"); } int quit_program = 0; @@ -341,12 +341,12 @@ void parse_cmdline (int argc, char **arg /* Check for new-style "-f xxx" argument, where xxx is config-file */ else if (strcmp (argv[i], "-f") == 0) { if (i + 1 == argc) - fprintf (stderr, "Missing argument for '-f' option.\n"); + write_log ("Missing argument for '-f' option.\n"); else cfgfile_load (&currprefs, argv[++i]); } else if (strcmp (argv[i], "-s") == 0) { if (i + 1 == argc) - fprintf (stderr, "Missing argument for '-s' option.\n"); + write_log ("Missing argument for '-s' option.\n"); else cfgfile_parse_line (&currprefs, argv[++i]); } else if (strcmp (argv[i], "-h") == 0 || strcmp (argv[i], "-help") == 0) { @@ -388,35 +388,12 @@ static void parse_cmdline_and_init_file /* sam: if not found in $HOME then look in current directory */ strcpy (optionsfile, OPTIONSFILENAME); cfgfile_load (&currprefs, optionsfile); - } #endif + } parse_cmdline (argc, argv); } -void write_log_standard (const char *fmt, ...) -{ - va_list ap; - va_start (ap, fmt); -#ifdef HAVE_VFPRINTF - vfprintf (stderr, fmt, ap); -#else - /* Technique stolen from GCC. */ - { - int x1, x2, x3, x4, x5, x6, x7, x8; - x1 = va_arg (ap, int); - x2 = va_arg (ap, int); - x3 = va_arg (ap, int); - x4 = va_arg (ap, int); - x5 = va_arg (ap, int); - x6 = va_arg (ap, int); - x7 = va_arg (ap, int); - x8 = va_arg (ap, int); - fprintf (stderr, fmt, x1, x2, x3, x4, x5, x6, x7, x8); - } -#endif -} - void reset_all_systems (void) { init_eventtab (); @@ -456,6 +433,11 @@ void do_leave_program (void) zfile_exit (); if (! no_gui) gui_exit (); +#ifdef USE_SDL + SDL_Quit (); +#endif + expansion_cleanup (); + memory_cleanup (); } void start_program (void) @@ -472,6 +454,10 @@ void real_main (int argc, char **argv) { FILE *hf; +#ifdef USE_SDL + SDL_Init (SDL_INIT_EVERYTHING | SDL_INIT_NOPARACHUTE); +#endif + default_prefs (&currprefs); if (! graphics_setup ()) { @@ -481,29 +467,30 @@ void real_main (int argc, char **argv) rtarea_init (); hardfile_install (); scsidev_install (); - ahi_install (); parse_cmdline_and_init_file (argc, argv); machdep_init (); if (! setup_sound ()) { - fprintf (stderr, "Sound driver unavailable: Sound output disabled\n"); + write_log ("Sound driver unavailable: Sound output disabled\n"); currprefs.produce_sound = 0; } init_joystick (); + changed_prefs = currprefs; no_gui = ! currprefs.start_gui; if (! no_gui) { int err = gui_init (); + currprefs = changed_prefs; if (err == -1) { - fprintf (stderr, "Failed to initialize the GUI\n"); + write_log ("Failed to initialize the GUI\n"); } else if (err == -2) { exit (0); } } if (sound_available && currprefs.produce_sound > 1 && ! init_audio ()) { - fprintf (stderr, "Sound driver unavailable: Sound output disabled\n"); + write_log ("Sound driver unavailable: Sound output disabled\n"); currprefs.produce_sound = 0; } @@ -531,7 +518,6 @@ void real_main (int argc, char **argv) reset_frame_rate_hack (); init_m68k(); /* must come after reset_frame_rate_hack (); */ - compiler_init (); gui_update (); if (graphics_init ()) {