Search
lxdream.org :: lxdream/src/gui/debugcb.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/debugcb.c
changeset 435:7a5d71e8560b
next450:207461e79f21
author nkeynes
date Wed Oct 10 11:02:04 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change First cut of new GUI
view annotate diff log raw
     1 /**
     2  * $Id: debugcb.c,v 1.1 2007-10-10 11:02:04 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/debugcb.h"
    26 #include "gui/debugif.h"
    27 #include "gui/gtkui.h"
    28 #include "gdrom/gdrom.h"
    29 #include "mem.h"
    30 #include "mmio.h"
    31 #include "dreamcast.h"
    32 #include "loader.h"
    33 #include "pvr2/pvr2.h"
    35 int selected_pc = -1;
    36 int selected_row = -1;
    38 debug_window_t get_debug_info( GtkWidget *widget );
    40 void
    41 on_new_file1_activate                  (GtkMenuItem     *menuitem,
    42                                         gpointer         user_data)
    43 {
    45 }
    48 void
    49 on_open1_activate                      (GtkMenuItem     *menuitem,
    50                                         gpointer         user_data)
    51 {
    52     const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
    53     open_file_dialog( "Open...", file_load_magic, NULL, NULL, dir );
    54 }
    57 void
    58 on_save1_activate                      (GtkMenuItem     *menuitem,
    59                                         gpointer         user_data)
    60 {
    62 }
    65 void
    66 on_save_as1_activate                   (GtkMenuItem     *menuitem,
    67                                         gpointer         user_data)
    68 {
    70 }
    72 void 
    73 on_save_next_scene_activate( GtkMenuItem *menuitem,
    74 			     gpointer user_data) 
    75 {
    76     const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
    77     save_file_dialog( "Save next scene...", pvr2_save_next_scene, "*.dsc", "lxdream scene file (*.dsc)", dir );
    78 }
    80 void
    81 on_exit1_activate                      (GtkMenuItem     *menuitem,
    82                                         gpointer         user_data)
    83 {
    84     gtk_main_quit();
    85 }
    88 void
    89 on_preferences1_activate               (GtkMenuItem     *menuitem,
    90                                         gpointer         user_data)
    91 {
    93 }
    96 void
    97 on_about1_activate                     (GtkMenuItem     *menuitem,
    98                                         gpointer         user_data)
    99 {
   100     GtkWidget *about = create_about_win();
   101     gtk_widget_show(about);
   102 }
   105 void
   106 on_load_btn_clicked                    (GtkButton       *button,
   107                                         gpointer         user_data)
   108 {
   109     const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
   110     open_file_dialog( "Open...", gdrom_mount_image, NULL, NULL, dir );
   111 }
   114 void
   115 on_reset_btn_clicked                   (GtkButton       *button,
   116                                         gpointer         user_data)
   117 {
   118     dreamcast_reset();
   119 }
   122 void
   123 on_stop_btn_clicked                    (GtkButton       *button,
   124                                         gpointer         user_data)
   125 {
   126     dreamcast_stop();
   127 }
   130 void
   131 on_step_btn_clicked                    (GtkButton       *button,
   132                                         gpointer         user_data)
   133 {
   134     debug_window_t data = get_debug_info(GTK_WIDGET(button));
   135     debug_win_single_step(data);
   136 }
   139 void
   140 on_run_btn_clicked                     (GtkButton       *button,
   141                                         gpointer         user_data)
   142 {
   143     dreamcast_run();
   144 }
   147 void
   148 on_runto_btn_clicked                   (GtkButton       *button,
   149                                         gpointer         user_data)
   150 {
   151     if( selected_pc == -1 )
   152         WARN( "No address selected, so can't run to it", NULL );
   153     else {
   154 	debug_window_t data = get_debug_info(GTK_WIDGET(button));
   155 	debug_win_set_oneshot_breakpoint( data, selected_row );
   156 	dreamcast_run();
   157     }
   158 }
   161 void
   162 on_break_btn_clicked                   (GtkButton       *button,
   163                                         gpointer         user_data)
   164 {
   165     debug_window_t data = get_debug_info(GTK_WIDGET(button));
   166     debug_win_toggle_breakpoint( data, selected_row );
   167 }
   169 void on_trace_button_toggled           (GtkToggleButton *button,
   170 					gpointer user_data)
   171 {
   172     struct mmio_region *io_rgn = (struct mmio_region *)user_data;
   173     gboolean isActive = gtk_toggle_button_get_active(button);
   174     if( io_rgn != NULL ) {
   175 	io_rgn->trace_flag = isActive ? 1 : 0;
   176     }
   177 }
   180 gboolean
   181 on_debug_win_delete_event              (GtkWidget       *widget,
   182                                         GdkEvent        *event,
   183                                         gpointer         user_data)
   184 {
   185     dreamcast_shutdown();
   186     gtk_main_quit();
   187     return FALSE;
   188 }
   191 void
   192 on_disasm_list_select_row              (GtkCList        *clist,
   193                                         gint             row,
   194                                         gint             column,
   195                                         GdkEvent        *event,
   196                                         gpointer         user_data)
   197 {
   198     debug_window_t data = get_debug_info(GTK_WIDGET(clist));
   199     selected_pc = row_to_address(data, row);
   200     selected_row = row;
   201 }
   204 void
   205 on_disasm_list_unselect_row            (GtkCList        *clist,
   206                                         gint             row,
   207                                         gint             column,
   208                                         GdkEvent        *event,
   209                                         gpointer         user_data)
   210 {
   211     debug_window_t data = get_debug_info(GTK_WIDGET(clist));
   212     int pc = row_to_address(data,row);
   213     if( selected_pc == pc ) selected_pc = -1;
   214 }
   217 void
   218 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   219                                         gpointer         user_data)
   220 {
   221     mmr_open_win();
   222 }
   225 gboolean
   226 on_mmr_win_delete_event                (GtkWidget       *widget,
   227                                         GdkEvent        *event,
   228                                         gpointer         user_data)
   229 {
   230     mmr_close_win();
   231     return TRUE;
   232 }
   235 void
   236 on_mmr_close_clicked                   (GtkButton       *button,
   237                                         gpointer         user_data)
   238 {
   239     mmr_close_win();
   240 }
   243 void
   244 on_mode_field_changed                  (GtkEditable     *editable,
   245                                         gpointer         user_data)
   246 {
   247     const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
   248     debug_window_t data = get_debug_info( GTK_WIDGET(editable) );
   249     set_disassembly_cpu( data, text );
   250 }
   253 void
   254 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   255                                         gpointer         user_data)
   256 {
   258 }
   261 gboolean
   262 on_page_field_key_press_event          (GtkWidget       *widget,
   263                                         GdkEventKey     *event,
   264                                         gpointer         user_data)
   265 {
   266     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   267 	debug_window_t data = get_debug_info(widget);
   268         const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   269         gchar *endptr;
   270         unsigned int val = strtoul( text, &endptr, 16 );
   271         if( text == endptr ) { /* invalid input */
   272             char buf[10];
   273             sprintf( buf, "%08X", row_to_address(data,0) );
   274             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   275         } else {
   276             set_disassembly_region(data, val);
   277         }
   278     }
   279     return FALSE;
   280 }
   283 void
   284 on_output_list_select_row              (GtkCList        *clist,
   285                                         gint             row,
   286                                         gint             column,
   287                                         GdkEvent        *event,
   288                                         gpointer         user_data)
   289 {
   290     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   291         char *val;
   292         gtk_clist_get_text( clist, row, 2, &val );
   293         if( val[0] != '\0' ) {
   294             int addr = strtoul( val, NULL, 16 );
   295 	    debug_window_t data = get_debug_info( GTK_WIDGET(clist) );
   296             jump_to_disassembly( data, addr, TRUE );
   297         }
   298     }
   299 }
   302 void
   303 on_jump_pc_btn_clicked                 (GtkButton       *button,
   304                                         gpointer         user_data)
   305 {
   306     debug_window_t data = get_debug_info( GTK_WIDGET(button) );
   307     jump_to_pc( data, TRUE );
   308 }
   311 void
   312 on_button_add_watch_clicked            (GtkButton       *button,
   313                                         gpointer         user_data)
   314 {
   316 }
   319 void
   320 on_button_clear_all_clicked            (GtkButton       *button,
   321                                         gpointer         user_data)
   322 {
   324 }
   327 void
   328 on_button_close_clicked                (GtkButton       *button,
   329                                         gpointer         user_data)
   330 {
   332 }
   335 void
   336 on_view_memory_activate                (GtkMenuItem     *menuitem,
   337                                         gpointer         user_data)
   338 {
   339     dump_window_new();
   340 }
   343 void
   344 on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
   345                                         gpointer         user_data)
   346 {
   347     const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
   348     open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "lxDream Save State (*.dst)", dir );
   349 }
   352 void
   353 on_savestate_button_clicked            (GtkToolButton   *toolbutton,
   354                                         gpointer         user_data)
   355 {
   356     const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
   357     save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "lxDream Save State (*.dst)", dir );
   358 }
.