2024-07-30 11:42:36 +00:00
|
|
|
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
|
|
|
|
// SPDX-License-Identifier: GPL-3.0+
|
2022-12-24 06:51:44 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ui_RegisterWidget.h"
|
|
|
|
|
|
|
|
#include "DebugTools/DebugInterface.h"
|
|
|
|
#include "DebugTools/DisassemblyManager.h"
|
|
|
|
|
|
|
|
#include <QtWidgets/QWidget>
|
|
|
|
#include <QtWidgets/QMenu>
|
|
|
|
#include <QtWidgets/QTabBar>
|
|
|
|
#include <QtGui/QPainter>
|
2024-07-15 15:29:31 +00:00
|
|
|
#include <QtCore/QtEndian>
|
2022-12-24 06:51:44 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
enum class MemoryViewType
|
|
|
|
{
|
|
|
|
BYTE = 1,
|
|
|
|
BYTEHW = 2,
|
|
|
|
WORD = 4,
|
|
|
|
DWORD = 8,
|
|
|
|
};
|
|
|
|
|
|
|
|
class MemoryViewTable
|
|
|
|
{
|
|
|
|
QWidget* parent;
|
|
|
|
DebugInterface* m_cpu;
|
|
|
|
MemoryViewType displayType = MemoryViewType::BYTE;
|
2024-07-15 15:29:31 +00:00
|
|
|
bool littleEndian = true;
|
2022-12-24 06:51:44 +00:00
|
|
|
u32 rowCount;
|
|
|
|
u32 rowVisible;
|
|
|
|
s32 rowHeight;
|
|
|
|
|
|
|
|
// Stuff used for selection handling
|
|
|
|
// This gets set every paint and depends on the window size / current display mode (1byte,2byte,etc)
|
2024-07-15 15:29:31 +00:00
|
|
|
s32 valuexAxis; // Where the hexadecimal view begins
|
|
|
|
s32 textXAxis; // Where the text view begins
|
|
|
|
s32 row1YAxis; // Where the first row starts
|
|
|
|
s32 segmentXAxis[16]; // Where the segments begin
|
2022-12-24 06:51:44 +00:00
|
|
|
bool selectedText = false; // Whether the user has clicked on text or hex
|
2024-07-15 15:29:31 +00:00
|
|
|
|
2022-12-24 06:51:44 +00:00
|
|
|
bool selectedNibbleHI = false;
|
|
|
|
|
|
|
|
void InsertIntoSelectedHexView(u8 value);
|
|
|
|
|
2024-07-15 15:29:31 +00:00
|
|
|
template <class T>
|
|
|
|
T convertEndian(T in)
|
|
|
|
{
|
|
|
|
if (littleEndian)
|
|
|
|
{
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return qToBigEndian(in);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 nextAddress(u32 addr);
|
|
|
|
u32 prevAddress(u32 addr);
|
|
|
|
|
2022-12-24 06:51:44 +00:00
|
|
|
public:
|
|
|
|
MemoryViewTable(QWidget* parent)
|
|
|
|
: parent(parent){};
|
|
|
|
u32 startAddress;
|
|
|
|
u32 selectedAddress;
|
|
|
|
|
|
|
|
void SetCpu(DebugInterface* cpu)
|
|
|
|
{
|
|
|
|
m_cpu = cpu;
|
|
|
|
}
|
|
|
|
void UpdateStartAddress(u32 start);
|
|
|
|
void UpdateSelectedAddress(u32 selected, bool page = false);
|
|
|
|
void DrawTable(QPainter& painter, const QPalette& palette, s32 height);
|
|
|
|
void SelectAt(QPoint pos);
|
|
|
|
u128 GetSelectedSegment();
|
2023-06-03 01:45:52 +00:00
|
|
|
void InsertAtCurrentSelection(const QString& text);
|
2024-07-15 15:29:31 +00:00
|
|
|
void ForwardSelection();
|
|
|
|
void BackwardSelection();
|
2023-10-06 15:46:21 +00:00
|
|
|
// Returns true if the keypress was handled
|
|
|
|
bool KeyPress(int key, QChar keychar);
|
2022-12-24 06:51:44 +00:00
|
|
|
|
|
|
|
MemoryViewType GetViewType()
|
|
|
|
{
|
|
|
|
return displayType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetViewType(MemoryViewType viewType)
|
|
|
|
{
|
|
|
|
displayType = viewType;
|
|
|
|
}
|
2024-07-15 15:29:31 +00:00
|
|
|
|
|
|
|
bool GetLittleEndian()
|
|
|
|
{
|
|
|
|
return littleEndian;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetLittleEndian(bool le)
|
|
|
|
{
|
|
|
|
littleEndian = le;
|
|
|
|
}
|
2022-12-24 06:51:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class MemoryViewWidget final : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
MemoryViewWidget(QWidget* parent);
|
|
|
|
~MemoryViewWidget();
|
|
|
|
|
|
|
|
void SetCpu(DebugInterface* cpu);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent* event);
|
|
|
|
void mousePressEvent(QMouseEvent* event);
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent* event);
|
|
|
|
void wheelEvent(QWheelEvent* event);
|
|
|
|
void keyPressEvent(QKeyEvent* event);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void customMenuRequested(QPoint pos);
|
|
|
|
|
|
|
|
void contextGoToAddress();
|
|
|
|
void contextCopyByte();
|
|
|
|
void contextCopySegment();
|
|
|
|
void contextCopyCharacter();
|
2023-06-03 01:45:52 +00:00
|
|
|
void contextPaste();
|
2022-12-24 06:51:44 +00:00
|
|
|
void gotoAddress(u32 address);
|
|
|
|
|
|
|
|
signals:
|
2023-12-14 19:40:23 +00:00
|
|
|
void gotoInDisasm(u32 address, bool should_set_focus = true);
|
2023-12-31 02:05:16 +00:00
|
|
|
void addToSavedAddresses(u32 address);
|
2022-12-24 06:51:44 +00:00
|
|
|
void VMUpdate();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::RegisterWidget ui;
|
|
|
|
|
|
|
|
QMenu* m_contextMenu = 0x0;
|
2024-07-15 15:29:31 +00:00
|
|
|
QAction* m_actionLittleEndian;
|
2022-12-24 06:51:44 +00:00
|
|
|
QAction* m_actionBYTE;
|
|
|
|
QAction* m_actionBYTEHW;
|
|
|
|
QAction* m_actionWORD;
|
|
|
|
QAction* m_actionDWORD;
|
|
|
|
|
|
|
|
DebugInterface* m_cpu;
|
|
|
|
MemoryViewTable m_table;
|
|
|
|
};
|