Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 1:eea311cfd33e
next2:42349f6ea216
author nkeynes
date Sat Mar 13 00:03:32 2004 +0000 (15 years ago)
permissions -rw-r--r--
last change This commit was generated by cvs2svn to compensate for changes in r2,
which included commits to RCS files with non-trunk default branches.
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 extern int disasm_from;
    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();
    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();
    78 }
    81 void
    82 on_reset_btn_clicked                   (GtkButton       *button,
    83                                         gpointer         user_data)
    84 {
    85     sh4_reset();
    86     mem_reset();
    87     update_registers();
    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_registers();
   107 }
   110 void run( 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();
   118             run_timers(1000000);
   119             while( gtk_events_pending() )
   120                 gtk_main_iteration();
   121             pvr2_next_frame();
   122         } while( sh4_isrunning() );
   123         update_registers();
   124     }    
   125 }
   126 void
   127 on_run_btn_clicked                     (GtkButton       *button,
   128                                         gpointer         user_data)
   129 {
   130     run(-1);
   131 }
   134 void
   135 on_runto_btn_clicked                   (GtkButton       *button,
   136                                         gpointer         user_data)
   137 {
   138     if( selected_pc == -1 )
   139         WARN( "No address selected, so can't run to it", NULL );
   140     else {
   141         INFO( "Running until %08X...", selected_pc );
   142         run( selected_pc );
   143     }
   144 }
   147 void
   148 on_break_btn_clicked                   (GtkButton       *button,
   149                                         gpointer         user_data)
   150 {
   152 }
   155 gboolean
   156 on_debug_win_delete_event              (GtkWidget       *widget,
   157                                         GdkEvent        *event,
   158                                         gpointer         user_data)
   159 {
   160     gtk_main_quit();
   161   return FALSE;
   162 }
   165 void
   166 on_disasm_list_select_row              (GtkCList        *clist,
   167                                         gint             row,
   168                                         gint             column,
   169                                         GdkEvent        *event,
   170                                         gpointer         user_data)
   171 {
   172     selected_pc = disasm_from + (row<<1);
   173 }
   176 void
   177 on_disasm_list_unselect_row            (GtkCList        *clist,
   178                                         gint             row,
   179                                         gint             column,
   180                                         GdkEvent        *event,
   181                                         gpointer         user_data)
   182 {
   183     int pc = disasm_from + (row<<1);
   184     if( selected_pc == pc ) selected_pc = -1;
   185 }
   188 void
   189 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   190                                         gpointer         user_data)
   191 {
   192     mmr_open_win();
   193 }
   196 gboolean
   197 on_mmr_win_delete_event                (GtkWidget       *widget,
   198                                         GdkEvent        *event,
   199                                         gpointer         user_data)
   200 {
   201     mmr_close_win();
   202     return TRUE;
   203 }
   206 void
   207 on_mmr_close_clicked                   (GtkButton       *button,
   208                                         gpointer         user_data)
   209 {
   210     mmr_close_win();
   211 }
   214 void
   215 on_mode_field_changed                  (GtkEditable     *editable,
   216                                         gpointer         user_data)
   217 {
   219 }
   222 void
   223 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   224                                         gpointer         user_data)
   225 {
   227 }
   230 gboolean
   231 on_page_field_key_press_event          (GtkWidget       *widget,
   232                                         GdkEventKey     *event,
   233                                         gpointer         user_data)
   234 {
   235     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   236         gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   237         gchar *endptr;
   238         unsigned int val = strtoul( text, &endptr, 16 );
   239         if( text == endptr ) { /* invalid input */
   240             char buf[10];
   241             sprintf( buf, "%08X", disasm_from );
   242             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   243         } else {
   244             set_disassembly_region(val);
   245         }
   246     }
   247     return FALSE;
   248 }
   251 void
   252 on_output_list_select_row              (GtkCList        *clist,
   253                                         gint             row,
   254                                         gint             column,
   255                                         GdkEvent        *event,
   256                                         gpointer         user_data)
   257 {
   258     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   259         char *val;
   260         gtk_clist_get_text( clist, row, 1, &val );
   261         if( val[0] != '\0' ) {
   262             int addr = strtoul( val, NULL, 16 );
   263             jump_to_disassembly( addr, TRUE );
   264         }
   265     }
   266 }
   269 void
   270 on_jump_pc_btn_clicked                 (GtkButton       *button,
   271                                         gpointer         user_data)
   272 {
   273     jump_to_disassembly( sh4r.pc, TRUE );
   274 }
.