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
file annotate diff log raw
nkeynes@435
     1
/**
nkeynes@435
     2
 * $Id: debugcb.c,v 1.1 2007-10-10 11:02:04 nkeynes Exp $
nkeynes@435
     3
 *
nkeynes@435
     4
 * All GTK callbacks go here (stubs are autogenerated by Glade)
nkeynes@435
     5
 *
nkeynes@435
     6
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@435
     7
 *
nkeynes@435
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@435
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@435
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@435
    11
 * (at your option) any later version.
nkeynes@435
    12
 *
nkeynes@435
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@435
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@435
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@435
    16
 * GNU General Public License for more details.
nkeynes@435
    17
 */
nkeynes@435
    18
nkeynes@435
    19
#ifdef HAVE_CONFIG_H
nkeynes@435
    20
#  include <config.h>
nkeynes@435
    21
#endif
nkeynes@435
    22
nkeynes@435
    23
#include <gnome.h>
nkeynes@435
    24
nkeynes@435
    25
#include "gui/debugcb.h"
nkeynes@435
    26
#include "gui/debugif.h"
nkeynes@435
    27
#include "gui/gtkui.h"
nkeynes@435
    28
#include "gdrom/gdrom.h"
nkeynes@435
    29
#include "mem.h"
nkeynes@435
    30
#include "mmio.h"
nkeynes@435
    31
#include "dreamcast.h"
nkeynes@435
    32
#include "loader.h"
nkeynes@435
    33
#include "pvr2/pvr2.h"
nkeynes@435
    34
nkeynes@435
    35
int selected_pc = -1;
nkeynes@435
    36
int selected_row = -1;
nkeynes@435
    37
nkeynes@435
    38
debug_window_t get_debug_info( GtkWidget *widget );
nkeynes@435
    39
nkeynes@435
    40
void
nkeynes@435
    41
on_new_file1_activate                  (GtkMenuItem     *menuitem,
nkeynes@435
    42
                                        gpointer         user_data)
nkeynes@435
    43
{
nkeynes@435
    44
nkeynes@435
    45
}
nkeynes@435
    46
nkeynes@435
    47
nkeynes@435
    48
void
nkeynes@435
    49
on_open1_activate                      (GtkMenuItem     *menuitem,
nkeynes@435
    50
                                        gpointer         user_data)
nkeynes@435
    51
{
nkeynes@435
    52
    const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
nkeynes@435
    53
    open_file_dialog( "Open...", file_load_magic, NULL, NULL, dir );
nkeynes@435
    54
}
nkeynes@435
    55
nkeynes@435
    56
nkeynes@435
    57
void
nkeynes@435
    58
on_save1_activate                      (GtkMenuItem     *menuitem,
nkeynes@435
    59
                                        gpointer         user_data)
nkeynes@435
    60
{
nkeynes@435
    61
nkeynes@435
    62
}
nkeynes@435
    63
nkeynes@435
    64
nkeynes@435
    65
void
nkeynes@435
    66
on_save_as1_activate                   (GtkMenuItem     *menuitem,
nkeynes@435
    67
                                        gpointer         user_data)
nkeynes@435
    68
{
nkeynes@435
    69
nkeynes@435
    70
}
nkeynes@435
    71
nkeynes@435
    72
void 
nkeynes@435
    73
on_save_next_scene_activate( GtkMenuItem *menuitem,
nkeynes@435
    74
			     gpointer user_data) 
nkeynes@435
    75
{
nkeynes@435
    76
    const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
nkeynes@435
    77
    save_file_dialog( "Save next scene...", pvr2_save_next_scene, "*.dsc", "lxdream scene file (*.dsc)", dir );
nkeynes@435
    78
}
nkeynes@435
    79
nkeynes@435
    80
void
nkeynes@435
    81
on_exit1_activate                      (GtkMenuItem     *menuitem,
nkeynes@435
    82
                                        gpointer         user_data)
nkeynes@435
    83
{
nkeynes@435
    84
    gtk_main_quit();
nkeynes@435
    85
}
nkeynes@435
    86
nkeynes@435
    87
nkeynes@435
    88
void
nkeynes@435
    89
on_preferences1_activate               (GtkMenuItem     *menuitem,
nkeynes@435
    90
                                        gpointer         user_data)
nkeynes@435
    91
{
nkeynes@435
    92
nkeynes@435
    93
}
nkeynes@435
    94
