Skip to content

Commit

Permalink
Merge pull request #2729 from lioncash/magic
Browse files Browse the repository at this point in the history
DolphinWX: Get rid of some magic numbers in MemoryView and MemoryWindow
  • Loading branch information
Tilka committed Jul 9, 2015
2 parents 7d41b8a + 81878d7 commit 95fed00
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
9 changes: 5 additions & 4 deletions Source/Core/DolphinWX/Debugger/MemoryView.cpp
Expand Up @@ -43,14 +43,15 @@ enum

CMemoryView::CMemoryView(DebugInterface* debuginterface, wxWindow* parent)
: wxControl(parent, wxID_ANY)
, curAddress(debuginterface->GetPC())
, debugger(debuginterface)
, align(debuginterface->GetInstructionSize(0))
, rowHeight(13)
, selection(0)
, oldSelection(0)
, selecting(false)
, memory(0)
, curAddress(debuginterface->GetPC())
, dataType(MemoryDataType::U8)
, viewAsType(VIEWAS_FP)
{
Bind(wxEVT_PAINT, &CMemoryView::OnPaint, this);
Expand Down Expand Up @@ -364,21 +365,21 @@ void CMemoryView::OnPaint(wxPaintEvent& event)
{
switch (dataType)
{
case 0:
case MemoryDataType::U8:
dis += StringFromFormat(" %02X %02X %02X %02X",
((word & 0xff000000) >> 24) & 0xFF,
((word & 0xff0000) >> 16) & 0xFF,
((word & 0xff00) >> 8) & 0xFF,
word & 0xff);
break;
case 1:
case MemoryDataType::U16:
dis += StringFromFormat(" %02X%02X %02X%02X",
((word & 0xff000000) >> 24) & 0xFF,
((word & 0xff0000) >> 16) & 0xFF,
((word & 0xff00) >> 8) & 0xFF,
word & 0xff);
break;
case 2:
case MemoryDataType::U32:
dis += StringFromFormat(" %02X%02X%02X%02X",
((word & 0xff000000) >> 24) & 0xFF,
((word & 0xff0000) >> 16) & 0xFF,
Expand Down
15 changes: 13 additions & 2 deletions Source/Core/DolphinWX/Debugger/MemoryView.h
Expand Up @@ -9,6 +9,11 @@

class DebugInterface;

enum class MemoryDataType
{
U8, U16, U32
};

class CMemoryView : public wxControl
{
public:
Expand All @@ -22,8 +27,12 @@ class CMemoryView : public wxControl
curAddress = addr;
Refresh();
}
int dataType; // u8,u16,u32
int curAddress; // Will be accessed by parent

void SetDataType(MemoryDataType data_type)
{
dataType = data_type;
Refresh();
}

private:
void OnPaint(wxPaintEvent& event);
Expand All @@ -47,6 +56,8 @@ class CMemoryView : public wxControl
bool selecting;

int memory;
int curAddress;
MemoryDataType dataType;

enum EViewAsType
{
Expand Down
11 changes: 4 additions & 7 deletions Source/Core/DolphinWX/Debugger/MemoryWindow.cpp
Expand Up @@ -79,7 +79,7 @@ CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id,
// wxSize(20, 100), 0, nullptr, wxLB_SORT);
//sizerLeft->Add(symbols, 1, wxEXPAND);
memview = new CMemoryView(di, this);
memview->dataType = 0;

//sizerBig->Add(sizerLeft, 1, wxEXPAND);
sizerBig->Add(memview, 20, wxEXPAND);
sizerBig->Add(sizerRight, 0, wxEXPAND | wxALL, 3);
Expand Down Expand Up @@ -281,24 +281,21 @@ void CMemoryWindow::U8(wxCommandEvent& event)
{
chk16->SetValue(0);
chk32->SetValue(0);
memview->dataType = 0;
memview->Refresh();
memview->SetDataType(MemoryDataType::U8);
}

void CMemoryWindow::U16(wxCommandEvent& event)
{
chk8->SetValue(0);
chk32->SetValue(0);
memview->dataType = 1;
memview->Refresh();
memview->SetDataType(MemoryDataType::U16);
}

void CMemoryWindow::U32(wxCommandEvent& event)
{
chk16->SetValue(0);
chk8->SetValue(0);
memview->dataType = 2;
memview->Refresh();
memview->SetDataType(MemoryDataType::U32);
}

void CMemoryWindow::onSearch(wxCommandEvent& event)
Expand Down

0 comments on commit 95fed00

Please sign in to comment.