Skip to content

Commit

Permalink
Merge pull request dolphin-emu#4310 from lioncash/dsptable
Browse files Browse the repository at this point in the history
DSPRegisterView: Minor changes
  • Loading branch information
degasus authored Oct 8, 2016
2 parents 4ba1100 + 2ba0d6e commit 1a2d71c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Source/Core/Core/DSP/DSPCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void CompileCurrent()
}
}

u16 DSPCore_ReadRegister(int reg)
u16 DSPCore_ReadRegister(size_t reg)
{
switch (reg)
{
Expand Down Expand Up @@ -388,7 +388,7 @@ u16 DSPCore_ReadRegister(int reg)
}
}

void DSPCore_WriteRegister(int reg, u16 val)
void DSPCore_WriteRegister(size_t reg, u16 val)
{
switch (reg)
{
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/Core/DSP/DSPCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <array>
#include <atomic>
#include <cstddef>
#include <memory>
#include <string>

Expand Down Expand Up @@ -358,5 +359,5 @@ DSPCoreState DSPCore_GetState();

void DSPCore_Step();

u16 DSPCore_ReadRegister(int reg);
void DSPCore_WriteRegister(int reg, u16 val);
u16 DSPCore_ReadRegister(size_t reg);
void DSPCore_WriteRegister(size_t reg, u16 val);
10 changes: 6 additions & 4 deletions Source/Core/DolphinWX/Debugger/DSPRegisterView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

wxString CDSPRegTable::GetValue(int row, int col)
{
if (row < 32) // 32 "normal" regs
if (row < GetNumberRows())
{
switch (col)
{
Expand Down Expand Up @@ -41,10 +41,12 @@ void CDSPRegTable::UpdateCachedRegs()

m_CachedCounter = g_dsp.step_counter;

for (int i = 0; i < 32; ++i)
for (size_t i = 0; i < m_CachedRegs.size(); ++i)
{
m_CachedRegHasChanged[i] = (m_CachedRegs[i] != DSPCore_ReadRegister(i));
m_CachedRegs[i] = DSPCore_ReadRegister(i);
const u16 value = DSPCore_ReadRegister(i);

m_CachedRegHasChanged[i] = m_CachedRegs[i] != value;
m_CachedRegs[i] = value;
}
}

Expand Down
28 changes: 12 additions & 16 deletions Source/Core/DolphinWX/Debugger/DSPRegisterView.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,15 @@

#pragma once

#include <cstring>
#include <array>
#include <wx/grid.h>

#include "Common/CommonTypes.h"

class CDSPRegTable : public wxGridTableBase
class CDSPRegTable final : public wxGridTableBase
{
private:
u64 m_CachedCounter;
u16 m_CachedRegs[32];
bool m_CachedRegHasChanged[32];

DECLARE_NO_COPY_CLASS(CDSPRegTable);

public:
CDSPRegTable()
{
memset(m_CachedRegs, 0, sizeof(m_CachedRegs));
memset(m_CachedRegHasChanged, 0, sizeof(m_CachedRegHasChanged));
}
CDSPRegTable() = default;

int GetNumberCols() override { return 2; }
int GetNumberRows() override { return 32; }
Expand All @@ -32,12 +21,19 @@ class CDSPRegTable : public wxGridTableBase
void SetValue(int row, int col, const wxString&) override;
wxGridCellAttr* GetAttr(int, int, wxGridCellAttr::wxAttrKind) override;
void UpdateCachedRegs();

private:
u64 m_CachedCounter = 0;
std::array<u16, 32> m_CachedRegs{};
std::array<bool, 32> m_CachedRegHasChanged{};

DECLARE_NO_COPY_CLASS(CDSPRegTable);
};

class DSPRegisterView : public wxGrid
class DSPRegisterView final : public wxGrid
{
public:
DSPRegisterView(wxWindow* parent, wxWindowID id = wxID_ANY);
explicit DSPRegisterView(wxWindow* parent, wxWindowID id = wxID_ANY);
void Repopulate();

private:
Expand Down

0 comments on commit 1a2d71c

Please sign in to comment.