Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 10:c898b37506e0
prev9:2784c7660165
next18:9a1b5d75703f
author nkeynes
date Sun Dec 11 05:15:36 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change Add CPU disasembly options to mode dropdown
Split sh4/mem.c into core mem.c and sh4/mem.c
Start adding copyright comments to file headers
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 {
   221     gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
   222     debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
   223     set_disassembly_cpu( data, text );
   224 }
   227 void
   228 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   229                                         gpointer         user_data)
   230 {
   232 }
   235 gboolean
   236 on_page_field_key_press_event          (GtkWidget       *widget,
   237                                         GdkEventKey     *event,
   238                                         gpointer         user_data)
   239 {
   240     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   241 	debug_info_t data = get_debug_info(widget);
   242         gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   243         gchar *endptr;
   244         unsigned int val = strtoul( text, &endptr, 16 );
   245         if( text == endptr ) { /* invalid input */
   246             char buf[10];
   247             sprintf( buf, "%08X", row_to_address(data,0) );
   248             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   249         } else {
   250             set_disassembly_region(data, val);
   251         }
   252     }
   253     return FALSE;
   254 }
   257 void
   258 on_output_list_select_row              (GtkCList        *clist,
   259                                         gint             row,
   260                                         gint             column,
   261                                         GdkEvent        *event,
   262                                         gpointer         user_data)
   263 {
   264     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   265         char *val;
   266         gtk_clist_get_text( clist, row, 1, &val );
   267         if( val[0] != '\0' ) {
   268             int addr = strtoul( val, NULL, 16 );
   269 	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
   270             jump_to_disassembly( data, addr, TRUE );
   271         }
   272     }
   273 }
   276 void
   277 on_jump_pc_btn_clicked                 (GtkButton       *button,
   278                                         gpointer         user_data)
   279 {
   280     debug_info_t data = get_debug_info( GTK_WIDGET(button) );
   281     jump_to_pc( data, TRUE );
   282 }
   285 void
   286 on_button_add_watch_clicked            (GtkButton       *button,
   287                                         gpointer         user_data)
   288 {
   290 }
   293 void
   294 on_button_clear_all_clicked            (GtkButton       *button,
   295                                         gpointer         user_data)
   296 {
   298 }
   301 void
   302 on_button_close_clicked                (GtkButton       *button,
   303                                         gpointer         user_data)
   304 {
   306 }
   309 void
   310 on_view_memory_activate                (GtkMenuItem     *menuitem,
   311                                         gpointer         user_data)
   312 {
   313     dump_window_new();
   314 }
.