Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/Windows/Debugger/CtrlMemView.h
3185 views
1
#pragma once
2
3
//////////////////////////////////////////////////////////////////////////
4
// CtrlMemView
5
//////////////////////////////////////////////////////////////////////////
6
//To add to a dialog box, just draw a User Control in the dialog editor,
7
//and set classname to "CtrlMemView". you also need to call CtrlMemView::init()
8
//before opening this dialog, to register the window class.
9
//
10
//To get a class instance to be able to access it, just use getFrom(HWND wnd).
11
12
#include <cstdint>
13
#include <vector>
14
#include "Core/Debugger/DebugInterface.h"
15
#include "Core/Debugger/MemBlockInfo.h"
16
#include "Core/MIPS/MIPSDebugInterface.h"
17
18
enum OffsetSpacing {
19
offsetSpace = 3, // the number of blank lines that should be left to make space for the offsets
20
offsetLine = 1, // the line on which the offsets should be written
21
};
22
23
enum CommonToggles {
24
On,
25
Off,
26
};
27
28
class CtrlMemView
29
{
30
public:
31
CtrlMemView(HWND _wnd);
32
~CtrlMemView();
33
static void init();
34
static void deinit();
35
static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
36
static CtrlMemView *getFrom(HWND wnd);
37
38
void setDebugger(MIPSDebugInterface *deb) {
39
debugger_ = deb;
40
}
41
MIPSDebugInterface *getDebugger() {
42
return debugger_;
43
}
44
std::vector<u32> searchString(const std::string &searchQuery);
45
void onPaint(WPARAM wParam, LPARAM lParam);
46
void onVScroll(WPARAM wParam, LPARAM lParam);
47
void onKeyDown(WPARAM wParam, LPARAM lParam);
48
void onChar(WPARAM wParam, LPARAM lParam);
49
void onMouseDown(WPARAM wParam, LPARAM lParam, int button);
50
void onMouseUp(WPARAM wParam, LPARAM lParam, int button);
51
void onMouseMove(WPARAM wParam, LPARAM lParam, int button);
52
void redraw();
53
void gotoAddr(unsigned int addr);
54
55
void drawOffsetScale(HDC hdc);
56
void toggleOffsetScale(CommonToggles toggle);
57
void setHighlightType(MemBlockFlags flags);
58
59
private:
60
bool ParseSearchString(const std::string &query, bool asHex, std::vector<uint8_t> &data);
61
void updateStatusBarText();
62
void search(bool continueSearch);
63
uint32_t pickTagColor(const std::string &tag);
64
65
enum class GotoMode {
66
RESET,
67
RESET_IF_OUTSIDE,
68
FROM_CUR,
69
EXTEND,
70
};
71
static GotoMode GotoModeFromModifiers(bool isRightClick);
72
void UpdateSelectRange(uint32_t target, GotoMode mode);
73
void GotoPoint(int x, int y, GotoMode mode);
74
void ScrollWindow(int lines, GotoMode mdoe);
75
void ScrollCursor(int bytes, GotoMode mdoe);
76
77
static wchar_t szClassName[];
78
MIPSDebugInterface *debugger_ = nullptr;
79
80
HWND wnd;
81
HFONT font;
82
HFONT underlineFont;
83
84
bool redrawScheduled_ = false;
85
// Whether to draw things using focused styles.
86
bool hasFocus_ = false;
87
MemBlockFlags highlightFlags_ = MemBlockFlags::ALLOC;
88
89
// Current cursor position.
90
uint32_t curAddress_ = 0;
91
// Selected range, which should always be around the cursor.
92
uint32_t selectRangeStart_ = 0;
93
uint32_t selectRangeEnd_ = 0;
94
// Last select reset position, for selecting ranges.
95
uint32_t lastSelectReset_ = 0;
96
// Address of the first displayed byte.
97
uint32_t windowStart_ = 0;
98
// Number of bytes displayed per row.
99
int rowSize_ = 16;
100
101
// Width of one monospace character (to maintain grid.)
102
int charWidth_ = 0;
103
// Height of one row of bytes.
104
int rowHeight_ = 0;
105
// Y position of offset header (at top.)
106
int offsetPositionY_;
107
// X position of addresses (at left.)
108
int addressStartX_ = 0;
109
// X position of hex display.
110
int hexStartX_ = 0;
111
// X position of text display.
112
int asciiStartX_ = 0;
113
// Whether cursor is within text display or hex display.
114
bool asciiSelected_ = false;
115
// Which nibble is selected, if in hex display. 0 means leftmost, i.e. most significant.
116
int selectedNibble_ = 0;
117
118
bool displayOffsetScale_ = false;
119
120
// Number of rows visible as of last redraw.
121
int visibleRows_ = 0;
122
// Position and size as of last redraw.
123
RECT rect_;
124
125
// Last used search query, used when continuing a search.
126
std::string searchQuery_;
127
// Address of last match when continuing search.
128
uint32_t matchAddress_ = 0xFFFFFFFF;
129
// Whether a search is in progress.
130
bool searching_ = false;
131
};
132
133