Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 277:fcc1274776cb
prev238:6af4cc93b137
next296:1aa1c5ba59fd
author nkeynes
date Fri Jan 12 10:16:02 2007 +0000 (14 years ago)
permissions -rw-r--r--
last change Add ability to save flash
file annotate diff log raw
nkeynes@26
     1
/**
nkeynes@277
     2
 * $Id: callbacks.c,v 1.18 2007-01-12 10:16:02 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@277
   175
    dreamcast_shutdown();
nkeynes@1
   176
    gtk_main_quit();
nkeynes@26
   177
    return FALSE;
nkeynes@1
   178
}
nkeynes@1
   179
nkeynes@1
   180
nkeynes@1
   181
void
nkeynes@1
   182
on_disasm_list_select_row              (GtkCList        *clist,
nkeynes@1
   183
                                        gint             row,
nkeynes@1
   184
                                        gint             column,
nkeynes@1
   185
                                        GdkEvent        *event,
nkeynes@1
   186
                                        gpointer         user_data)
nkeynes@1
   187
{
nkeynes@9
   188
    debug_info_t data = get_debug_info(GTK_WIDGET(clist));
nkeynes@9
   189
    selected_pc = row_to_address(data, row);
nkeynes@43
   190
    selected_row = row;
nkeynes@1
   191
}
nkeynes@1
   192
nkeynes@1
   193
nkeynes@1
   194
void
nkeynes@1
   195
on_disasm_list_unselect_row            (GtkCList        *clist,
nkeynes@1
   196
                                        gint             row,
nkeynes@1
   197
                                        gint             column,
nkeynes@1
   198
                                        GdkEvent        *event,
nkeynes@1
   199
                                        gpointer         user_data)
nkeynes@1
   200
{
nkeynes@9
   201
    debug_info_t data = get_debug_info(GTK_WIDGET(clist));
nkeynes@9
   202
    int pc = row_to_address(data,row);
nkeynes@1
   203
    if( selected_pc == pc ) selected_pc = -1;
nkeynes@1
   204
}
nkeynes@1
   205
nkeynes@1
   206
nkeynes@1
   207
void
nkeynes@1
   208
on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
nkeynes@1
   209
                                        gpointer         user_data)
nkeynes@1
   210
{
nkeynes@1
   211
    mmr_open_win();
nkeynes@1
   212
}
nkeynes@1
   213
nkeynes@1
   214
nkeynes@1
   215
gboolean
nkeynes@1
   216
on_mmr_win_delete_event                (GtkWidget       *widget,
nkeynes@1
   217
                                        GdkEvent        *event,
nkeynes@1
   218
                                        gpointer         user_data)
nkeynes@1
   219
{
nkeynes@1
   220
    mmr_close_win();
nkeynes@1
   221
    return TRUE;
nkeynes@1
   222
}
nkeynes@1
   223
nkeynes@1
   224
nkeynes@1
   225
void
nkeynes@1
   226
on_mmr_close_clicked                   (GtkButton       *button,
nkeynes@1
   227
                                        gpointer         user_data)
nkeynes@1
   228
{
nkeynes@1
   229
    mmr_close_win();
nkeynes@1
   230
}
nkeynes@1
   231
nkeynes@1
   232
nkeynes@1
   233
void
nkeynes@1
   234
on_mode_field_changed                  (GtkEditable     *editable,
nkeynes@1
   235
                                        gpointer         user_data)
nkeynes@1
   236
{
nkeynes@18
   237
    const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
nkeynes@10
   238
    debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
nkeynes@10
   239
    set_disassembly_cpu( data, text );
nkeynes@1
   240
}
nkeynes@1
   241
nkeynes@1
   242
nkeynes@1
   243
void
nkeynes@1
   244
on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
nkeynes@1
   245
                                        gpointer         user_data)
nkeynes@1
   246
{
nkeynes@1
   247
nkeynes@1
   248
}
nkeynes@1
   249
nkeynes@1
   250
nkeynes@1
   251
gboolean
nkeynes@1
   252
on_page_field_key_press_event          (GtkWidget       *widget,
nkeynes@1
   253
                                        GdkEventKey     *event,
nkeynes@1
   254
                                        gpointer         user_data)
nkeynes@1
   255
{
nkeynes@1
   256
    if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
nkeynes@9
   257
	debug_info_t data = get_debug_info(widget);
nkeynes@18
   258
        const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
nkeynes@1
   259
        gchar *endptr;
nkeynes@1
   260
        unsigned int val = strtoul( text, &endptr, 16 );
nkeynes@1
   261
        if( text == endptr ) { /* invalid input */
