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