Search
lxdream.org :: lxdream/src/gui/gui.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/gui.c
changeset 9:2784c7660165
prev2:42349f6ea216
next18:9a1b5d75703f
author nkeynes
date Thu Dec 08 13:38:00 2005 +0000 (16 years ago)
permissions -rw-r--r--
last change Generalise the core debug window to allow multiple instances.
Add cpu description structure to define different cpus for use by the
debug window, in preparation for ARM implementation
file annotate diff log raw
nkeynes@1
     1
#include <stdlib.h>
nkeynes@1
     2
#include <stdarg.h>
nkeynes@1
     3
#include <gnome.h>
nkeynes@1
     4
#include <math.h>
nkeynes@1
     5
#include "gui.h"
nkeynes@1
     6
#include "mem.h"
nkeynes@1
     7
#include "sh4dasm.h"
nkeynes@1
     8
#include "sh4core.h"
nkeynes@1
     9
nkeynes@1
    10
#define REGISTER_FONT "-*-fixed-medium-r-normal--12-*-*-*-*-*-iso8859-1"
nkeynes@1
    11
nkeynes@1
    12
GdkColor clrNormal, clrChanged, clrError, clrWarn, clrPC, clrDebug, clrTrace;
nkeynes@1
    13
PangoFontDescription *fixed_list_font;
nkeynes@1
    14
nkeynes@1
    15
void open_file_callback(GtkWidget *btn, gpointer user_data);
nkeynes@1
    16
void open_file_canceled(GtkWidget *btn, gpointer user_data);
nkeynes@1
    17
void open_file( char *filename );
nkeynes@1
    18
nkeynes@2
    19
void init_gui() {
nkeynes@2
    20
    GdkColormap *map;
nkeynes@2
    21
    
nkeynes@2
    22
    clrNormal.red = clrNormal.green = clrNormal.blue = 0;
nkeynes@2
    23
    clrChanged.red = clrChanged.green = 64*256;
nkeynes@2
    24
    clrChanged.blue = 154*256;
nkeynes@2
    25
    clrError.red = 65535;
nkeynes@2
    26
    clrError.green = clrError.blue = 64*256;
nkeynes@2
    27
    clrPC.red = 32*256;
nkeynes@2
    28
    clrPC.green = 170*256;
nkeynes@2
    29
    clrPC.blue = 52*256;
nkeynes@2
    30
    clrWarn = clrChanged;
nkeynes@2
    31
    clrTrace.red = 156*256;
nkeynes@2
    32
    clrTrace.green = 78*256;
nkeynes@2
    33
    clrTrace.blue = 201*256;
nkeynes@2
    34
    clrDebug = clrPC;
nkeynes@1
    35
nkeynes@2
    36
    map = gdk_colormap_new(gdk_visual_get_best(), TRUE);
nkeynes@2
    37
    gdk_colormap_alloc_color(map, &clrNormal, TRUE, TRUE);
nkeynes@2
    38
    gdk_colormap_alloc_color(map, &clrChanged, TRUE, TRUE);
nkeynes@2
    39
    gdk_colormap_alloc_color(map, &clrError, TRUE, TRUE);
nkeynes@2
    40
    gdk_colormap_alloc_color(map, &clrWarn, TRUE, TRUE);
nkeynes@2
    41
    gdk_colormap_alloc_color(map, &clrPC, TRUE, TRUE);
nkeynes@2
    42
    gdk_colormap_alloc_color(map, &clrDebug, TRUE, TRUE);
nkeynes@2
    43
    gdk_colormap_alloc_color(map, &clrTrace, TRUE, TRUE);
nkeynes@2
    44
    fixed_list_font = pango_font_description_from_string("Courier 10");
nkeynes@2
    45
}
nkeynes@2
    46
nkeynes@2
    47
void update_gui(void) {
nkeynes@9
    48
    update_registers(main_debug);
nkeynes@9
    49
    update_icount(main_debug);
nkeynes@1
    50
    update_mmr_win();
nkeynes@2
    51
    dump_win_update_all();
nkeynes@1
    52
}
nkeynes@1
    53
nkeynes@1
    54
nkeynes@1
    55
void open_file_callback(GtkWidget *btn, gpointer user_data) {
nkeynes@1
    56
    GtkFileSelection *file = GTK_FILE_SELECTION(user_data);
nkeynes@1
    57
    gchar *filename = strdup( gtk_file_selection_get_filename(
nkeynes@1
    58
        GTK_FILE_SELECTION(file) ) );
nkeynes@1
    59
    gtk_widget_destroy(GTK_WIDGET(file));
nkeynes@1
    60
    open_file( filename );
nkeynes@1
    61
    free(filename);
nkeynes@1
    62
}
nkeynes@1
    63
nkeynes@1
    64
void open_file_canceled(GtkWidget *btn, gpointer user_data) {
nkeynes@1
    65
    gtk_widget_destroy(GTK_WIDGET(user_data));
nkeynes@1
    66
}
nkeynes@1
    67
nkeynes@1
    68
void open_file_dialog( void )
nkeynes@1
    69
{
nkeynes@1
    70
    GtkWidget *file;
nkeynes@1
    71
nkeynes@1
    72
    file = gtk_file_selection_new( "Open..." );
nkeynes@1
    73
    gtk_signal_connect( GTK_OBJECT(GTK_FILE_SELECTION(file)->ok_button),
nkeynes@1
    74
                        "clicked", GTK_SIGNAL_FUNC(open_file_callback), file );
nkeynes@1
    75
    gtk_signal_connect( GTK_OBJECT(GTK_FILE_SELECTION(file)->cancel_button),
nkeynes@1
    76
                        "clicked", GTK_SIGNAL_FUNC(open_file_canceled), file );
nkeynes@1
    77
    gtk_widget_show( file );
nkeynes@1
    78
}
nkeynes@1
    79
nkeynes@2
    80
uint32_t gtk_entry_get_hex_value( GtkEntry *entry, uint32_t defaultValue )
nkeynes@1
    81
{
nkeynes@2
    82
    gchar *text = gtk_entry_get_text(entry);
nkeynes@2
    83
    if( text == NULL )
nkeynes@2
    84
        return defaultValue;
nkeynes@2
    85
    gchar *endptr;
nkeynes@2
    86
    uint32_t value = strtoul( text, &endptr, 16 );
nkeynes@2
    87
    if( text == endptr ) { /* invalid input */
nkeynes@2
    88
        value = defaultValue;
nkeynes@2
    89
        gtk_entry_set_hex_value( entry, value );
nkeynes@2
    90
    }
nkeynes@2
    91
    return value;
nkeynes@1
    92
}
nkeynes@1
    93
nkeynes@2
    94
void gtk_entry_set_hex_value( GtkEntry *entry, uint32_t value )
nkeynes@1
    95
{
nkeynes@2
    96
    char buf[10];
nkeynes@2
    97
    sprintf( buf, "%08X", value );
nkeynes@2
    98
    gtk_entry_set_text( entry, buf );
nkeynes@1
    99
}
.