added changes tracking to memory viewer

(oh yeah ;) this mean autoupdate has been done too)
This commit is contained in:
damdoum 2007-01-14 01:50:32 +00:00
parent 2a4634faf0
commit 8498880540
7 changed files with 156 additions and 13 deletions

View File

@ -28,6 +28,16 @@ static BOOL hword;
static GtkLabel * reg_address;
static GtkEntry * reg_value;
void display_current_reg();
/* update */
void wtools_1_update () {
display_current_reg();
}
/* registers */
void display_current_reg() {
char text_address[16];
@ -58,12 +68,20 @@ void on_wtools_1_combo_cpu_changed (GtkComboBox *widget, gpointer user_data)
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);
}
gboolean on_wtools_1_IOregs_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) {
unregister_Tool(wtools_1_update);
}
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); }

View File

@ -33,8 +33,10 @@ enum SHOW {
static BOOL init=FALSE;
static enum SHOW packmode=Bit8;
static u32 address=0, tmpaddr=0, bpl=0; int cpu=0;
static PangoAttrList *attr_Text8,*attr_Text16,*attr_Text32;
static PangoAttrList *attr_Text8,*attr_Text16,*attr_Text32,*attr_red;
static char patt[512];
static u8 mem[0x100];
static int w,h;
static GtkEntry *wAddress;
static GtkDrawingArea *wPaint;
@ -44,6 +46,78 @@ void refresh();
void initialise();
/* update */
void wtools_2_update() {
int i,j, x,y=5;
int px = w/78, qx;
u8 m8, *mem8 =mem; u16 m16, *mem16=(u16*)mem; u32 m32, *mem32=(u32*)mem;
u32 addr;
char txt[16];
GtkWidget * area = (GtkWidget*)wPaint;
PangoLayout* playout = gtk_widget_create_pango_layout(area, NULL);
GdkGC * GC = area->style->fg_gc[area->state];
pango_layout_set_attributes(playout, attr_red);
#define PAINT_TEXT(w) \
gdk_draw_rectangle(area->window, area->style->white_gc, TRUE, x, y, w, h); \
pango_layout_set_text(playout, txt, -1); \
gdk_draw_layout(area->window, GC, x, y, playout);
addr = address;
switch (packmode) {
case Bit8:
for (i=0; i<0x10; i++, y+=h) {
x = 12 * px + 10; qx = 62 * px + 10;
for (j=0; j<16; j++, addr++,mem8++,x+=3*px,qx+=px) {
m8 = *mem8; *mem8 = MMU_readByte(cpu, addr);
if (m8 != *mem8) {
sprintf(txt, "%02X", *mem8);
PAINT_TEXT(3*px)
}
}
}
break;
case Bit16:
for (i=0; i<0x10; i++, y+=h) {
x = 12 * px + 10; qx = 62 * px + 10;
for (j=0; j<8; j++, addr+=2,mem16++,x+=6*px,qx+=2*px) {
m16 = *mem16; *mem16 = MMU_readHWord(cpu, addr);
if (m16 != *mem16) {
sprintf(txt, " %04X", *mem16);
PAINT_TEXT(6*px)
}
}
}
break;
case Bit32:
for (i=0; i<0x10; i++, y+=h) {
x = 12 * px + 10; qx = 62 * px + 10;
for (j=0; j<4; j++, addr+=4,mem32++,x+=12*px,qx+=4*px) {
m32 = *mem32; *mem32 = MMU_readWord(cpu, addr);
if (m32 != *mem32) {
sprintf(txt, " %08X", *mem32);
PAINT_TEXT(12*px)
}
}
}
break;
}
g_object_unref(playout);
#undef PAINT_TEXT
}
gboolean on_wtools_2_draw_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data) {
// clear the red marks :)
if (event->button==1)
refresh();
}
/* which cpu we look into */
@ -94,8 +168,11 @@ void on_wtools_2_GotoButton_clicked (GtkButton *button, gpointer user_data) {
void on_wtools_2_MemView_show (GtkWidget *widget, gpointer user_data) {
initialize();
change_address(RANGE_MIN);
register_Tool(wtools_2_update);
}
gboolean on_wtools_2_MemView_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) {
unregister_Tool(wtools_2_update);
}
/* scroll functions :D */
@ -141,6 +218,9 @@ void initialize() {
gtk_combo_box_set_active((GtkComboBox*)combo, 0);
gtk_range_set_adjustment(wRange, adj);
strcpy(patt, "<tt><span foreground=\"red\">__00000000__</span></tt>");
pango_parse_markup(patt,-1,0,&attr_red,NULL,NULL,NULL);
#define PATT(x) x"<span foreground=\"#608060\">" x "</span>"
#define DUP(x) x x
strcpy(patt, "<tt><span foreground=\"blue\">0000:0000</span> | ");
@ -167,7 +247,11 @@ 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; u8 c;
int i,j,addr, x,y; u8 c;
u8 *mem8=mem;
u16 *mem16=(u16*)mem;
u32 *mem32=(u32*)mem;
char *ptxt, txt[]="0000:0000 | 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF | 0123456789ABCDEF\0";
PangoAttrList *attr;
@ -178,6 +262,10 @@ void refresh() {
case Bit32: attr=attr_Text32; break;
}
for (i=0; i<0x100; i++)
mem[i] = MMU_readByte(cpu, address+i);
gdk_draw_rectangle(area->window, area->style->white_gc, TRUE, 0, 0,
area->allocation.width, area->allocation.height);
@ -194,21 +282,23 @@ void refresh() {
switch(packmode) {
case Bit8:
for (j=0; j<16; j++,ptxt+=3)
sprintf(ptxt, "%02X ", MMU_readByte(cpu, addr+j));
sprintf(ptxt, "%02X ", mem8[j]);
break;
case Bit16:
for (j=0; j<16; j+=2,ptxt+=6)
sprintf(ptxt, " %04X ", MMU_readHWord(cpu, addr+j));
for (j=0; j<16; j+=2,ptxt+=6, mem16++)
sprintf(ptxt, " %04X ", *mem16);
break;
case Bit32:
for (j=0; j<16; j+=4,ptxt+=12)
sprintf(ptxt, " %08X ", (int)MMU_readWord(cpu, addr+j));
for (j=0; j<16; j+=4,ptxt+=12, mem32++)
sprintf(ptxt, " %08X ", *mem32);
break;
}
sprintf(ptxt, "| "); ptxt +=2;
for (j=0; j<16; j++,ptxt++)
sprintf(ptxt, "%c", ((c=MMU_readByte(cpu, addr+j))<0x20)?'.':((c>=0x7F)?'.':c)); // only ASCII printable
// only ASCII printable
sprintf(ptxt, "%c", ((c=mem8[j])<0x20)?'.':((c>=0x7F)?'.':c));
addr += 16;
mem8 +=16;
*(ptxt)=0;
pango_layout_set_text(playout, txt, -1);

View File

@ -20,11 +20,15 @@
*/
#include "../globals.h"
/* update functions */
void wtools_1_update();
void wtools_2_update();
/* ***** ***** IO REGISTERS ***** ***** */
void on_wtools_1_combo_cpu_changed (GtkComboBox *widget, gpointer user_data);
void on_wtools_1_IOregs_show (GtkWidget *widget, gpointer user_data);
gboolean on_wtools_1_IOregs_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data);
void on_wtools_1_r_ipcfifocnt_toggled (GtkToggleButton *togglebutton, gpointer user_data);
void on_wtools_1_r_spicnt_toggled (GtkToggleButton *togglebutton, gpointer user_data);
void on_wtools_1_r_ime_toggled (GtkToggleButton *togglebutton, gpointer user_data);
@ -45,7 +49,8 @@ void on_wtools_1_r_dispb_winin_toggled(GtkToggleButton *togglebutton, gpointer u
void on_wtools_1_r_dispb_winout_toggled(GtkToggleButton *togglebutton, gpointer user_data);
/* ***** ***** MEMORY VIEWER ***** ***** */
gboolean on_wtools_2_MemView_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data);
gboolean on_wtools_2_draw_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
void on_wtools_2_cpu_changed (GtkComboBox *widget, gpointer user_data);
void on_wtools_2_MemView_show (GtkWidget *widget, gpointer user_data);
void on_wtools_2_r8_toggled (GtkToggleButton *togglebutton, gpointer user_data);

View File

@ -178,6 +178,7 @@ gboolean EmuLoop(gpointer data)
Draw();
// _updateDTools();
notify_Tools();
gtk_widget_queue_draw(pDrawingArea);
gtk_widget_queue_draw(pDrawingArea2);

View File

@ -18,9 +18,9 @@
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">True</property>
<signal name="delete_event" handler="gtk_widget_hide" last_modification_time="Thu, 04 Jan 2007 11:26:10 GMT"/>
<signal name="response" handler="gtk_widget_hide" last_modification_time="Thu, 04 Jan 2007 11:19:44 GMT"/>
<signal name="show" handler="on_wtools_1_IOregs_show" last_modification_time="Thu, 04 Jan 2007 12:47:11 GMT"/>
<signal name="delete_event" handler="on_wtools_1_IOregs_delete_event" last_modification_time="Sat, 13 Jan 2007 23:53:46 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox3">
@ -600,9 +600,9 @@ cpu : ARM9</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">True</property>
<signal name="delete_event" handler="gtk_widget_hide" last_modification_time="Sat, 13 Jan 2007 20:13:44 GMT"/>
<signal name="response" handler="gtk_widget_hide" last_modification_time="Fri, 12 Jan 2007 12:58:38 GMT"/>
<signal name="show" handler="on_wtools_2_MemView_show" last_modification_time="Fri, 12 Jan 2007 13:35:53 GMT"/>
<signal name="delete_event" handler="on_wtools_2_MemView_delete_event" last_modification_time="Sat, 13 Jan 2007 23:56:33 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox4">
@ -825,6 +825,7 @@ ARM7 cpu</property>
<property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<signal name="expose_event" handler="on_wtools_2_draw_expose_event" last_modification_time="Fri, 12 Jan 2007 13:14:44 GMT"/>
<signal name="scroll_event" handler="on_wtools_2_draw_scroll_event" last_modification_time="Sat, 13 Jan 2007 19:50:18 GMT"/>
<signal name="button_release_event" handler="on_wtools_2_draw_button_release_event" last_modification_time="Sun, 14 Jan 2007 01:44:37 GMT"/>
</widget>
<packing>
<property name="left_attach">0</property>

View File

@ -57,6 +57,11 @@ GtkWidget * pDrawingArea;
GtkWidget * pDrawingArea2;
GladeXML * xml, * xml_tools;
typedef void (*VoidFunPtr)();
void notify_Tools();
void register_Tool(VoidFunPtr fun);
void unregister_Tool(VoidFunPtr fun);
/* callbacks.c */
void enable_rom_features();

View File

@ -36,6 +36,29 @@ SoundInterface_struct *SNDCoreList[] = {
NULL
};
/* ***** ***** TOOLS ***** ***** */
GList * tools_to_update = NULL;
// register tool
void register_Tool(VoidFunPtr fun) {
tools_to_update = g_list_append(tools_to_update, fun);
}
void unregister_Tool(VoidFunPtr fun) {
if (tools_to_update == NULL) return;
tools_to_update = g_list_remove(tools_to_update, fun);
}
void notify_Tool (VoidFunPtr fun, gpointer func_data) {
fun();
}
void notify_Tools() {
g_list_foreach(tools_to_update, &notify_Tool, NULL);
}
/* ***** ***** CONFIG FILE ***** ***** */
gint Keypad_Config[DESMUME_NB_KEYS];