Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 23:1ec3acd0594d
prev19:9da7a8e38f9d
next26:ad258e3daaa5
author nkeynes
date Fri Dec 23 11:44:55 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change Start of "real" time slices, general structure in place now
file annotate diff log raw
nkeynes@1
     1
#ifdef HAVE_CONFIG_H
nkeynes@1
     2
#  include <config.h>
nkeynes@1
     3
#endif
nkeynes@1
     4
nkeynes@1
     5
#include <gnome.h>
nkeynes@1
     6
nkeynes@1
     7
#include "callbacks.h"
nkeynes@1
     8
#include "interface.h"
nkeynes@1
     9
#include "gui.h"
nkeynes@1
    10
#include "sh4core.h"
nkeynes@1
    11
#include "asic.h"
nkeynes@18
    12
#include "dreamcast.h"
nkeynes@1
    13
nkeynes@1
    14
int selected_pc = -1;
nkeynes@1
    15
nkeynes@1
    16
void
nkeynes@1
    17
on_new_file1_activate                  (GtkMenuItem     *menuitem,
nkeynes@1
    18
                                        gpointer         user_data)
nkeynes@1
    19
{
nkeynes@1
    20
nkeynes@1
    21
}
nkeynes@1
    22
nkeynes@1
    23
nkeynes@1
    24
void
nkeynes@1
    25
on_open1_activate                      (GtkMenuItem     *menuitem,
nkeynes@1
    26
                                        gpointer         user_data)
nkeynes@1
    27
{
nkeynes@18
    28
    open_file_dialog( "Open...", open_file, NULL, NULL );
nkeynes@1
    29
}
nkeynes@1
    30
nkeynes@1
    31
nkeynes@1
    32
void
nkeynes@1
    33
on_save1_activate                      (GtkMenuItem     *menuitem,
nkeynes@1
    34
                                        gpointer         user_data)
nkeynes@1
    35
{
nkeynes@1
    36
nkeynes@1
    37
}
nkeynes@1
    38
nkeynes@1
    39
nkeynes@1
    40
void
nkeynes@1
    41
on_save_as1_activate                   (GtkMenuItem     *menuitem,
nkeynes@1
    42
                                        gpointer         user_data)
nkeynes@1
    43
{
nkeynes@1
    44
nkeynes@1
    45
}
nkeynes@1
    46
nkeynes@1
    47
nkeynes@1
    48
void
nkeynes@1
    49
on_exit1_activate                      (GtkMenuItem     *menuitem,
nkeynes@1
    50
                                        gpointer         user_data)
nkeynes@1
    51
{
nkeynes@1
    52
    gtk_main_quit();
nkeynes@1
    53
}
nkeynes@1
    54
nkeynes@1
    55
nkeynes@1
    56
void
nkeynes@1
    57
on_preferences1_activate               (GtkMenuItem     *menuitem,
nkeynes@1
    58
                                        gpointer         user_data)
nkeynes@1
    59
{
nkeynes@1
    60
nkeynes@1
    61
}
nkeynes@1
    62
nkeynes@1
    63
nkeynes@1
    64
void
nkeynes@1
    65
on_about1_activate                     (GtkMenuItem     *menuitem,
nkeynes@1
    66
                                        gpointer         user_data)
nkeynes@1
    67
{
nkeynes@1
    68
    GtkWidget *about = create_about_win();
nkeynes@1
    69
    gtk_widget_show(about);
nkeynes@1
    70
}
nkeynes@1
    71
nkeynes@1
    72
nkeynes@1
    73
void
nkeynes@1
    74
on_load_btn_clicked                    (GtkButton       *button,
nkeynes@1
    75
                                        gpointer         user_data)
nkeynes@1
    76
{
nkeynes@19
    77
    open_file_dialog( "Open...", load_bin_file, NULL, NULL );
nkeynes@1
    78
}
nkeynes@1
    79
nkeynes@1
    80
nkeynes@1
    81
void
nkeynes@1
    82
on_reset_btn_clicked                   (GtkButton       *button,
nkeynes@1
    83
                                        gpointer         user_data)
nkeynes@1
    84
{
nkeynes@1
    85
    sh4_reset();
nkeynes@1
    86
    mem_reset();
nkeynes@2
    87
    update_gui();
nkeynes@1
    88
}
nkeynes@1
    89
nkeynes@1
    90
nkeynes@1
    91
void
nkeynes@1
    92
on_stop_btn_clicked                    (GtkButton       *button,
nkeynes@1
    93
                                        gpointer         user_data)
nkeynes@1
    94
{
nkeynes@1
    95
    if( sh4_isrunning() ) {
nkeynes@1
    96
        sh4_stop();
nkeynes@1
    97
    }
nkeynes@1
    98
}
nkeynes@1
    99
nkeynes@1
   100
nkeynes@1
   101
void
nkeynes@1
   102
on_step_btn_clicked                    (GtkButton       *button,
nkeynes@1
   103
                                        gpointer         user_data)
nkeynes@1
   104
{
nkeynes@1
   105
    sh4_execute_instruction();
nkeynes@2
   106
    update_gui();
nkeynes@1
   107
}
nkeynes@1
   108
