Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 9:2784c7660165
prev2:42349f6ea216
next10:c898b37506e0
author nkeynes
date Thu Dec 08 13:38:00 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change Generalise the core debug window to allow multiple instances.
Add cpu description structure to define different cpus for use by the
debug window, in preparation for ARM implementation
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"
    13 int selected_pc = -1;
    15 void
    16 on_new_file1_activate                  (GtkMenuItem     *menuitem,
    17                                         gpointer         user_data)
    18 {
    20 }
    23 void
    24 on_open1_activate                      (GtkMenuItem     *menuitem,
    25                                         gpointer         user_data)
    26 {
    27     open_file_dialog();
    28 }
    31 void
    32 on_save1_activate                      (GtkMenuItem     *menuitem,
    33                                         gpointer         user_data)
    34 {
    36 }
    39 void
    40 on_save_as1_activate                   (GtkMenuItem     *menuitem,
    41                                         gpointer         user_data)
    42 {
    44 }
    47 void
    48 on_exit1_activate                      (GtkMenuItem     *menuitem,
    49                                         gpointer         user_data)
    50 {
    51     gtk_main_quit();
    52 }
    55 void
    56 on_preferences1_activate               (GtkMenuItem     *menuitem,
    57                                         gpointer         user_data)
    58 {
    60 }
    63 void
    64 on_about1_activate                     (GtkMenuItem     *menuitem,
    65                                         gpointer         user_data)
    66 {
    67     GtkWidget *about = create_about_win();
    68     gtk_widget_show(about);
    69 }
    72 void
    73 on_load_btn_clicked                    (GtkButton       *button,
    74                                         gpointer         user_data)
    75 {
    76     open_file_dialog();
    77 }
    80 void
    81 on_reset_btn_clicked                   (GtkButton       *button,
    82                                         gpointer         user_data)
    83 {
    84     sh4_reset();
    85     mem_reset();
    86     update_gui();
    87 }
    90 void
    91 on_stop_btn_clicked                    (GtkButton       *button,
    92                                         gpointer         user_data)
    93 {
    94     if( sh4_isrunning() ) {
    95         sh4_stop();
    96     }
    97 }
   100 void
   101 on_step_btn_clicked                    (GtkButton       *button,
   102                                         gpointer         user_data)
   103 {
   104     sh4_execute_instruction();
   105     update_gui();
   106 }
   109 void run( debug_info_t data, uint32_t target ) {
   110     if( ! sh4_isrunning() ) {
   111         do {
   112             if( target == -1 )
   113                 sh4_runfor(1000000);
   114             else
   115                 sh4_runto(target, 1000000);
   116             update_icount(data);
   117             run_timers(1000000);
   118             while( gtk_events_pending() )
   119                 gtk_main_iteration();
   120             pvr2_next_frame();
   121         } while( sh4_isrunning() );
   122         update_gui();
   123     }    
   124 }
   125 void
   126 on_run_btn_clicked                     (GtkButton       *button,
   127                                         gpointer         user_data)
   128 {
   129     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   130     run(data,-1);
   131 }
   134 void
   135 on_runto_btn_clicked                   (GtkButton       *button,
   136                                         gpointer         user_data)
   137 {
   138     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   139     if( selected_pc == -1 )
   140         WARN( "No address selected, so can't run to it", NULL );
   141     else {
   142         INFO( "Running until %08X...", selected_pc );
   143         run( data, selected_pc );
   144     }
   145 }
   148 void
   149 on_break_btn_clicked                   (GtkButton       *button,
   150                                         gpointer         user_data)
   151 {
   153 }
   156 gboolean
   157 on_debug_win_delete_event              (GtkWidget       *widget,
   158                                         GdkEvent        *event,
   159                                         gpointer         user_data)
   160 {
   161     gtk_main_quit();
   162   return FALSE;
   163 }
   166 void
   167 on_disasm_list_select_row              (GtkCList        *clist,
   168                                         gint             row,
   169                                         gint             column,
   170                                         GdkEvent        *event,
   171                                         gpointer         user_data)
   172 {
   173     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   174     selected_pc = row_to_address(data, row);
   175 }
   178 void
   179 on_disasm_list_unselect_row            (GtkCList        *clist,
   180                                         gint             row,
   181                                         gint             column,
   182                                         GdkEvent        *event,
   183                                         gpointer         user_data)
   184 {
   185     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   186     int pc = row_to_address(data,row);
   187     if( selected_pc == pc ) selected_pc = -1;
   188 }
   191 void
   192 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   193                                         gpointer         user_data)
   194 {
   195     mmr_open_win();
   196 }
   199 gboolean
   200 on_mmr_win_delete_event                (GtkWidget       *widget,
   201                                         GdkEvent        *event,
   202                                         gpointer         user_data)
   203 {
   204     mmr_close_win();
   205     return TRUE;
   206 }
   209 void
   210 on_mmr_close_clicked                   (GtkButton       *button,
   211                                         gpointer         user_data)
   212 {
   213     mmr_close_win();
   214 }
   217 void
   218 on_mode_field_changed                  (GtkEditable     *editable,
   219                                         gpointer         user_data)
   220 {
   222 }
   225 void
   226 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   227                                         gpointer         user_data)
   228 {
   230 }
   233 gboolean
   234 on_page_field_key_press_event          (GtkWidget       *widget,
   235                                         GdkEventKey     *event,
   236                                         gpointer         user_data)
   237 {
   238     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   239 	debug_info_t data = get_debug_info(widget);
   240         gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   241         gchar *endptr;
   242         unsigned int val = strtoul( text, &endptr, 16 );
   243         if( text == endptr ) { /* invalid input */
   244             char buf[10];
   245             sprintf( buf, "%08X", row_to_address(data,0) );
   246             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   247         } else {
   248             set_disassembly_region(data, val);
   249         }
   250     }
   251     return FALSE;
   252 }
   255 void
   256 on_output_list_select_row              (GtkCList        *clist,
   257                                         gint             row,
   258                                         gint             column,
   259                                         GdkEvent        *event,
   260                                         gpointer         user_data)
   261 {
   262     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   263         char *val;
   264         gtk_clist_get_text( clist, row, 1, &val );
   265         if( val[0] != '\0' ) {
   266             int addr = strtoul( val, NULL, 16 );
   267 	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
   268             jump_to_disassembly( data, addr, TRUE );
   269         }
   270     }
   271 }
   274 void
   275 on_jump_pc_btn_clicked                 (GtkButton       *button,
   276                                         gpointer         user_data)
   277 {
   278     debug_info_t data = get_debug_info( GTK_WIDGET(button) );
   279     jump_to_pc( data, TRUE );
   280 }
   283 void
   284 on_button_add_watch_clicked            (GtkButton       *button,
   285                                         gpointer         user_data)
   286 {
   288 }
   291 void
   292 on_button_clear_all_clicked            (GtkButton       *button,
   293                                         gpointer         user_data)
   294 {
   296 }
   299 void
   300 on_button_close_clicked                (GtkButton       *button,
   301                                         gpointer         user_data)
   302 {
   304 }
   307 void
   308 on_view_memory_activate                (GtkMenuItem     *menuitem,
   309                                         gpointer         user_data)
   310 {
   311     dump_window_new();
   312 }
.