diff --git a/desmume/src/gtk-glade/dTools/callbacks_2_memview.c b/desmume/src/gtk-glade/dTools/callbacks_2_memview.c
index 37f4511cd..b98c6c419 100755
--- a/desmume/src/gtk-glade/dTools/callbacks_2_memview.c
+++ b/desmume/src/gtk-glade/dTools/callbacks_2_memview.c
@@ -37,17 +37,17 @@ static PangoAttrList *attr_Address, *attr_Pattern1, *attr_Pattern2, *attr_Text;
static GtkEntry *wAddress;
static GtkDrawingArea *wPaint;
+void refresh();
+
/* how to pack bytes */
-void on_wtools_2_r8_toggled (GtkToggleButton *togglebutton, gpointer user_data) { packmode=Bit8; }
-void on_wtools_2_r16_toggled (GtkToggleButton *togglebutton, gpointer user_data) { packmode=Bit16; }
-void on_wtools_2_r32_toggled (GtkToggleButton *togglebutton, gpointer user_data) { packmode=Bit32; }
+void on_wtools_2_r8_toggled (GtkToggleButton *togglebutton, gpointer user_data) { packmode=Bit8; refresh(); }
+void on_wtools_2_r16_toggled (GtkToggleButton *togglebutton, gpointer user_data) { packmode=Bit16; refresh(); }
+void on_wtools_2_r32_toggled (GtkToggleButton *togglebutton, gpointer user_data) { packmode=Bit32; refresh(); }
/* which address */
-void refresh();
-
void on_wtools_2_GotoAddress_activate (GtkEntry *entry, gpointer user_data) {
address=strtol(gtk_entry_get_text(entry),NULL,0);
refresh();
@@ -77,10 +77,10 @@ gboolean on_wtools_2_draw_expose_event (GtkWidget *widget, GdkEventExpose *event
void initialize() {
if (init) return;
- pango_parse_markup("", -1, 0, &attr_Address, NULL, NULL, NULL);
- pango_parse_markup("", -1, 0, &attr_Pattern1, NULL, NULL, NULL);
- pango_parse_markup("", -1, 0, &attr_Pattern2, NULL, NULL, NULL);
- pango_parse_markup("", -1, 0, &attr_Text, NULL, NULL, NULL);
+ pango_parse_markup(" ", -1, 0, &attr_Address, NULL, NULL, NULL);
+ pango_parse_markup(" ", -1, 0, &attr_Pattern1, NULL, NULL, NULL);
+ pango_parse_markup(" ", -1, 0, &attr_Pattern2, NULL, NULL, NULL);
+ pango_parse_markup(" ", -1, 0, &attr_Text, NULL, NULL, NULL);
init = TRUE;
}
@@ -89,51 +89,49 @@ void refresh() {
GtkWidget * area = (GtkWidget*)wPaint;
PangoLayout* playout = gtk_widget_create_pango_layout(area, NULL);
GdkGC * GC = area->style->fg_gc[area->state];
+ int i,j,addr, w,h,x,y, cpu=0; u8 c;
+ char txt[80],*ptxt;
+ char words[4][13];
initialize();
gdk_draw_rectangle(area->window, area->style->white_gc, TRUE, 0, 0,
area->allocation.width, area->allocation.height);
-// draw memory content here
- pango_layout_set_text(playout, "hello", -1);
- pango_layout_set_attributes(playout,attr_Address);
- gdk_draw_layout(area->window, GC, 10,20, playout);
+ char * def_patt = "0000:0000 | 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF | 0123456789ABCDEF";
+ pango_layout_set_markup(playout, def_patt , -1);
+ pango_layout_get_pixel_size(playout, &w, &h);
+ gtk_widget_set_usize(area,w+20, (10*h)+10);
+// draw memory content here
+ addr=address;
+ for (i=0,x=10,y=5; i<10; i++,y+=h) {
+ ptxt = txt;
+ sprintf(ptxt, "%04X:%04X | ", (addr>>16), (addr&0xFFFF)); ptxt+=12;
+ switch(packmode) {
+ case Bit8:
+ for (j=0; j<16; j++,ptxt+=3)
+ sprintf(ptxt, "%02X ", MMU_readByte(cpu, addr+j));
+ break;
+ case Bit16:
+ for (j=0; j<16; j+=2,ptxt+=6)
+ sprintf(ptxt, " %04X ", MMU_readHWord(cpu, addr+j));
+ break;
+ case Bit32:
+ for (j=0; j<16; j+=4,ptxt+=12)
+ sprintf(ptxt, " %08X ", (int)MMU_readWord(cpu, addr+j));
+ break;
+ }
+ sprintf(ptxt, "| "); ptxt +=2;
+ for (j=0; j<16; j++,ptxt++)
+ sprintf(ptxt, "%c", ((c=MMU_readByte(cpu, addr+j))<32)?'.':((c&0x80)?',':c));
+ addr += 16;
+ *(ptxt)=0;
+
+ pango_layout_set_text(playout, txt, -1);
+ pango_layout_set_attributes(playout,attr_Text);
+ gdk_draw_layout(area->window, GC, x, y, playout);
+ }
+
// done
g_object_unref(playout);
}
-
-
-
-/*
-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();
-}
-*/
-
-/* ***** ***** IO REGISTERS ***** ***** */
-/*
-
-static int cpu=0;
-static u32 address;
-static BOOL hword;
-
-static GtkLabel * reg_address;
-static GtkEntry * reg_value;
-
-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);
-}
-
-*/
\ No newline at end of file