Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 23:1ec3acd0594d
prev19:9da7a8e38f9d
next26:ad258e3daaa5
author nkeynes
date Fri Dec 23 11:44:55 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change Start of "real" time slices, general structure in place now
view annotate diff log raw
     1 #ifdef HAVE_CONFIG_H
     2 #  include <config.h>
     3 #endif
     5 #include <gnome.h>
     7 #include "callbacks.h"
     8 #include "interface.h"
     9 #include "gui.h"
    10 #include "sh4core.h"
    11 #include "asic.h"
    12 #include "dreamcast.h"
    14 int selected_pc = -1;
    16 void
    17 on_new_file1_activate                  (GtkMenuItem     *menuitem,
    18                                         gpointer         user_data)
    19 {
    21 }
    24 void
    25 on_open1_activate                      (GtkMenuItem     *menuitem,
    26                                         gpointer         user_data)
    27 {
    28     open_file_dialog( "Open...", open_file, NULL, NULL );
    29 }
    32 void
    33 on_save1_activate                      (GtkMenuItem     *menuitem,
    34                                         gpointer         user_data)
    35 {
    37 }
    40 void
    41 on_save_as1_activate                   (GtkMenuItem     *menuitem,
    42                                         gpointer         user_data)
    43 {
    45 }
    48 void
    49 on_exit1_activate                      (GtkMenuItem     *menuitem,
    50                                         gpointer         user_data)
    51 {
    52     gtk_main_quit();
    53 }
    56 void
    57 on_preferences1_activate               (GtkMenuItem     *menuitem,
    58                                         gpointer         user_data)
    59 {
    61 }
    64 void
    65 on_about1_activate                     (GtkMenuItem     *menuitem,
    66                                         gpointer         user_data)
    67 {
    68     GtkWidget *about = create_about_win();
    69     gtk_widget_show(about);
    70 }
    73 void
    74 on_load_btn_clicked                    (GtkButton       *button,
    75                                         gpointer         user_data)
    76 {
    77     open_file_dialog( "Open...", load_bin_file, NULL, NULL );
    78 }
    81 void
    82 on_reset_btn_clicked                   (GtkButton       *button,
    83                                         gpointer         user_data)
    84 {
    85     sh4_reset();
    86     mem_reset();
    87     update_gui();
    88 }
    91 void
    92 on_stop_btn_clicked                    (GtkButton       *button,
    93                                         gpointer         user_data)
    94 {
    95     if( sh4_isrunning() ) {
    96         sh4_stop();
    97     }
    98 }
   101 void
   102 on_step_btn_clicked                    (GtkButton       *button,
   103                                         gpointer         user_data)
   104 {
   105     sh4_execute_instruction();
   106     update_gui();
   107 }
   110 void
   111 on_run_btn_clicked                     (GtkButton       *button,
   112                                         gpointer         user_data)
   113 {
   114     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   115     dreamcast_run();
   116 }
   119 void
   120 on_runto_btn_clicked                   (GtkButton       *button,
   121                                         gpointer         user_data)
   122 {
   123     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   124     if( selected_pc == -1 )
   125         WARN( "No address selected, so can't run to it", NULL );
   126     else {
   127         INFO( "Running until %08X...", selected_pc );
   128 	sh4_set_breakpoint( selected_pc, BREAK_ONESHOT );
   129 	dreamcast_run();
   130     }
   131 }
   134 void
   135 on_break_btn_clicked                   (GtkButton       *button,
   136                                         gpointer         user_data)
   137 {
   139 }
   142 gboolean
   143 on_debug_win_delete_event              (GtkWidget       *widget,
   144                                         GdkEvent        *event,
   145                                         gpointer         user_data)
   146 {
   147     gtk_main_quit();
   148   return FALSE;
   149 }
   152 void
   153 on_disasm_list_select_row              (GtkCList        *clist,
   154                                         gint             row,
   155                                         gint             column,
   156                                         GdkEvent        *event,
   157                                         gpointer         user_data)
   158 {
   159     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   160     selected_pc = row_to_address(data, row);
   161 }
   164 void
   165 on_disasm_list_unselect_row            (GtkCList        *clist,
   166                                         gint             row,
   167                                         gint             column,
   168                                         GdkEvent        *event,
   169                                         gpointer         user_data)
   170 {
   171     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   172     int pc = row_to_address(data,row);
   173     if( selected_pc == pc ) selected_pc = -1;
   174 }
   177 void
   178 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   179                                         gpointer         user_data)
   180 {
   181     mmr_open_win();
   182 }
   185 gboolean
   186 on_mmr_win_delete_event                (GtkWidget       *widget,
   187                                         GdkEvent        *event,
   188                                         gpointer         user_data)
   189 {
   190     mmr_close_win();
   191     return TRUE;
   192 }
   195 void
   196 on_mmr_close_clicked                   (GtkButton       *button,
   197                                         gpointer         user_data)
   198 {
   199     mmr_close_win();
   200 }
   203 void
   204 on_mode_field_changed                  (GtkEditable     *editable,
   205                                         gpointer         user_data)
   206 {
   207     const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
   208     debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
   209     set_disassembly_cpu( data, text );
   210 }
   213 void
   214 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   215                                         gpointer         user_data)
   216 {
   218 }
   221 gboolean
   222 on_page_field_key_press_event          (GtkWidget       *widget,
   223                                         GdkEventKey     *event,
   224                                         gpointer         user_data)
   225 {
   226     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   227 	debug_info_t data = get_debug_info(widget);
   228         const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   229         gchar *endptr;
   230         unsigned int val = strtoul( text, &endptr, 16 );
   231         if( text == endptr ) { /* invalid input */
   232             char buf[10];
   233             sprintf( buf, "%08X", row_to_address(data,0) );
   234             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   235         } else {
   236             set_disassembly_region(data, val);
   237         }
   238     }
   239     return FALSE;
   240 }
   243 void
   244 on_output_list_select_row              (GtkCList        *clist,
   245                                         gint             row,
   246                                         gint             column,
   247                                         GdkEvent        *event,
   248                                         gpointer         user_data)
   249 {
   250     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   251         char *val;
   252         gtk_clist_get_text( clist, row, 1, &val );
   253         if( val[0] != '\0' ) {
   254             int addr = strtoul( val, NULL, 16 );
   255 	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
   256             jump_to_disassembly( data, addr, TRUE );
   257         }
   258     }
   259 }
   262 void
   263 on_jump_pc_btn_clicked                 (GtkButton       *button,
   264                                         gpointer         user_data)
   265 {
   266     debug_info_t data = get_debug_info( GTK_WIDGET(button) );
   267     jump_to_pc( data, TRUE );
   268 }
   271 void
   272 on_button_add_watch_clicked            (GtkButton       *button,
   273                                         gpointer         user_data)
   274 {
   276 }
   279 void
   280 on_button_clear_all_clicked            (GtkButton       *button,
   281                                         gpointer         user_data)
   282 {
   284 }
   287 void
   288 on_button_close_clicked                (GtkButton       *button,
   289                                         gpointer         user_data)
   290 {
   292 }
   295 void
   296 on_view_memory_activate                (GtkMenuItem     *menuitem,
   297                                         gpointer         user_data)
   298 {
   299     dump_window_new();
   300 }
   303 void
   304 on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
   305                                         gpointer         user_data)
   306 {
   307     open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "DreamOn Save State (*.dst)" );
   308 }
   311 void
   312 on_savestate_button_clicked            (GtkToolButton   *toolbutton,
   313                                         gpointer         user_data)
   314 {
   315     save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "DreamOn Save State (*.dst)" );
   316 }
.