--- uae/src/main.c 2018/04/24 17:03:46 1.1.1.16 +++ uae/src/main.c 2018/04/24 17:16:30 1.1.1.21 @@ -10,7 +10,6 @@ #include "sysdeps.h" #include -#include "config.h" #include "options.h" #include "threaddep/thread.h" #include "uae.h" @@ -25,14 +24,13 @@ #include "disk.h" #include "debug.h" #include "xwin.h" -#include "joystick.h" +#include "inputdevice.h" #include "keybuf.h" #include "gui.h" #include "zfile.h" #include "autoconf.h" #include "osemu.h" #include "osdep/exectasks.h" -#include "compiler.h" #include "picasso96.h" #include "bsdsocket.h" #include "uaeexe.h" @@ -43,9 +41,8 @@ #include "SDL.h" #endif -long int version = 256*65536L*UAEMAJOR + 65536L*UAEMINOR + UAESUBREV; - struct uae_prefs currprefs, changed_prefs; +struct gfx_params *curr_gfx; int no_gui = 0; int joystickpresent = 0; @@ -77,6 +74,20 @@ char *colormodes[] = { "256 colors", "32 "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }; +unsigned long gtod_resolution, gtod_secs; + +static void init_gtod (void) +{ + struct timeval tv1, tv2; + gettimeofday (&tv1, NULL); + do { + gettimeofday (&tv2, NULL); + } while (tv1.tv_sec == tv2.tv_sec + && tv1.tv_usec == tv2.tv_usec); + + gtod_resolution = (tv2.tv_usec - tv1.tv_usec + 1000000 * (tv2.tv_sec - tv1.tv_sec)); +} + void discard_prefs (struct uae_prefs *p) { struct strlist **ps = &p->unknown_lines; @@ -95,6 +106,7 @@ void default_prefs (struct uae_prefs *p) p->start_gui = 1; p->start_debugger = 0; + p->leds_on_screen = 1; p->unknown_lines = 0; /* Note to porters: please don't change any of these options! UAE is supposed @@ -105,14 +117,15 @@ void default_prefs (struct uae_prefs *p) p->serial_demand = 0; p->parallel_demand = 0; - p->jport0 = 2; - p->jport1 = 0; + p->jport0 = JSEM_MICE; + p->jport1 = JSEM_JOYS; + p->keyboard_lang = KBD_LANG_US; p->emul_accuracy = 2; 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; @@ -120,15 +133,16 @@ void default_prefs (struct uae_prefs *p) p->sound_interpol = 0; p->gfx_framerate = 1; - p->gfx_width = 800; - p->gfx_height = 600; - p->gfx_lores = 0; - p->gfx_linedbl = 2; + p->gfx_w.width = 800; + p->gfx_w.height = 600; + p->gfx_w.lores = 0; + p->gfx_w.linedbl = 2; + p->gfx_w.correct_aspect = 0; + p->gfx_w.xcenter = 0; + p->gfx_w.ycenter = 0; + p->gfx_f = p->gfx_w; p->gfx_afullscreen = 0; p->gfx_pfullscreen = 0; - p->gfx_correct_aspect = 0; - p->gfx_xcenter = 0; - p->gfx_ycenter = 0; p->color_mode = 0; p->x11_use_low_bandwidth = 0; @@ -147,7 +161,6 @@ void default_prefs (struct uae_prefs *p) p->immediate_blits = 0; p->collision_level = 1; - p->fast_copper = 1; strcpy (p->df[0], "df0.adf"); strcpy (p->df[1], "df1.adf"); @@ -180,21 +193,22 @@ void default_prefs (struct uae_prefs *p) p->nr_floppies = 4; p->mountinfo = alloc_mountinfo (); + inputdevice_default_prefs (p); } -void fixup_prefs_dimensions (struct uae_prefs *prefs) +void fixup_prefs_dimensions (struct gfx_params *p) { - if (prefs->gfx_width < 320) - prefs->gfx_width = 320; - if (prefs->gfx_height < 200) - prefs->gfx_height = 200; - if (prefs->gfx_height > 300 && ! prefs->gfx_linedbl) - prefs->gfx_height = 300; - if (prefs->gfx_height > 600) - prefs->gfx_height = 600; + if (p->width < 320) + p->width = 320; + if (p->height < 200) + p->height = 200; + if (p->height > 300 && ! p->linedbl) + p->height = 300; + if (p->height > 600) + p->height = 600; - prefs->gfx_width += 7; /* X86.S wants multiples of 4 bytes, might be 8 in the future. */ - prefs->gfx_width &= ~7; + p->width += 7; /* X86.S wants multiples of 4 bytes, might be 8 in the future. */ + p->width &= ~7; } static void fix_options (void) @@ -255,7 +269,7 @@ static void fix_options (void) err = 1; } #endif - + if (currprefs.produce_sound < 0 || currprefs.produce_sound > 3) { write_log ("Bad value for -S parameter: enable value must be within 0..3\n"); currprefs.produce_sound = 0; @@ -298,10 +312,13 @@ static void fix_options (void) int quit_program = 0; -void uae_reset (void) +void uae_reset (int hardreset) { - if (quit_program == 0) + if (quit_program == 0) { quit_program = -2; + if (hardreset) + quit_program = -3; + } } void uae_quit (void) @@ -310,24 +327,6 @@ void uae_quit (void) quit_program = -1; } -const char *gameport_state (int nr) -{ - if (JSEM_ISJOY0 (nr, &currprefs) && nr_joysticks > 0) - return "using joystick #0"; - else if (JSEM_ISJOY1 (nr, &currprefs) && nr_joysticks > 1) - return "using joystick #1"; - else if (JSEM_ISMOUSE (nr, &currprefs)) - return "using mouse"; - else if (JSEM_ISNUMPAD (nr, &currprefs)) - return "using numeric pad as joystick"; - else if (JSEM_ISCURSOR (nr, &currprefs)) - return "using cursor keys as joystick"; - else if (JSEM_ISSOMEWHEREELSE (nr, &currprefs)) - return "using T/F/H/B/Alt as joystick"; - - return "not connected"; -} - #ifndef DONT_PARSE_CMDLINE void usage (void) @@ -343,12 +342,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) { @@ -390,8 +389,8 @@ 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); } @@ -420,15 +419,20 @@ void reset_all_systems (void) void do_start_program (void) { + if (quit_program == -1) + return; + inputdevice_updateconfig (&currprefs); + /* Do a reset on startup. Whether this is elegant is debatable. */ - quit_program = 2; + if (quit_program >= 0) + quit_program = 2; m68k_go (1); } void do_leave_program (void) { graphics_leave (); - close_joystick (); + inputdevice_close (); close_sound (); dump_counts (); serial_exit (); @@ -461,7 +465,7 @@ void real_main (int argc, char **argv) #endif default_prefs (&currprefs); - + if (! graphics_setup ()) { exit (1); } @@ -469,17 +473,21 @@ void real_main (int argc, char **argv) rtarea_init (); hardfile_install (); scsidev_install (); - ahi_install (); parse_cmdline_and_init_file (argc, argv); machdep_init (); + init_gtod (); + if (gtod_resolution < 1000) { + use_gtod = 1; + syncbase = 1000000; + } if (! setup_sound ()) { write_log ("Sound driver unavailable: Sound output disabled\n"); currprefs.produce_sound = 0; } - init_joystick (); + inputdevice_init (); changed_prefs = currprefs; no_gui = ! currprefs.start_gui; @@ -521,7 +529,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 ()) { @@ -534,6 +541,12 @@ void real_main (int argc, char **argv) leave_program (); } +void uae_abort (const char *msg) +{ + write_log ("%s", msg); + abort (); +} + #ifndef NO_MAIN_IN_MAIN_C int main (int argc, char **argv) {