nkeynes@1
   262
            char buf[10];
nkeynes@9
   263
            sprintf( buf, "%08X", row_to_address(data,0) );
nkeynes@1
   264
            gtk_entry_set_text( GTK_ENTRY(widget), buf );
nkeynes@1
   265
        } else {
nkeynes@9
   266
            set_disassembly_region(data, val);
nkeynes@1
   267
        }
nkeynes@1
   268
    }
nkeynes@1
   269
    return FALSE;
nkeynes@1
   270
}
nkeynes@1
   271
nkeynes@1
   272
nkeynes@1
   273
void
nkeynes@1
   274
on_output_list_select_row              (GtkCList        *clist,
nkeynes@1
   275
                                        gint             row,
nkeynes@1
   276
                                        gint             column,
nkeynes@1
   277
                                        GdkEvent        *event,
nkeynes@1
   278
                                        gpointer         user_data)
nkeynes@1
   279
{
nkeynes@1
   280
    if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
nkeynes@1
   281
        char *val;
nkeynes@45
   282
        gtk_clist_get_text( clist, row, 2, &val );
nkeynes@1
   283
        if( val[0] != '\0' ) {
nkeynes@1
   284
            int addr = strtoul( val, NULL, 16 );
nkeynes@9
   285
	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
nkeynes@9
   286
            jump_to_disassembly( data, addr, TRUE );
nkeynes@1
   287
        }
nkeynes@1
   288
    }
nkeynes@1
   289
}
nkeynes@1
   290
nkeynes@1
   291
nkeynes@1
   292
void
nkeynes@1
   293
on_jump_pc_btn_clicked                 (GtkButton       *button,
nkeynes@1
   294
                                        gpointer         user_data)
nkeynes@1
   295
{
nkeynes@9
   296
    debug_info_t data = get_debug_info( GTK_WIDGET(button) );
nkeynes@9
   297
    jump_to_pc( data, TRUE );
nkeynes@1
   298
}
nkeynes@1
   299
nkeynes@2
   300
nkeynes@2
   301
void
nkeynes@2
   302
on_button_add_watch_clicked            (GtkButton       *button,
nkeynes@2
   303
                                        gpointer         user_data)
nkeynes@2
   304
{
nkeynes@2
   305
nkeynes@2
   306
}
nkeynes@2
   307
nkeynes@2
   308
nkeynes@2
   309
void
nkeynes@2
   310
on_button_clear_all_clicked            (GtkButton       *button,
nkeynes@2
   311
                                        gpointer         user_data)
nkeynes@2
   312
{
nkeynes@2
   313
nkeynes@2
   314
}
nkeynes@2
   315
nkeynes@2
   316
nkeynes@2
   317
void
nkeynes@2
   318
on_button_close_clicked                (GtkButton       *button,
nkeynes@2
   319
                                        gpointer         user_data)
nkeynes@2
   320
{
nkeynes@2
   321
nkeynes@2
   322
}
nkeynes@2
   323
nkeynes@2
   324
nkeynes@2
   325
void
nkeynes@2
   326
on_view_memory_activate                (GtkMenuItem     *menuitem,
nkeynes@2
   327
                                        gpointer         user_data)
nkeynes@2
   328
{
nkeynes@2
   329
    dump_window_new();
nkeynes@2
   330
}
nkeynes@2
   331
nkeynes@18
   332
nkeynes@18
   333
void
nkeynes@18
   334
on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
nkeynes@18
   335
                                        gpointer         user_data)
nkeynes@18
   336
{
nkeynes@167
   337
    const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
nkeynes@180
   338
    open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "lxDream Save State (*.dst)", dir );
nkeynes@18
   339
}
nkeynes@18
   340
nkeynes@18
   341
nkeynes@18
   342
void
nkeynes@18
   343
on_savestate_button_clicked            (GtkToolButton   *toolbutton,
nkeynes@18
   344
                                        gpointer         user_data)
nkeynes@18
   345
{
nkeynes@167
   346
    const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
nkeynes@180
   347
    save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "lxDream Save State (*.dst)", dir );
nkeynes@18
   348
}
nkeynes@18
   349
.