Search
lxdream.org :: lxdream :: r461:63d4de8dcec6
lxdream 0.9.1
released Jun 29
Download Now
changeset461:63d4de8dcec6
parent460:a0c865b74c63
child462:9add12452876
authornkeynes
dateTue Oct 23 10:48:24 2007 +0000 (16 years ago)
Reload BIOS/flash when changed in configuration.
Fix mem_load_rom to deal with repeat loads and dodgy files
src/dreamcast.c
src/dreamcast.h
src/gui/path_dlg.c
src/mem.c
1.1 --- a/src/dreamcast.c Tue Oct 23 10:47:17 2007 +0000
1.2 +++ b/src/dreamcast.c Tue Oct 23 10:48:24 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: dreamcast.c,v 1.24 2007-10-17 11:26:45 nkeynes Exp $
1.6 + * $Id: dreamcast.c,v 1.25 2007-10-23 10:48:24 nkeynes Exp $
1.7 * Central switchboard for the system. This pulls all the individual modules
1.8 * together into some kind of coherent structure. This is also where you'd
1.9 * add Naomi support, if I ever get a board to play with...
1.10 @@ -85,6 +85,14 @@
1.11 dreamcast_register_module( &ide_module );
1.12 }
1.13
1.14 +void dreamcast_config_changed(void)
1.15 +{
1.16 + mem_load_rom( lxdream_get_config_value(CONFIG_BIOS_PATH),
1.17 + 0x00000000, 0x00200000, 0x89f2b1a1 );
1.18 + mem_load_block( lxdream_get_config_value(CONFIG_FLASH_PATH),
1.19 + 0x00200000, 0x00020000 );
1.20 +}
1.21 +
1.22 void dreamcast_save_flash()
1.23 {
1.24 const char *file = lxdream_get_config_value(CONFIG_FLASH_PATH);
2.1 --- a/src/dreamcast.h Tue Oct 23 10:47:17 2007 +0000
2.2 +++ b/src/dreamcast.h Tue Oct 23 10:48:24 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: dreamcast.h,v 1.18 2007-10-17 11:26:45 nkeynes Exp $
2.6 + * $Id: dreamcast.h,v 1.19 2007-10-23 10:48:24 nkeynes Exp $
2.7 *
2.8 * Public interface for dreamcast.c -
2.9 * Central switchboard for the system. This pulls all the individual modules
2.10 @@ -46,6 +46,7 @@
2.11 void dreamcast_run_for( unsigned int seconds, unsigned int nanosecs );
2.12 void dreamcast_stop(void);
2.13 void dreamcast_shutdown(void);
2.14 +void dreamcast_config_changed(void);
2.15 gboolean dreamcast_is_running(void);
2.16
2.17 #define DREAMCAST_SAVE_MAGIC "%!-lxDream!Save\0"
3.1 --- a/src/gui/path_dlg.c Tue Oct 23 10:47:17 2007 +0000
3.2 +++ b/src/gui/path_dlg.c Tue Oct 23 10:48:24 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: path_dlg.c,v 1.2 2007-10-21 05:21:35 nkeynes Exp $
3.6 + * $Id: path_dlg.c,v 1.3 2007-10-23 10:48:24 nkeynes Exp $
3.7 *
3.8 * Define the main (emu) GTK window, along with its menubars,
3.9 * toolbars, etc.
3.10 @@ -94,6 +94,7 @@
3.11 gtk_table_attach( GTK_TABLE(table), gtk_label_new(path_label[i]), 0, 1, i, i+1,
3.12 GTK_SHRINK, GTK_SHRINK, 0, 0);
3.13 gtk_entry_set_text( GTK_ENTRY(text), lxdream_get_config_value(path_id[i]) );
3.14 + gtk_entry_set_width_chars( GTK_ENTRY(text), 48 );
3.15 gtk_table_attach_defaults( GTK_TABLE(table), text, 1, 2, i, i+1 );
3.16 gtk_table_attach( GTK_TABLE(table), button, 2, 3, i, i+1, GTK_SHRINK, GTK_SHRINK, 0, 0 );
3.17 if( path_action[i] == GTK_FILE_CHOOSER_ACTION_OPEN ) {
3.18 @@ -110,32 +111,21 @@
3.19
3.20 }
3.21
3.22 -void path_panel_commit_changes()
3.23 +void path_panel_done( GtkWidget *panel, gboolean isOK )
3.24 {
3.25 - int i;
3.26 - for(i=0; i<5; i++ ) {
3.27 - const char *filename = gtk_entry_get_text( GTK_ENTRY(path_entry[i]) );
3.28 - lxdream_set_config_value( path_id[i], filename );
3.29 + if( isOK ) {
3.30 + int i;
3.31 + for(i=0; i<5; i++ ) {
3.32 + const char *filename = gtk_entry_get_text( GTK_ENTRY(path_entry[i]) );
3.33 + lxdream_set_global_config_value( path_id[i], filename );
3.34 + }
3.35 +
3.36 + lxdream_save_config();
3.37 + dreamcast_config_changed();
3.38 }
3.39 -
3.40 - lxdream_save_config();
3.41 }
3.42
3.43 void path_dialog_run( void )
3.44 {
3.45 - GtkWidget *dialog =
3.46 - gtk_dialog_new_with_buttons("Path Settings", NULL,
3.47 - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
3.48 - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
3.49 - GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
3.50 - NULL);
3.51 - gint result;
3.52 - GtkWidget *panel = path_panel_new();
3.53 - gtk_widget_show_all(panel);
3.54 - gtk_container_add( GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), panel );
3.55 - result = gtk_dialog_run( GTK_DIALOG(dialog) );
3.56 - if( result == GTK_RESPONSE_ACCEPT ) {
3.57 - path_panel_commit_changes();
3.58 - }
3.59 - gtk_widget_destroy( dialog );
3.60 + gtk_gui_run_property_dialog( "Path Settings", path_panel_new(), path_panel_done );
3.61 }
4.1 --- a/src/mem.c Tue Oct 23 10:47:17 2007 +0000
4.2 +++ b/src/mem.c Tue Oct 23 10:48:24 2007 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: mem.c,v 1.15 2007-10-06 08:59:42 nkeynes Exp $
4.6 + * $Id: mem.c,v 1.16 2007-10-23 10:48:24 nkeynes Exp $
4.7 * mem.c is responsible for creating and maintaining the overall system memory
4.8 * map, as visible from the SH4 processor.
4.9 *
4.10 @@ -270,18 +270,21 @@
4.11 char *mem;
4.12 int fd;
4.13 uint32_t calc_crc;
4.14 - fd = open( file, O_RDONLY );
4.15 - if( fd == -1 ) {
4.16 - ERROR( "Bios file not found: %s", file );
4.17 - return NULL;
4.18 +
4.19 + mem = mem_get_region(base);
4.20 + if( mem == NULL ) {
4.21 + mem = mmap( NULL, size, PROT_WRITE|PROT_READ, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0 );
4.22 + if( mem == MAP_FAILED ) {
4.23 + ERROR( "Unable to allocate ROM memory: %s (%s)", file, strerror(errno) );
4.24 + return NULL;
4.25 + }
4.26 + mem_map_region( mem, base, size, file, MEM_FLAG_ROM, size, base );
4.27 + } else {
4.28 + mprotect( mem, size, PROT_READ|PROT_WRITE );
4.29 }
4.30 - mem = mmap( NULL, size, PROT_READ, MAP_PRIVATE, fd, 0 );
4.31 - if( mem == MAP_FAILED ) {
4.32 - ERROR( "Unable to map bios file: %s (%s)", file, strerror(errno) );
4.33 - close(fd);
4.34 - return NULL;
4.35 - }
4.36 - mem_map_region( mem, base, size, file, MEM_FLAG_ROM, size, base );
4.37 +
4.38 + mem_load_block( file, base, size );
4.39 + mprotect( mem, size, PROT_READ );
4.40
4.41 /* CRC check */
4.42 calc_crc = crc32(0L, (unsigned char *)mem, size);
.