Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 43:0cf3e339cc59
prev30:89b30313d757
next45:f99236f0632e
author nkeynes
date Mon Dec 26 11:47:15 2005 +0000 (14 years ago)
permissions -rw-r--r--
last change Add sh4 + arm breakpoints
Hook up break button in GUI
Enable ARM slice in main loop
view annotate diff log raw
     1 /**
     2  * $Id: callbacks.c,v 1.11 2005-12-26 11:47:15 nkeynes Exp $
     3  *
     4  * All GTK callbacks go here (stubs are autogenerated by Glade)
     5  *
     6  * Copyright (c) 2005 Nathan Keynes.
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  * GNU General Public License for more details.
    17  */
    19 #ifdef HAVE_CONFIG_H
    20 #  include <config.h>
    21 #endif
    23 #include <gnome.h>
    25 #include "gui/callbacks.h"
    26 #include "gui/interface.h"
    27 #include "gui/gui.h"
    28 #include "sh4core.h"
    29 #include "mem.h"
    30 #include "dreamcast.h"
    31 #include "loader.h"
    33 int selected_pc = -1;
    34 int selected_row = -1;
    36 void
    37 on_new_file1_activate                  (GtkMenuItem     *menuitem,
    38                                         gpointer         user_data)
    39 {
    41 }
    44 void
    45 on_open1_activate                      (GtkMenuItem     *menuitem,
    46                                         gpointer         user_data)
    47 {
    48     open_file_dialog( "Open...", file_load_magic, NULL, NULL );
    49 }
    52 void
    53 on_save1_activate                      (GtkMenuItem     *menuitem,
    54                                         gpointer         user_data)
    55 {
    57 }
    60 void
    61 on_save_as1_activate                   (GtkMenuItem     *menuitem,
    62                                         gpointer         user_data)
    63 {
    65 }
    68 void
    69 on_exit1_activate                      (GtkMenuItem     *menuitem,
    70                                         gpointer         user_data)
    71 {
    72     gtk_main_quit();
    73 }
    76 void
    77 on_preferences1_activate               (GtkMenuItem     *menuitem,
    78                                         gpointer         user_data)
    79 {
    81 }
    84 void
    85 on_about1_activate                     (GtkMenuItem     *menuitem,
    86                                         gpointer         user_data)
    87 {
    88     GtkWidget *about = create_about_win();
    89     gtk_widget_show(about);
    90 }
    93 void
    94 on_load_btn_clicked                    (GtkButton       *button,
    95                                         gpointer         user_data)
    96 {
    97     open_file_dialog( "Open...", file_load_magic, NULL, NULL );
    98 }
   101 void
   102 on_reset_btn_clicked                   (GtkButton       *button,
   103                                         gpointer         user_data)
   104 {
   105     dreamcast_reset();
   106 }
   109 void
   110 on_stop_btn_clicked                    (GtkButton       *button,
   111                                         gpointer         user_data)
   112 {
   113     dreamcast_stop();
   114 }
   117 void
   118 on_step_btn_clicked                    (GtkButton       *button,
   119                                         gpointer         user_data)
   120 {
   121     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   122     debug_win_single_step(data);
   123 }
   126 void
   127 on_run_btn_clicked                     (GtkButton       *button,
   128                                         gpointer         user_data)
   129 {
   130     dreamcast_run();
   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 	sh4_set_breakpoint( selected_pc, BREAK_ONESHOT );
   143 	dreamcast_run();
   144     }
   145 }
   148 void
   149 on_break_btn_clicked                   (GtkButton       *button,
   150                                         gpointer         user_data)
   151 {
   152     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   153     debug_win_toggle_breakpoint( data, selected_row, BREAK_KEEP );
   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     selected_row = 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 }
.