Search
lxdream.org :: lxdream/src/gui/debugcb.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/debugcb.c
changeset 450:207461e79f21
prev435:7a5d71e8560b
next455:3080881d00d4
author nkeynes
date Wed Oct 17 11:26:45 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Split config management out to config.[ch]
Manage config filename
Check home dir + sysconfdir for conf file
Initial work on a path settings dialog
view annotate diff log raw
     1 /**
     2  * $Id: debugcb.c,v 1.2 2007-10-17 11:26:45 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 #include <gnome.h>
    21 #include "config.h"
    22 #include "gui/debugcb.h"
    23 #include "gui/debugif.h"
    24 #include "gui/gtkui.h"
    25 #include "gdrom/gdrom.h"
    26 #include "mem.h"
    27 #include "mmio.h"
    28 #include "dreamcast.h"
    29 #include "loader.h"
    30 #include "pvr2/pvr2.h"
    32 int selected_pc = -1;
    33 int selected_row = -1;
    35 debug_window_t get_debug_info( GtkWidget *widget );
    37 void
    38 on_new_file1_activate                  (GtkMenuItem     *menuitem,
    39                                         gpointer         user_data)
    40 {
    42 }
    45 void
    46 on_open1_activate                      (GtkMenuItem     *menuitem,
    47                                         gpointer         user_data)
    48 {
    49     const gchar *dir = lxdream_get_config_value(CONFIG_DEFAULT_PATH);
    50     open_file_dialog( "Open...", file_load_magic, NULL, NULL, dir );
    51 }
    54 void
    55 on_save1_activate                      (GtkMenuItem     *menuitem,
    56                                         gpointer         user_data)
    57 {
    59 }
    62 void
    63 on_save_as1_activate                   (GtkMenuItem     *menuitem,
    64                                         gpointer         user_data)
    65 {
    67 }
    69 void 
    70 on_save_next_scene_activate( GtkMenuItem *menuitem,
    71 			     gpointer user_data) 
    72 {
    73     const gchar *dir = lxdream_get_config_value(CONFIG_SAVE_PATH);
    74     save_file_dialog( "Save next scene...", pvr2_save_next_scene, "*.dsc", "lxdream scene file (*.dsc)", dir );
    75 }
    77 void
    78 on_exit1_activate                      (GtkMenuItem     *menuitem,
    79                                         gpointer         user_data)
    80 {
    81     gtk_main_quit();
    82 }
    85 void
    86 on_preferences1_activate               (GtkMenuItem     *menuitem,
    87                                         gpointer         user_data)
    88 {
    90 }
    93 void
    94 on_about1_activate                     (GtkMenuItem     *menuitem,
    95                                         gpointer         user_data)
    96 {
    97     GtkWidget *about = create_about_win();
    98     gtk_widget_show(about);
    99 }
   102 void
   103 on_load_btn_clicked                    (GtkButton       *button,
   104                                         gpointer         user_data)
   105 {
   106     const gchar *dir = lxdream_get_config_value(CONFIG_DEFAULT_PATH);
   107     open_file_dialog( "Open...", gdrom_mount_image, NULL, NULL, dir );
   108 }
   111 void
   112 on_reset_btn_clicked                   (GtkButton       *button,
   113                                         gpointer         user_data)
   114 {
   115     dreamcast_reset();
   116 }
   119 void
   120 on_stop_btn_clicked                    (GtkButton       *button,
   121                                         gpointer         user_data)
   122 {
   123     dreamcast_stop();
   124 }
   127 void
   128 on_step_btn_clicked                    (GtkButton       *button,
   129                                         gpointer         user_data)
   130 {
   131     debug_window_t data = get_debug_info(GTK_WIDGET(button));
   132     debug_win_single_step(data);
   133 }
   136 void
   137 on_run_btn_clicked                     (GtkButton       *button,
   138                                         gpointer         user_data)
   139 {
   140     dreamcast_run();
   141 }
   144 void
   145 on_runto_btn_clicked                   (GtkButton       *button,
   146                                         gpointer         user_data)
   147 {
   148     if( selected_pc == -1 )
   149         WARN( "No address selected, so can't run to it", NULL );
   150     else {
   151 	debug_window_t data = get_debug_info(GTK_WIDGET(button));
   152 	debug_win_set_oneshot_breakpoint( data, selected_row );
   153 	dreamcast_run();
   154     }
   155 }
   158 void
   159 on_break_btn_clicked                   (GtkButton       *button,
   160                                         gpointer         user_data)
   161 {
   162     debug_window_t data = get_debug_info(GTK_WIDGET(button));
   163     debug_win_toggle_breakpoint( data, selected_row );
   164 }
   166 void on_trace_button_toggled           (GtkToggleButton *button,
   167 					gpointer user_data)
   168 {
   169     struct mmio_region *io_rgn = (struct mmio_region *)user_data;
   170     gboolean isActive = gtk_toggle_button_get_active(button);
   171     if( io_rgn != NULL ) {
   172 	io_rgn->trace_flag = isActive ? 1 : 0;
   173     }
   174 }
   177 gboolean
   178 on_debug_win_delete_event              (GtkWidget       *widget,
   179                                         GdkEvent        *event,
   180                                         gpointer         user_data)
   181 {
   182     dreamcast_shutdown();
   183     gtk_main_quit();
   184     return FALSE;
   185 }
   188 void
   189 on_disasm_list_select_row              (GtkCList        *clist,
   190                                         gint             row,
   191                                         gint             column,
   192                                         GdkEvent        *event,
   193                                         gpointer         user_data)
   194 {
   195     debug_window_t data = get_debug_info(GTK_WIDGET(clist));
   196     selected_pc = row_to_address(data, row);
   197     selected_row = row;
   198 }
   201 void
   202 on_disasm_list_unselect_row            (GtkCList        *clist,
   203                                         gint             row,
   204                                         gint             column,
   205                                         GdkEvent        *event,
   206                                         gpointer         user_data)
   207 {
   208     debug_window_t data = get_debug_info(GTK_WIDGET(clist));
   209     int pc = row_to_address(data,row);
   210     if( selected_pc == pc ) selected_pc = -1;
   211 }
   214 void
   215 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   216                                         gpointer         user_data)
   217 {
   218     mmr_open_win();
   219 }
   222 gboolean
   223 on_mmr_win_delete_event                (GtkWidget       *widget,
   224                                         GdkEvent        *event,
   225                                         gpointer         user_data)
   226 {
   227     mmr_close_win();
   228     return TRUE;
   229 }
   232 void
   233 on_mmr_close_clicked                   (GtkButton       *button,
   234                                         gpointer         user_data)
   235 {
   236     mmr_close_win();
   237 }
   240 void
   241 on_mode_field_changed                  (GtkEditable     *editable,
   242                                         gpointer         user_data)
   243 {
   244     const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
   245     debug_window_t data = get_debug_info( GTK_WIDGET(editable) );
   246     set_disassembly_cpu( data, text );
   247 }
   250 void
   251 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   252                                         gpointer         user_data)
   253 {
   255 }
   258 gboolean
   259 on_page_field_key_press_event          (GtkWidget       *widget,
   260                                         GdkEventKey     *event,
   261                                         gpointer         user_data)
   262 {
   263     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   264 	debug_window_t data = get_debug_info(widget);
   265         const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   266         gchar *endptr;
   267         unsigned int val = strtoul( text, &endptr, 16 );
   268         if( text == endptr ) { /* invalid input */
   269             char buf[10];
   270             sprintf( buf, "%08X", row_to_address(data,0) );
   271             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   272         } else {
   273             set_disassembly_region(data, val);
   274         }
   275     }
   276     return FALSE;
   277 }
   280 void
   281 on_output_list_select_row              (GtkCList        *clist,
   282                                         gint             row,
   283                                         gint             column,
   284                                         GdkEvent        *event,
   285                                         gpointer         user_data)
   286 {
   287     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   288         char *val;
   289         gtk_clist_get_text( clist, row, 2, &val );
   290         if( val[0] != '\0' ) {
   291             int addr = strtoul( val, NULL, 16 );
   292 	    debug_window_t data = get_debug_info( GTK_WIDGET(clist) );
   293             jump_to_disassembly( data, addr, TRUE );
   294         }
   295     }
   296 }
   299 void
   300 on_jump_pc_btn_clicked                 (GtkButton       *button,
   301                                         gpointer         user_data)
   302 {
   303     debug_window_t data = get_debug_info( GTK_WIDGET(button) );
   304     jump_to_pc( data, TRUE );
   305 }
   308 void
   309 on_button_add_watch_clicked            (GtkButton       *button,
   310                                         gpointer         user_data)
   311 {
   313 }
   316 void
   317 on_button_clear_all_clicked            (GtkButton       *button,
   318                                         gpointer         user_data)
   319 {
   321 }
   324 void
   325 on_button_close_clicked                (GtkButton       *button,
   326                                         gpointer         user_data)
   327 {
   329 }
   332 void
   333 on_view_memory_activate                (GtkMenuItem     *menuitem,
   334                                         gpointer         user_data)
   335 {
   336     dump_window_new();
   337 }
   340 void
   341 on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
   342                                         gpointer         user_data)
   343 {
   344     const gchar *dir = lxdream_get_config_value(CONFIG_SAVE_PATH);
   345     open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "lxDream Save State (*.dst)", dir );
   346 }
   349 void
   350 on_savestate_button_clicked            (GtkToolButton   *toolbutton,
   351                                         gpointer         user_data)
   352 {
   353     const gchar *dir = lxdream_get_config_value(CONFIG_SAVE_PATH);
   354     save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "lxDream Save State (*.dst)", dir );
   355 }
.