Search
lxdream.org :: lxdream :: r167:71c0cc416a64
lxdream 0.9.1
released Jun 29
Download Now
changeset167:71c0cc416a64
parent166:8aa70cf503a2
child168:203a72138e16
authornkeynes
dateMon Jun 19 11:00:42 2006 +0000 (13 years ago)
Add config value retrieval for pathnames
Implement default path for disc + save state loaders
Dump disc ID when mounting a CD
src/bootstrap.c
src/bootstrap.h
src/dreamcast.c
src/dreamcast.h
src/gdrom/gdrom.c
src/gui/callbacks.c
src/gui/gui.c
src/gui/gui.h
1.1 --- a/src/bootstrap.c Sun Jun 18 12:01:53 2006 +0000
1.2 +++ b/src/bootstrap.c Mon Jun 19 11:00:42 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: bootstrap.c,v 1.5 2005-12-26 03:54:52 nkeynes Exp $
1.6 + * $Id: bootstrap.c,v 1.6 2006-06-19 11:00:40 nkeynes Exp $
1.7 *
1.8 * CD Bootstrap header parsing. Mostly for informational purposes.
1.9 *
1.10 @@ -103,8 +103,10 @@
1.11 /**
1.12 * Dump the bootstrap info to the output log for infomational/debugging
1.13 * purposes.
1.14 + * @param detail true to include a ful information dump, false for just
1.15 + * the facts, maam.
1.16 */
1.17 -void bootstrap_dump( char *data )
1.18 +void bootstrap_dump( char *data, gboolean detail )
1.19 {
1.20 struct dc_bootstrap_head *head;
1.21 int i, got, periph, crc, hcrc;
1.22 @@ -118,42 +120,39 @@
1.23 for( i=127; i>0 && buf[i] == ' '; i-- );
1.24 buf[i] = '\0';
1.25 periph = strtol( head->peripherals, NULL, 16 );
1.26 - INFO( "Bootstrap Name: %s Author: %-16.16s",
1.27 + INFO( "Name: %s Author: %-16.16s",
1.28 buf, head->vendor_id );
1.29 sprintf( buf, "%4.4s", head->crc );
1.30 crc = compute_crc16(head);
1.31 hcrc = strtol( buf, NULL, 16 );
1.32 - emit( NULL, crc == hcrc ? EMIT_INFO : EMIT_WARN, "File",
1.33 - " Header CRC: %04X (Computed %04X)", hcrc, crc );
1.34 - INFO( " Boot File: %-16.16s", head->boot_file );
1.35 INFO( " Product ID: %-10.10s Product Ver: %-6.6s Date: %-8.8s",
1.36 head->product_id, head->product_ver, head->product_date );
1.37 - INFO( " Disc ID: %-11.11s Regions: %-8.8s Peripherals: %07X",
1.38 - head->gdrom_id, head->regions, periph );
1.39 - strcpy( buf, " Supports: " );
1.40 - got = 0;
1.41 - for( i=0; i<28; i++ ) {
1.42 - if( periph & (1<<i) ){
1.43 - if( got ) strcat( buf, ", " );
1.44 - strcat( buf, dc_peripherals[i] );
1.45 - got = 1;
1.46 - }
1.47 - if( i == 11 ) i = 23; /* Skip 8-23 */
1.48 + if( detail ) {
1.49 + emit( NULL, crc == hcrc ? EMIT_INFO : EMIT_WARN, "File",
1.50 + " Header CRC: %04X (Computed %04X)", hcrc, crc );
1.51 + INFO( " Boot File: %-16.16s", head->boot_file );
1.52 + INFO( " Disc ID: %-11.11s Regions: %-8.8s Peripherals: %07X",
1.53 + head->gdrom_id, head->regions, periph );
1.54 + strcpy( buf, " Supports: " );
1.55 + got = 0;
1.56 + for( i=0; i<28; i++ ) {
1.57 + if( periph & (1<<i) ){
1.58 + if( got ) strcat( buf, ", " );
1.59 + strcat( buf, dc_peripherals[i] );
1.60 + got = 1;
1.61 + }
1.62 + if( i == 11 ) i = 23; /* Skip 8-23 */
1.63 + }
1.64 + INFO( buf, NULL );
1.65 + strcpy( buf, " Requires: " );
1.66 + got = 0;
1.67 + for( i=12; i<24; i++ ) {
1.68 + if( periph & (1<<i) ) {
1.69 + if( got ) strcat( buf, ", " );
1.70 + strcat( buf, dc_peripherals[i] );
1.71 + got = 1;
1.72 + }
1.73 + }
1.74 + INFO( buf, NULL );
1.75 }
1.76 - INFO( buf, NULL );
1.77 - strcpy( buf, " Requires: " );
1.78 - got = 0;
1.79 - for( i=12; i<24; i++ ) {
1.80 - if( periph & (1<<i) ) {
1.81 - if( got ) strcat( buf, ", " );
1.82 - strcat( buf, dc_peripherals[i] );
1.83 - got = 1;
1.84 - }
1.85 - }
1.86 - INFO( buf, NULL );
1.87 -#if 0
1.88 - INFO( " Area protection symbols:", NULL );
1.89 - for( i=0; i<8; i++ )
1.90 - INFO( " %d: %28.28s", i, &prot_symbols[(i*32)+4] );
1.91 -#endif
1.92 }
2.1 --- a/src/bootstrap.h Sun Jun 18 12:01:53 2006 +0000
2.2 +++ b/src/bootstrap.h Mon Jun 19 11:00:42 2006 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: bootstrap.h,v 1.3 2006-01-22 22:41:40 nkeynes Exp $
2.6 + * $Id: bootstrap.h,v 1.4 2006-06-19 11:00:40 nkeynes Exp $
2.7 *
2.8 * CD Bootstrap header parsing. Mostly for informational purposes.
2.9 *
2.10 @@ -26,13 +26,13 @@
2.11 extern "C" {
2.12 #endif
2.13
2.14 -#define DEFAULT_BOOTSTRAP_FILE "IP.BIN"
2.15 +#include "dream.h"
2.16
2.17 /**
2.18 * Dump the bootstrap info to the output log for infomational/debugging
2.19 * purposes.
2.20 */
2.21 -void bootstrap_dump(char *data);
2.22 +void bootstrap_dump(char *data, gboolean detail);
2.23
2.24 #ifdef __cplusplus
2.25 }
3.1 --- a/src/dreamcast.c Sun Jun 18 12:01:53 2006 +0000
3.2 +++ b/src/dreamcast.c Mon Jun 19 11:00:42 2006 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: dreamcast.c,v 1.16 2006-05-20 02:38:58 nkeynes Exp $
3.6 + * $Id: dreamcast.c,v 1.17 2006-06-19 11:00:40 nkeynes Exp $
3.7 * Central switchboard for the system. This pulls all the individual modules
3.8 * together into some kind of coherent structure. This is also where you'd
3.9 * add Naomi support, if I ever get a board to play with...
3.10 @@ -66,10 +66,11 @@
3.11 mem_create_ram_region( 0x00800000, 2 MB, MEM_REGION_AUDIO );
3.12 mem_create_ram_region( 0x00703000, 8 KB, MEM_REGION_AUDIO_SCRATCH );
3.13 mem_create_ram_region( 0x05000000, 8 MB, MEM_REGION_VIDEO );
3.14 - mem_load_rom( "dcboot.rom", 0x00000000, 0x00200000, 0x89f2b1a1 );
3.15 + mem_load_rom( dreamcast_get_config_value(CONFIG_BIOS_PATH),
3.16 + 0x00000000, 0x00200000, 0x89f2b1a1 );
3.17 mem_create_ram_region( 0x00200000, 0x00020000, MEM_REGION_FLASH );
3.18 - mem_load_block( "../bios/dcflash.rom", 0x00200000, 0x00020000 );
3.19 - // mem_load_rom( "dcflash.rom",0x00200000, 0x00020000, 0x357c3568 );
3.20 + mem_load_block( dreamcast_get_config_value(CONFIG_FLASH_PATH),
3.21 + 0x00200000, 0x00020000 );
3.22
3.23 /* Load in the rest of the core modules */
3.24 dreamcast_register_module( &sh4_module );
3.25 @@ -78,14 +79,6 @@
3.26 dreamcast_register_module( &aica_module );
3.27 dreamcast_register_module( &maple_module );
3.28 dreamcast_register_module( &ide_module );
3.29 -
3.30 - /* Attach any default maple devices, ie a pair of controllers */
3.31 - /*
3.32 - maple_device_t controller1 = maple_new_device("Sega Controller");
3.33 - maple_device_t controller2 = maple_new_device("Sega Controller");
3.34 - maple_attach_device( controller1, 0, 0 );
3.35 - maple_attach_device( controller2, 1, 0 );
3.36 - */
3.37 }
3.38
3.39 /**
3.40 @@ -164,6 +157,7 @@
3.41
3.42 /***************************** User Configuration **************************/
3.43
3.44 +
3.45 static struct dreamcast_config_entry global_config[] =
3.46 {{ "bios", CONFIG_TYPE_FILE, "dcboot.rom" },
3.47 { "flash", CONFIG_TYPE_FILE, "dcflash.rom" },
3.48 @@ -202,6 +196,11 @@
3.49 maple_detach_all();
3.50 }
3.51
3.52 +const gchar *dreamcast_get_config_value( int key )
3.53 +{
3.54 + return global_config[key].value;
3.55 +}
3.56 +
3.57 gboolean dreamcast_load_config( const gchar *filename )
3.58 {
3.59 FILE *f = fopen(filename, "ro");
4.1 --- a/src/dreamcast.h Sun Jun 18 12:01:53 2006 +0000
4.2 +++ b/src/dreamcast.h Mon Jun 19 11:00:42 2006 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: dreamcast.h,v 1.9 2006-05-15 08:28:48 nkeynes Exp $
4.6 + * $Id: dreamcast.h,v 1.10 2006-06-19 11:00:40 nkeynes Exp $
4.7 *
4.8 * Public interface for dreamcast.c -
4.9 * Central switchboard for the system. This pulls all the individual modules
4.10 @@ -63,6 +63,14 @@
4.11
4.12 extern struct dreamcast_config_group dreamcast_config_root[];
4.13
4.14 +/* Global config values */
4.15 +const gchar *dreamcast_get_config_value( int key );
4.16 +#define CONFIG_BIOS_PATH 0
4.17 +#define CONFIG_FLASH_PATH 1
4.18 +#define CONFIG_DEFAULT_PATH 2
4.19 +#define CONFIG_SAVE_PATH 3
4.20 +#define CONFIG_BOOTSTRAP 4
4.21 +
4.22 #ifdef __cplusplus
4.23 }
4.24 #endif
5.1 --- a/src/gdrom/gdrom.c Sun Jun 18 12:01:53 2006 +0000
5.2 +++ b/src/gdrom/gdrom.c Mon Jun 19 11:00:42 2006 +0000
5.3 @@ -1,5 +1,5 @@
5.4 /**
5.5 - * $Id: gdrom.c,v 1.7 2006-06-15 10:32:42 nkeynes Exp $
5.6 + * $Id: gdrom.c,v 1.8 2006-06-19 11:00:42 nkeynes Exp $
5.7 *
5.8 * GD-Rom access functions.
5.9 *
5.10 @@ -124,15 +124,35 @@
5.11 }
5.12
5.13
5.14 -void gdrom_dump_disc( gdrom_disc_t disc ) {
5.15 +void gdrom_dump_disc_info( gdrom_disc_t disc ) {
5.16 int i;
5.17 + int last_session = disc->track[disc->track_count-1].session;
5.18 + gboolean is_bootable = FALSE;
5.19 +
5.20 INFO( "Disc ID: %s, %d tracks in %d sessions", disc->mcn, disc->track_count,
5.21 disc->track[disc->track_count-1].session + 1 );
5.22 - for( i=0; i<disc->track_count; i++ ) {
5.23 - INFO( "Sess %d Trk %d: Start %06X Length %06X, %s",
5.24 - disc->track[i].session+1, i+1, disc->track[i].lba,
5.25 - disc->track[i].sector_count, gdrom_mode_names[disc->track[i].mode] );
5.26 + if( last_session > 0 ) {
5.27 + /* Boot track is the first data track of the last session, provided that it
5.28 + * cannot be a single-session disc.
5.29 + */
5.30 + int boot_track = -1;
5.31 + for( i=disc->track_count-1; i>=0 && disc->track[i].session == last_session; i-- ) {
5.32 + if( disc->track[i].flags & TRACK_DATA ) {
5.33 + boot_track = i;
5.34 + }
5.35 + }
5.36 + if( boot_track != -1 ) {
5.37 + char boot_sector[2048];
5.38 + uint32_t length = sizeof(boot_sector);
5.39 + if( disc->read_sectors( disc, disc->track[boot_track].lba, 1, GDROM_MODE1,
5.40 + boot_sector, &length ) == PKT_ERR_OK ) {
5.41 + bootstrap_dump(boot_sector, FALSE);
5.42 + is_bootable = TRUE;
5.43 + }
5.44 + }
5.45 }
5.46 + if( !is_bootable )
5.47 + WARN( "Disc does not appear to be bootable" );
5.48 }
5.49
5.50 gdrom_error_t gdrom_get_toc( char *buf )
5.51 @@ -192,7 +212,7 @@
5.52 gdrom_unmount_disc();
5.53 gdrom_disc = disc;
5.54 idereg.disc = disc->disc_type | IDE_DISC_READY;
5.55 - gdrom_dump_disc( disc );
5.56 + gdrom_dump_disc_info( disc );
5.57 }
5.58
5.59 gdrom_disc_t gdrom_mount_image( const gchar *filename )
6.1 --- a/src/gui/callbacks.c Sun Jun 18 12:01:53 2006 +0000
6.2 +++ b/src/gui/callbacks.c Mon Jun 19 11:00:42 2006 +0000
6.3 @@ -1,5 +1,5 @@
6.4 /**
6.5 - * $Id: callbacks.c,v 1.14 2006-04-30 01:51:29 nkeynes Exp $
6.6 + * $Id: callbacks.c,v 1.15 2006-06-19 11:00:42 nkeynes Exp $
6.7 *
6.8 * All GTK callbacks go here (stubs are autogenerated by Glade)
6.9 *
6.10 @@ -45,7 +45,8 @@
6.11 on_open1_activate (GtkMenuItem *menuitem,
6.12 gpointer user_data)
6.13 {
6.14 - open_file_dialog( "Open...", file_load_magic, NULL, NULL );
6.15 + const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
6.16 + open_file_dialog( "Open...", file_load_magic, NULL, NULL, dir );
6.17 }
6.18
6.19
6.20 @@ -94,7 +95,8 @@
6.21 on_load_btn_clicked (GtkButton *button,
6.22 gpointer user_data)
6.23 {
6.24 - open_file_dialog( "Open...", gdrom_mount_image, NULL, NULL );
6.25 + const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
6.26 + open_file_dialog( "Open...", gdrom_mount_image, NULL, NULL, dir );
6.27 }
6.28
6.29
6.30 @@ -320,7 +322,8 @@
6.31 on_loadstate_button_clicked (GtkToolButton *toolbutton,
6.32 gpointer user_data)
6.33 {
6.34 - open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "DreamOn Save State (*.dst)" );
6.35 + const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
6.36 + open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "DreamOn Save State (*.dst)", dir );
6.37 }
6.38
6.39
6.40 @@ -328,6 +331,7 @@
6.41 on_savestate_button_clicked (GtkToolButton *toolbutton,
6.42 gpointer user_data)
6.43 {
6.44 - save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "DreamOn Save State (*.dst)" );
6.45 + const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
6.46 + save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "DreamOn Save State (*.dst)", dir );
6.47 }
6.48
7.1 --- a/src/gui/gui.c Sun Jun 18 12:01:53 2006 +0000
7.2 +++ b/src/gui/gui.c Mon Jun 19 11:00:42 2006 +0000
7.3 @@ -1,5 +1,5 @@
7.4 /**
7.5 - * $Id: gui.c,v 1.11 2006-03-15 13:17:23 nkeynes Exp $
7.6 + * $Id: gui.c,v 1.12 2006-06-19 11:00:42 nkeynes Exp $
7.7 *
7.8 * Top-level GUI (GTK2) module.
7.9 *
7.10 @@ -166,10 +166,10 @@
7.11 }
7.12 }
7.13
7.14 -void open_file_dialog( char *title, file_callback_t action, char *pattern, char *patname )
7.15 +void open_file_dialog( char *title, file_callback_t action, char *pattern, char *patname,
7.16 + gchar const *initial_dir )
7.17 {
7.18 GtkWidget *file;
7.19 -
7.20 file = gtk_file_chooser_dialog_new( title, NULL,
7.21 GTK_FILE_CHOOSER_ACTION_OPEN,
7.22 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
7.23 @@ -179,13 +179,14 @@
7.24 g_signal_connect( GTK_OBJECT(file), "response",
7.25 GTK_SIGNAL_FUNC(open_file_callback), file );
7.26 gtk_object_set_data( GTK_OBJECT(file), "file_action", action );
7.27 + gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file), initial_dir );
7.28 gtk_widget_show( file );
7.29 }
7.30
7.31 -void save_file_dialog( char *title, file_callback_t action, char *pattern, char *patname )
7.32 +void save_file_dialog( char *title, file_callback_t action, char *pattern, char *patname,
7.33 + gchar const *initial_dir )
7.34 {
7.35 GtkWidget *file;
7.36 -
7.37 file = gtk_file_chooser_dialog_new( title, NULL,
7.38 GTK_FILE_CHOOSER_ACTION_SAVE,
7.39 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
7.40 @@ -195,6 +196,7 @@
7.41 g_signal_connect( GTK_OBJECT(file), "response",
7.42 GTK_SIGNAL_FUNC(open_file_callback), file );
7.43 gtk_object_set_data( GTK_OBJECT(file), "file_action", action );
7.44 + gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file), initial_dir );
7.45 gtk_widget_show( file );
7.46 }
7.47
8.1 --- a/src/gui/gui.h Sun Jun 18 12:01:53 2006 +0000
8.2 +++ b/src/gui/gui.h Mon Jun 19 11:00:42 2006 +0000
8.3 @@ -1,5 +1,5 @@
8.4 /**
8.5 - * $Id: gui.h,v 1.14 2005-12-27 08:41:22 nkeynes Exp $
8.6 + * $Id: gui.h,v 1.15 2006-06-19 11:00:42 nkeynes Exp $
8.7 *
8.8 * General GUI definitions
8.9 *
8.10 @@ -39,8 +39,8 @@
8.11 extern debug_info_t main_debug;
8.12
8.13 typedef int (*file_callback_t)( const gchar *filename );
8.14 -void open_file_dialog( char *title, file_callback_t file_handler, char *pattern, char *patname );
8.15 -void save_file_dialog( char *title, file_callback_t file_handler, char *pattern, char *patname );
8.16 +void open_file_dialog( char *title, file_callback_t file_handler, char *pattern, char *patname, const gchar *initial_dir );
8.17 +void save_file_dialog( char *title, file_callback_t file_handler, char *pattern, char *patname, const gchar *initial_dir );
8.18
8.19 void update_mmr_win( void );
8.20 void init_mmr_win( void );
.