diff options
| author | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2010-04-10 10:05:27 +0000 |
|---|---|---|
| committer | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2010-04-10 10:05:27 +0000 |
| commit | 45dac4a02a8ac6976dea295fd831bbcee0f8fd72 (patch) | |
| tree | f2b830a7a0e667442646432d14f2ff5dc0d7a64f /gui | |
| parent | ce894d34418f20f937ca1dfa532fa3f9afb61fee (diff) | |
| download | pcsxr-45dac4a02a8ac6976dea295fd831bbcee0f8fd72.tar.gz | |
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@44475 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/Cheat.c | 28 | ||||
| -rw-r--r-- | gui/DebugMemory.c | 176 | ||||
| -rw-r--r-- | gui/DebugMemory.h | 25 | ||||
| -rw-r--r-- | gui/Gtk2Gui.c | 6 | ||||
| -rw-r--r-- | gui/Makefile.am | 3 | ||||
| -rw-r--r-- | gui/Makefile.in | 6 |
6 files changed, 227 insertions, 17 deletions
diff --git a/gui/Cheat.c b/gui/Cheat.c index 0bec52a3..7b7c7957 100644 --- a/gui/Cheat.c +++ b/gui/Cheat.c @@ -402,26 +402,26 @@ void RunCheatListDialog() { widget = glade_xml_get_widget(xml, "GtkCList_Cheat"); // column for enable - renderer = gtk_cell_renderer_toggle_new (); - column = gtk_tree_view_column_new_with_attributes (_("Enable"), - renderer, "active", 0, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(widget), column); + renderer = gtk_cell_renderer_toggle_new(); + column = gtk_tree_view_column_new_with_attributes(_("Enable"), + renderer, "active", 0, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column); - g_signal_connect (G_OBJECT(renderer), "toggled", G_CALLBACK(OnCheatListDlg_EnableToggled), 0); + g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(OnCheatListDlg_EnableToggled), 0); // column for description - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Description"), - renderer, "text", 1, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(widget), column); + renderer = gtk_cell_renderer_text_new(); + column = gtk_tree_view_column_new_with_attributes(_("Description"), + renderer, "text", 1, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column); LoadCheatListItems(-1); - treesel = gtk_tree_view_get_selection (GTK_TREE_VIEW(widget)); - gtk_tree_selection_set_mode (treesel, GTK_SELECTION_SINGLE); - g_signal_connect_data (G_OBJECT (treesel), "changed", - G_CALLBACK (CheatList_TreeSelectionChanged), - NULL, NULL, G_CONNECT_AFTER); + treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); + gtk_tree_selection_set_mode(treesel, GTK_SELECTION_SINGLE); + g_signal_connect_data(G_OBJECT (treesel), "changed", + G_CALLBACK (CheatList_TreeSelectionChanged), + NULL, NULL, G_CONNECT_AFTER); widget = glade_xml_get_widget(xml, "addbutton1"); g_signal_connect_data(GTK_OBJECT(widget), "clicked", diff --git a/gui/DebugMemory.c b/gui/DebugMemory.c new file mode 100644 index 00000000..c2a4fcb0 --- /dev/null +++ b/gui/DebugMemory.c @@ -0,0 +1,176 @@ +/* Memory Viewer/Dumper for PCSX-Reloaded + * + * Copyright (C) 2010, Wei Mingzhi <whistler_wmz@users.sf.net>. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307 USA + */ + +#include "Linux.h" +#include "../libpcsxcore/psxmem.h" +#include <glade/glade.h> + +#define MEMVIEW_MAX_LINES 256 + +static GtkWidget *MemViewDlg = NULL; +static u32 MemViewAddress = 0; + +static void UpdateMemViewDlg() { + s32 start, end; + int i; + char bufaddr[9], bufdata[16][3], buftext[17]; + + GtkListStore *store = gtk_list_store_new(18, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING); + + GtkTreeIter iter; + GtkWidget *widget; + GladeXML *xml; + + xml = glade_get_widget_tree(MemViewDlg); + + MemViewAddress &= 0x1fffff; + + sprintf(buftext, "%.8X", MemViewAddress); + widget = glade_xml_get_widget(xml, "entry_address"); + gtk_entry_set_text(GTK_ENTRY(widget), buftext); + + start = MemViewAddress & 0x1ffff0; + end = start + MEMVIEW_MAX_LINES * 16; + + if (end > 0x1fffff) end = 0x1fffff; + + widget = glade_xml_get_widget(xml, "GtkCList_MemView"); + + buftext[16] = '\0'; + + while (start < end) { + sprintf(bufaddr, "%.8X", start); + + for (i = 0; i < 16; i++) { + buftext[i] = PSXMs8(start + i); + sprintf(bufdata[i], "%.2X", (u8)buftext[i]); + if (buftext[i] < 32) buftext[i] = '.'; + } + + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, bufaddr, 1, bufdata[0], + 2, bufdata[1], 3, bufdata[2], 4, bufdata[3], 5, bufdata[4], + 6, bufdata[5], 7, bufdata[6], 8, bufdata[7], 9, bufdata[8], + 10, bufdata[9], 11, bufdata[10], 12, bufdata[11], 13, bufdata[12], + 14, bufdata[13], 15, bufdata[14], 16, bufdata[15], 17, buftext, -1); + + start += 16; + } + + gtk_tree_view_set_model(GTK_TREE_VIEW(widget), GTK_TREE_MODEL(store)); + g_object_unref(G_OBJECT(store)); + gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(widget), TRUE); + gtk_widget_show(widget); +} + +static void MemView_Go() { + GtkWidget *widget; + GladeXML *xml; + + xml = glade_get_widget_tree(MemViewDlg); + widget = glade_xml_get_widget(xml, "entry_address"); + + sscanf(gtk_entry_get_text(GTK_ENTRY(widget)), "%x", &MemViewAddress); + + UpdateMemViewDlg(); +} + +static void MemView_Dump() { + // TODO +} + +static void MemView_Patch() { + // TODO + UpdateMemViewDlg(); +} + +// close the memory viewer window +static void MemView_Close(GtkWidget *widget, gpointer user_data) { + gtk_widget_destroy(MemViewDlg); + MemViewDlg = NULL; +} + +void RunDebugMemoryDialog() { + GladeXML *xml; + GtkWidget *widget; + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + PangoFontDescription *pfd; + int i; + + xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "MemViewDlg", NULL); + if (!xml) { + g_warning(_("Error: Glade interface could not be loaded!")); + return; + } + + MemViewDlg = glade_xml_get_widget(xml, "MemViewDlg"); + gtk_window_set_title(GTK_WINDOW(MemViewDlg), _("Memory Viewer")); + + widget = glade_xml_get_widget(xml, "GtkCList_MemView"); + + renderer = gtk_cell_renderer_text_new(); + column = gtk_tree_view_column_new_with_attributes(_("Address"), + renderer, "text", 0, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column); + + for (i = 0; i < 16; i++) { + const char *p = "0123456789ABCDEF"; + char buf[2]; + + buf[0] = p[i]; + buf[1] = '\0'; + + renderer = gtk_cell_renderer_text_new(); + column = gtk_tree_view_column_new_with_attributes(buf, + renderer, "text", i + 1, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column); + } + + renderer = gtk_cell_renderer_text_new(); + column = gtk_tree_view_column_new_with_attributes(_("Text"), + renderer, "text", 17, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column); + + pfd = pango_font_description_from_string("Bitstream Vera Sans Mono, " + "DejaVu Sans Mono, Liberation Mono, FreeMono, Sans Mono 9"); + gtk_widget_modify_font(widget, pfd); + pango_font_description_free(pfd); + + UpdateMemViewDlg(); + + widget = glade_xml_get_widget(xml, "btn_dump"); + g_signal_connect_data(GTK_OBJECT(widget), "clicked", + GTK_SIGNAL_FUNC(MemView_Dump), xml, NULL, G_CONNECT_AFTER); + + widget = glade_xml_get_widget(xml, "btn_patch"); + g_signal_connect_data(GTK_OBJECT(widget), "clicked", + GTK_SIGNAL_FUNC(MemView_Patch), xml, NULL, G_CONNECT_AFTER); + + widget = glade_xml_get_widget(xml, "btn_go"); + g_signal_connect_data(GTK_OBJECT(widget), "clicked", + GTK_SIGNAL_FUNC(MemView_Go), xml, NULL, G_CONNECT_AFTER); + + g_signal_connect_data(GTK_OBJECT(MemViewDlg), "response", + GTK_SIGNAL_FUNC(MemView_Close), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER); +} diff --git a/gui/DebugMemory.h b/gui/DebugMemory.h new file mode 100644 index 00000000..07277158 --- /dev/null +++ b/gui/DebugMemory.h @@ -0,0 +1,25 @@ +/* Memory Viewer/Dumper for PCSX-Reloaded + * + * Copyright (C) 2010, Wei Mingzhi <whistler_wmz@users.sf.net>. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307 USA + */ + +#ifndef DEBUGMEMORY_H +#define DEBUGMEMORY_H + +void RunDebugMemoryDialog(); + +#endif diff --git a/gui/Gtk2Gui.c b/gui/Gtk2Gui.c index 81da513e..6517ed82 100644 --- a/gui/Gtk2Gui.c +++ b/gui/Gtk2Gui.c @@ -37,6 +37,7 @@ #include "MemcardDlg.h" #include "ConfDlg.h" +#include "DebugMemory.h" // Functions Callbacks void OnFile_RunCd(); @@ -99,6 +100,8 @@ void ResetMenuSlots(GladeXML *xml) { gtk_widget_set_sensitive(widget, FALSE); widget = glade_xml_get_widget(xml, "SwitchImage"); gtk_widget_set_sensitive(widget, FALSE); + widget = glade_xml_get_widget(xml, "memorydump1"); + gtk_widget_set_sensitive(widget, FALSE); widget = glade_xml_get_widget(xml, "toolbutton_run"); gtk_widget_set_sensitive(widget, FALSE); widget = glade_xml_get_widget(xml, "toolbutton_switchimage"); @@ -322,6 +325,9 @@ void StartGui() { widget = glade_xml_get_widget(xml, "net1"); g_signal_connect_data(GTK_OBJECT(widget), "activate", GTK_SIGNAL_FUNC(OnConf_Net), NULL, NULL, G_CONNECT_AFTER); + widget = glade_xml_get_widget(xml, "memorydump1"); + g_signal_connect_data(GTK_OBJECT(widget), "activate", + GTK_SIGNAL_FUNC(RunDebugMemoryDialog), NULL, NULL, G_CONNECT_AFTER); // Cheat menu widget = glade_xml_get_widget(xml, "browse1"); diff --git a/gui/Makefile.am b/gui/Makefile.am index eacfd672..b17d5e74 100644 --- a/gui/Makefile.am +++ b/gui/Makefile.am @@ -15,7 +15,8 @@ pcsx_SOURCES = \ Gtk2Gui.c \ MemcardDlg.c \ ConfDlg.c \ - Cheat.c + Cheat.c \ + DebugMemory.c pcsx_LDADD = \ $(GTK2_LIBS) $(GLADE2_LIBS) -lpthread -lz -lm -lXext -lXtst \ diff --git a/gui/Makefile.in b/gui/Makefile.in index 040e7b6d..b3b1dbaf 100644 --- a/gui/Makefile.in +++ b/gui/Makefile.in @@ -48,7 +48,7 @@ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_pcsx_OBJECTS = LnxMain.$(OBJEXT) Plugin.$(OBJEXT) Config.$(OBJEXT) \ Gtk2Gui.$(OBJEXT) MemcardDlg.$(OBJEXT) ConfDlg.$(OBJEXT) \ - Cheat.$(OBJEXT) + Cheat.$(OBJEXT) DebugMemory.$(OBJEXT) pcsx_OBJECTS = $(am_pcsx_OBJECTS) am__DEPENDENCIES_1 = pcsx_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @@ -237,7 +237,8 @@ pcsx_SOURCES = \ Gtk2Gui.c \ MemcardDlg.c \ ConfDlg.c \ - Cheat.c + Cheat.c \ + DebugMemory.c pcsx_LDADD = \ $(GTK2_LIBS) $(GLADE2_LIBS) -lpthread -lz -lm -lXext -lXtst \ @@ -317,6 +318,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cheat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConfDlg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Config.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DebugMemory.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Gtk2Gui.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LnxMain.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MemcardDlg.Po@am__quote@ |
