Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 30:89b30313d757
prev27:1ef09a52cd1e
next43:0cf3e339cc59
author nkeynes
date Sun Dec 25 05:57:00 2005 +0000 (14 years ago)
permissions -rw-r--r--
last change Change timeslice to nanoseconds (was microseconds)
Generize single step (now steps through active CPU)
Add lots of header blocks
view annotate diff log raw
     1 /**
     2  * $Id: callbacks.c,v 1.10 2005-12-25 05:57:00 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 "asic.h"
    30 #include "dreamcast.h"
    31 #include "loader.h"
    33 int selected_pc = -1;
    35 void
    36 on_new_file1_activate                  (GtkMenuItem     *menuitem,
    37                                         gpointer         user_data)
    38 {
    40 }
    43 void
    44 on_open1_activate                      (GtkMenuItem     *menuitem,
    45                                         gpointer         user_data)
    46 {
    47     open_file_dialog( "Open...", file_load_magic, NULL, NULL );
    48 }
    51 void
    52 on_save1_activate                      (GtkMenuItem     *menuitem,
    53                                         gpointer         user_data)
    54 {
    56 }
    59 void
    60 on_save_as1_activate                   (GtkMenuItem     *menuitem,
    61                                         gpointer         user_data)
    62 {
    64 }
    67 void
    68 on_exit1_activate                      (GtkMenuItem     *menuitem,
    69                                         gpointer         user_data)
    70 {
    71     gtk_main_quit();
    72 }
    75 void
    76 on_preferences1_activate               (GtkMenuItem     *menuitem,
    77                                         gpointer         user_data)
    78 {
    80 }
    83 void
    84 on_about1_activate                     (GtkMenuItem     *menuitem,
    85                                         gpointer         user_data)
    86 {
    87     GtkWidget *about = create_about_win();
    88     gtk_widget_show(about);
    89 }
    92 void
    93 on_load_btn_clicked                    (GtkButton       *button,
    94                                         gpointer         user_data)
    95 {
    96     open_file_dialog( "Open...", file_load_magic, NULL, NULL );
    97 }
   100 void
   101 on_reset_btn_clicked                   (GtkButton       *button,
   102                                         gpointer         user_data)
   103 {
   104     dreamcast_reset();
   105 }
   108 void
   109 on_stop_btn_clicked                    (GtkButton       *button,
   110                                         gpointer         user_data)
   111 {
   112     dreamcast_stop();
   113 }
   116 void
   117 on_step_btn_clicked                    (GtkButton       *button,
   118                                         gpointer         user_data)
   119 {
   120     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   121     debug_win_single_step(data);
   122 }
   125 void
   126 on_run_btn_clicked                     (GtkButton       *button,
   127                                         gpointer         user_data)
   128 {
   129     dreamcast_run();
   130 }
   133 void
   134 on_runto_btn_clicked                   (GtkButton       *button,
   135                                         gpointer         user_data)
   136 {
   137     if( selected_pc == -1 )
   138         WARN( "No address selected, so can't run to it", NULL );
   139     else {
   140         INFO( "Running until %08X...", selected_pc );
   141 	sh4_set_breakpoint( selected_pc, BREAK_ONESHOT );
   142 	dreamcast_run();
   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     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   173     selected_pc = row_to_address(data, row);
   174 }
   177 void
   178 on_disasm_list_unselect_row            (GtkCList        *clist,
   179                                         gint             row,
   180                                         gint             column,
   181                                         GdkEvent        *event,
   182                                         gpointer         user_data)
   183 {
   184     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   185     int pc = row_to_address(data,row);
   186     if( selected_pc == pc ) selected_pc = -1;
   187 }
   190 void
   191 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   192                                         gpointer         user_data)
   193 {
   194     mmr_open_win();
   195 }
   198 gboolean
   199 on_mmr_win_delete_event                (GtkWidget       *widget,
   200                                         GdkEvent        *event,
   201                                         gpointer         user_data)
   202 {
   203     mmr_close_win();
   204     return TRUE;
   205 }
   208 void
   209 on_mmr_close_clicked                   (GtkButton       *button,
   210                                         gpointer         user_data)
   211 {
   212     mmr_close_win();
   213 }
   216 void
   217 on_mode_field_changed                  (GtkEditable     *editable,
   218                                         gpointer         user_data)
   219 {
   220     const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
   221     debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
   222     set_disassembly_cpu( data, text );
   223 }
   226 void
   227 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   228                                         gpointer         user_data)
   229 {
   231 }
   234 gboolean
   235 on_page_field_key_press_event          (GtkWidget       *widget,
   236                                         GdkEventKey     *event,
   237                                         gpointer         user_data)
   238 {
   239     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   240 	debug_info_t data = get_debug_info(widget);
   241         const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   242         gchar *endptr;
   243         unsigned int val = strtoul( text, &endptr, 16 );
   244         if( text == endptr ) { /* invalid input */
   245             char buf[10];
   246             sprintf( buf, "%08X", row_to_address(data,0) );
   247             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   248         } else {
   249             set_disassembly_region(data, val);
   250         }
   251     }
   252     return FALSE;
   253 }
   256 void
   257 on_output_list_select_row              (GtkCList        *clist,
   258                                         gint             row,
   259                                         gint             column,
   260                                         GdkEvent        *event,
   261                                         gpointer         user_data)
   262 {
   263     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   264         char *val;
   265         gtk_clist_get_text( clist, row, 1, &val );
   266         if( val[0] != '\0' ) {
   267             int addr = strtoul( val, NULL, 16 );
   268 	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
   269             jump_to_disassembly( data, addr, TRUE );
   270         }
   271     }
   272 }
   275 void
   276 on_jump_pc_btn_clicked                 (GtkButton       *button,
   277                                         gpointer         user_data)
   278 {
   279     debug_info_t data = get_debug_info( GTK_WIDGET(button) );
   280     jump_to_pc( data, TRUE );
   281 }
   284 void
   285 on_button_add_watch_clicked            (GtkButton       *button,
   286                                         gpointer         user_data)
   287 {
   289 }
   292 void
   293 on_button_clear_all_clicked            (GtkButton       *button,
   294                                         gpointer         user_data)
   295 {
   297 }
   300 void
   301 on_button_close_clicked                (GtkButton       *button,
   302                                         gpointer         user_data)
   303 {
   305 }
   308 void
   309 on_view_memory_activate                (GtkMenuItem     *menuitem,
   310                                         gpointer         user_data)
   311 {
   312     dump_window_new();
   313 }
   316 void
   317 on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
   318                                         gpointer         user_data)
   319 {
   320     open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "DreamOn Save State (*.dst)" );
   321 }
   324 void
   325 on_savestate_button_clicked            (GtkToolButton   *toolbutton,
   326                                         gpointer         user_data)
   327 {
   328     save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "DreamOn Save State (*.dst)" );
   329 }
.