From 04efc44e8d72725408356a2341876b2cb78f5d3e Mon Sep 17 00:00:00 2001 From: evilynux Date: Sun, 14 Jan 2007 19:06:38 +0000 Subject: [PATCH] Refactored io_regs: - showing all registers at the same time; - possibility to autorefresh or refresh manually; - removed display registers, please use the nice memory viewer. --- .../src/gtk-glade/dTools/callbacks_1_ioregs.c | 130 +-- .../src/gtk-glade/dTools/callbacks_dtools.h | 21 +- .../src/gtk-glade/glade/DeSmuMe_Dtools.glade | 793 ++++++++---------- 3 files changed, 412 insertions(+), 532 deletions(-) diff --git a/desmume/src/gtk-glade/dTools/callbacks_1_ioregs.c b/desmume/src/gtk-glade/dTools/callbacks_1_ioregs.c index f50b1541e..bf618f8dd 100755 --- a/desmume/src/gtk-glade/dTools/callbacks_1_ioregs.c +++ b/desmume/src/gtk-glade/dTools/callbacks_1_ioregs.c @@ -23,64 +23,71 @@ /* ***** ***** IO REGISTERS ***** ***** */ static int cpu=0; -static u32 address; -static BOOL hword; +static BOOL autorefresh; -static GtkLabel * reg_address; -static GtkEntry * reg_value; -static void display_current_reg(); +static void update_regs(); + +/* Register name list */ +#define NBR_IO_REGS 6 + +typedef struct +{ + char name[20]; + u32 addr; + BOOL trunc; +} reg_name_addr; + +const reg_name_addr Reg_Names_Addr[NBR_IO_REGS] = + { + { "REG_IPCFIFOCNT", REG_IPCFIFOCNT, TRUE }, + { "REG_SPICNT", REG_SPICNT, TRUE }, + { "REG_IME", REG_IME, TRUE }, + { "REG_IE", REG_IE, FALSE }, + { "REG_IF", REG_IF, FALSE }, + { "REG_POWCNT1", REG_POWCNT1, TRUE } + }; /* update */ static void wtools_1_update () { - display_current_reg(); + if(autorefresh) update_regs(); } +/* Update register display */ +static void update_regs() +{ + char lbl_name[40]; + char lbl_text[40]; + char * mask; + GtkWidget * lbl; + int i; + u32 w; -/* registers */ - -static void display_current_reg() { - char text_address[16]; - char text_value[16]; - char * patt = "0x%08X"; - u32 w = MMU_read32(cpu,address); - - if (hword) { patt = "0x%04X"; w &= 0xFFFF; } - sprintf(text_address, "0x%08X", address); - sprintf(text_value, patt, w); - gtk_label_set_text(reg_address, text_address); - gtk_entry_set_text(reg_value, text_value); + for( i = 0; i < NBR_IO_REGS; i++ ) + { + mask = ( Reg_Names_Addr[i].trunc ) ? "0x%04x" : "0x%08x"; + sprintf(lbl_name,"wtools_1_%s_value\0\0", Reg_Names_Addr[i].name); + w = MMU_read32(cpu,Reg_Names_Addr[i].addr); + sprintf(lbl_text, mask, w); + lbl = glade_xml_get_widget(xml_tools, lbl_name); + gtk_label_set_text((GtkLabel *)lbl, lbl_text); + } } -static void display_reg(u32 address_, BOOL hword_) { - address = address_; - hword = hword_; - display_current_reg(); -} - - void on_wtools_1_combo_cpu_changed (GtkComboBox *widget, gpointer user_data) { - /* c == 0 means ARM9 */ - cpu=gtk_combo_box_get_active(widget); - display_current_reg(); + /* c == 0 means ARM9 */ + cpu=gtk_combo_box_get_active(widget); + update_regs(); } - - /* show, register, unregister */ - void on_wtools_1_IOregs_show (GtkWidget *widget, gpointer user_data) { - GtkWidget * b = glade_xml_get_widget(xml_tools, "wtools_1_r_ime"); - GtkWidget * combo = glade_xml_get_widget(xml_tools, "wtools_1_combo_cpu"); - - reg_address = (GtkLabel*)glade_xml_get_widget(xml_tools, "wtools_1_REGADRESS"); - reg_value = (GtkEntry*)glade_xml_get_widget(xml_tools, "wtools_1_REGVALUE"); - - // do as if we had selected this button and ARM7 cpu - gtk_toggle_button_set_active((GtkToggleButton*)b, TRUE); - gtk_combo_box_set_active((GtkComboBox*)combo, 0); - - register_Tool(wtools_1_update); + GtkWidget * combo = glade_xml_get_widget(xml_tools, "wtools_1_combo_cpu"); + + // do as if we had selected this button and ARM7 cpu + gtk_combo_box_set_active((GtkComboBox*)combo, 0); + + register_Tool(wtools_1_update); } gboolean on_wtools_1_IOregs_close (GtkWidget *widget, ...) { @@ -89,23 +96,22 @@ gboolean on_wtools_1_IOregs_close (GtkWidget *widget, ...) { return TRUE; } +void on_wtools_1_autorefresh_toggled (GtkToggleButton *tb, gpointer user_data) +{ + GtkWidget * b = glade_xml_get_widget(xml_tools, "wtools_1_refresh"); + if( gtk_toggle_button_get_active(tb) == TRUE ) + { + autorefresh = TRUE; + gtk_widget_set_sensitive( b, FALSE ); + } + else + { + autorefresh = FALSE; + gtk_widget_set_sensitive( b, TRUE ); + } +} - -void on_wtools_1_r_ipcfifocnt_toggled (GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_IPCFIFOCNT,TRUE); } -void on_wtools_1_r_spicnt_toggled (GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_SPICNT,TRUE); } -void on_wtools_1_r_ime_toggled (GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_IME,TRUE); } -void on_wtools_1_r_ie_toggled (GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_IE,FALSE); } -void on_wtools_1_r_if_toggled (GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_IF,FALSE); } -void on_wtools_1_r_power_cr_toggled (GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_POWCNT1,TRUE); } -void on_wtools_1_r_dispa_win0h_toggled(GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_DISPA_WIN0H,FALSE); } -void on_wtools_1_r_dispa_win1h_toggled(GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_DISPA_WIN1H,FALSE); } -void on_wtools_1_r_dispa_win0v_toggled(GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_DISPA_WIN0V,FALSE); } -void on_wtools_1_r_dispa_win1v_toggled(GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_DISPA_WIN1V,FALSE); } -void on_wtools_1_r_dispa_winin_toggled(GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_DISPA_WININ,FALSE); } -void on_wtools_1_r_dispa_winout_toggled(GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_DISPA_WINOUT,FALSE); } -void on_wtools_1_r_dispb_win0h_toggled(GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_DISPB_WIN0H,FALSE); } -void on_wtools_1_r_dispb_win1h_toggled(GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_DISPB_WIN1H,FALSE); } -void on_wtools_1_r_dispb_win0v_toggled(GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_DISPB_WIN0V,FALSE); } -void on_wtools_1_r_dispb_win1v_toggled(GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_DISPB_WIN1V,FALSE); } -void on_wtools_1_r_dispb_winin_toggled(GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_DISPB_WININ,FALSE); } -void on_wtools_1_r_dispb_winout_toggled(GtkToggleButton *togglebutton, gpointer user_data) { display_reg(REG_DISPB_WINOUT,FALSE); } +void on_wtools_1_refresh_clicked (GtkButton *b, gpointer user_data) +{ + update_regs(); +} diff --git a/desmume/src/gtk-glade/dTools/callbacks_dtools.h b/desmume/src/gtk-glade/dTools/callbacks_dtools.h index b5463f4fb..49991fadb 100755 --- a/desmume/src/gtk-glade/dTools/callbacks_dtools.h +++ b/desmume/src/gtk-glade/dTools/callbacks_dtools.h @@ -25,25 +25,8 @@ void on_wtools_1_combo_cpu_changed (GtkComboBox *, gpointer ); void on_wtools_1_IOregs_show (GtkWidget *, gpointer ); gboolean on_wtools_1_IOregs_close (GtkWidget *, ...); - -void on_wtools_1_r_ipcfifocnt_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_spicnt_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_ime_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_ie_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_if_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_power_cr_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_dispa_win0h_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_dispa_win1h_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_dispa_win0v_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_dispa_win1v_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_dispa_winin_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_dispa_winout_toggled(GtkToggleButton *, gpointer ); -void on_wtools_1_r_dispb_win0h_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_dispb_win1h_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_dispb_win0v_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_dispb_win1v_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_dispb_winin_toggled (GtkToggleButton *, gpointer ); -void on_wtools_1_r_dispb_winout_toggled(GtkToggleButton *, gpointer ); +void on_wtools_1_autorefresh_toggled (GtkToggleButton *, gpointer); +void on_wtools_1_refresh_clicked (GtkButton *, gpointer); /* ***** ***** MEMORY VIEWER ***** ***** */ void on_wtools_2_MemView_show (GtkWidget *, gpointer ); diff --git a/desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade b/desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade index 1645d9ce1..74686d974 100755 --- a/desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade +++ b/desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade @@ -57,53 +57,48 @@ True - 3 + 8 2 False 0 - 0 + 5 - + True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN + cpu : ARM7 +cpu : ARM9 + False + True + + + + 0 + 1 + 0 + 1 + fill + + - - - True - False - 0 - - - - - - - - - - True - Details - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - label_item - - + + + True + True + 0x0000 + False + False + GTK_JUSTIFY_RIGHT + False + True + 1 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 1 @@ -111,406 +106,14 @@ 2 3 fill + - + True - False - 0 - - - - True - True - REG__IPCFIFOCNT(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - - - - 0 - False - False - - - - - - True - True - REG__SPICNT(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__IME(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__IE(32) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__IF(32) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - POWER__CR(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__DISPA__WIN0H(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__DISPA__WIN1H(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__DISPA__WIN0V(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__DISPA__WIN1V(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__DISPA__WININ(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__DISPA__WINOUT(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__DISPB__WIN0H(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__DISPB__WIN1H(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__DISPB__WIN0V(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__DISPB__WIN1V(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__DISPB__WININ(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - - True - True - REG__DISPB__WINOUT(16) - True - GTK_RELIEF_NORMAL - True - False - False - True - wtools_1_r_ipcfifocnt - - - - 0 - False - False - - - - - 0 - 1 - 2 - 3 - fill - fill - - - - - - True - (0xADDRESS) + REG_SPICNT False False GTK_JUSTIFY_LEFT @@ -525,6 +128,286 @@ False 0 + + 0 + 1 + 3 + 4 + fill + + + + + + + True + True + 0x0000 + False + False + GTK_JUSTIFY_RIGHT + False + True + 1 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + REG_IME + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + REG_IE + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 5 + 6 + fill + + + + + + + True + REG_IF + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 6 + 7 + fill + + + + + + + True + REG_POWCNT1 + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 7 + 8 + fill + + + + + + + True + True + 0x0000 + False + False + GTK_JUSTIFY_RIGHT + False + True + 1 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + True + 0x00000000 + False + False + GTK_JUSTIFY_RIGHT + False + True + 1 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 5 + 6 + fill + + + + + + + True + True + 0x00000000 + False + False + GTK_JUSTIFY_RIGHT + False + True + 1 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 6 + 7 + fill + + + + + + + True + True + 0x0000 + False + False + GTK_JUSTIFY_RIGHT + False + True + 1 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 7 + 8 + fill + + + + + + + True + True + autorefresh + True + GTK_RELIEF_NORMAL + True + False + False + True + + 0 1 @@ -536,16 +419,14 @@ - + True True - False - True - 0 - (0xVALUE) - True - - False + _Refresh + True + GTK_RELIEF_NORMAL + True + 1 @@ -557,20 +438,30 @@ - + True - cpu : ARM7 -cpu : ARM9 - False - True - + REG_IPCFIFOCNT + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 1 - 0 - 1 + 2 + 3 fill +