Search
lxdream.org :: lxdream/src/gui/debugcb.c :: diff
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 (12 years ago)
permissions -rw-r--r--
last change First cut of new GUI
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/gui/debugcb.c Wed Oct 10 11:02:04 2007 +0000
1.3 @@ -0,0 +1,359 @@
1.4 +/**
1.5 + * $Id: debugcb.c,v 1.1 2007-10-10 11:02:04 nkeynes Exp $
1.6 + *
1.7 + * All GTK callbacks go here (stubs are autogenerated by Glade)
1.8 + *
1.9 + * Copyright (c) 2005 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +
1.22 +#ifdef HAVE_CONFIG_H
1.23 +# include <config.h>
1.24 +#endif
1.25 +
1.26 +#include <gnome.h>
1.27 +
1.28 +#include "gui/debugcb.h"
1.29 +#include "gui/debugif.h"
1.30 +#include "gui/gtkui.h"
1.31 +#include "gdrom/gdrom.h"
1.32 +#include "mem.h"
1.33 +#include "mmio.h"
1.34 +#include "dreamcast.h"
1.35 +#include "loader.h"
1.36 +#include "pvr2/pvr2.h"
1.37 +
1.38 +int selected_pc = -1;
1.39 +int selected_row = -1;
1.40 +
1.41 +debug_window_t get_debug_info( GtkWidget *widget );
1.42 +
1.43 +void
1.44 +on_new_file1_activate (GtkMenuItem *menuitem,
1.45 + gpointer user_data)
1.46 +{
1.47 +
1.48 +}
1.49 +
1.50 +
1.51 +void
1.52 +on_open1_activate (GtkMenuItem *menuitem,
1.53 + gpointer user_data)
1.54 +{
1.55 + const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
1.56 + open_file_dialog( "Open...", file_load_magic, NULL, NULL, dir );
1.57 +}
1.58 +
1.59 +
1.60 +void
1.61 +on_save1_activate (GtkMenuItem *menuitem,
1.62 + gpointer user_data)
1.63 +{
1.64 +
1.65 +}
1.66 +
1.67 +
1.68 +void
1.69 +on_save_as1_activate (GtkMenuItem *menuitem,
1.70 + gpointer user_data)
1.71 +{
1.72 +
1.73 +}
1.74 +
1.75 +void
1.76 +on_save_next_scene_activate( GtkMenuItem *menuitem,
1.77 + gpointer user_data)
1.78 +{
1.79 + const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
1.80 + save_file_dialog( "Save next scene...", pvr2_save_next_scene, "*.dsc", "lxdream scene file (*.dsc)", dir );
1.81 +}
1.82 +
1.83 +void
1.84 +on_exit1_activate (GtkMenuItem *menuitem,
1.85 + gpointer user_data)
1.86 +{
1.87 + gtk_main_quit();
1.88 +}
1.89 +
1.90 +
1.91 +void
1.92 +on_preferences1_activate (GtkMenuItem *menuitem,
1.93 + gpointer user_data)
1.94 +{
1.95 +
1.96 +}
1.97 +
1.98 +
1.99 +void
1.100 +on_about1_activate (GtkMenuItem *menuitem,
1.101 + gpointer user_data)
1.102 +{
1.103 + GtkWidget *about = create_about_win();
1.104 + gtk_widget_show(about);
1.105 +}
1.106 +
1.107 +
1.108 +void
1.109 +on_load_btn_clicked (GtkButton *button,
1.110 + gpointer user_data)
1.111 +{
1.112 + const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
1.113 + open_file_dialog( "Open...", gdrom_mount_image, NULL, NULL, dir );
1.114 +}
1.115 +
1.116 +
1.117 +void
1.118 +on_reset_btn_clicked (GtkButton *button,
1.119 + gpointer user_data)
1.120 +{
1.121 + dreamcast_reset();
1.122 +}
1.123 +
1.124 +
1.125 +void
1.126 +on_stop_btn_clicked (GtkButton *button,
1.127 + gpointer user_data)
1.128 +{
1.129 + dreamcast_stop();
1.130 +}
1.131 +
1.132 +
1.133 +void
1.134 +on_step_btn_clicked (GtkButton *button,
1.135 + gpointer user_data)
1.136 +{
1.137 + debug_window_t data = get_debug_info(GTK_WIDGET(button));
1.138 + debug_win_single_step(data);
1.139 +}
1.140 +
1.141 +
1.142 +void
1.143 +on_run_btn_clicked (GtkButton *button,
1.144 + gpointer user_data)
1.145 +{
1.146 + dreamcast_run();
1.147 +}
1.148 +
1.149 +
1.150 +void
1.151 +on_runto_btn_clicked (GtkButton *button,
1.152 + gpointer user_data)
1.153 +{
1.154 + if( selected_pc == -1 )
1.155 + WARN( "No address selected, so can't run to it", NULL );
1.156 + else {
1.157 + debug_window_t data = get_debug_info(GTK_WIDGET(button));
1.158 + debug_win_set_oneshot_breakpoint( data, selected_row );
1.159 + dreamcast_run();
1.160 + }
1.161 +}
1.162 +
1.163 +
1.164 +void
1.165 +on_break_btn_clicked (GtkButton *button,
1.166 + gpointer user_data)
1.167 +{
1.168 + debug_window_t data = get_debug_info(GTK_WIDGET(button));
1.169 + debug_win_toggle_breakpoint( data, selected_row );
1.170 +}
1.171 +
1.172 +void on_trace_button_toggled (GtkToggleButton *button,
1.173 + gpointer user_data)
1.174 +{
1.175 + struct mmio_region *io_rgn = (struct mmio_region *)user_data;
1.176 + gboolean isActive = gtk_toggle_button_get_active(button);
1.177 + if( io_rgn != NULL ) {
1.178 + io_rgn->trace_flag = isActive ? 1 : 0;
1.179 + }
1.180 +}
1.181 +
1.182 +
1.183 +gboolean
1.184 +on_debug_win_delete_event (GtkWidget *widget,
1.185 + GdkEvent *event,
1.186 + gpointer user_data)
1.187 +{
1.188 + dreamcast_shutdown();
1.189 + gtk_main_quit();
1.190 + return FALSE;
1.191 +}
1.192 +
1.193 +
1.194 +void
1.195 +on_disasm_list_select_row (GtkCList *clist,
1.196 + gint row,
1.197 + gint column,
1.198 + GdkEvent *event,
1.199 + gpointer user_data)
1.200 +{
1.201 + debug_window_t data = get_debug_info(GTK_WIDGET(clist));
1.202 + selected_pc = row_to_address(data, row);
1.203 + selected_row = row;
1.204 +}
1.205 +
1.206 +
1.207 +void
1.208 +on_disasm_list_unselect_row (GtkCList *clist,
1.209 + gint row,
1.210 + gint column,
1.211 + GdkEvent *event,
1.212 + gpointer user_data)
1.213 +{
1.214 + debug_window_t data = get_debug_info(GTK_WIDGET(clist));
1.215 + int pc = row_to_address(data,row);
1.216 + if( selected_pc == pc ) selected_pc = -1;
1.217 +}
1.218 +
1.219 +
1.220 +void
1.221 +on_mem_mapped_regs1_activate (GtkMenuItem *menuitem,
1.222 + gpointer user_data)
1.223 +{
1.224 + mmr_open_win();
1.225 +}
1.226 +
1.227 +
1.228 +gboolean
1.229 +on_mmr_win_delete_event (GtkWidget *widget,
1.230 + GdkEvent *event,
1.231 + gpointer user_data)
1.232 +{
1.233 + mmr_close_win();
1.234 + return TRUE;
1.235 +}
1.236 +
1.237 +
1.238 +void
1.239 +on_mmr_close_clicked (GtkButton *button,
1.240 + gpointer user_data)
1.241 +{
1.242 + mmr_close_win();
1.243 +}
1.244 +
1.245 +
1.246 +void
1.247 +on_mode_field_changed (GtkEditable *editable,
1.248 + gpointer user_data)
1.249 +{
1.250 + const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
1.251 + debug_window_t data = get_debug_info( GTK_WIDGET(editable) );
1.252 + set_disassembly_cpu( data, text );
1.253 +}
1.254 +
1.255 +
1.256 +void
1.257 +on_page_locked_btn_toggled (GtkToggleButton *togglebutton,
1.258 + gpointer user_data)
1.259 +{
1.260 +
1.261 +}
1.262 +
1.263 +
1.264 +gboolean
1.265 +on_page_field_key_press_event (GtkWidget *widget,
1.266 + GdkEventKey *event,
1.267 + gpointer user_data)
1.268 +{
1.269 + if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
1.270 + debug_window_t data = get_debug_info(widget);
1.271 + const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
1.272 + gchar *endptr;
1.273 + unsigned int val = strtoul( text, &endptr, 16 );
1.274 + if( text == endptr ) { /* invalid input */
1.275 + char buf[10];
1.276 + sprintf( buf, "%08X", row_to_address(data,0) );
1.277 + gtk_entry_set_text( GTK_ENTRY(widget), buf );
1.278 + } else {
1.279 + set_disassembly_region(data, val);
1.280 + }
1.281 + }
1.282 + return FALSE;
1.283 +}
1.284 +
1.285 +
1.286 +void
1.287 +on_output_list_select_row (GtkCList *clist,
1.288 + gint row,
1.289 + gint column,
1.290 + GdkEvent *event,
1.291 + gpointer user_data)
1.292 +{
1.293 + if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
1.294 + char *val;
1.295 + gtk_clist_get_text( clist, row, 2, &val );
1.296 + if( val[0] != '\0' ) {
1.297 + int addr = strtoul( val, NULL, 16 );
1.298 + debug_window_t data = get_debug_info( GTK_WIDGET(clist) );
1.299 + jump_to_disassembly( data, addr, TRUE );
1.300 + }
1.301 + }
1.302 +}
1.303 +
1.304 +
1.305 +void
1.306 +on_jump_pc_btn_clicked (GtkButton *button,
1.307 + gpointer user_data)
1.308 +{
1.309 + debug_window_t data = get_debug_info( GTK_WIDGET(button) );
1.310 + jump_to_pc( data, TRUE );
1.311 +}
1.312 +
1.313 +
1.314 +void
1.315 +on_button_add_watch_clicked (GtkButton *button,
1.316 + gpointer user_data)
1.317 +{
1.318 +
1.319 +}
1.320 +
1.321 +
1.322 +void
1.323 +on_button_clear_all_clicked (GtkButton *button,
1.324 + gpointer user_data)
1.325 +{
1.326 +
1.327 +}
1.328 +
1.329 +
1.330 +void
1.331 +on_button_close_clicked (GtkButton *button,
1.332 + gpointer user_data)
1.333 +{
1.334 +
1.335 +}
1.336 +
1.337 +
1.338 +void
1.339 +on_view_memory_activate (GtkMenuItem *menuitem,
1.340 + gpointer user_data)
1.341 +{
1.342 + dump_window_new();
1.343 +}
1.344 +
1.345 +
1.346 +void
1.347 +on_loadstate_button_clicked (GtkToolButton *toolbutton,
1.348 + gpointer user_data)
1.349 +{
1.350 + const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
1.351 + open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "lxDream Save State (*.dst)", dir );
1.352 +}
1.353 +
1.354 +
1.355 +void
1.356 +on_savestate_button_clicked (GtkToolButton *toolbutton,
1.357 + gpointer user_data)
1.358 +{
1.359 + const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
1.360 + save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "lxDream Save State (*.dst)", dir );
1.361 +}
1.362 +
.