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