From 3c71be61007c4984b6f9db319a1716fec83a5cd8 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Mon, 21 Jul 2008 18:42:44 +0000 Subject: [PATCH] Improved some error msgs, added preliminary memory view window, split plugin ini files. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@42 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DebuggerWX/DebuggerWX.vcproj | 18 +- Source/Core/DebuggerWX/src/CodeWindow.cpp | 124 ++++-- Source/Core/DebuggerWX/src/CodeWindow.h | 4 + Source/Core/DebuggerWX/src/MemoryView.cpp | 417 ++++++++++++++++++ Source/Core/DebuggerWX/src/MemoryView.h | 77 ++++ Source/Core/DebuggerWX/src/MemoryWindow.cpp | 177 ++++++++ Source/Core/DebuggerWX/src/MemoryWindow.h | 68 +++ Source/Core/DebuggerWX/src/RegisterWindow.h | 2 +- Source/Core/DolphinWX/src/Config.cpp | 7 +- .../Plugins/Plugin_PadDX9/Src/DIHandler.cpp | 4 +- .../Plugins/Plugin_VideoDX9/Src/Globals.cpp | 6 +- .../Plugins/Plugin_VideoOGL/Src/Globals.cpp | 6 +- .../Plugin_VideoOGL/Src/Windows/resource.rc | 2 +- 13 files changed, 866 insertions(+), 46 deletions(-) create mode 100644 Source/Core/DebuggerWX/src/MemoryView.cpp create mode 100644 Source/Core/DebuggerWX/src/MemoryView.h create mode 100644 Source/Core/DebuggerWX/src/MemoryWindow.cpp create mode 100644 Source/Core/DebuggerWX/src/MemoryWindow.h diff --git a/Source/Core/DebuggerWX/DebuggerWX.vcproj b/Source/Core/DebuggerWX/DebuggerWX.vcproj index f26b6c8292..0ad7535185 100644 --- a/Source/Core/DebuggerWX/DebuggerWX.vcproj +++ b/Source/Core/DebuggerWX/DebuggerWX.vcproj @@ -1,7 +1,7 @@ + + + + @@ -486,6 +494,14 @@ RelativePath=".\src\MemoryCheckDlg.h" > + + + + diff --git a/Source/Core/DebuggerWX/src/CodeWindow.cpp b/Source/Core/DebuggerWX/src/CodeWindow.cpp index 54f6f454d8..1752b8d4a7 100644 --- a/Source/Core/DebuggerWX/src/CodeWindow.cpp +++ b/Source/Core/DebuggerWX/src/CodeWindow.cpp @@ -20,6 +20,7 @@ #include "RegisterWindow.h" #include "LogWindow.h" #include "BreakpointWindow.h" +#include "MemoryWindow.h" #include "IniFile.h" #include "wx/button.h" @@ -28,6 +29,7 @@ #include "wx/thread.h" #include "wx/listctrl.h" #include "CodeWindow.h" +#include "CodeView.h" #include "HW/CPU.h" #include "PowerPC/PowerPC.h" #include "Host.h" @@ -65,7 +67,8 @@ enum IDM_DUALCORE, IDM_LOGWINDOW, IDM_REGISTERWINDOW, - IDM_BREAKPOINTWINDOW + IDM_BREAKPOINTWINDOW, + IDM_MEMORYWINDOW, }; BEGIN_EVENT_TABLE(CCodeWindow, wxFrame) @@ -82,6 +85,7 @@ BEGIN_EVENT_TABLE(CCodeWindow, wxFrame) EVT_MENU(IDM_LOGWINDOW, CCodeWindow::OnToggleLogWindow) EVT_MENU(IDM_REGISTERWINDOW, CCodeWindow::OnToggleRegisterWindow) EVT_MENU(IDM_BREAKPOINTWINDOW, CCodeWindow::OnToggleBreakPointWindow) + EVT_MENU(IDM_MEMORYWINDOW, CCodeWindow::OnToggleMemoryWindow) END_EVENT_TABLE() @@ -137,10 +141,11 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter m_BreakpointWindow = new CBreakPointWindow(this, this); m_BreakpointWindow->Show(true); + m_MemoryWindow = new CMemoryWindow(this); + m_MemoryWindow->Show(true); UpdateButtonStates(); - int x,y,w,h; IniFile file; @@ -152,23 +157,38 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter file.Get("Code", "h", &h, GetSize().GetHeight()); this->SetSize(x, y, w, h); - file.Get("BreakPoint", "x", &x, m_BreakpointWindow->GetPosition().x); - file.Get("BreakPoint", "y", &y, m_BreakpointWindow->GetPosition().y); - file.Get("BreakPoint", "w", &w, m_BreakpointWindow->GetSize().GetWidth()); - file.Get("BreakPoint", "h", &h, m_BreakpointWindow->GetSize().GetHeight()); - m_BreakpointWindow->SetSize(x, y, w, h); + // These really should be in the respective constructors. + if (m_BreakpointWindow) { + file.Get("BreakPoint", "x", &x, m_BreakpointWindow->GetPosition().x); + file.Get("BreakPoint", "y", &y, m_BreakpointWindow->GetPosition().y); + file.Get("BreakPoint", "w", &w, m_BreakpointWindow->GetSize().GetWidth()); + file.Get("BreakPoint", "h", &h, m_BreakpointWindow->GetSize().GetHeight()); + m_BreakpointWindow->SetSize(x, y, w, h); + } - file.Get("LogWindow", "x", &x, m_logwindow->GetPosition().x); - file.Get("LogWindow", "y", &y, m_logwindow->GetPosition().y); - file.Get("LogWindow", "w", &w, m_logwindow->GetSize().GetWidth()); - file.Get("LogWindow", "h", &h, m_logwindow->GetSize().GetHeight()); - m_logwindow->SetSize(x, y, w, h); + if (m_logwindow) { + file.Get("LogWindow", "x", &x, m_logwindow->GetPosition().x); + file.Get("LogWindow", "y", &y, m_logwindow->GetPosition().y); + file.Get("LogWindow", "w", &w, m_logwindow->GetSize().GetWidth()); + file.Get("LogWindow", "h", &h, m_logwindow->GetSize().GetHeight()); + m_logwindow->SetSize(x, y, w, h); + } - file.Get("RegisterWindow", "x", &x, m_RegisterWindow->GetPosition().x); - file.Get("RegisterWindow", "y", &y, m_RegisterWindow->GetPosition().y); - file.Get("RegisterWindow", "w", &w, m_RegisterWindow->GetSize().GetWidth()); - file.Get("RegisterWindow", "h", &h, m_RegisterWindow->GetSize().GetHeight()); - m_RegisterWindow->SetSize(x, y, w, h); + if (m_RegisterWindow) { + file.Get("RegisterWindow", "x", &x, m_RegisterWindow->GetPosition().x); + file.Get("RegisterWindow", "y", &y, m_RegisterWindow->GetPosition().y); + //file.Get("RegisterWindow", "w", &w, m_RegisterWindow->GetSize().GetWidth()); + //file.Get("RegisterWindow", "h", &h, m_RegisterWindow->GetSize().GetHeight()); + m_RegisterWindow->SetSize(x, y, w, h); + } + + if (m_MemoryWindow) { + file.Get("MemoryWindow", "x", &x, m_MemoryWindow->GetPosition().x); + file.Get("MemoryWindow", "y", &y, m_MemoryWindow->GetPosition().y); + file.Get("MemoryWindow", "w", &w, m_MemoryWindow->GetSize().GetWidth()); + file.Get("MemoryWindow", "h", &h, m_MemoryWindow->GetSize().GetHeight()); + m_RegisterWindow->SetSize(x, y, w, h); + } } @@ -182,22 +202,35 @@ CCodeWindow::~CCodeWindow() file.Set("Code", "w", GetSize().GetWidth()); file.Set("Code", "h", GetSize().GetHeight()); - file.Set("BreakPoint", "x", m_BreakpointWindow->GetPosition().x); - file.Set("BreakPoint", "y", m_BreakpointWindow->GetPosition().y); - file.Set("BreakPoint", "w", m_BreakpointWindow->GetSize().GetWidth()); - file.Set("BreakPoint", "h", m_BreakpointWindow->GetSize().GetHeight()); + // These really should be in the respective destructors. + if (m_BreakpointWindow) { + file.Set("BreakPoint", "x", m_BreakpointWindow->GetPosition().x); + file.Set("BreakPoint", "y", m_BreakpointWindow->GetPosition().y); + file.Set("BreakPoint", "w", m_BreakpointWindow->GetSize().GetWidth()); + file.Set("BreakPoint", "h", m_BreakpointWindow->GetSize().GetHeight()); + } - file.Set("LogWindow", "x", m_logwindow->GetPosition().x); - file.Set("LogWindow", "y", m_logwindow->GetPosition().y); - file.Set("LogWindow", "w", m_logwindow->GetSize().GetWidth()); - file.Set("LogWindow", "h", m_logwindow->GetSize().GetHeight()); + if (m_logwindow) { + file.Set("LogWindow", "x", m_logwindow->GetPosition().x); + file.Set("LogWindow", "y", m_logwindow->GetPosition().y); + file.Set("LogWindow", "w", m_logwindow->GetSize().GetWidth()); + file.Set("LogWindow", "h", m_logwindow->GetSize().GetHeight()); + } - file.Set("RegisterWindow", "x", m_RegisterWindow->GetPosition().x); - file.Set("RegisterWindow", "y", m_RegisterWindow->GetPosition().y); - file.Set("RegisterWindow", "w", m_RegisterWindow->GetSize().GetWidth()); - file.Set("RegisterWindow", "h", m_RegisterWindow->GetSize().GetHeight()); + if (m_RegisterWindow) { + file.Set("RegisterWindow", "x", m_RegisterWindow->GetPosition().x); + file.Set("RegisterWindow", "y", m_RegisterWindow->GetPosition().y); + file.Set("RegisterWindow", "w", m_RegisterWindow->GetSize().GetWidth()); + file.Set("RegisterWindow", "h", m_RegisterWindow->GetSize().GetHeight()); + } - file.Save("Debugger.ini"); + if (m_MemoryWindow) { + file.Set("MemoryWindow", "x", m_MemoryWindow->GetPosition().x); + file.Set("MemoryWindow", "y", m_MemoryWindow->GetPosition().y); + file.Set("MemoryWindow", "w", m_MemoryWindow->GetSize().GetWidth()); + file.Set("MemoryWindow", "h", m_MemoryWindow->GetSize().GetHeight()); + } + file.Save("Debugger.ini"); } @@ -231,7 +264,9 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam wxMenuItem* pBreakPoints = pDebugDialogs->Append(IDM_BREAKPOINTWINDOW, _T("&BreakPoints"), wxEmptyString, wxITEM_CHECK); pBreakPoints->Check(true); - pMenuBar->Append(pDebugDialogs, _T("&Dialogs")); + wxMenuItem* pMemory = pDebugDialogs->Append(IDM_MEMORYWINDOW, _T("&Memory"), wxEmptyString, wxITEM_CHECK); + pMemory->Check(true); + pMenuBar->Append(pDebugDialogs, _T("&Views")); } SetMenuBar(pMenuBar); @@ -523,6 +558,33 @@ void CCodeWindow::OnToggleBreakPointWindow(wxCommandEvent& event) } } +void CCodeWindow::OnToggleMemoryWindow(wxCommandEvent& event) +{ + bool show = GetMenuBar()->IsChecked(event.GetId()); + + if (show) + { + if (!m_MemoryWindow) + { + m_MemoryWindow = new CMemoryWindow(this); + } + + m_MemoryWindow->Show(true); + } + else // hide + { + // If m_dialog is NULL, then possibly the system + // didn't report the checked menu item status correctly. + // It should be true just after the menu item was selected, + // if there was no modeless dialog yet. + wxASSERT(m_MemoryWindow != NULL); + + if (m_MemoryWindow) + { + m_MemoryWindow->Hide(); + } + } +} void CCodeWindow::OnHostMessage(wxCommandEvent& event) { switch (event.GetId()) diff --git a/Source/Core/DebuggerWX/src/CodeWindow.h b/Source/Core/DebuggerWX/src/CodeWindow.h index 0ad945abf1..81319e9d90 100644 --- a/Source/Core/DebuggerWX/src/CodeWindow.h +++ b/Source/Core/DebuggerWX/src/CodeWindow.h @@ -30,6 +30,8 @@ class CRegisterWindow; class CLogWindow; class CBreakPointWindow; +class CMemoryWindow; +class CCodeView; class CCodeWindow : public wxFrame @@ -58,6 +60,7 @@ class CCodeWindow CLogWindow* m_logwindow; CRegisterWindow* m_RegisterWindow; CBreakPointWindow* m_BreakpointWindow; + CMemoryWindow* m_MemoryWindow; CCodeView* codeview; wxListBox* callstack; @@ -81,6 +84,7 @@ class CCodeWindow void OnToggleRegisterWindow(wxCommandEvent& event); void OnToggleBreakPointWindow(wxCommandEvent& event); void OnToggleLogWindow(wxCommandEvent& event); + void OnToggleMemoryWindow(wxCommandEvent& event); void OnHostMessage(wxCommandEvent& event); void CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter); diff --git a/Source/Core/DebuggerWX/src/MemoryView.cpp b/Source/Core/DebuggerWX/src/MemoryView.cpp new file mode 100644 index 0000000000..7decb67b80 --- /dev/null +++ b/Source/Core/DebuggerWX/src/MemoryView.cpp @@ -0,0 +1,417 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// 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, version 2.0. + +// 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 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#include "Debugger.h" +#include "Common.h" + +#include "MemoryView.h" +#include +#include + + +enum +{ + IDM_GOTOINMEMVIEW = 12000, + IDM_COPYADDRESS, + IDM_COPYHEX, + IDM_COPYCODE, + IDM_RUNTOHERE, + IDM_DYNARECRESULTS, +}; + + +BEGIN_EVENT_TABLE(CMemoryView, wxControl) +EVT_ERASE_BACKGROUND(CMemoryView::OnErase) +EVT_PAINT(CMemoryView::OnPaint) +EVT_LEFT_DOWN(CMemoryView::OnMouseDown) +EVT_LEFT_UP(CMemoryView::OnMouseUpL) +EVT_MOTION(CMemoryView::OnMouseMove) +EVT_RIGHT_DOWN(CMemoryView::OnMouseDown) +EVT_RIGHT_UP(CMemoryView::OnMouseUpR) +EVT_MENU(-1, CMemoryView::OnPopupMenu) +END_EVENT_TABLE() + +CMemoryView::CMemoryView(DebugInterface* debuginterface, wxWindow* parent, wxWindowID Id, const wxSize& Size) + : wxControl(parent, Id, wxDefaultPosition, Size), debugger(debuginterface) +{ + rowHeight = 13; + align = debuginterface->getInstructionSize(0); + curAddress = debuginterface->getPC(); +} + + +wxSize CMemoryView::DoGetBestSize() const +{ + wxSize bestSize; + bestSize.x = 300; + bestSize.y = 300; + return(bestSize); +} + + +int CMemoryView::YToAddress(int y) +{ + wxRect rc = GetClientRect(); + int ydiff = y - rc.height / 2 - rowHeight / 2; + ydiff = (int)(floorf((float)ydiff / (float)rowHeight)) + 1; + return(curAddress + ydiff * align); +} + + +void CMemoryView::OnMouseDown(wxMouseEvent& event) +{ + int x = event.m_x; + int y = event.m_y; + + if (x > 16) + { + oldSelection = selection; + selection = YToAddress(y); + // SetCapture(wnd); + bool oldselecting = selecting; + selecting = true; + + if (!oldselecting || (selection != oldSelection)) + { + redraw(); + } + } + else + { + debugger->toggleBreakpoint(YToAddress(y)); + redraw(); + } + + event.Skip(true); +} + + +void CMemoryView::OnMouseMove(wxMouseEvent& event) +{ + wxRect rc = GetClientRect(); + + if (event.m_leftDown) + { + if (event.m_x > 16) + { + if (event.m_y < 0) + { + curAddress -= align; + redraw(); + } + else if (event.m_y > rc.height) + { + curAddress += align; + redraw(); + } + else + { + OnMouseDown(event); + } + } + } + + event.Skip(true); +} + + +void CMemoryView::OnMouseUpL(wxMouseEvent& event) +{ + if (event.m_x > 16) + { + curAddress = YToAddress(event.m_y); + selecting = false; + //ReleaseCapture(); + redraw(); + } + + event.Skip(true); +} + + +void CMemoryView::OnPopupMenu(wxCommandEvent& event) +{ +#if wxUSE_CLIPBOARD + wxTheClipboard->Open(); +#endif + + switch (event.GetId()) + { + case IDM_GOTOINMEMVIEW: + // CMemoryDlg::Goto(selection); + break; + +#if wxUSE_CLIPBOARD + case IDM_COPYADDRESS: + { + wxTheClipboard->SetData(new wxTextDataObject(wxString::Format(_T("%08x"), selection))); + } + break; + + case IDM_COPYCODE: + wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(debugger->disasm(selection)))); //Have to manually convert from char* to wxString, don't have to in Windows? + break; + + case IDM_COPYHEX: + { + char temp[24]; + sprintf(temp, "%08x", debugger->readMemory(selection)); + wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(temp))); + } + break; +#endif + + case IDM_RUNTOHERE: + { + debugger->setBreakpoint(selection); + debugger->runToBreakpoint(); + redraw(); + } + break; + + case IDM_DYNARECRESULTS: + { +// CDynaViewDlg::ViewAddr(selection); +// CDynaViewDlg::Show(TRUE); +// MessageBox(NULL, "not impl", "CtrlDisAsmView", MB_OK); + } + break; + } + +#if wxUSE_CLIPBOARD + wxTheClipboard->Close(); +#endif + event.Skip(true); +} + + +void CMemoryView::OnMouseUpR(wxMouseEvent& event) +{ + // popup menu + wxMenu menu; + //menu.Append(IDM_GOTOINMEMVIEW, "&Goto in mem view"); +#if wxUSE_CLIPBOARD + menu.Append(IDM_COPYADDRESS, wxString::FromAscii("Copy &address")); + menu.Append(IDM_COPYCODE, wxString::FromAscii("Copy &code")); + menu.Append(IDM_COPYHEX, wxString::FromAscii("Copy &hex")); +#endif + menu.Append(IDM_RUNTOHERE, _T("&Run To Here")); + //menu.Append(IDM_DYNARECRESULTS, "Copy &address"); + PopupMenu(&menu); + event.Skip(true); +} + + +void CMemoryView::OnErase(wxEraseEvent& event) +{} + + +void CMemoryView::OnPaint(wxPaintEvent& event) +{ + wxPaintDC dc(this); + wxRect rc = GetClientRect(); + wxFont font(7, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT); + dc.SetFont(font); + struct branch + { + int src, dst, srcAddr; + }; + + branch branches[256]; + int numBranches = 0; + // TODO: Add any drawing code here... + int width = rc.width; + int numRows = (rc.height / rowHeight) / 2 + 2; + //numRows=(numRows&(~1)) + 1; + dc.SetBackgroundMode(wxTRANSPARENT); + const wxChar* bgColor = _T("#ffffff"); + wxPen nullPen(bgColor); + wxPen currentPen(_T("#000000")); + wxPen selPen(_T("#808080")); + nullPen.SetStyle(wxTRANSPARENT); + + wxBrush currentBrush(_T("#FFEfE8")); + wxBrush pcBrush(_T("#70FF70")); + wxBrush bpBrush(_T("#FF3311")); + wxBrush bgBrush(bgColor); + wxBrush nullBrush(bgColor); + nullBrush.SetStyle(wxTRANSPARENT); + + dc.SetPen(nullPen); + dc.SetBrush(bgBrush); + dc.DrawRectangle(0, 0, 16, rc.height); + dc.DrawRectangle(0, 0, rc.width, 5); + // TODO - clean up this freaking mess!!!!! + int i; + + for (i = -numRows; i <= numRows; i++) + { + unsigned int address = curAddress + i * align; + + int rowY1 = rc.height / 2 + rowHeight * i - rowHeight / 2; + int rowY2 = rc.height / 2 + rowHeight * i + rowHeight / 2; + + wxString temp = wxString::Format(_T("%08x"), address); + u32 col = debugger->getColor(address); + wxBrush rowBrush(wxColor(col >> 16, col >> 8, col)); + dc.SetBrush(nullBrush); + dc.SetPen(nullPen); + dc.DrawRectangle(0, rowY1, 16, rowY2); + + if (selecting && (address == selection)) + { + dc.SetPen(selPen); + } + else + { + dc.SetPen(i == 0 ? currentPen : nullPen); + } + + if (address == debugger->getPC()) + { + dc.SetBrush(pcBrush); + } + else + { + dc.SetBrush(rowBrush); + } + + dc.DrawRectangle(16, rowY1, width, rowY2 - 1); + dc.SetBrush(currentBrush); + dc.SetTextForeground(_T("#600000")); + dc.DrawText(temp, 17, rowY1); + dc.SetTextForeground(_T("#000000")); + + if (debugger->isAlive()) + { + char dis[256] = {0}; + strcpy(dis, debugger->disasm(address)); + char* dis2 = strchr(dis, '\t'); + char desc[256] = ""; + + if (dis2) + { + *dis2 = 0; + dis2++; + const char* mojs = strstr(dis2, "0x8"); + + if (mojs) + { + for (int i = 0; i < 8; i++) + { + bool found = false; + + for (int j = 0; j < 22; j++) + { + if (mojs[i + 2] == "0123456789ABCDEFabcdef"[j]) + { + found = true; + } + } + + + if (!found) + { + mojs = 0; + break; + } + } + } + + if (mojs) + { + int offs; + sscanf(mojs + 2, "%08x", &offs); + branches[numBranches].src = rowY1 + rowHeight / 2; + branches[numBranches].srcAddr = address / align; + branches[numBranches++].dst = (int)(rowY1 + ((s64)offs - (s64)address) * rowHeight / align + rowHeight / 2); + sprintf(desc, "-->%s", debugger->getDescription(offs).c_str()); + dc.SetTextForeground(_T("#600060")); + } + else + { + dc.SetTextForeground(_T("#000000")); + } + + dc.DrawText(wxString::FromAscii(dis2), 126, rowY1); + } + + if (strcmp(dis, "blr")) + { + dc.SetTextForeground(_T("#007000")); + } + else + { + dc.SetTextForeground(_T("#8000FF")); + } + + dc.DrawText(wxString::FromAscii(dis), 70, rowY1); + + if (desc[0] == 0) + { + strcpy(desc, debugger->getDescription(address).c_str()); + } + + dc.SetTextForeground(_T("#0000FF")); + + //char temp[256]; + //UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE); + if (strlen(desc)) + { + dc.DrawText(wxString::FromAscii(desc), 235, rowY1); + } + + if (debugger->isBreakpoint(address)) + { + dc.SetBrush(bpBrush); + dc.DrawRectangle(2, rowY1, 7, 7); +// DrawIconEx(hdc, 2, rowY1, breakPoint, 32, 32, 0, 0, DI_NORMAL); + } + } + } + + dc.SetPen(currentPen); + /* + for (i = 0; i < numBranches; i++) + { + int x = 250 + (branches[i].srcAddr % 9) * 8; + MoveToEx(hdc, x-2, branches[i].src, 0); + + if (branches[i].dst < rect.bottom + 200 && branches[i].dst > -200) + { + LineTo(hdc, x+2, branches[i].src); + LineTo(hdc, x+2, branches[i].dst); + LineTo(hdc, x-4, branches[i].dst); + + MoveToEx(hdc, x, branches[i].dst - 4,0); + LineTo(hdc, x-4, branches[i].dst); + LineTo(hdc, x+1, branches[i].dst+5); + } + else + { + LineTo(hdc, x+4, branches[i].src); + //MoveToEx(hdc,x+2,branches[i].dst-4,0); + //LineTo(hdc,x+6,branches[i].dst); + //LineTo(hdc,x+1,branches[i].dst+5); + } + //LineTo(hdc,x,branches[i].dst+4); + + //LineTo(hdc,x-2,branches[i].dst); + }*/ +} + + diff --git a/Source/Core/DebuggerWX/src/MemoryView.h b/Source/Core/DebuggerWX/src/MemoryView.h new file mode 100644 index 0000000000..63733801af --- /dev/null +++ b/Source/Core/DebuggerWX/src/MemoryView.h @@ -0,0 +1,77 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// 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, version 2.0. + +// 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 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef MEMORYVIEW_H_ +#define MEMORYVIEW_H_ + +#include "Debugger.h" +#include "Common.h" +#include "Debugger/DebugInterface.h" + +#include + +class CMemoryView + : public wxControl +{ + public: + + CMemoryView(DebugInterface* debuginterface, wxWindow* parent, wxWindowID Id = -1, const wxSize& Size = wxDefaultSize); + wxSize DoGetBestSize() const; + void OnPaint(wxPaintEvent& event); + void OnErase(wxEraseEvent& event); + void OnMouseDown(wxMouseEvent& event); + void OnMouseMove(wxMouseEvent& event); + void OnMouseUpL(wxMouseEvent& event); + void OnMouseUpR(wxMouseEvent& event); + void OnPopupMenu(wxCommandEvent& event); + + + u32 GetSelection() {return(selection);} + + + void Center(u32 addr) + { + curAddress = addr; + redraw(); + } + + + private: + + int YToAddress(int y); + + + void redraw() {Refresh();} + + + DebugInterface* debugger; + + int curAddress; + int align; + int rowHeight; + + u32 selection; + u32 oldSelection; + bool selectionChanged; + bool selecting; + bool hasFocus; + bool showHex; + + DECLARE_EVENT_TABLE() +}; + +#endif /*MEMORYVIEW_H_*/ diff --git a/Source/Core/DebuggerWX/src/MemoryWindow.cpp b/Source/Core/DebuggerWX/src/MemoryWindow.cpp new file mode 100644 index 0000000000..b323d7c26d --- /dev/null +++ b/Source/Core/DebuggerWX/src/MemoryWindow.cpp @@ -0,0 +1,177 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// 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, version 2.0. + +// 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 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#include "Debugger.h" + +#include "IniFile.h" + +#include "wx/button.h" +#include "wx/textctrl.h" +#include "wx/listctrl.h" +#include "wx/thread.h" +#include "wx/listctrl.h" +#include "MemoryWindow.h" +#include "HW/CPU.h" +#include "PowerPC/PowerPC.h" +#include "Host.h" + +#include "Debugger/PPCDebugInterface.h" +#include "Debugger/Debugger_SymbolMap.h" + +#include "Core.h" +#include "LogManager.h" + +// ugly that this lib included code from the main +#include "../../DolphinWX/src/Globals.h" + +class SymbolList + : public wxListCtrl +{ + wxString OnGetItemText(long item, long column) + { + return(_T("hello")); + } +}; + +enum +{ + IDM_DEBUG_GO = 350, + IDM_STEP, + IDM_STEPOVER, + IDM_SKIP, + IDM_SETPC, + IDM_GOTOPC, + IDM_ADDRBOX, + IDM_CALLSTACKLIST, + IDM_SYMBOLLIST, + IDM_INTERPRETER, + IDM_DUALCORE, + IDM_LOGWINDOW, + IDM_REGISTERWINDOW, + IDM_BREAKPOINTWINDOW +}; + +BEGIN_EVENT_TABLE(CMemoryWindow, wxFrame) + EVT_TEXT(IDM_ADDRBOX, CMemoryWindow::OnAddrBoxChange) + EVT_LISTBOX(IDM_SYMBOLLIST, CMemoryWindow::OnSymbolListChange) + EVT_HOST_COMMAND(wxID_ANY, CMemoryWindow::OnHostMessage) +END_EVENT_TABLE() + + +CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id, + const wxString& title, const wxPoint& pos, const wxSize& size, long style) + : wxFrame(parent, id, title, pos, size, style) +{ + wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer* sizerRight = new wxBoxSizer(wxVERTICAL); + wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL); + + DebugInterface* di = new PPCDebugInterface(); + + sizerLeft->Add(symbols = new wxListBox(this, IDM_SYMBOLLIST, wxDefaultPosition, wxSize(90, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND); + memview = new CMemoryView(di, this, wxID_ANY); + sizerBig->Add(sizerLeft, 2, wxEXPAND); + sizerBig->Add(memview, 5, wxEXPAND); + sizerBig->Add(sizerRight, 0, wxEXPAND | wxALL, 3); + sizerRight->Add(buttonGo = new wxButton(this, IDM_DEBUG_GO, _T("&Go"))); + sizerRight->Add(addrbox = new wxTextCtrl(this, IDM_ADDRBOX, _T(""))); + sizerRight->Add(new wxButton(this, IDM_SETPC, _T("S&et PC"))); + + SetSizer(sizerBig); + + sizerLeft->SetSizeHints(this); + sizerLeft->Fit(this); + sizerRight->SetSizeHints(this); + sizerRight->Fit(this); + sizerBig->SetSizeHints(this); + sizerBig->Fit(this); +} + + +CMemoryWindow::~CMemoryWindow() +{ +} + + + +void CMemoryWindow::JumpToAddress(u32 _Address) +{ + memview->Center(_Address); +} + + +void CMemoryWindow::OnAddrBoxChange(wxCommandEvent& event) +{ + wxString txt = addrbox->GetValue(); + if (txt.size() == 8) + { + u32 addr; + sscanf(txt.mb_str(), "%08x", &addr); + memview->Center(addr); + } + + event.Skip(1); +} + +void CMemoryWindow::Update() +{ + memview->Refresh(); + memview->Center(PC); +} + +void CMemoryWindow::NotifyMapLoaded() +{ + symbols->Show(false); // hide it for faster filling + symbols->Clear(); +#ifdef _WIN32 + const Debugger::XVectorSymbol& syms = Debugger::AccessSymbols(); + + for (int i = 0; i < (int)syms.size(); i++) + { + int idx = symbols->Append(syms[i].GetName().c_str()); + symbols->SetClientData(idx, (void*)&syms[i]); + } + + // +#endif + + symbols->Show(true); + Update(); +} + +void CMemoryWindow::OnSymbolListChange(wxCommandEvent& event) +{ + int index = symbols->GetSelection(); + Debugger::CSymbol* pSymbol = static_cast(symbols->GetClientData(index)); + + if (pSymbol != NULL) + { + memview->Center(pSymbol->vaddress); + } +} + +void CMemoryWindow::OnHostMessage(wxCommandEvent& event) +{ + switch (event.GetId()) + { + case IDM_NOTIFYMAPLOADED: + NotifyMapLoaded(); + break; + } +} + + diff --git a/Source/Core/DebuggerWX/src/MemoryWindow.h b/Source/Core/DebuggerWX/src/MemoryWindow.h new file mode 100644 index 0000000000..fffb55201d --- /dev/null +++ b/Source/Core/DebuggerWX/src/MemoryWindow.h @@ -0,0 +1,68 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// 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, version 2.0. + +// 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 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef MEMORYWINDOW_H_ +#define MEMORYWINDOW_H_ + +#include "wx/dialog.h" +#include "wx/textctrl.h" +#include "wx/listbox.h" +#include "Debugger.h" +#include "MemoryView.h" +#include "Thread.h" + +#include "CoreParameter.h" + +class CRegisterWindow; +class CLogWindow; +class CBreakPointWindow; + +class CMemoryWindow + : public wxFrame +{ + public: + + CMemoryWindow(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxString& title = _T("Dolphin-Memory"), + const wxPoint& pos = wxPoint(950, 100), + const wxSize& size = wxSize(400, 500), + long style = wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN | wxNO_FULL_REPAINT_ON_RESIZE); + + ~CMemoryWindow(); + + void Update(); + void NotifyMapLoaded(); + + void JumpToAddress(u32 _Address); + + private: + CMemoryView* memview; + wxListBox* symbols; + + wxButton* buttonGo; + wxTextCtrl* addrbox; + + DECLARE_EVENT_TABLE() + + void OnSymbolListChange(wxCommandEvent& event); + void OnCallstackListChange(wxCommandEvent& event); + void OnAddrBoxChange(wxCommandEvent& event); + void OnHostMessage(wxCommandEvent& event); +}; + +#endif /*MEMORYWINDOW_*/ diff --git a/Source/Core/DebuggerWX/src/RegisterWindow.h b/Source/Core/DebuggerWX/src/RegisterWindow.h index 426d19dda5..3c6bd4cabe 100644 --- a/Source/Core/DebuggerWX/src/RegisterWindow.h +++ b/Source/Core/DebuggerWX/src/RegisterWindow.h @@ -26,7 +26,7 @@ class CRegisterView; class CRegisterWindow : public wxDialog { - private: + private: DECLARE_EVENT_TABLE(); diff --git a/Source/Core/DolphinWX/src/Config.cpp b/Source/Core/DolphinWX/src/Config.cpp index 382f5ba816..4d1bc4e739 100644 --- a/Source/Core/DolphinWX/src/Config.cpp +++ b/Source/Core/DolphinWX/src/Config.cpp @@ -84,8 +84,8 @@ void SConfig::LoadSettings() // hard coded default plugin { ini.Get("Default", "GFXPlugin", &m_DefaultGFXPlugin); - ini.Get("Default", "DSPPlugin", &m_DefaultDSPPlugin); - ini.Get("Default", "PadPlugin", &m_DefaultPADPlugin); + ini.Get("Default", "DSPPlugin", &m_DefaultDSPPlugin); + ini.Get("Default", "PadPlugin", &m_DefaultPADPlugin); } // misc @@ -114,7 +114,8 @@ void SConfig::LoadSettings() ini.Get("Core", "DSPPlugin", &m_LocalCoreStartupParameter.m_strDSPPlugin, m_DefaultDSPPlugin.c_str()); ini.Get("Core", "PadPlugin", &m_LocalCoreStartupParameter.m_strPadPlugin, m_DefaultPADPlugin.c_str()); - ini.Get("Core", "UseDynarec", &m_LocalCoreStartupParameter.bUseDynarec, false); + ini.Get("Core", "HLEBios", &m_LocalCoreStartupParameter.bHLEBios, true); + ini.Get("Core", "UseDynarec", &m_LocalCoreStartupParameter.bUseDynarec, true); ini.Get("Core", "UseDualCore", &m_LocalCoreStartupParameter.bUseDualCore, false); ini.Get("Core", "Throttle", &m_LocalCoreStartupParameter.bThrottle, true); ini.Get("Core", "LockThreads", &m_LocalCoreStartupParameter.bLockThreads, true); diff --git a/Source/Plugins/Plugin_PadDX9/Src/DIHandler.cpp b/Source/Plugins/Plugin_PadDX9/Src/DIHandler.cpp index 79e4281f05..ef734ed38a 100644 --- a/Source/Plugins/Plugin_PadDX9/Src/DIHandler.cpp +++ b/Source/Plugins/Plugin_PadDX9/Src/DIHandler.cpp @@ -251,11 +251,9 @@ CDIHandler::ChangeNumPlayers( DWORD dwNumPlayers, BOOL bResetOwnership, BOOL bRe MessageBox( m_hWnd, sz, _T("Too Many Users"), MB_OK | MB_ICONEXCLAMATION ); break; } - default: - MessageBox(NULL, "ChangeNumPlayers", "Pad", MB_OK); + MessageBox(NULL, "Error creating DirectInput device.", "Pad DX9", MB_OK); return S_FALSE; - break; } m_pInputDeviceManager->Cleanup(); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Globals.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Globals.cpp index 8ff072fe81..ba67ac22f8 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Globals.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Globals.cpp @@ -10,7 +10,7 @@ Config::Config() void Config::Load() { IniFile iniFile; - iniFile.Load("flipper.ini"); + iniFile.Load("gfx_dx9.ini"); iniFile.Get("Hardware", "Adapter", &iAdapter, 0); iniFile.Get("Hardware", "WindowedRes", &iWindowedRes, 0); iniFile.Get("Hardware", "FullscreenRes", &iFSResolution, 0); @@ -35,7 +35,7 @@ void Config::Load() void Config::Save() { IniFile iniFile; - iniFile.Load("flipper.ini"); + iniFile.Load("gfx_dx9.ini"); iniFile.Set("Hardware", "Adapter", iAdapter); iniFile.Set("Hardware", "WindowedRes", iWindowedRes); iniFile.Set("Hardware", "FullscreenRes", iFSResolution); @@ -54,7 +54,7 @@ void Config::Save() iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering); iniFile.Set("Enhancements", "ForceMaxAniso", bForceMaxAniso); - iniFile.Save("flipper.ini"); + iniFile.Save("gfx_dx9.ini"); } Statistics stats; \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp index f76bc96694..41cd0f83cd 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp @@ -51,7 +51,7 @@ Config::Config() void Config::Load() { IniFile iniFile; - iniFile.Load("flipper.ini"); + iniFile.Load("gfx_opengl.ini"); iniFile.Get("Hardware", "Adapter", &iAdapter, 0); iniFile.Get("Hardware", "WindowedRes", &iWindowedRes, 0); iniFile.Get("Hardware", "FullscreenRes", &iFSResolution, 0); @@ -82,7 +82,7 @@ void Config::Load() void Config::Save() { IniFile iniFile; - iniFile.Load("flipper.ini"); + iniFile.Load("gfx_opengl.ini"); iniFile.Set("Hardware", "Adapter", iAdapter); iniFile.Set("Hardware", "WindowedRes", iWindowedRes); iniFile.Set("Hardware", "FullscreenRes", iFSResolution); @@ -99,7 +99,7 @@ void Config::Save() iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering); iniFile.Set("Enhancements", "ForceMaxAniso", bForceMaxAniso); - iniFile.Save("flipper.ini"); + iniFile.Save("gfx_opengl.ini"); } #ifdef _M_IX86 diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Windows/resource.rc b/Source/Plugins/Plugin_VideoOGL/Src/Windows/resource.rc index 0080df9f69..5214410b29 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Windows/resource.rc +++ b/Source/Plugins/Plugin_VideoOGL/Src/Windows/resource.rc @@ -82,7 +82,7 @@ BEGIN LTEXT "&Antialias mode:",IDC_STATIC,7,77,61,8 COMBOBOX IDC_ANTIALIASMODE,68,74,156,73,CBS_DROPDOWNLIST | WS_DISABLED | WS_VSCROLL | WS_TABSTOP LTEXT "&Windowed resolution:",IDC_STATIC,7,58,74,8 - COMBOBOX IDC_RESOLUTIONWINDOWED,87,56,137,73,CBS_DROPDOWNLIST | WS_DISABLED | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_RESOLUTIONWINDOWED,87,56,137,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "&Fullscreen",IDC_FULLSCREENENABLE,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,87,7,84,8 COMBOBOX IDC_RESOLUTION,87,37,137,73,CBS_DROPDOWNLIST | WS_DISABLED | WS_VSCROLL | WS_TABSTOP CONTROL "&Render to main window",IDC_RENDER_TO_MAINWINDOW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,87,20,103,8