Search
lxdream.org :: lxdream/src/main.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/main.c
changeset 1109:700c5ab26a63
prev1108:305ef2082079
next1111:742c073f353f
author nkeynes
date Thu Jun 10 22:13:16 2010 +1000 (11 years ago)
permissions -rw-r--r--
last change Integrate executable wrapping into the user interface
- command-line now loads wrapped by default, -e <bin> to run binary
- add support for .bin executables
- Add useful (internal) error codes
file annotate diff log raw
1.1 --- a/src/main.c Fri Jun 04 09:13:40 2010 +1000
1.2 +++ b/src/main.c Thu Jun 10 22:13:16 2010 +1000
1.3 @@ -42,13 +42,14 @@
1.4 #include "hotkeys.h"
1.5 #include "plugin.h"
1.6
1.7 -char *option_list = "a:A:bc:dfg:G:hHl:m:npt:T:uvV:w:x?";
1.8 +char *option_list = "a:A:bc:e:dfg:G:hHl:m:npt:T:uvV:x?";
1.9 struct option longopts[] = {
1.10 { "aica", required_argument, NULL, 'a' },
1.11 { "audio", required_argument, NULL, 'A' },
1.12 { "biosless", no_argument, NULL, 'b' },
1.13 { "config", required_argument, NULL, 'c' },
1.14 { "debugger", no_argument, NULL, 'd' },
1.15 + { "execute", required_argument, NULL, 'e' },
1.16 { "fullscreen", no_argument, NULL, 'f' },
1.17 { "gdb-sh4", required_argument, NULL, 'g' },
1.18 { "gdb-arm", required_argument, NULL, 'G' },
1.19 @@ -61,7 +62,6 @@
1.20 { "unsafe", no_argument, NULL, 'u' },
1.21 { "video", no_argument, NULL, 'V' },
1.22 { "version", no_argument, NULL, 'v' },
1.23 - { "wrap", required_argument, NULL, 'w' },
1.24 { NULL, 0, 0, 0 } };
1.25 char *aica_program = NULL;
1.26 char *display_driver_name = NULL;
1.27 @@ -86,13 +86,14 @@
1.28 static void print_usage()
1.29 {
1.30 print_version();
1.31 - printf( "Usage: lxdream %s [options] [disc-file] [program-file]\n\n", lxdream_full_version );
1.32 + printf( "Usage: lxdream %s [options] [disc-file] [save-state]\n\n", lxdream_full_version );
1.33
1.34 printf( "Options:\n" );
1.35 printf( " -a, --aica=PROGFILE %s\n", _("Run the AICA SPU only, with the supplied program") );
1.36 printf( " -A, --audio=DRIVER %s\n", _("Use the specified audio driver (? to list)") );
1.37 printf( " -b, --biosless %s\n", _("Run without the BIOS boot rom even if available") );
1.38 printf( " -c, --config=CONFFILE %s\n", _("Load configuration from CONFFILE") );
1.39 + printf( " -e, --execute=PROGRAM %s\n", _("Load and execute the given SH4 program") );
1.40 printf( " -d, --debugger %s\n", _("Start in debugger mode") );
1.41 printf( " -f, --fullscreen %s\n", _("Start in fullscreen mode") );
1.42 printf( " -g, --gdb-sh4=PORT %s\n", _("Start GDB remote server on PORT for SH4") );
1.43 @@ -108,7 +109,6 @@
1.44 printf( " -u, --unsafe %s\n", _("Allow unsafe dcload syscalls") );
1.45 printf( " -v, --version %s\n", _("Print the lxdream version string") );
1.46 printf( " -V, --video=DRIVER %s\n", _("Use the specified video driver (? to list)") );
1.47 - printf( " -w, --wrap=FILENAME %s\n", _("Wrap the specified binary file in a disc image") );
1.48 printf( " -x %s\n", _("Disable the SH4 translator") );
1.49 }
1.50
1.51 @@ -124,9 +124,9 @@
1.52 {
1.53 int opt;
1.54 double t;
1.55 - gboolean display_ok;
1.56 + gboolean display_ok, have_disc = FALSE, have_save = FALSE, have_exec = FALSE;
1.57 uint32_t time_secs, time_nanos;
1.58 - const char *wrap_name = NULL;
1.59 + const char *exec_name = NULL;
1.60
1.61 install_crash_handler();
1.62 bind_gettext_domain();
1.63 @@ -148,6 +148,9 @@
1.64 case 'd': /* Launch w/ debugger */
1.65 show_debugger = TRUE;
1.66 break;
1.67 + case 'e':
1.68 + exec_name = optarg;
1.69 + break;
1.70 case 'f':
1.71 show_fullscreen = TRUE;
1.72 break;
1.73 @@ -203,9 +206,6 @@
1.74 case 'V': /* Video driver */
1.75 display_driver_name = optarg;
1.76 break;
1.77 - case 'w': /* Wrap image file */
1.78 - wrap_name = optarg;
1.79 - break;
1.80 case 'x': /* Disable translator */
1.81 use_xlat = FALSE;
1.82 break;
1.83 @@ -268,37 +268,52 @@
1.84 maple_reattach_all();
1.85 INFO( "%s! ready...", APP_NAME );
1.86
1.87 - if( wrap_name != NULL ) {
1.88 + for( ; optind < argc; optind++ ) {
1.89 ERROR err;
1.90 - cdrom_disc_t disc = cdrom_wrap_magic( CDROM_DISC_XA, wrap_name, &err );
1.91 - if( disc == NULL )
1.92 - ERROR(err.msg);
1.93 - else {
1.94 - gdrom_mount_disc(disc);
1.95 - if( !no_start ) {
1.96 - start_immediately = TRUE;
1.97 + lxdream_file_type_t type = file_identify(argv[optind], -1, &err);
1.98 + if( type == FILE_SAVE_STATE ) {
1.99 + if( have_save ) {
1.100 + ERROR( "Multiple save states given on command-line, ignoring %s", argv[optind] );
1.101 + } else {
1.102 + have_save = dreamcast_load_state(argv[optind]);
1.103 + if( !have_save )
1.104 + no_start = TRUE;
1.105 + }
1.106 + } else {
1.107 + if( have_disc ) {
1.108 + ERROR( "Multiple GD-ROM discs given on command-line, ignoring %s", argv[optind] );
1.109 + } else {
1.110 + have_disc = gdrom_mount_image(argv[optind], &err);
1.111 + if( !have_disc )
1.112 + no_start = TRUE;
1.113 }
1.114 }
1.115 }
1.116
1.117 - for( ; optind < argc; optind++ ) {
1.118 - gboolean ok = gdrom_mount_image(argv[optind]);
1.119 - if( !ok ) {
1.120 - ok = file_load_magic( argv[optind] );
1.121 - }
1.122 - if( !ok ) {
1.123 - ERROR( "Unrecognized file '%s'", argv[optind] );
1.124 - }
1.125 - if( !no_start ) {
1.126 - start_immediately = ok;
1.127 + if( exec_name != NULL ) {
1.128 + ERROR err;
1.129 + if( have_save ) {
1.130 + ERROR( "Both a save state and an executable were specified, ignoring %s", exec_name );
1.131 + } else {
1.132 + have_exec = file_load_exec( exec_name, &err );
1.133 + if( !have_exec )
1.134 + no_start = TRUE;
1.135 }
1.136 }
1.137
1.138 + if( !no_start && (have_exec || have_disc || have_save) ) {
1.139 + start_immediately = TRUE;
1.140 + }
1.141 +
1.142 if( gdrom_get_current_disc() == NULL ) {
1.143 + ERROR err;
1.144 gchar *disc_file = lxdream_get_global_config_path_value( CONFIG_GDROM );
1.145 if( disc_file != NULL ) {
1.146 - gdrom_mount_image( disc_file );
1.147 + gboolean ok = gdrom_mount_image( disc_file, &err );
1.148 g_free(disc_file);
1.149 + if( !ok ) {
1.150 + WARN( err.msg );
1.151 + }
1.152 }
1.153 }
1.154
.