16 char ip_bin_magic[32] = "SEGA SEGAKATANA SEGA ENTERPRISES";
17 char iso_magic[6] = "\001CD001";
19 #define CDI_V2 0x80000004
20 #define CDI_V3 0x80000005
22 void open_file( char *filename )
28 int fd = open( filename, O_RDONLY );
30 ERROR( "Unable to open file: '%s' (%s)", filename,
36 if( st.st_size < 32768 ) {
37 ERROR( "File '%s' too small to be a dreamcast image", filename );
43 if( read( fd, buf, 32 ) != 32 ) {
44 ERROR( "Unable to read from file '%s'", filename );
48 if( memcmp( buf, ip_bin_magic, 32 ) == 0 ) {
49 /* we have a DC bootstrap */
50 if( st.st_size == BOOTSTRAP_SIZE ) {
51 char *load = mem_get_region( BOOTSTRAP_LOAD_ADDR );
52 /* Just the bootstrap, no image... */
53 WARN( "File '%s' contains bootstrap only, loading anyway",
55 lseek( fd, 0, SEEK_SET );
56 read( fd, load, BOOTSTRAP_SIZE );
59 sh4_set_pc( BOOTSTRAP_LOAD_ADDR + 0x300 );
60 set_disassembly_region( main_debug, BOOTSTRAP_LOAD_ADDR );
61 set_disassembly_pc( main_debug, sh4r.pc, TRUE );
64 /* look for a valid ISO9660 header */
65 lseek( fd, 32768, SEEK_SET );
67 if( memcmp( buf, iso_magic, 6 ) == 0 ) {
69 INFO( "Loading ISO9660 filesystem from '%s'",
74 /* check if it's a CDI file: */
75 lseek( fd, -8, SEEK_END );
77 if( tmpa[0] == CDI_V2 || tmpa[0] == CDI_V3 ) {
79 INFO( "Loading CDI file '%s'", filename );
81 ERROR( "Don't know what to do with '%s'", filename );
.