nkeynes@435
    95
nkeynes@435
    96
void
nkeynes@435
    97
on_about1_activate                     (GtkMenuItem     *menuitem,
nkeynes@435
    98
                                        gpointer         user_data)
nkeynes@435
    99
{
nkeynes@435
   100
    GtkWidget *about = create_about_win();
nkeynes@435
   101
    gtk_widget_show(about);
nkeynes@435
   102
}
nkeynes@435
   103
nkeynes@435
   104
nkeynes@435
   105
void
nkeynes@435
   106
on_load_btn_clicked                    (GtkButton       *button,
nkeynes@435
   107
                                        gpointer         user_data)
nkeynes@435
   108
{
nkeynes@435
   109
    const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
nkeynes@435
   110
    open_file_dialog( "Open...", gdrom_mount_image, NULL, NULL, dir );
nkeynes@435
   111
}
nkeynes@435
   112
nkeynes@435
   113
nkeynes@435
   114
void
nkeynes@435
   115
on_reset_btn_clicked                   (GtkButton       *button,
nkeynes@435
   116
                                        gpointer         user_data)
nkeynes@435
   117
{
nkeynes@435
   118
    dreamcast_reset();
nkeynes@435
   119
}
nkeynes@435
   120
nkeynes@435
   121
nkeynes@435
   122
void
nkeynes@435
   123
on_stop_btn_clicked                    (GtkButton       *button,
nkeynes@435
   124
                                        gpointer         user_data)
nkeynes@435
   125
{
nkeynes@435
   126
    dreamcast_stop();
nkeynes@435
   127
}
nkeynes@435
   128
nkeynes@435
   129
nkeynes@435
   130
void
nkeynes@435
   131
on_step_btn_clicked                    (GtkButton       *button,
nkeynes@435
   132
                                        gpointer         user_data)
nkeynes@435
   133
{
nkeynes@435
   134
    debug_window_t data = get_debug_info(GTK_WIDGET(button));
nkeynes@435
   135
    debug_win_single_step(data);
nkeynes@435
   136
}
nkeynes@435
   137
nkeynes@435
   138
nkeynes@435
   139
void
nkeynes@435
   140
on_run_btn_clicked                     (GtkButton       *button,
nkeynes@435
   141
                                        gpointer         user_data)
nkeynes@435
   142
{
nkeynes@435
   143
    dreamcast_run();
nkeynes@435
   144
}
nkeynes@435
   145
nkeynes@435
   146
nkeynes@435
   147
void
nkeynes@435
   148
on_runto_btn_clicked                   (GtkButton       *button,
nkeynes@435
   149
                                        gpointer         user_data)
nkeynes@435
   150
{
nkeynes@435
   151
    if( selected_pc == -1 )
nkeynes@435
   152
        WARN( "No address selected, so can't run to it", NULL );
nkeynes@435
   153
    else {
nkeynes@435
   154
	debug_window_t data = get_debug_info(GTK_WIDGET(button));
nkeynes@435
   155
	debug_win_set_oneshot_breakpoint( data, selected_row );
nkeynes@435
   156
	dreamcast_run();
nkeynes@435
   157
    }
nkeynes@435
   158
}
nkeynes@435
   159
nkeynes@435
   160
nkeynes@435
   161
void
nkeynes@435
   162
on_break_btn_clicked                   (GtkButton       *button,
nkeynes@435
   163
                                        gpointer         user_data)
nkeynes@435
   164
{
nkeynes@435
   165
    debug_window_t data = get_debug_info(GTK_WIDGET(button));
nkeynes@435
   166
    debug_win_toggle_breakpoint( data, selected_row );
nkeynes@435
   167
}
nkeynes@435
   168
nkeynes@435
   169
void on_trace_button_toggled           (GtkToggleButton *button,
nkeynes@435
   170
					gpointer user_data)
nkeynes@435
   171
{
nkeynes@435
   172
    struct mmio_region *io_rgn = (struct mmio_region *)user_data;
nkeynes@435
   173
    gboolean isActive = gtk_toggle_button_get_active(button);
nkeynes@435
   174
    if( io_rgn != NULL ) {
nkeynes@435
   175
	io_rgn->trace_flag = isActive ? 1 : 0;
nkeynes@435
   176
    }
nkeynes@435
   177
}
nkeynes@435
   178
nkeynes@435
   179
