17 char ip_bin_magic[32] = "SEGA SEGAKATANA SEGA ENTERPRISES";
18 char iso_magic[6] = "\001CD001";
20 #define CDI_V2 0x80000004
21 #define CDI_V3 0x80000005
23 int open_file( const gchar *filename )
29 int fd = open( filename, O_RDONLY );
31 ERROR( "Unable to open file: '%s' (%s)", filename,
37 if( st.st_size < 32768 ) {
38 ERROR( "File '%s' too small to be a dreamcast image", filename );
44 if( read( fd, buf, 32 ) != 32 ) {
45 ERROR( "Unable to read from file '%s'", filename );
49 if( memcmp( buf, ip_bin_magic, 32 ) == 0 ) {
50 /* we have a DC bootstrap */
51 if( st.st_size == BOOTSTRAP_SIZE ) {
52 char *load = mem_get_region( BOOTSTRAP_LOAD_ADDR );
53 /* Just the bootstrap, no image... */
54 WARN( "File '%s' contains bootstrap only, loading anyway",
56 lseek( fd, 0, SEEK_SET );
57 read( fd, load, BOOTSTRAP_SIZE );
60 sh4_set_pc( BOOTSTRAP_LOAD_ADDR + 0x300 );
61 set_disassembly_region( main_debug, BOOTSTRAP_LOAD_ADDR );
62 set_disassembly_pc( main_debug, sh4r.pc, TRUE );
65 /* look for a valid ISO9660 header */
66 lseek( fd, 32768, SEEK_SET );
68 if( memcmp( buf, iso_magic, 6 ) == 0 ) {
70 INFO( "Loading ISO9660 filesystem from '%s'",
75 /* check if it's a CDI file: */
76 lseek( fd, -8, SEEK_END );
78 if( tmpa[0] == CDI_V2 || tmpa[0] == CDI_V3 ) {
80 INFO( "Loading CDI file '%s'", filename );
82 ERROR( "Don't know what to do with '%s'", filename );
89 int load_bin_file( const gchar *filename ) {
90 mem_load_block( filename, 0x8c010000, -1 );
91 sh4_set_pc( 0x8c010000 );
92 set_disassembly_region( main_debug, 0x8c010000 );
93 set_disassembly_pc( main_debug, sh4r.pc, TRUE );
94 pvr2_set_base_address( 0x00025940 );
.