nkeynes@1
   109
nkeynes@1
   110
void
nkeynes@1
   111
on_run_btn_clicked                     (GtkButton       *button,
nkeynes@1
   112
                                        gpointer         user_data)
nkeynes@1
   113
{
nkeynes@9
   114
    debug_info_t data = get_debug_info(GTK_WIDGET(button));
nkeynes@23
   115
    dreamcast_run();
nkeynes@1
   116
}
nkeynes@1
   117
nkeynes@1
   118
nkeynes@1
   119
void
nkeynes@1
   120
on_runto_btn_clicked                   (GtkButton       *button,
nkeynes@1
   121
                                        gpointer         user_data)
nkeynes@1
   122
{
nkeynes@9
   123
    debug_info_t data = get_debug_info(GTK_WIDGET(button));
nkeynes@1
   124
    if( selected_pc == -1 )
nkeynes@1
   125
        WARN( "No address selected, so can't run to it", NULL );
nkeynes@1
   126
    else {
nkeynes@1
   127
        INFO( "Running until %08X...", selected_pc );
nkeynes@23
   128
	sh4_set_breakpoint( selected_pc, BREAK_ONESHOT );
nkeynes@23
   129
	dreamcast_run();
nkeynes@1
   130
    }
nkeynes@1
   131
}
nkeynes@1
   132
nkeynes@1
   133
nkeynes@1
   134
void
nkeynes@1
   135
on_break_btn_clicked                   (GtkButton       *button,
nkeynes@1
   136
                                        gpointer         user_data)
nkeynes@1
   137
{
nkeynes@1
   138
nkeynes@1
   139
}
nkeynes@1
   140
nkeynes@1
   141
nkeynes@1
   142
gboolean
nkeynes@1
   143
on_debug_win_delete_event              (GtkWidget       *widget,
nkeynes@1
   144
                                        GdkEvent        *event,
nkeynes@1
   145
                                        gpointer         user_data)
nkeynes@1
   146
{
nkeynes@1
   147
    gtk_main_quit();
nkeynes@1
   148
  return FALSE;
nkeynes@1
   149
}
nkeynes@1
   150
nkeynes@1
   151
nkeynes@1
   152
void
nkeynes@1
   153
on_disasm_list_select_row              (GtkCList        *clist,
nkeynes@1
   154
                                        gint             row,
nkeynes@1
   155
                                        gint             column,
nkeynes@1
   156
                                        GdkEvent        *event,
nkeynes@1
   157
                                        gpointer         user_data)
nkeynes@1
   158
{
nkeynes@9
   159
    debug_info_t data = get_debug_info(GTK_WIDGET(clist));
nkeynes@9
   160
    selected_pc = row_to_address(data, row);
nkeynes@1
   161
}
nkeynes@1
   162
nkeynes@1
   163
nkeynes@1
   164
void
nkeynes@1
   165
on_disasm_list_unselect_row            (GtkCList        *clist,
nkeynes@1
   166
                                        gint             row,
nkeynes@1
   167
                                        gint             column,
nkeynes@1
   168
                                        GdkEvent        *event,
nkeynes@1
   169
                                        gpointer         user_data)
nkeynes@1
   170
{
nkeynes@9
   171
    debug_info_t data = get_debug_info(GTK_WIDGET(clist));
nkeynes@9
   172
    int pc = row_to_address(data,row);
nkeynes@1
   173
    if( selected_pc == pc ) selected_pc = -1;
nkeynes@1
   174
}
nkeynes@1
   175
nkeynes@1
   176
nkeynes@1
   177
void
nkeynes@1
   178
on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
nkeynes@1
   179
                                        gpointer         user_data)
nkeynes@1
   180
{
nkeynes@1
   181
    mmr_open_win();
nkeynes@1
   182
}
nkeynes@1
   183
nkeynes@1
   184
nkeynes@1
   185
gboolean
nkeynes@1
   186
on_mmr_win_delete_event                (GtkWidget       *widget,
nkeynes@1
   187
                                        GdkEvent        *event,
nkeynes@1
   188
                                        gpointer         user_data)
nkeynes@1
   189
{
nkeynes@1
   190
    mmr_close_win();
nkeynes@1
   191
    return TRUE;
nkeynes@1
   192
}
nkeynes@1
   193
nkeynes@1
   194
nkeynes@1
   195
void
nkeynes@1
   196
on_mmr_close_clicked                   (GtkButton       *button,
nkeynes@1
   197
                                        gpointer         user_data)
nkeynes@1
   198
{
nkeynes@1
   199
    mmr_close_win();
nkeynes@1
   200
}
nkeynes@1
   201
nkeynes@1
   202
nkeynes@1
   203
void
nkeynes@1
   204
on_mode_field_changed                  (GtkEditable     *editable,
nkeynes@1
   205
                                        gpointer         user_data)
nkeynes@1
   206
{
nkeynes@18
   207
    const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
nkeynes@10
   208
    debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
nkeynes@10
   209
    set_disassembly_cpu( data, text );
nkeynes@1
   210
}
nkeynes@1
   211