nkeynes@435
   180
gboolean
nkeynes@435
   181
on_debug_win_delete_event              (GtkWidget       *widget,
nkeynes@435
   182
                                        GdkEvent        *event,
nkeynes@435
   183
                                        gpointer         user_data)
nkeynes@435
   184
{
nkeynes@435
   185
    dreamcast_shutdown();
nkeynes@435
   186
    gtk_main_quit();
nkeynes@435
   187
    return FALSE;
nkeynes@435
   188
}
nkeynes@435
   189
nkeynes@435
   190
nkeynes@435
   191
void
nkeynes@435
   192
on_disasm_list_select_row              (GtkCList        *clist,
nkeynes@435
   193
                                        gint             row,
nkeynes@435
   194
                                        gint             column,
nkeynes@435
   195
                                        GdkEvent        *event,
nkeynes@435
   196
                                        gpointer         user_data)
nkeynes@435
   197
{
nkeynes@435
   198
    debug_window_t data = get_debug_info(GTK_WIDGET(clist));
nkeynes@435
   199
    selected_pc = row_to_address(data, row);
nkeynes@435
   200
    selected_row = row;
nkeynes@435
   201
}
nkeynes@435
   202
nkeynes@435
   203
nkeynes@435
   204
void
nkeynes@435
   205
on_disasm_list_unselect_row            (GtkCList        *clist,
nkeynes@435
   206
                                        gint             row,
nkeynes@435
   207
                                        gint             column,
nkeynes@435
   208
                                        GdkEvent        *event,
nkeynes@435
   209
                                        gpointer         user_data)
nkeynes@435
   210
{
nkeynes@435
   211
    debug_window_t data = get_debug_info(GTK_WIDGET(clist));
nkeynes@435
   212
    int pc = row_to_address(data,row);
nkeynes@435
   213
    if( selected_pc == pc ) selected_pc = -1;
nkeynes@435
   214
}
nkeynes@435
   215
nkeynes@435
   216
nkeynes@435
   217
void
nkeynes@435
   218
on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
nkeynes@435
   219
                                        gpointer         user_data)
nkeynes@435
   220
{
nkeynes@435
   221
    mmr_open_win();
nkeynes@435
   222
}
nkeynes@435
   223
nkeynes@435
   224
nkeynes@435
   225
gboolean
nkeynes@435
   226
on_mmr_win_delete_event                (GtkWidget       *widget,
nkeynes@435
   227
                                        GdkEvent        *event,
nkeynes@435
   228
                                        gpointer         user_data)
nkeynes@435
   229
{
nkeynes@435
   230
    mmr_close_win();
nkeynes@435
   231
    return TRUE;
nkeynes@435
   232
}
nkeynes@435
   233
nkeynes@435
   234
nkeynes@435
   235
void
nkeynes@435
   236
on_mmr_close_clicked                   (GtkButton       *button,
nkeynes@435
   237
                                        gpointer         user_data)
nkeynes@435
   238
{
nkeynes@435
   239
    mmr_close_win();
nkeynes@435
   240
}
nkeynes@435
   241
nkeynes@435
   242
nkeynes@435
   243
void
nkeynes@435
   244
on_mode_field_changed                  (GtkEditable     *editable,
nkeynes@435
   245
                                        gpointer         user_data)
nkeynes@435
   246
{
nkeynes@435
   247
    const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
nkeynes@435
   248
    debug_window_t data = get_debug_info( GTK_WIDGET(editable) );
nkeynes@435
   249
    set_disassembly_cpu( data, text );
nkeynes@435
   250
}
nkeynes@435
   251
nkeynes@435
   252
nkeynes@435
   253
void
nkeynes@435
   254
on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
nkeynes@435
   255
                                        gpointer         user_data)
nkeynes@435
   256
{
nkeynes@435
   257
nkeynes@435
   258
}
nkeynes@435
   259
nkeynes@435
   260
nkeynes@435
   261
gboolean
nkeynes@435
   262
on_page_field_key_press_event          (GtkWidget       *widget,
nkeynes@435
   263
                                        GdkEventKey     *event,
nkeynes@435
   264
                                        gpointer         user_data)
