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