CodeView: Assemble menu item added

This commit is contained in:
Sepalani 2017-05-04 00:08:24 +01:00
parent 5d6074f157
commit 9b2cc62393
6 changed files with 158 additions and 0 deletions

View File

@ -21,6 +21,7 @@ set(SRCS
Config/InterfaceConfigPane.cpp Config/InterfaceConfigPane.cpp
Config/PathConfigPane.cpp Config/PathConfigPane.cpp
Config/WiiConfigPane.cpp Config/WiiConfigPane.cpp
Debugger/AssemblerEntryDialog.cpp
Debugger/BreakpointDlg.cpp Debugger/BreakpointDlg.cpp
Debugger/BreakpointView.cpp Debugger/BreakpointView.cpp
Debugger/BreakpointWindow.cpp Debugger/BreakpointWindow.cpp

View File

@ -0,0 +1,90 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinWX/Debugger/AssemblerEntryDialog.h"
#include <string>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/utils.h>
#include "Common/GekkoDisassembler.h"
#include "Common/StringUtil.h"
AssemblerEntryDialog::AssemblerEntryDialog(u32 address, wxWindow* parent, const wxString& message,
const wxString& caption, const wxString& value,
long style, const wxPoint& pos)
: m_address(address)
{
Create(parent, message, caption, value, style, pos);
}
bool AssemblerEntryDialog::Create(wxWindow* parent, const wxString& message,
const wxString& caption, const wxString& value, long style,
const wxPoint& pos)
{
// Do not pass style to GetParentForModalDialog() as wxDIALOG_NO_PARENT
// has the same numeric value as wxTE_MULTILINE and so attempting to create
// a dialog for editing multiline text would also prevent it from having a
// parent which is undesirable. As it is, we can't create a text entry
// dialog without a parent which is not ideal neither but is a much less
// important problem.
if (!wxDialog::Create(GetParentForModalDialog(parent, 0), wxID_ANY, caption, pos, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER))
{
return false;
}
m_dialogStyle = style;
m_value = value;
wxBeginBusyCursor();
wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL);
// 1) text message
top_sizer->Add(CreateTextSizer(message), wxSizerFlags().DoubleBorder());
// 2) text ctrl
m_textctrl = new wxTextCtrl(this, 3000, value, wxDefaultPosition, wxSize(300, wxDefaultCoord),
style & ~wxTextEntryDialogStyle);
m_textctrl->Bind(wxEVT_TEXT, &AssemblerEntryDialog::OnTextChanged, this);
top_sizer->Add(
m_textctrl,
wxSizerFlags(style & wxTE_MULTILINE ? 1 : 0).Expand().TripleBorder(wxLEFT | wxRIGHT));
m_preview = new wxStaticText(this, wxID_ANY, "");
top_sizer->Add(m_preview, wxSizerFlags().DoubleBorder(wxUP | wxLEFT | wxRIGHT));
wxSizer* button_sizer = CreateSeparatedButtonSizer(style & (wxOK | wxCANCEL));
if (button_sizer)
top_sizer->Add(button_sizer, wxSizerFlags().DoubleBorder().Expand());
SetAutoLayout(true);
SetSizer(top_sizer);
top_sizer->SetSizeHints(this);
top_sizer->Fit(this);
if (style & wxCENTRE)
Centre(wxBOTH);
m_textctrl->SelectAll();
m_textctrl->SetFocus();
wxEndBusyCursor();
return true;
}
void AssemblerEntryDialog::OnTextChanged(wxCommandEvent& evt)
{
unsigned long code;
std::string result = "Input text is invalid";
if (evt.GetString().ToULong(&code, 0) && code <= std::numeric_limits<u32>::max())
result = TabsToSpaces(1, GekkoDisassembler::Disassemble(code, m_address));
m_preview->SetLabel(wxString::Format(_("Preview: %s"), result.c_str()));
}

View File

@ -0,0 +1,32 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <wx/textdlg.h>
#include "Common/CommonTypes.h"
class wxStaticText;
class AssemblerEntryDialog : public wxTextEntryDialog
{
public:
AssemblerEntryDialog(u32 address, wxWindow* parent, const wxString& message,
const wxString& caption = wxGetTextFromUserPromptStr,
const wxString& value = wxEmptyString, long style = wxTextEntryDialogStyle,
const wxPoint& pos = wxDefaultPosition);
bool Create(wxWindow* parent, const wxString& message,
const wxString& caption = wxGetTextFromUserPromptStr,
const wxString& value = wxEmptyString, long style = wxTextEntryDialogStyle,
const wxPoint& pos = wxDefaultPosition);
protected:
u32 m_address;
wxStaticText* m_preview;
private:
void OnTextChanged(wxCommandEvent& evt);
};

View File