nkeynes@435
   265
{
nkeynes@435
   266
    if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
nkeynes@435
   267
	debug_window_t data = get_debug_info(widget);
nkeynes@435
   268
        const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
nkeynes@435
   269
        gchar *endptr;
nkeynes@435
   270
        unsigned int val = strtoul( text, &endptr, 16 );
nkeynes@435
   271
        if( text == endptr ) { /* invalid input */
nkeynes@435
   272
            char buf[10];
nkeynes@435
   273
            sprintf( buf, "%08X", row_to_address(data,0) );
nkeynes@435
   274
            gtk_entry_set_text( GTK_ENTRY(widget), buf );
nkeynes@435
   275
        } else {
nkeynes@435
   276
            set_disassembly_region(data, val);
nkeynes@435
   277
        }
nkeynes@435
   278
    }
nkeynes@435
   279
    return FALSE;
nkeynes@435
   280
}
nkeynes@435
   281
nkeynes@435
   282
nkeynes@435
   283
void
nkeynes@435
   284
on_output_list_select_row              (GtkCList        *clist,
nkeynes@435
   285
                                        gint             row,
nkeynes@435
   286
                                        gint             column,
nkeynes@435
   287
                                        GdkEvent        *event,
nkeynes@435
   288
                                        gpointer         user_data)
nkeynes@435
   289
{
nkeynes@435
   290
    if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
nkeynes@435
   291
        char *val;
nkeynes@435
   292
        gtk_clist_get_text( clist, row, 2, &val );
nkeynes@435
   293
        if( val[0] != '\0' ) {
nkeynes@435
   294
            int addr = strtoul( val, NULL, 16 );
nkeynes@435
   295
	    debug_window_t data = get_debug_info( GTK_WIDGET(clist) );
nkeynes@435
   296
            jump_to_disassembly( data, addr, TRUE );
nkeynes@435
   297
        }
nkeynes@435
   298
    }
nkeynes@435
   299
}
nkeynes@435
   300
nkeynes@435
   301
nkeynes@435
   302
void
nkeynes@435
   303
on_jump_pc_btn_clicked                 (GtkButton       *button,
nkeynes@435
   304
                                        gpointer         user_data)
nkeynes@435
   305
{
nkeynes@435
   306
    debug_window_t data = get_debug_info( GTK_WIDGET(button) );
nkeynes@435
   307
    jump_to_pc( data, TRUE );
nkeynes@435
   308
}
nkeynes@435
   309
nkeynes@435
   310
nkeynes@435
   311
void
nkeynes@435
   312
on_button_add_watch_clicked            (GtkButton       *button,
nkeynes@435
   313
                                        gpointer         user_data)
nkeynes@435
   314
{
nkeynes@435
   315
nkeynes@435
   316
}
nkeynes@435
   317
nkeynes@435
   318
nkeynes@435
   319
void
nkeynes@435
   320
on_button_clear_all_clicked            (GtkButton       *button,
nkeynes@435
   321
                                        gpointer         user_data)
nkeynes@435
   322
{
nkeynes@435
   323
nkeynes@435
   324
}
nkeynes@435
   325
nkeynes@435
   326
nkeynes@435
   327
void
nkeynes@435
   328
on_button_close_clicked                (GtkButton       *button,
nkeynes@435
   329
                                        gpointer         user_data)
nkeynes@435
   330
{
nkeynes@435
   331
nkeynes@435
   332
}
nkeynes@435
   333
nkeynes@435
   334
nkeynes@435
   335
void
nkeynes@435
   336
on_view_memory_activate                (GtkMenuItem     *menuitem,
nkeynes@435
   337
                                        gpointer         user_data)
nkeynes@435
   338
{
nkeynes@435
   339
    dump_window_new();
nkeynes@435
   340
}
nkeynes@435
   341
nkeynes@435
   342
nkeynes@435
   343
void
nkeynes@435
   344
on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
nkeynes@435
   345
                                        gpointer         user_data)
nkeynes@435
   346
{
nkeynes@435
   347
    const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
nkeynes@435
   348
    open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "lxDream Save State (*.dst)", dir );
nkeynes@435
   349
}
nkeynes@435
   350
nkeynes@435
   351
nkeynes@435
   352
void
nkeynes@435
   353
on_savestate_button_clicked            (GtkToolButton   *toolbutton,
nkeynes@435
   354
                                        gpointer         user_data)
nkeynes@435
   355
{
nkeynes@435
   356
    const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
nkeynes@435
   357
    save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "lxDream Save State (*.dst)", dir );
nkeynes@435
   358
}
nkeynes@435
   359
.