Search
lxdream.org :: lxdream/src/loader.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/loader.c
changeset 88:0a1bd43fa4ad
prev27:1ef09a52cd1e
next93:bb1def61e901
author nkeynes
date Sun Jan 22 22:41:40 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change When loading a binary file, load IP.BIN before it to initialize everything
file annotate diff log raw
1.1 --- a/src/loader.c Sun Dec 25 01:28:39 2005 +0000
1.2 +++ b/src/loader.c Sun Jan 22 22:41:40 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: loader.c,v 1.8 2005-12-25 01:28:36 nkeynes Exp $
1.6 + * $Id: loader.c,v 1.9 2006-01-22 22:41:40 nkeynes Exp $
1.7 *
1.8 * File loading routines, mostly for loading demos without going through the
1.9 * whole procedure of making a CD image for them.
1.10 @@ -27,6 +27,7 @@
1.11 #include "sh4core.h"
1.12 #include "bootstrap.h"
1.13
1.14 +char *bootstrap_file = DEFAULT_BOOTSTRAP_FILE;
1.15 char bootstrap_magic[32] = "SEGA SEGAKATANA SEGA ENTERPRISES";
1.16 char iso_magic[6] = "\001CD001";
1.17 char *file_loader_extensions[][2] = {
1.18 @@ -54,13 +55,15 @@
1.19 strerror(errno) );
1.20 return FALSE;
1.21 }
1.22 -
1.23 +
1.24 fstat( fd, &st );
1.25 + /*
1.26 if( st.st_size < 32768 ) {
1.27 ERROR( "File '%s' too small to be a dreamcast image", filename );
1.28 close(fd);
1.29 return FALSE;
1.30 }
1.31 + */
1.32
1.33 /* begin magic */
1.34 if( read( fd, buf, 32 ) != 32 ) {
1.35 @@ -90,6 +93,9 @@
1.36 } else if( memcmp( buf, "PK\x03\x04", 4 ) == 0 ) {
1.37 /* ZIP file, aka SBI file */
1.38 WARN( "SBI files not supported yet" );
1.39 + } else if( memcpy( buf, "\x7fELF", 4 ) == 0 ) {
1.40 + /* ELF binary */
1.41 + WARN( "ELF files not supported yet" );
1.42 } else {
1.43 /* Assume raw binary */
1.44 file_load_binary( filename );
1.45 @@ -99,7 +105,16 @@
1.46 }
1.47
1.48 int file_load_binary( const gchar *filename ) {
1.49 + /* Load the binary itself */
1.50 mem_load_block( filename, BINARY_LOAD_ADDR, -1 );
1.51 - sh4_set_pc( BINARY_LOAD_ADDR );
1.52 + if( bootstrap_file != NULL ) {
1.53 + /* Load in a bootstrap before the binary, to initialize everything
1.54 + * correctly
1.55 + */
1.56 + mem_load_block( bootstrap_file, BOOTSTRAP_LOAD_ADDR, BOOTSTRAP_SIZE );
1.57 + sh4_set_pc( BOOTSTRAP_LOAD_ADDR + 0x300 );
1.58 + } else {
1.59 + sh4_set_pc( BINARY_LOAD_ADDR );
1.60 + }
1.61 gtk_gui_update();
1.62 }
.