Search
lxdream.org :: lxdream :: r446:def93c34c84c
lxdream 0.9.1
released Jun 29
Download Now
changeset446:def93c34c84c
parent445:75c668cdfdc0
child447:3e095bfcb476
authornkeynes
dateTue Oct 16 12:28:42 2007 +0000 (12 years ago)
Change command line handling to not require -d
src/gdrom/gdrom.c
src/loader.c
src/main.c
1.1 --- a/src/gdrom/gdrom.c Tue Oct 16 12:27:28 2007 +0000
1.2 +++ b/src/gdrom/gdrom.c Tue Oct 16 12:28:42 2007 +0000
1.3 @@ -1,6 +1,6 @@
1.4
1.5 /**
1.6 - * $Id: gdrom.c,v 1.14 2007-10-09 08:45:00 nkeynes Exp $
1.7 + * $Id: gdrom.c,v 1.15 2007-10-16 12:28:42 nkeynes Exp $
1.8 *
1.9 * GD-Rom access functions.
1.10 *
1.11 @@ -79,9 +79,6 @@
1.12 }
1.13 }
1.14
1.15 - if( !recognized ) {
1.16 - ERROR( "Unable to open disc %s: Unsupported format", filename );
1.17 - }
1.18 fclose(f);
1.19 return NULL;
1.20 }
2.1 --- a/src/loader.c Tue Oct 16 12:27:28 2007 +0000
2.2 +++ b/src/loader.c Tue Oct 16 12:28:42 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: loader.c,v 1.17 2007-10-10 11:02:04 nkeynes Exp $
2.6 + * $Id: loader.c,v 1.18 2007-10-16 12:28:42 nkeynes Exp $
2.7 *
2.8 * File loading routines, mostly for loading demos without going through the
2.9 * whole procedure of making a CD image for them.
2.10 @@ -45,13 +45,14 @@
2.11 #define CDI_V2 0x80000004
2.12 #define CDI_V3 0x80000005
2.13
2.14 -int file_load_elf_fd( int fd );
2.15 +gboolean file_load_elf_fd( int fd );
2.16
2.17
2.18 gboolean file_load_magic( const gchar *filename )
2.19 {
2.20 char buf[32];
2.21 struct stat st;
2.22 + gboolean result = TRUE;
2.23
2.24 int fd = open( filename, O_RDONLY );
2.25 if( fd == -1 ) {
2.26 @@ -90,20 +91,20 @@
2.27 } else if( memcmp( buf, "PK\x03\x04", 4 ) == 0 ) {
2.28 /* ZIP file, aka SBI file */
2.29 WARN( "SBI files not supported yet" );
2.30 + result = FALSE;
2.31 } else if( memcmp( buf, DREAMCAST_SAVE_MAGIC, 16 ) == 0 ) {
2.32 /* Save state */
2.33 - dreamcast_load_state( filename );
2.34 + result = (dreamcast_load_state( filename )==0);
2.35 } else if( buf[0] == 0x7F && buf[1] == 'E' &&
2.36 buf[2] == 'L' && buf[3] == 'F' ) {
2.37 /* ELF binary */
2.38 lseek( fd, 0, SEEK_SET );
2.39 - file_load_elf_fd( fd );
2.40 + result = file_load_elf_fd( fd );
2.41 } else {
2.42 - /* Assume raw binary */
2.43 - file_load_binary( filename );
2.44 - }
2.45 + result = FALSE;
2.46 + }
2.47 close(fd);
2.48 - return TRUE;
2.49 + return result;
2.50 }
2.51
2.52 void file_load_postload( int pc )
2.53 @@ -139,14 +140,14 @@
2.54 }
2.55 }
2.56
2.57 -int file_load_elf_fd( int fd )
2.58 +gboolean file_load_elf_fd( int fd )
2.59 {
2.60 Elf32_Ehdr head;
2.61 Elf32_Phdr phdr;
2.62 int i;
2.63
2.64 if( read( fd, &head, sizeof(head) ) != sizeof(head) )
2.65 - return -1;
2.66 + return FALSE;
2.67 if( head.e_ident[EI_CLASS] != ELFCLASS32 ||
2.68 head.e_ident[EI_DATA] != ELFDATA2LSB ||
2.69 head.e_ident[EI_VERSION] != 1 ||
2.70 @@ -154,7 +155,7 @@
2.71 head.e_machine != EM_SH ||
2.72 head.e_version != 1 ) {
2.73 ERROR( "File is not an SH4 ELF executable file" );
2.74 - return -1;
2.75 + return FALSE;
2.76 }
2.77
2.78 /* Program headers */
2.79 @@ -173,5 +174,5 @@
2.80 }
2.81
2.82 file_load_postload( head.e_entry );
2.83 - return 0;
2.84 + return TRUE;
2.85 }
3.1 --- a/src/main.c Tue Oct 16 12:27:28 2007 +0000
3.2 +++ b/src/main.c Tue Oct 16 12:28:42 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: main.c,v 1.28 2007-10-10 11:02:04 nkeynes Exp $
3.6 + * $Id: main.c,v 1.29 2007-10-16 12:28:42 nkeynes Exp $
3.7 *
3.8 * Main program, initializes dreamcast and gui, then passes control off to
3.9 * the gtk main loop (currently).
3.10 @@ -179,8 +179,16 @@
3.11
3.12 maple_reattach_all();
3.13 INFO( "%s! ready...", APP_NAME );
3.14 - if( optind < argc ) {
3.15 - file_load_magic( argv[optind] );
3.16 +
3.17 + for( ; optind < argc; optind++ ) {
3.18 + gboolean ok = gdrom_mount_image(argv[optind]);
3.19 + if( !ok ) {
3.20 + ok = file_load_magic( argv[optind] );
3.21 + }
3.22 + if( !ok ) {
3.23 + ERROR( "Unrecognized file '%s'", argv[optind] );
3.24 + }
3.25 + start_immediately = ok;
3.26 }
3.27
3.28 if( disc_file != NULL ) {
.