Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 19:9da7a8e38f9d
prev18:9a1b5d75703f
next23:1ec3acd0594d
author nkeynes
date Thu Dec 22 07:38:12 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change Implement 95% of the SCIF serial interface
Implement basic load_bin_file function to try to load demos directly
Update TMU to run all 3 timers, start on general timing
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 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 	    SCIF_clock_tick();
   120             while( gtk_events_pending() )
   121                 gtk_main_iteration();
   122             pvr2_next_frame();
   123         } while( sh4_isrunning() );
   124         update_gui();
   125     }    
   126 }
   127 void
   128 on_run_btn_clicked                     (GtkButton       *button,
   129                                         gpointer         user_data)
   130 {
   131     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   132     run(data,-1);
   133 }
   136 void
   137 on_runto_btn_clicked                   (GtkButton       *button,
   138                                         gpointer         user_data)
   139 {
   140     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   141     if( selected_pc == -1 )
   142         WARN( "No address selected, so can't run to it", NULL );
   143     else {
   144         INFO( "Running until %08X...", selected_pc );
   145         run( data, selected_pc );
   146     }
   147 }
   150 void
   151 on_break_btn_clicked                   (GtkButton       *button,
   152                                         gpointer         user_data)
   153 {
   155 }
   158 gboolean
   159 on_debug_win_delete_event              (GtkWidget       *widget,
   160                                         GdkEvent        *event,
   161                                         gpointer         user_data)
   162 {
   163     gtk_main_quit();
   164   return FALSE;
   165 }
   168 void
   169 on_disasm_list_select_row              (GtkCList        *clist,
   170                                         gint             row,
   171                                         gint             column,
   172                                         GdkEvent        *event,
   173                                         gpointer         user_data)
   174 {
   175     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   176     selected_pc = row_to_address(data, row);
   177 }
   180 void
   181 on_disasm_list_unselect_row            (GtkCList        *clist,
   182                                         gint             row,
   183                                         gint             column,
   184                                         GdkEvent        *event,
   185                                         gpointer         user_data)
   186 {
   187     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   188     int pc = row_to_address(data,row);
   189     if( selected_pc == pc ) selected_pc = -1;
   190 }
   193 void
   194 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   195                                         gpointer         user_data)
   196 {
   197     mmr_open_win();
   198 }
   201 gboolean
   202 on_mmr_win_delete_event                (GtkWidget       *widget,
   203                                         GdkEvent        *event,
   204                                         gpointer         user_data)
   205 {
   206     mmr_close_win();
   207     return TRUE;
   208 }
   211 void
   212 on_mmr_close_clicked                   (GtkButton       *button,
   213                                         gpointer         user_data)
   214 {
   215     mmr_close_win();
   216 }
   219 void
   220 on_mode_field_changed                  (GtkEditable     *editable,
   221                                         gpointer         user_data)
   222 {
   223     const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
   224     debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
   225     set_disassembly_cpu( data, text );
   226 }
   229 void
   230 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   231                                         gpointer         user_data)
   232 {
   234 }
   237 gboolean
   238 on_page_field_key_press_event          (GtkWidget       *widget,
   239                                         GdkEventKey     *event,
   240                                         gpointer         user_data)
   241 {
   242     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   243 	debug_info_t data = get_debug_info(widget);
   244         const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   245         gchar *endptr;
   246         unsigned int val = strtoul( text, &endptr, 16 );
   247         if( text == endptr ) { /* invalid input */
   248             char buf[10];
   249             sprintf( buf, "%08X", row_to_address(data,0) );
   250             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   251         } else {
   252             set_disassembly_region(data, val);
   253         }
   254     }
   255     return FALSE;
   256 }
   259 void
   260 on_output_list_select_row              (GtkCList        *clist,
   261                                         gint             row,
   262                                         gint             column,
   263                                         GdkEvent        *event,
   264                                         gpointer         user_data)
   265 {
   266     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   267         char *val;
   268         gtk_clist_get_text( clist, row, 1, &val );
   269         if( val[0] != '\0' ) {
   270             int addr = strtoul( val, NULL, 16 );
   271 	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
   272             jump_to_disassembly( data, addr, TRUE );
   273         }
   274     }
   275 }
   278 void
   279 on_jump_pc_btn_clicked                 (GtkButton       *button,
   280                                         gpointer         user_data)
   281 {
   282     debug_info_t data = get_debug_info( GTK_WIDGET(button) );
   283     jump_to_pc( data, TRUE );
   284 }
   287 void
   288 on_button_add_watch_clicked            (GtkButton       *button,
   289                                         gpointer         user_data)
   290 {
   292 }
   295 void
   296 on_button_clear_all_clicked            (GtkButton       *button,
   297                                         gpointer         user_data)
   298 {
   300 }
   303 void
   304 on_button_close_clicked                (GtkButton       *button,
   305                                         gpointer         user_data)
   306 {
   308 }
   311 void
   312 on_view_memory_activate                (GtkMenuItem     *menuitem,
   313                                         gpointer         user_data)
   314 {
   315     dump_window_new();
   316 }
   319 void
   320 on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
   321                                         gpointer         user_data)
   322 {
   323     open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "DreamOn Save State (*.dst)" );
   324 }
   327 void
   328 on_savestate_button_clicked            (GtkToolButton   *toolbutton,
   329                                         gpointer         user_data)
   330 {
   331     save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "DreamOn Save State (*.dst)" );
   332 }
.