Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 18:9a1b5d75703f
prev10:c898b37506e0
next19:9da7a8e38f9d
author nkeynes
date Thu Dec 15 13:33:14 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change Implement save states
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...", open_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 run( debug_info_t data, uint32_t target ) {
   111     if( ! sh4_isrunning() ) {
   112         do {
   113             if( target == -1 )
   114                 sh4_runfor(1000000);
   115             else
   116                 sh4_runto(target, 1000000);
   117             update_icount(data);
   118             run_timers(1000000);
   119             while( gtk_events_pending() )
   120                 gtk_main_iteration();
   121             pvr2_next_frame();
   122         } while( sh4_isrunning() );
   123         update_gui();
   124     }    
   125 }
   126 void
   127 on_run_btn_clicked                     (GtkButton       *button,
   128                                         gpointer         user_data)
   129 {
   130     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   131     run(data,-1);
   132 }
   135 void
   136 on_runto_btn_clicked                   (GtkButton       *button,
   137                                         gpointer         user_data)
   138 {
   139     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   140     if( selected_pc == -1 )
   141         WARN( "No address selected, so can't run to it", NULL );
   142     else {
   143         INFO( "Running until %08X...", selected_pc );
   144         run( data, selected_pc );
   145     }
   146 }
   149 void
   150 on_break_btn_clicked                   (GtkButton       *button,
   151                                         gpointer         user_data)
   152 {
   154 }
   157 gboolean
   158 on_debug_win_delete_event              (GtkWidget       *widget,
   159                                         GdkEvent        *event,
   160                                         gpointer         user_data)
   161 {
   162     gtk_main_quit();
   163   return FALSE;
   164 }
   167 void
   168 on_disasm_list_select_row              (GtkCList        *clist,
   169                                         gint             row,
   170                                         gint             column,
   171                                         GdkEvent        *event,
   172                                         gpointer         user_data)
   173 {
   174     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   175     selected_pc = row_to_address(data, row);
   176 }
   179 void
   180 on_disasm_list_unselect_row            (GtkCList        *clist,
   181                                         gint             row,
   182                                         gint             column,
   183                                         GdkEvent        *event,
   184                                         gpointer         user_data)
   185 {
   186     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   187     int pc = row_to_address(data,row);
   188     if( selected_pc == pc ) selected_pc = -1;
   189 }
   192 void
   193 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   194                                         gpointer         user_data)
   195 {
   196     mmr_open_win();
   197 }
   200 gboolean
   201 on_mmr_win_delete_event                (GtkWidget       *widget,
   202                                         GdkEvent        *event,
   203                                         gpointer         user_data)
   204 {
   205     mmr_close_win();
   206     return TRUE;
   207 }
   210 void
   211 on_mmr_close_clicked                   (GtkButton       *button,
   212                                         gpointer         user_data)
   213 {
   214     mmr_close_win();
   215 }
   218 void
   219 on_mode_field_changed                  (GtkEditable     *editable,
   220                                         gpointer         user_data)
   221 {
   222     const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
   223     debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
   224     set_disassembly_cpu( data, text );
   225 }
   228 void
   229 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   230                                         gpointer         user_data)
   231 {
   233 }
   236 gboolean
   237 on_page_field_key_press_event          (GtkWidget       *widget,
   238                                         GdkEventKey     *event,
   239                                         gpointer         user_data)
   240 {
   241     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   242 	debug_info_t data = get_debug_info(widget);
   243         const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   244         gchar *endptr;
   245         unsigned int val = strtoul( text, &endptr, 16 );
   246         if( text == endptr ) { /* invalid input */
   247             char buf[10];
   248             sprintf( buf, "%08X", row_to_address(data,0) );
   249             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   250         } else {
   251             set_disassembly_region(data, val);
   252         }
   253     }
   254     return FALSE;
   255 }
   258 void
   259 on_output_list_select_row              (GtkCList        *clist,
   260                                         gint             row,
   261                                         gint             column,
   262                                         GdkEvent        *event,
   263                                         gpointer         user_data)
   264 {
   265     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   266         char *val;
   267         gtk_clist_get_text( clist, row, 1, &val );
   268         if( val[0] != '\0' ) {
   269             int addr = strtoul( val, NULL, 16 );
   270 	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
   271             jump_to_disassembly( data, addr, TRUE );
   272         }
   273     }
   274 }
   277 void
   278 on_jump_pc_btn_clicked                 (GtkButton       *button,
   279                                         gpointer         user_data)
   280 {
   281     debug_info_t data = get_debug_info( GTK_WIDGET(button) );
   282     jump_to_pc( data, TRUE );
   283 }
   286 void
   287 on_button_add_watch_clicked            (GtkButton       *button,
   288                                         gpointer         user_data)
   289 {
   291 }
   294 void
   295 on_button_clear_all_clicked            (GtkButton       *button,
   296                                         gpointer         user_data)
   297 {
   299 }
   302 void
   303 on_button_close_clicked                (GtkButton       *button,
   304                                         gpointer         user_data)
   305 {
   307 }
   310 void
   311 on_view_memory_activate                (GtkMenuItem     *menuitem,
   312                                         gpointer         user_data)
   313 {
   314     dump_window_new();
   315 }
   318 void
   319 on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
   320                                         gpointer         user_data)
   321 {
   322     open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "DreamOn Save State (*.dst)" );
   323 }
   326 void
   327 on_savestate_button_clicked            (GtkToolButton   *toolbutton,
   328                                         gpointer         user_data)
   329 {
   330     save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "DreamOn Save State (*.dst)" );
   331 }
.