filename | src/dreamcast.c |
changeset | 1100:50e702af9373 |
prev | 1072:d82e04e6d497 |
next | 1109:700c5ab26a63 |
author | nkeynes |
date | Fri Jun 04 09:13:40 2010 +1000 (13 years ago) |
permissions | -rw-r--r-- |
last change | Add ability to wrap a binary program up in a virtual cd image (so that we can boot it normally) |
file | annotate | diff | log | raw |
1.1 --- a/src/dreamcast.c Tue Jul 21 20:33:21 2009 +10001.2 +++ b/src/dreamcast.c Fri Jun 04 09:13:40 2010 +10001.3 @@ -43,6 +43,7 @@1.4 STATE_STOPPING, STATE_STOPPED } dreamcast_state_t;1.6 static volatile dreamcast_state_t dreamcast_state = STATE_UNINIT;1.7 +static gboolean dreamcast_use_bios = TRUE;1.8 static gboolean dreamcast_has_bios = FALSE;1.9 static gboolean dreamcast_has_flash = FALSE;1.10 static gboolean dreamcast_exit_on_stop = FALSE;1.11 @@ -86,7 +87,7 @@1.12 * Note currently the locations of the various MMIO pages are hard coded in1.13 * the MMIO definitions - they should probably be moved here.1.14 */1.15 -void dreamcast_configure( )1.16 +void dreamcast_configure( gboolean use_bootrom )1.17 {1.18 char *bios_path = lxdream_get_global_config_path_value(CONFIG_BIOS_PATH);1.19 char *flash_path = lxdream_get_global_config_path_value(CONFIG_FLASH_PATH);1.20 @@ -108,7 +109,12 @@1.21 mem_map_region( NULL, 0x11000000, 16 MB, MEM_REGION_PVR2VDMA1, &mem_region_pvr2vdma1, 0, 16 MB, 0 );1.22 mem_map_region( NULL, 0x13000000, 16 MB, MEM_REGION_PVR2VDMA2, &mem_region_pvr2vdma2, 0, 16 MB, 0 );1.24 - dreamcast_has_bios = mem_load_rom( dc_boot_rom, bios_path, 2 MB, 0x89f2b1a1 );1.25 + dreamcast_use_bios = use_bootrom;1.26 + dreamcast_has_bios = dreamcast_load_bios( bios_path );1.27 + if( !dreamcast_has_bios ) {1.28 + dreamcast_load_fakebios();1.29 + }1.30 +1.31 if( flash_path != NULL && flash_path[0] != '\0' ) {1.32 mem_load_block( flash_path, 0x00200000, 0x00020000 );1.33 }1.34 @@ -128,10 +134,28 @@1.36 gboolean dreamcast_load_bios( const gchar *filename )1.37 {1.38 - dreamcast_has_bios = mem_load_rom( dc_boot_rom, filename, 2 MB, 0x89f2b1a1 );1.39 + if( dreamcast_use_bios ) {1.40 + dreamcast_has_bios = mem_load_rom( dc_boot_rom, filename, 2 MB, 0x89f2b1a1 );1.41 + } else {1.42 + dreamcast_has_bios = FALSE;1.43 + }1.44 return dreamcast_has_bios;1.45 }1.47 +static const char fakebios[] = {1.48 + 0x00, 0xd1, /* movl $+4, r1 */1.49 + 0x2b, 0x41, /* jmp @r1 */1.50 + 0xa0, 0xff, /* .long 0xffffffa0 */1.51 + 0xff, 0xff };1.52 +gboolean dreamcast_load_fakebios( )1.53 +{1.54 + memset( dc_boot_rom, 0, 2 MB );1.55 + memcpy( dc_boot_rom, fakebios, sizeof(fakebios) );1.56 + syscall_add_hook( 0xA0, bios_boot );1.57 + dreamcast_has_bios = TRUE;1.58 + return TRUE;1.59 +}1.60 +1.61 gboolean dreamcast_load_flash( const gchar *filename )1.62 {1.63 if( filename != NULL && filename[0] != '\0' ) {1.64 @@ -201,9 +225,9 @@1.65 dreamcast_exit_on_stop = flag;1.66 }1.68 -void dreamcast_init( void )1.69 +void dreamcast_init( gboolean use_bootrom )1.70 {1.71 - dreamcast_configure();1.72 + dreamcast_configure( use_bootrom );1.73 dreamcast_state = STATE_STOPPED;1.74 }1.76 @@ -326,8 +350,7 @@1.78 gboolean dreamcast_can_run(void)1.79 {1.80 - return dreamcast_state != STATE_UNINIT &&1.81 - (dreamcast_has_bios || dreamcast_program_name != NULL);1.82 + return dreamcast_state != STATE_UNINIT;1.83 }1.85 /********************************* Save States *****************************/
.