Search
lxdream.org :: lxdream :: r18:9a1b5d75703f
lxdream 0.9.1
released Jun 29
Download Now
changeset18:9a1b5d75703f
parent17:944f75eea496
child19:9da7a8e38f9d
authornkeynes
dateThu Dec 15 13:33:14 2005 +0000 (14 years ago)
Implement save states
dream.glade
src/dreamcast.c
src/dreamcast.h
src/gui/callbacks.c
src/gui/callbacks.h
src/gui/gui.c
src/gui/gui.h
src/gui/interface.c
src/loader.c
src/mem.c
src/mem.h
src/sh4/sh4core.c
1.1 --- a/dream.glade Tue Dec 13 14:47:59 2005 +0000
1.2 +++ b/dream.glade Thu Dec 15 13:33:14 2005 +0000
1.3 @@ -202,10 +202,10 @@
1.4 <child>
1.5 <widget class="GtkToolButton" id="load_btn">
1.6 <property name="visible">True</property>
1.7 - <property name="tooltip" translatable="yes">New File</property>
1.8 - <property name="label" translatable="yes">Load</property>
1.9 + <property name="tooltip" translatable="yes">Mount CD-Rom</property>
1.10 + <property name="label" translatable="yes">Mount</property>
1.11 <property name="use_underline">True</property>
1.12 - <property name="stock_id">gtk-open</property>
1.13 + <property name="stock_id">gtk-cdrom</property>
1.14 <property name="visible_horizontal">True</property>
1.15 <property name="visible_vertical">True</property>
1.16 <property name="is_important">False</property>
1.17 @@ -220,7 +220,7 @@
1.18 <child>
1.19 <widget class="GtkToolButton" id="reset_btn">
1.20 <property name="visible">True</property>
1.21 - <property name="tooltip" translatable="yes">Open File</property>
1.22 + <property name="tooltip" translatable="yes">Reset emulator</property>
1.23 <property name="label" translatable="yes">Reset</property>
1.24 <property name="use_underline">True</property>
1.25 <property name="stock_id">gtk-refresh</property>
1.26 @@ -238,7 +238,7 @@
1.27 <child>
1.28 <widget class="GtkToolButton" id="stop_btn">
1.29 <property name="visible">True</property>
1.30 - <property name="tooltip" translatable="yes">Save File</property>
1.31 + <property name="tooltip" translatable="yes">Stop</property>
1.32 <property name="label" translatable="yes">Stop</property>
1.33 <property name="use_underline">True</property>
1.34 <property name="stock_id">gtk-stop</property>
1.35 @@ -256,6 +256,7 @@
1.36 <child>
1.37 <widget class="GtkToolButton" id="step_btn">
1.38 <property name="visible">True</property>
1.39 + <property name="tooltip" translatable="yes">Single step</property>
1.40 <property name="label" translatable="yes">Step</property>
1.41 <property name="use_underline">True</property>
1.42 <property name="stock_id">gtk-redo</property>
1.43 @@ -273,6 +274,7 @@
1.44 <child>
1.45 <widget class="GtkToolButton" id="run_btn">
1.46 <property name="visible">True</property>
1.47 + <property name="tooltip" translatable="yes">Run</property>
1.48 <property name="label" translatable="yes">Run</property>
1.49 <property name="use_underline">True</property>
1.50 <property name="stock_id">gtk-go-forward</property>
1.51 @@ -290,6 +292,7 @@
1.52 <child>
1.53 <widget class="GtkToolButton" id="runto_btn">
1.54 <property name="visible">True</property>
1.55 + <property name="tooltip" translatable="yes">Run to current selection</property>
1.56 <property name="label" translatable="yes">Run to</property>
1.57 <property name="use_underline">True</property>
1.58 <property name="stock_id">gtk-goto-last</property>
1.59 @@ -307,6 +310,7 @@
1.60 <child>
1.61 <widget class="GtkToolButton" id="break_btn">
1.62 <property name="visible">True</property>
1.63 + <property name="tooltip" translatable="yes">Set breakpoint</property>
1.64 <property name="label" translatable="yes">Break</property>
1.65 <property name="use_underline">True</property>
1.66 <property name="stock_id">gtk-close</property>
1.67 @@ -320,6 +324,42 @@
1.68 <property name="homogeneous">True</property>
1.69 </packing>
1.70 </child>
1.71 +
1.72 + <child>
1.73 + <widget class="GtkToolButton" id="loadstate_button">
1.74 + <property name="visible">True</property>
1.75 + <property name="tooltip" translatable="yes">Load save-state file</property>
1.76 + <property name="label" translatable="yes">Load</property>
1.77 + <property name="use_underline">True</property>
1.78 + <property name="stock_id">gtk-open</property>
1.79 + <property name="visible_horizontal">True</property>
1.80 + <property name="visible_vertical">True</property>
1.81 + <property name="is_important">False</property>
1.82 + <signal name="clicked" handler="on_loadstate_button_clicked" last_modification_time="Thu, 15 Dec 2005 09:36:10 GMT"/>
1.83 + </widget>
1.84 + <packing>
1.85 + <property name="expand">False</property>
1.86 + <property name="homogeneous">True</property>
1.87 + </packing>
1.88 + </child>
1.89 +
1.90 + <child>
1.91 + <widget class="GtkToolButton" id="savestate_button">
1.92 + <property name="visible">True</property>
1.93 + <property name="tooltip" translatable="yes">Save save-state file</property>
1.94 + <property name="label" translatable="yes">Save</property>
1.95 + <property name="use_underline">True</property>
1.96 + <property name="stock_id">gtk-save</property>
1.97 + <property name="visible_horizontal">True</property>
1.98 + <property name="visible_vertical">True</property>
1.99 + <property name="is_important">False</property>
1.100 + <signal name="clicked" handler="on_savestate_button_clicked" last_modification_time="Thu, 15 Dec 2005 09:36:23 GMT"/>
1.101 + </widget>
1.102 + <packing>
1.103 + <property name="expand">False</property>
1.104 + <property name="homogeneous">True</property>
1.105 + </packing>
1.106 + </child>
1.107 </widget>
1.108 </child>
1.109 </widget>
1.110 @@ -479,7 +519,7 @@
1.111 <property name="editable">False</property>
1.112 <property name="visibility">True</property>
1.113 <property name="max_length">0</property>
1.114 - <property name="text" translatable="yes">SH4</property>
1.115 + <property name="text" translatable="yes"></property>
1.116 <property name="has_frame">True</property>
1.117 <property name="invisible_char">*</property>
1.118 <property name="activates_default">False</property>
2.1 --- a/src/dreamcast.c Tue Dec 13 14:47:59 2005 +0000
2.2 +++ b/src/dreamcast.c Thu Dec 15 13:33:14 2005 +0000
2.3 @@ -1,3 +1,4 @@
2.4 +#include <errno.h>
2.5 #include "dream.h"
2.6 #include "mem.h"
2.7 #include "aica/aica.h"
2.8 @@ -98,13 +99,17 @@
2.9 };
2.10
2.11
2.12 -int dreamcast_load_state( FILE *f )
2.13 +int dreamcast_load_state( const gchar *filename )
2.14 {
2.15 int i,j;
2.16 uint32_t count, len;
2.17 int have_read[MAX_MODULES];
2.18 char tmp[64];
2.19 struct save_state_header header;
2.20 + FILE *f;
2.21 +
2.22 + f = fopen( filename, "r" );
2.23 + if( f == NULL ) return errno;
2.24
2.25 fread( &header, sizeof(header), 1, f );
2.26 if( strncmp( header.magic, DREAMCAST_SAVE_MAGIC, 16 ) != 0 ) {
2.27 @@ -115,24 +120,23 @@
2.28 ERROR( "DreamOn save state version not supported" );
2.29 return 1;
2.30 }
2.31 - fread( &count, sizeof(count), 1, f );
2.32 - if( count > MAX_MODULES ) {
2.33 - ERROR( "DreamOn save state is corrupted" );
2.34 + if( header.module_count > MAX_MODULES ) {
2.35 + ERROR( "DreamOn save state is corrupted (bad module count)" );
2.36 return 1;
2.37 }
2.38 for( i=0; i<MAX_MODULES; i++ ) {
2.39 have_read[i] = 0;
2.40 }
2.41
2.42 - for( i=0; i<count; i++ ) {
2.43 + for( i=0; i<header.module_count; i++ ) {
2.44 fread(tmp, 4, 1, f );
2.45 - if( strcmp(tmp, "BLCK") != 0 ) {
2.46 - ERROR( "DreamOn save state is corrupted" );
2.47 + if( strncmp(tmp, "BLCK", 4) != 0 ) {
2.48 + ERROR( "DreamOn save state is corrupted (missing block header %d)", i );
2.49 return 2;
2.50 }
2.51 len = fread_string(tmp, sizeof(tmp), f );
2.52 if( len > 64 || len < 1 ) {
2.53 - ERROR( "DreamOn save state is corrupted" );
2.54 + ERROR( "DreamOn save state is corrupted (bad string)" );
2.55 return 2;
2.56 }
2.57
2.58 @@ -141,10 +145,10 @@
2.59 if( strcmp(modules[j]->name,tmp) == 0 ) {
2.60 have_read[j] = 1;
2.61 if( modules[j]->load == NULL ) {
2.62 - ERROR( "DreamOn save state is corrupted" );
2.63 + ERROR( "DreamOn save state is corrupted (no loader for %s)", modules[j]->name );
2.64 return 2;
2.65 } else if( modules[j]->load(f) != 0 ) {
2.66 - ERROR( "DreamOn save state is corrupted" );
2.67 + ERROR( "DreamOn save state is corrupted (%s failed)", modules[j]->name );
2.68 return 2;
2.69 }
2.70 break;
2.71 @@ -165,18 +169,28 @@
2.72 modules[j]->reset();
2.73 }
2.74 }
2.75 + fclose(f);
2.76 + INFO( "Save state read from %s", filename );
2.77 }
2.78
2.79 -void dreamcast_save_state( FILE *f )
2.80 +int dreamcast_save_state( const gchar *filename )
2.81 {
2.82 int i;
2.83 + FILE *f;
2.84 struct save_state_header header;
2.85
2.86 + f = fopen( filename, "w" );
2.87 + if( f == NULL )
2.88 + return errno;
2.89 strcpy( header.magic, DREAMCAST_SAVE_MAGIC );
2.90 header.version = DREAMCAST_SAVE_VERSION;
2.91 - header.module_count = num_modules;
2.92 + header.module_count = 0;
2.93 +
2.94 + for( i=0; i<num_modules; i++ ) {
2.95 + if( modules[i]->save != NULL )
2.96 + header.module_count++;
2.97 + }
2.98 fwrite( &header, sizeof(header), 1, f );
2.99 - fwrite_string( dreamcast_config, f );
2.100 for( i=0; i<num_modules; i++ ) {
2.101 if( modules[i]->save != NULL ) {
2.102 fwrite( "BLCK", 4, 1, f );
2.103 @@ -184,5 +198,7 @@
2.104 modules[i]->save(f);
2.105 }
2.106 }
2.107 + fclose( f );
2.108 + INFO( "Save state written to %s", filename );
2.109 }
2.110
3.1 --- a/src/dreamcast.h Tue Dec 13 14:47:59 2005 +0000
3.2 +++ b/src/dreamcast.h Thu Dec 15 13:33:14 2005 +0000
3.3 @@ -4,6 +4,7 @@
3.4
3.5 #include <stdlib.h>
3.6 #include <stdio.h>
3.7 +#include <glib/gtypes.h>
3.8
3.9 #ifdef __cplusplus
3.10 extern "C" {
3.11 @@ -16,8 +17,11 @@
3.12 #define DREAMCAST_SAVE_MAGIC "%!-DreamOn!Save\0"
3.13 #define DREAMCAST_SAVE_VERSION 0x00010000
3.14
3.15 -void dreamcast_save_state( FILE *f );
3.16 -int dreamcast_load_state( FILE *f );
3.17 +int dreamcast_save_state( const gchar *filename );
3.18 +int dreamcast_load_state( const gchar *filename );
3.19 +
3.20 +int open_file( gchar *filename );
3.21 +
3.22
3.23 #ifdef __cplusplus
3.24 }
4.1 --- a/src/gui/callbacks.c Tue Dec 13 14:47:59 2005 +0000
4.2 +++ b/src/gui/callbacks.c Thu Dec 15 13:33:14 2005 +0000
4.3 @@ -9,6 +9,7 @@
4.4 #include "gui.h"
4.5 #include "sh4core.h"
4.6 #include "asic.h"
4.7 +#include "dreamcast.h"
4.8
4.9 int selected_pc = -1;
4.10
4.11 @@ -24,7 +25,7 @@
4.12 on_open1_activate (GtkMenuItem *menuitem,
4.13 gpointer user_data)
4.14 {
4.15 - open_file_dialog();
4.16 + open_file_dialog( "Open...", open_file, NULL, NULL );
4.17 }
4.18
4.19
4.20 @@ -73,7 +74,7 @@
4.21 on_load_btn_clicked (GtkButton *button,
4.22 gpointer user_data)
4.23 {
4.24 - open_file_dialog();
4.25 + open_file_dialog( "Open...", open_file, NULL, NULL );
4.26 }
4.27
4.28
4.29 @@ -218,7 +219,7 @@
4.30 on_mode_field_changed (GtkEditable *editable,
4.31 gpointer user_data)
4.32 {
4.33 - gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
4.34 + const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
4.35 debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
4.36 set_disassembly_cpu( data, text );
4.37 }
4.38 @@ -239,7 +240,7 @@
4.39 {
4.40 if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
4.41 debug_info_t data = get_debug_info(widget);
4.42 - gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
4.43 + const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
4.44 gchar *endptr;
4.45 unsigned int val = strtoul( text, &endptr, 16 );
4.46 if( text == endptr ) { /* invalid input */
4.47 @@ -313,3 +314,19 @@
4.48 dump_window_new();
4.49 }
4.50
4.51 +
4.52 +void
4.53 +on_loadstate_button_clicked (GtkToolButton *toolbutton,
4.54 + gpointer user_data)
4.55 +{
4.56 + open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "DreamOn Save State (*.dst)" );
4.57 +}
4.58 +
4.59 +
4.60 +void
4.61 +on_savestate_button_clicked (GtkToolButton *toolbutton,
4.62 + gpointer user_data)
4.63 +{
4.64 + save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "DreamOn Save State (*.dst)" );
4.65 +}
4.66 +
5.1 --- a/src/gui/callbacks.h Tue Dec 13 14:47:59 2005 +0000
5.2 +++ b/src/gui/callbacks.h Thu Dec 15 13:33:14 2005 +0000
5.3 @@ -175,3 +175,11 @@
5.4 void
5.5 on_view_memory_activate (GtkMenuItem *menuitem,
5.6 gpointer user_data);
5.7 +
5.8 +void
5.9 +on_loadstate_button_clicked (GtkToolButton *toolbutton,
5.10 + gpointer user_data);
5.11 +
5.12 +void
5.13 +on_savestate_button_clicked (GtkToolButton *toolbutton,
5.14 + gpointer user_data);
6.1 --- a/src/gui/gui.c Tue Dec 13 14:47:59 2005 +0000
6.2 +++ b/src/gui/gui.c Thu Dec 15 13:33:14 2005 +0000
6.3 @@ -2,6 +2,7 @@
6.4 #include <stdarg.h>
6.5 #include <gnome.h>
6.6 #include <math.h>
6.7 +#include "dreamcast.h"
6.8 #include "gui.h"
6.9 #include "mem.h"
6.10 #include "sh4dasm.h"
6.11 @@ -12,9 +13,7 @@
6.12 GdkColor clrNormal, clrChanged, clrError, clrWarn, clrPC, clrDebug, clrTrace;
6.13 PangoFontDescription *fixed_list_font;
6.14
6.15 -void open_file_callback(GtkWidget *btn, gpointer user_data);
6.16 -void open_file_canceled(GtkWidget *btn, gpointer user_data);
6.17 -void open_file( char *filename );
6.18 +void open_file_callback(GtkWidget *btn, gint result, gpointer user_data);
6.19
6.20 void init_gui() {
6.21 GdkColormap *map;
6.22 @@ -51,29 +50,63 @@
6.23 dump_win_update_all();
6.24 }
6.25
6.26 -
6.27 -void open_file_callback(GtkWidget *btn, gpointer user_data) {
6.28 - GtkFileSelection *file = GTK_FILE_SELECTION(user_data);
6.29 - gchar *filename = strdup( gtk_file_selection_get_filename(
6.30 - GTK_FILE_SELECTION(file) ) );
6.31 - gtk_widget_destroy(GTK_WIDGET(file));
6.32 - open_file( filename );
6.33 - free(filename);
6.34 +void open_file_callback(GtkWidget *btn, gint result, gpointer user_data) {
6.35 + GtkFileChooser *file = GTK_FILE_CHOOSER(user_data);
6.36 + if( result == GTK_RESPONSE_ACCEPT ) {
6.37 + gchar *filename =gtk_file_chooser_get_filename(
6.38 + GTK_FILE_CHOOSER(file) );
6.39 + file_callback_t action = (file_callback_t)gtk_object_get_data( GTK_OBJECT(file), "file_action" );
6.40 + gtk_widget_destroy(GTK_WIDGET(file));
6.41 + action( filename );
6.42 + g_free(filename);
6.43 + } else {
6.44 + gtk_widget_destroy(GTK_WIDGET(file));
6.45 + }
6.46 }
6.47
6.48 -void open_file_canceled(GtkWidget *btn, gpointer user_data) {
6.49 - gtk_widget_destroy(GTK_WIDGET(user_data));
6.50 +static void add_file_pattern( GtkFileChooser *chooser, char *pattern, char *patname )
6.51 +{
6.52 + if( pattern != NULL ) {
6.53 + GtkFileFilter *filter = gtk_file_filter_new();
6.54 + gtk_file_filter_add_pattern( filter, pattern );
6.55 + gtk_file_filter_set_name( filter, patname );
6.56 + gtk_file_chooser_add_filter( chooser, filter );
6.57 + filter = gtk_file_filter_new();
6.58 + gtk_file_filter_set_name( filter, "All files" );
6.59 + gtk_file_filter_add_pattern( filter, "*" );
6.60 + gtk_file_chooser_add_filter( chooser, filter );
6.61 + }
6.62 }
6.63
6.64 -void open_file_dialog( void )
6.65 +void open_file_dialog( char *title, file_callback_t action, char *pattern, char *patname )
6.66 {
6.67 GtkWidget *file;
6.68
6.69 - file = gtk_file_selection_new( "Open..." );
6.70 - gtk_signal_connect( GTK_OBJECT(GTK_FILE_SELECTION(file)->ok_button),
6.71 - "clicked", GTK_SIGNAL_FUNC(open_file_callback), file );
6.72 - gtk_signal_connect( GTK_OBJECT(GTK_FILE_SELECTION(file)->cancel_button),
6.73 - "clicked", GTK_SIGNAL_FUNC(open_file_canceled), file );
6.74 + file = gtk_file_chooser_dialog_new( title, NULL,
6.75 + GTK_FILE_CHOOSER_ACTION_OPEN,
6.76 + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
6.77 + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
6.78 + NULL );
6.79 + add_file_pattern( GTK_FILE_CHOOSER(file), pattern, patname );
6.80 + g_signal_connect( GTK_OBJECT(file), "response",
6.81 + GTK_SIGNAL_FUNC(open_file_callback), file );
6.82 + gtk_object_set_data( GTK_OBJECT(file), "file_action", action );
6.83 + gtk_widget_show( file );
6.84 +}
6.85 +
6.86 +void save_file_dialog( char *title, file_callback_t action, char *pattern, char *patname )
6.87 +{
6.88 + GtkWidget *file;
6.89 +
6.90 + file = gtk_file_chooser_dialog_new( title, NULL,
6.91 + GTK_FILE_CHOOSER_ACTION_SAVE,
6.92 + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
6.93 + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
6.94 + NULL );
6.95 + add_file_pattern( GTK_FILE_CHOOSER(file), pattern, patname );
6.96 + g_signal_connect( GTK_OBJECT(file), "response",
6.97 + GTK_SIGNAL_FUNC(open_file_callback), file );
6.98 + gtk_object_set_data( GTK_OBJECT(file), "file_action", action );
6.99 gtk_widget_show( file );
6.100 }
6.101
7.1 --- a/src/gui/gui.h Tue Dec 13 14:47:59 2005 +0000
7.2 +++ b/src/gui/gui.h Thu Dec 15 13:33:14 2005 +0000
7.3 @@ -21,9 +21,12 @@
7.4 typedef struct debug_info_struct *debug_info_t;
7.5 extern debug_info_t main_debug;
7.6
7.7 +typedef int (*file_callback_t)( const gchar *filename );
7.8 +void open_file_dialog( char *title, file_callback_t file_handler, char *pattern, char *patname );
7.9 +void save_file_dialog( char *title, file_callback_t file_handler, char *pattern, char *patname );
7.10 +
7.11 debug_info_t init_debug_win(GtkWidget *, cpu_desc_t *cpu );
7.12 debug_info_t get_debug_info(GtkWidget *widget);
7.13 -void open_file_dialog( void );
7.14 void update_mmr_win( void );
7.15 void init_mmr_win( void );
7.16 void update_registers( debug_info_t debug );
8.1 --- a/src/gui/interface.c Tue Dec 13 14:47:59 2005 +0000
8.2 +++ b/src/gui/interface.c Thu Dec 15 13:33:14 2005 +0000
8.3 @@ -116,6 +116,8 @@
8.4 GtkWidget *run_btn;
8.5 GtkWidget *runto_btn;
8.6 GtkWidget *break_btn;
8.7 + GtkWidget *loadstate_button;
8.8 + GtkWidget *savestate_button;
8.9 GtkWidget *vpaned1;
8.10 GtkWidget *hpaned1;
8.11 GtkWidget *vbox2;
8.12 @@ -166,50 +168,68 @@
8.13 gtk_toolbar_set_style (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_BOTH);
8.14 tmp_toolbar_icon_size = gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar1));
8.15
8.16 - tmp_image = gtk_image_new_from_stock ("gtk-open", tmp_toolbar_icon_size);
8.17 + tmp_image = gtk_image_new_from_stock ("gtk-cdrom", tmp_toolbar_icon_size);
8.18 gtk_widget_show (tmp_image);
8.19 - load_btn = (GtkWidget*) gtk_tool_button_new (tmp_image, _("Load"));
8.20 + load_btn = (GtkWidget*) gtk_tool_button_new (tmp_image, _("Mount"));
8.21 gtk_widget_show (load_btn);
8.22 gtk_container_add (GTK_CONTAINER (toolbar1), load_btn);
8.23 - gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (load_btn), tooltips, _("New File"), NULL);
8.24 + gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (load_btn), tooltips, _("Mount CD-Rom"), NULL);
8.25
8.26 tmp_image = gtk_image_new_from_stock ("gtk-refresh", tmp_toolbar_icon_size);
8.27 gtk_widget_show (tmp_image);
8.28 reset_btn = (GtkWidget*) gtk_tool_button_new (tmp_image, _("Reset"));
8.29 gtk_widget_show (reset_btn);
8.30 gtk_container_add (GTK_CONTAINER (toolbar1), reset_btn);
8.31 - gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (reset_btn), tooltips, _("Open File"), NULL);
8.32 + gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (reset_btn), tooltips, _("Reset emulator"), NULL);
8.33
8.34 tmp_image = gtk_image_new_from_stock ("gtk-stop", tmp_toolbar_icon_size);
8.35 gtk_widget_show (tmp_image);
8.36 stop_btn = (GtkWidget*) gtk_tool_button_new (tmp_image, _("Stop"));
8.37 gtk_widget_show (stop_btn);
8.38 gtk_container_add (GTK_CONTAINER (toolbar1), stop_btn);
8.39 - gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (stop_btn), tooltips, _("Save File"), NULL);
8.40 + gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (stop_btn), tooltips, _("Stop"), NULL);
8.41
8.42 tmp_image = gtk_image_new_from_stock ("gtk-redo", tmp_toolbar_icon_size);
8.43 gtk_widget_show (tmp_image);
8.44 step_btn = (GtkWidget*) gtk_tool_button_new (tmp_image, _("Step"));
8.45 gtk_widget_show (step_btn);
8.46 gtk_container_add (GTK_CONTAINER (toolbar1), step_btn);
8.47 + gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (step_btn), tooltips, _("Single step"), NULL);
8.48
8.49 tmp_image = gtk_image_new_from_stock ("gtk-go-forward", tmp_toolbar_icon_size);
8.50 gtk_widget_show (tmp_image);
8.51 run_btn = (GtkWidget*) gtk_tool_button_new (tmp_image, _("Run"));
8.52 gtk_widget_show (run_btn);
8.53 gtk_container_add (GTK_CONTAINER (toolbar1), run_btn);
8.54 + gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (run_btn), tooltips, _("Run"), NULL);
8.55
8.56 tmp_image = gtk_image_new_from_stock ("gtk-goto-last", tmp_toolbar_icon_size);
8.57 gtk_widget_show (tmp_image);
8.58 runto_btn = (GtkWidget*) gtk_tool_button_new (tmp_image, _("Run to"));
8.59 gtk_widget_show (runto_btn);
8.60 gtk_container_add (GTK_CONTAINER (toolbar1), runto_btn);
8.61 + gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (runto_btn), tooltips, _("Run to current selection"), NULL);
8.62
8.63 tmp_image = gtk_image_new_from_stock ("gtk-close", tmp_toolbar_icon_size);
8.64 gtk_widget_show (tmp_image);
8.65 break_btn = (GtkWidget*) gtk_tool_button_new (tmp_image, _("Break"));
8.66 gtk_widget_show (break_btn);
8.67 gtk_container_add (GTK_CONTAINER (toolbar1), break_btn);
8.68 + gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (break_btn), tooltips, _("Set breakpoint"), NULL);
8.69 +
8.70 + tmp_image = gtk_image_new_from_stock ("gtk-open", tmp_toolbar_icon_size);
8.71 + gtk_widget_show (tmp_image);
8.72 + loadstate_button = (GtkWidget*) gtk_tool_button_new (tmp_image, _("Load"));
8.73 + gtk_widget_show (loadstate_button);
8.74 + gtk_container_add (GTK_CONTAINER (toolbar1), loadstate_button);
8.75 + gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (loadstate_button), tooltips, _("Load save-state file"), NULL);
8.76 +
8.77 + tmp_image = gtk_image_new_from_stock ("gtk-save", tmp_toolbar_icon_size);
8.78 + gtk_widget_show (tmp_image);
8.79 + savestate_button = (GtkWidget*) gtk_tool_button_new (tmp_image, _("Save"));
8.80 + gtk_widget_show (savestate_button);
8.81 + gtk_container_add (GTK_CONTAINER (toolbar1), savestate_button);
8.82 + gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (savestate_button), tooltips, _("Save save-state file"), NULL);
8.83
8.84 vpaned1 = gtk_vpaned_new ();
8.85 gtk_widget_show (vpaned1);
8.86 @@ -266,7 +286,6 @@
8.87 mode_field = GTK_COMBO (mode_box)->entry;
8.88 gtk_widget_show (mode_field);
8.89 gtk_editable_set_editable (GTK_EDITABLE (mode_field), FALSE);
8.90 - gtk_entry_set_text (GTK_ENTRY (mode_field), _("SH4"));
8.91
8.92 label23 = gtk_label_new ("");
8.93 gtk_widget_show (label23);
8.94 @@ -382,6 +401,12 @@
8.95 g_signal_connect ((gpointer) break_btn, "clicked",
8.96 G_CALLBACK (on_break_btn_clicked),
8.97 NULL);
8.98 + g_signal_connect ((gpointer) loadstate_button, "clicked",
8.99 + G_CALLBACK (on_loadstate_button_clicked),
8.100 + NULL);
8.101 + g_signal_connect ((gpointer) savestate_button, "clicked",
8.102 + G_CALLBACK (on_savestate_button_clicked),
8.103 + NULL);
8.104 g_signal_connect ((gpointer) page_field, "key_press_event",
8.105 G_CALLBACK (on_page_field_key_press_event),
8.106 NULL);
8.107 @@ -429,6 +454,8 @@
8.108 GLADE_HOOKUP_OBJECT (debug_win, run_btn, "run_btn");
8.109 GLADE_HOOKUP_OBJECT (debug_win, runto_btn, "runto_btn");
8.110 GLADE_HOOKUP_OBJECT (debug_win, break_btn, "break_btn");
8.111 + GLADE_HOOKUP_OBJECT (debug_win, loadstate_button, "loadstate_button");
8.112 + GLADE_HOOKUP_OBJECT (debug_win, savestate_button, "savestate_button");
8.113 GLADE_HOOKUP_OBJECT (debug_win, vpaned1, "vpaned1");
8.114 GLADE_HOOKUP_OBJECT (debug_win, hpaned1, "hpaned1");
8.115 GLADE_HOOKUP_OBJECT (debug_win, vbox2, "vbox2");
9.1 --- a/src/loader.c Tue Dec 13 14:47:59 2005 +0000
9.2 +++ b/src/loader.c Thu Dec 15 13:33:14 2005 +0000
9.3 @@ -19,7 +19,7 @@
9.4 #define CDI_V2 0x80000004
9.5 #define CDI_V3 0x80000005
9.6
9.7 -void open_file( char *filename )
9.8 +int open_file( const gchar *filename )
9.9 {
9.10 char buf[32];
9.11 uint32_t tmpa[2];
9.12 @@ -82,4 +82,5 @@
9.13 }
9.14 }
9.15 close(fd);
9.16 + return 0;
9.17 }
10.1 --- a/src/mem.c Tue Dec 13 14:47:59 2005 +0000
10.2 +++ b/src/mem.c Thu Dec 15 13:33:14 2005 +0000
10.3 @@ -1,5 +1,5 @@
10.4 /**
10.5 - * $Id: mem.c,v 1.4 2005-12-13 14:47:59 nkeynes Exp $
10.6 + * $Id: mem.c,v 1.5 2005-12-15 13:33:14 nkeynes Exp $
10.7 * mem.c is responsible for creating and maintaining the overall system memory
10.8 * map, as visible from the SH4 processor.
10.9 *
10.10 @@ -43,7 +43,7 @@
10.11 struct mmio_region *io_rgn[MAX_IO_REGIONS];
10.12 struct mmio_region *P4_io[4096];
10.13
10.14 -int num_io_rgns = 1, num_mem_rgns = 0;
10.15 +int num_io_rgns = 0, num_mem_rgns = 0;
10.16
10.17 void *mem_alloc_pages( int n )
10.18 {
10.19 @@ -97,7 +97,8 @@
10.20 fwrite( &mem_rgn[i].base, sizeof(uint32_t), 1, f );
10.21 fwrite( &mem_rgn[i].flags, sizeof(int), 1, f );
10.22 fwrite( &mem_rgn[i].size, sizeof(uint32_t), 1, f );
10.23 - fwrite( mem_rgn[i].mem, mem_rgn[i].size, 1, f );
10.24 + if( mem_rgn[i].flags != MEM_FLAG_ROM )
10.25 + fwrite( mem_rgn[i].mem, mem_rgn[i].size, 1, f );
10.26 }
10.27
10.28 /* All MMIO regions */
10.29 @@ -105,7 +106,9 @@
10.30 for( i=0; i<num_io_rgns; i++ ) {
10.31 fwrite_string( io_rgn[i]->id, f );
10.32 fwrite( &io_rgn[i]->base, sizeof( uint32_t ), 1, f );
10.33 - fwrite( io_rgn[i]->mem, 4096, 1, f );
10.34 + len = 4096;
10.35 + fwrite( &len, sizeof(len), 1, f );
10.36 + fwrite( io_rgn[i]->mem, len, 1, f );
10.37 }
10.38 }
10.39
10.40 @@ -113,10 +116,47 @@
10.41 {
10.42 char tmp[64];
10.43 uint32_t len;
10.44 + uint32_t base, size;
10.45 + int flags;
10.46 int i;
10.47
10.48 /* All memory regions */
10.49 -
10.50 + fread( &len, sizeof(len), 1, f );
10.51 + if( len != num_mem_rgns )
10.52 + return -1;
10.53 + for( i=0; i<len; i++ ) {
10.54 + fread_string( tmp, sizeof(tmp), f );
10.55 + fread( &base, sizeof(base), 1, f );
10.56 + fread( &flags, sizeof(flags), 1, f );
10.57 + fread( &size, sizeof(size), 1, f );
10.58 + if( strcmp( mem_rgn[i].name, tmp ) != 0 ||
10.59 + base != mem_rgn[i].base ||
10.60 + flags != mem_rgn[i].flags ||
10.61 + size != mem_rgn[i].size ) {
10.62 + ERROR( "Bad memory region %d %s", i, tmp );
10.63 + return -1;
10.64 + }
10.65 + if( flags != MEM_FLAG_ROM )
10.66 + fread( mem_rgn[i].mem, size, 1, f );
10.67 + }
10.68 +
10.69 + /* All MMIO regions */
10.70 + fread( &len, sizeof(len), 1, f );
10.71 + if( len != num_io_rgns )
10.72 + return -1;
10.73 + for( i=0; i<len; i++ ) {
10.74 + fread_string( tmp, sizeof(tmp), f );
10.75 + fread( &base, sizeof(base), 1, f );
10.76 + fread( &size, sizeof(size), 1, f );
10.77 + if( strcmp( io_rgn[i]->id, tmp ) != 0 ||
10.78 + base != io_rgn[i]->base ||
10.79 + size != 4096 ) {
10.80 + ERROR( "Bad MMIO region %d %s", i, tmp );
10.81 + return -1;
10.82 + }
10.83 + fread( io_rgn[i]->mem, size, 1, f );
10.84 + }
10.85 + return 0;
10.86 }
10.87
10.88 struct mem_region *mem_map_region( void *mem, uint32_t base, uint32_t size,
10.89 @@ -147,7 +187,7 @@
10.90
10.91 mem = mem_alloc_pages( size>>PAGE_BITS );
10.92
10.93 - mem_map_region( mem, base, size, name, 6 );
10.94 + mem_map_region( mem, base, size, name, MEM_FLAG_RAM );
10.95 return mem;
10.96 }
10.97
10.98 @@ -168,7 +208,7 @@
10.99 close(fd);
10.100 return NULL;
10.101 }
10.102 - mem_map_region( mem, base, size, file, 4 );
10.103 + mem_map_region( mem, base, size, file, MEM_FLAG_ROM );
10.104
10.105 /* CRC check */
10.106 calc_crc = crc32(0L, mem, size);
10.107 @@ -176,6 +216,7 @@
10.108 WARN( "Bios CRC Mismatch in %s: %08X (expected %08X)",
10.109 file, calc_crc, crc);
10.110 }
10.111 +
10.112 return mem;
10.113 }
10.114
11.1 --- a/src/mem.h Tue Dec 13 14:47:59 2005 +0000
11.2 +++ b/src/mem.h Thu Dec 15 13:33:14 2005 +0000
11.3 @@ -42,6 +42,9 @@
11.4 #define WATCH_READ 2
11.5 #define WATCH_EXEC 3 /* AKA Breakpoint :) */
11.6
11.7 +#define MEM_FLAG_ROM 4 /* Mem region is ROM-based */
11.8 +#define MEM_FLAG_RAM 6
11.9 +
11.10 typedef struct watch_point *watch_point_t;
11.11
11.12 watch_point_t mem_new_watch( uint32_t start, uint32_t end, int flags );
12.1 --- a/src/sh4/sh4core.c Tue Dec 13 14:47:59 2005 +0000
12.2 +++ b/src/sh4/sh4core.c Thu Dec 15 13:33:14 2005 +0000
12.3 @@ -7,7 +7,7 @@
12.4 #include "intc.h"
12.5
12.6 void sh4_save( FILE *f );
12.7 -void sh4_load( FILE *f );
12.8 +int sh4_load( FILE *f );
12.9
12.10 struct dreamcast_module sh4_module = { "SH4", sh4_init, sh4_reset,
12.11 NULL, sh4_stop,
12.12 @@ -51,9 +51,10 @@
12.13 /* Save all additional on-board MMIO state */
12.14 }
12.15
12.16 -void sh4_load( FILE * f )
12.17 +int sh4_load( FILE * f )
12.18 {
12.19 -
12.20 + fread( &sh4r, sizeof(sh4r), 1, f );
12.21 + return 0;
12.22 }
12.23
12.24 void sh4_run(void)
.