Search
lxdream.org :: lxdream :: r88:0a1bd43fa4ad
lxdream 0.9.1
released Jun 29
Download Now
changeset88:0a1bd43fa4ad
parent87:11208d725b61
child89:939afb9f0f98
authornkeynes
dateSun Jan 22 22:41:40 2006 +0000 (18 years ago)
When loading a binary file, load IP.BIN before it to initialize everything
src/bootstrap.h
src/loader.c
1.1 --- a/src/bootstrap.h Sun Jan 22 22:40:53 2006 +0000
1.2 +++ b/src/bootstrap.h Sun Jan 22 22:41:40 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: bootstrap.h,v 1.2 2005-12-24 08:02:14 nkeynes Exp $
1.6 + * $Id: bootstrap.h,v 1.3 2006-01-22 22:41:40 nkeynes Exp $
1.7 *
1.8 * CD Bootstrap header parsing. Mostly for informational purposes.
1.9 *
1.10 @@ -26,6 +26,8 @@
1.11 extern "C" {
1.12 #endif
1.13
1.14 +#define DEFAULT_BOOTSTRAP_FILE "IP.BIN"
1.15 +
1.16 /**
1.17 * Dump the bootstrap info to the output log for infomational/debugging
1.18 * purposes.
2.1 --- a/src/loader.c Sun Jan 22 22:40:53 2006 +0000
2.2 +++ b/src/loader.c Sun Jan 22 22:41:40 2006 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: loader.c,v 1.8 2005-12-25 01:28:36 nkeynes Exp $
2.6 + * $Id: loader.c,v 1.9 2006-01-22 22:41:40 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 @@ -27,6 +27,7 @@
2.11 #include "sh4core.h"
2.12 #include "bootstrap.h"
2.13
2.14 +char *bootstrap_file = DEFAULT_BOOTSTRAP_FILE;
2.15 char bootstrap_magic[32] = "SEGA SEGAKATANA SEGA ENTERPRISES";
2.16 char iso_magic[6] = "\001CD001";
2.17 char *file_loader_extensions[][2] = {
2.18 @@ -54,13 +55,15 @@
2.19 strerror(errno) );
2.20 return FALSE;
2.21 }
2.22 -
2.23 +
2.24 fstat( fd, &st );
2.25 + /*
2.26 if( st.st_size < 32768 ) {
2.27 ERROR( "File '%s' too small to be a dreamcast image", filename );
2.28 close(fd);
2.29 return FALSE;
2.30 }
2.31 + */
2.32
2.33 /* begin magic */
2.34 if( read( fd, buf, 32 ) != 32 ) {
2.35 @@ -90,6 +93,9 @@
2.36 } else if( memcmp( buf, "PK\x03\x04", 4 ) == 0 ) {
2.37 /* ZIP file, aka SBI file */
2.38 WARN( "SBI files not supported yet" );
2.39 + } else if( memcpy( buf, "\x7fELF", 4 ) == 0 ) {
2.40 + /* ELF binary */
2.41 + WARN( "ELF files not supported yet" );
2.42 } else {
2.43 /* Assume raw binary */
2.44 file_load_binary( filename );
2.45 @@ -99,7 +105,16 @@
2.46 }
2.47
2.48 int file_load_binary( const gchar *filename ) {
2.49 + /* Load the binary itself */
2.50 mem_load_block( filename, BINARY_LOAD_ADDR, -1 );
2.51 - sh4_set_pc( BINARY_LOAD_ADDR );
2.52 + if( bootstrap_file != NULL ) {
2.53 + /* Load in a bootstrap before the binary, to initialize everything
2.54 + * correctly
2.55 + */
2.56 + mem_load_block( bootstrap_file, BOOTSTRAP_LOAD_ADDR, BOOTSTRAP_SIZE );
2.57 + sh4_set_pc( BOOTSTRAP_LOAD_ADDR + 0x300 );
2.58 + } else {
2.59 + sh4_set_pc( BINARY_LOAD_ADDR );
2.60 + }
2.61 gtk_gui_update();
2.62 }
.