Search
lxdream.org :: lxdream/src/dreamcast.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/dreamcast.c
changeset 1100:50e702af9373
prev1072:d82e04e6d497
next1109:700c5ab26a63
author nkeynes
date Mon Feb 15 17:27:14 2010 +1000 (10 years ago)
permissions -rw-r--r--
last change Hook up the fake bios boot
Use fakebios if invoked with -b, or if there's no boot rom loaded
file annotate diff log raw
1.1 --- a/src/dreamcast.c Tue Jul 21 20:33:21 2009 +1000
1.2 +++ b/src/dreamcast.c Mon Feb 15 17:27:14 2010 +1000
1.3 @@ -43,6 +43,7 @@
1.4 STATE_STOPPING, STATE_STOPPED } dreamcast_state_t;
1.5
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 in
1.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.23
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.35
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.46
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.67
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.75
1.76 @@ -326,8 +350,7 @@
1.77
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.84
1.85 /********************************* Save States *****************************/
.