@ -9,6 +9,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
#include <wx/brush.h> #include <wx/brush.h>
#include <wx/clipbrd.h> #include <wx/clipbrd.h>
#include <wx/colour.h> #include <wx/colour.h>
@ -26,6 +27,8 @@
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/Host.h" #include "Core/Host.h"
#include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/PPCAnalyst.h"
#include "Core/PowerPC/PowerPC.h"
#include "DolphinWX/Debugger/AssemblerEntryDialog.h"
#include "DolphinWX/Debugger/CodeView.h" #include "DolphinWX/Debugger/CodeView.h"
#include "DolphinWX/Debugger/DebuggerUIUtil.h" #include "DolphinWX/Debugger/DebuggerUIUtil.h"
#include "DolphinWX/Globals.h" #include "DolphinWX/Globals.h"
@ -41,6 +44,7 @@ enum
IDM_COPYCODE, IDM_COPYCODE,
IDM_INSERTBLR, IDM_INSERTBLR,
IDM_INSERTNOP, IDM_INSERTNOP,
IDM_ASSEMBLE,
IDM_RUNTOHERE, IDM_RUNTOHERE,
IDM_JITRESULTS, IDM_JITRESULTS,
IDM_FOLLOWBRANCH, IDM_FOLLOWBRANCH,
@ -301,6 +305,28 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
Refresh(); Refresh();
break; break;
case IDM_ASSEMBLE:
{
if (!PowerPC::HostIsInstructionRAMAddress(m_selection))
break;
const PowerPC::TryReadInstResult read_result = PowerPC::TryReadInstruction(m_selection);
if (!read_result.valid)
break;
AssemblerEntryDialog dialog(m_selection, this, _("Enter instruction code:"),
wxGetTextFromUserPromptStr,
wxString::Format(wxT("%#08x"), read_result.hex));
if (dialog.ShowModal() == wxID_OK)
{
unsigned long code;
if (dialog.GetValue().ToULong(&code, 0) && code <= std::numeric_limits<u32>::max())
{
m_debugger->InsertBLR(m_selection, code);
Refresh();
}
}
break;
}
case IDM_JITRESULTS: case IDM_JITRESULTS:
{ {
// Propagate back to the parent window and tell it // Propagate back to the parent window and tell it
@ -424,6 +450,7 @@ void CCodeView::OnMouseUpR(wxMouseEvent& event)
menu.Append(IDM_JITRESULTS, _("PPC vs x86"))->Enable(Core::IsRunning()); menu.Append(IDM_JITRESULTS, _("PPC vs x86"))->Enable(Core::IsRunning());
menu.Append(IDM_INSERTBLR, _("&Insert blr"))->Enable(Core::IsRunning()); menu.Append(IDM_INSERTBLR, _("&Insert blr"))->Enable(Core::IsRunning());
menu.Append(IDM_INSERTNOP, _("Insert &nop"))->Enable(Core::IsRunning()); menu.Append(IDM_INSERTNOP, _("Insert &nop"))->Enable(Core::IsRunning());
menu.Append(IDM_ASSEMBLE, _("Re&place Instruction"))->Enable(Core::IsRunning());
// menu.Append(IDM_PATCHALERT, _("Patch alert"))->Enable(Core::IsRunning()); // menu.Append(IDM_PATCHALERT, _("Patch alert"))->Enable(Core::IsRunning());
PopupMenu(&menu); PopupMenu(&menu);
event.Skip(); event.Skip();

View File

@ -71,6 +71,7 @@
<ClCompile Include="Config\InterfaceConfigPane.cpp" /> <ClCompile Include="Config\InterfaceConfigPane.cpp" />
<ClCompile Include="Config\PathConfigPane.cpp" /> <ClCompile Include="Config\PathConfigPane.cpp" />
<ClCompile Include="Config\WiiConfigPane.cpp" /> <ClCompile Include="Config\WiiConfigPane.cpp" />
<ClCompile Include="Debugger\AssemblerEntryDialog.cpp" />
<ClCompile Include="Debugger\BreakpointDlg.cpp" /> <ClCompile Include="Debugger\BreakpointDlg.cpp" />
<ClCompile Include="Debugger\BreakpointView.cpp" /> <ClCompile Include="Debugger\BreakpointView.cpp" />
<ClCompile Include="Debugger\BreakpointWindow.cpp" /> <ClCompile Include="Debugger\BreakpointWindow.cpp" />
@ -163,6 +164,7 @@
<ClInclude Include="Cheats\CreateCodeDialog.h" /> <ClInclude Include="Cheats\CreateCodeDialog.h" />
<ClInclude Include="Cheats\GeckoCodeDiag.h" /> <ClInclude Include="Cheats\GeckoCodeDiag.h" />
<ClInclude Include="Config\ConfigMain.h" /> <ClInclude Include="Config\ConfigMain.h" />
<ClInclude Include="Debugger\AssemblerEntryDialog.h" />
<ClInclude Include="Debugger\BreakpointDlg.h" /> <ClInclude Include="Debugger\BreakpointDlg.h" />
<ClInclude Include="Debugger\BreakpointView.h" /> <ClInclude Include="Debugger\BreakpointView.h" />
<ClInclude Include="Debugger\BreakpointWindow.h" /> <ClInclude Include="Debugger\BreakpointWindow.h" />

View File

@ -52,6 +52,9 @@
<ClCompile Include="Cheats\GeckoCodeDiag.cpp"> <ClCompile Include="Cheats\GeckoCodeDiag.cpp">
<Filter>GUI\Cheats</Filter> <Filter>GUI\Cheats</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Debugger\AssemblerEntryDialog.cpp">
<Filter>GUI\Debugger</Filter>
</ClCompile>
<ClCompile Include="Debugger\BreakpointDlg.cpp"> <ClCompile Include="Debugger\BreakpointDlg.cpp">
<Filter>GUI\Debugger</Filter> <Filter>GUI\Debugger</Filter>
</ClCompile> </ClCompile>
@ -279,6 +282,9 @@
<ClInclude Include="Cheats\GeckoCodeDiag.h"> <ClInclude Include="Cheats\GeckoCodeDiag.h">
<Filter>GUI\Cheats</Filter> <Filter>GUI\Cheats</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Debugger\AssemblerEntryDialog.h">
<Filter>GUI\Debugger</Filter>
</ClInclude>
<ClInclude Include="Debugger\BreakpointDlg.h"> <ClInclude Include="Debugger\BreakpointDlg.h">
<Filter>GUI\Debugger</Filter> <Filter>GUI\Debugger</Filter>
</ClInclude> </ClInclude>