nkeynes@1
   212
nkeynes@1
   213
void
nkeynes@1
   214
on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
nkeynes@1
   215
                                        gpointer         user_data)
nkeynes@1
   216
{
nkeynes@1
   217
nkeynes@1
   218
}
nkeynes@1
   219
nkeynes@1
   220
nkeynes@1
   221
gboolean
nkeynes@1
   222
on_page_field_key_press_event          (GtkWidget       *widget,
nkeynes@1
   223
                                        GdkEventKey     *event,
nkeynes@1
   224
                                        gpointer         user_data)
nkeynes@1
   225
{
nkeynes@1
   226
    if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
nkeynes@9
   227
	debug_info_t data = get_debug_info(widget);
nkeynes@18
   228
        const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
nkeynes@1
   229
        gchar *endptr;
nkeynes@1
   230
        unsigned int val = strtoul( text, &endptr, 16 );
nkeynes@1
   231
        if( text == endptr ) { /* invalid input */
nkeynes@1
   232
            char buf[10];
nkeynes@9
   233
            sprintf( buf, "%08X", row_to_address(data,0) );
nkeynes@1
   234
            gtk_entry_set_text( GTK_ENTRY(widget), buf );
nkeynes@1
   235
        } else {
nkeynes@9
   236
            set_disassembly_region(data, val);
nkeynes@1
   237
        }
nkeynes@1
   238
    }
nkeynes@1
   239
    return FALSE;
nkeynes@1
   240
}
nkeynes@1
   241
nkeynes@1
   242
nkeynes@1
   243
void
nkeynes@1
   244
on_output_list_select_row              (GtkCList        *clist,
nkeynes@1
   245
                                        gint             row,
nkeynes@1
   246
                                        gint             column,
nkeynes@1
   247
                                        GdkEvent        *event,
nkeynes@1
   248
                                        gpointer         user_data)
nkeynes@1
   249
{
nkeynes@1
   250
    if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
nkeynes@1
   251
        char *val;
nkeynes@1
   252
        gtk_clist_get_text( clist, row, 1, &val );
nkeynes@1
   253
        if( val[0] != '\0' ) {
nkeynes@1
   254
            int addr = strtoul( val, NULL, 16 );
nkeynes@9
   255
	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
nkeynes@9
   256
            jump_to_disassembly( data, addr, TRUE );
nkeynes@1
   257
        }
nkeynes@1
   258
    }
nkeynes@1
   259
}
nkeynes@1
   260
nkeynes@1
   261
nkeynes@1
   262
void
nkeynes@1
   263
on_jump_pc_btn_clicked                 (GtkButton       *button,
nkeynes@1
   264
                                        gpointer         user_data)
nkeynes@1
   265
{
nkeynes@9
   266
    debug_info_t data = get_debug_info( GTK_WIDGET(button) );
nkeynes@9
   267
    jump_to_pc( data, TRUE );
nkeynes@1
   268
}
nkeynes@1
   269
nkeynes@2
   270
nkeynes@2
   271
void
nkeynes@2
   272
on_button_add_watch_clicked            (GtkButton       *button,
nkeynes@2
   273
                                        gpointer         user_data)
nkeynes@2
   274
{
nkeynes@2
   275
nkeynes@2
   276
}
nkeynes@2
   277
nkeynes@2
   278
nkeynes@2
   279
void
nkeynes@2
   280
on_button_clear_all_clicked            (GtkButton       *button,
nkeynes@2
   281
                                        gpointer         user_data)
nkeynes@2
   282
{
nkeynes@2
   283
nkeynes@2
   284
}
nkeynes@2
   285
nkeynes@2
   286
nkeynes@2
   287
void
nkeynes@2
   288
on_button_close_clicked                (GtkButton       *button,
nkeynes@2
   289
                                        gpointer         user_data)
nkeynes@2
   290
{
nkeynes@2
   291
nkeynes@2
   292
}
nkeynes@2
   293
nkeynes@2
   294
nkeynes@2
   295
void
nkeynes@2
   296
on_view_memory_activate                (GtkMenuItem     *menuitem,
nkeynes@2
   297
                                        gpointer         user_data)
nkeynes@2
   298
{
nkeynes@2
   299
    dump_window_new();
nkeynes@2
   300
}
nkeynes@2
   301
nkeynes@18
   302
nkeynes@18
   303
void
nkeynes@18
   304
on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
nkeynes@18
   305
                                        gpointer         user_data)
nkeynes@18
   306
{
nkeynes@18
   307
    open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "DreamOn Save State (*.dst)" );
nkeynes@18
   308
}
nkeynes@18
   309
nkeynes@18
   310
nkeynes@18
   311
void
nkeynes@18
   312
on_savestate_button_clicked            (GtkToolButton   *toolbutton,
nkeynes@18
   313
                                        gpointer         user_data)
nkeynes@18
   314
{
nkeynes@18
   315
    save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "DreamOn Save State (*.dst)" );
nkeynes@18
   316
}
nkeynes@18
   317
.