mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Debugger: Reorganize memory view painting.
This also grabs tag info, but doesn't display it yet.
This commit is contained in:
parent
595a17e9bc
commit
d80655287b
2 changed files with 103 additions and 73 deletions
|
@ -173,8 +173,7 @@ CtrlMemView *CtrlMemView::getFrom(HWND hwnd)
|
|||
}
|
||||
|
||||
|
||||
void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) {
|
||||
auto memLock = Memory::Lock();
|
||||
|
||||
// draw to a bitmap for double buffering
|
||||
|
@ -187,6 +186,7 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam)
|
|||
SetBkMode(hdc,OPAQUE);
|
||||
HPEN standardPen = CreatePen(0,0,0xFFFFFF);
|
||||
HBRUSH standardBrush = CreateSolidBrush(0xFFFFFF);
|
||||
COLORREF standardBG = GetBkColor(hdc);
|
||||
|
||||
HPEN oldPen = (HPEN) SelectObject(hdc,standardPen);
|
||||
HBRUSH oldBrush = (HBRUSH) SelectObject(hdc,standardBrush);
|
||||
|
@ -199,88 +199,112 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam)
|
|||
|
||||
if (displayOffsetScale)
|
||||
drawOffsetScale(hdc);
|
||||
|
||||
|
||||
std::vector<MemBlockInfo> memRangeInfo = FindMemInfoByFlag(highlightFlags_, windowStart, (visibleRows + 1) * rowSize);
|
||||
|
||||
COLORREF lastTextCol = 0x000000;
|
||||
COLORREF lastBGCol = standardBG;
|
||||
auto setTextColors = [&](COLORREF fg, COLORREF bg) {
|
||||
if (lastTextCol != fg) {
|
||||
SetTextColor(hdc, fg);
|
||||
lastTextCol = fg;
|
||||
}
|
||||
if (lastBGCol != bg) {
|
||||
SetBkColor(hdc, bg);
|
||||
lastBGCol = bg;
|
||||
}
|
||||
};
|
||||
|
||||
// draw one extra row that may be partially visible
|
||||
for (int i = 0; i < visibleRows+1; i++)
|
||||
{
|
||||
char temp[32];
|
||||
|
||||
unsigned int address=windowStart + i*rowSize;
|
||||
int rowY = rowHeight*i;
|
||||
|
||||
for (int i = 0; i < visibleRows + 1; i++) {
|
||||
int rowY = rowHeight * i;
|
||||
// Skip the first X rows to make space for the offsets.
|
||||
if (displayOffsetScale)
|
||||
rowY += rowHeight * offsetSpace; // skip the first X rows to make space for the offsets
|
||||
|
||||
|
||||
sprintf(temp,"%08X",address);
|
||||
SetTextColor(hdc,0x600000);
|
||||
TextOutA(hdc,addressStart,rowY,temp,(int)strlen(temp));
|
||||
rowY += rowHeight * offsetSpace;
|
||||
|
||||
SetTextColor(hdc,0x000000);
|
||||
char temp[32];
|
||||
uint32_t address = windowStart + i * rowSize;
|
||||
sprintf(temp, "%08X", address);
|
||||
|
||||
u32 memory[4];
|
||||
bool valid = debugger != NULL && debugger->isAlive() && Memory::IsValidAddress(address);
|
||||
if (valid)
|
||||
{
|
||||
memory[0] = debugger->readMemory(address);
|
||||
memory[1] = debugger->readMemory(address+4);
|
||||
memory[2] = debugger->readMemory(address+8);
|
||||
memory[3] = debugger->readMemory(address+12);
|
||||
setTextColors(0x600000, standardBG);
|
||||
TextOutA(hdc, addressStart, rowY, temp, (int)strlen(temp));
|
||||
|
||||
union {
|
||||
uint32_t words[4];
|
||||
uint8_t bytes[16];
|
||||
} memory;
|
||||
bool valid = debugger != nullptr && debugger->isAlive() && Memory::IsValidAddress(address);
|
||||
for (int i = 0; valid && i < 4; ++i) {
|
||||
memory.words[i] = debugger->readMemory(address + i * 4);
|
||||
}
|
||||
|
||||
u8* m = (u8*) memory;
|
||||
for (int j = 0; j < rowSize; j++)
|
||||
{
|
||||
if (valid) sprintf(temp,"%02X",m[j]);
|
||||
else strcpy(temp,"??");
|
||||
|
||||
unsigned char c = m[j];
|
||||
if (c < 32 || c >= 128 || valid == false) c = '.';
|
||||
|
||||
if (address+j == curAddress && searching == false)
|
||||
{
|
||||
COLORREF oldBkColor = GetBkColor(hdc);
|
||||
COLORREF oldTextColor = GetTextColor(hdc);
|
||||
|
||||
if (hasFocus && !asciiSelected)
|
||||
{
|
||||
SetTextColor(hdc,0xFFFFFF);
|
||||
SetBkColor(hdc,0xFF9933);
|
||||
if (selectedNibble == 0) SelectObject(hdc,(HGDIOBJ)underlineFont);
|
||||
} else {
|
||||
SetTextColor(hdc,0);
|
||||
SetBkColor(hdc,0xC0C0C0);
|
||||
}
|
||||
TextOutA(hdc,hexStart+j*3*charWidth,rowY,&temp[0],1);
|
||||
|
||||
if (hasFocus && !asciiSelected)
|
||||
{
|
||||
if (selectedNibble == 1) SelectObject(hdc,(HGDIOBJ)underlineFont);
|
||||
else SelectObject(hdc,(HGDIOBJ)font);
|
||||
}
|
||||
TextOutA(hdc,hexStart+j*3*charWidth+charWidth,rowY,&temp[1],1);
|
||||
|
||||
if (hasFocus && asciiSelected)
|
||||
{
|
||||
SetTextColor(hdc,0xFFFFFF);
|
||||
SetBkColor(hdc,0xFF9933);
|
||||
} else {
|
||||
SetTextColor(hdc,0);
|
||||
SetBkColor(hdc,0xC0C0C0);
|
||||
SelectObject(hdc,(HGDIOBJ)font);
|
||||
}
|
||||
TextOutA(hdc,asciiStart+j*(charWidth+2),rowY,(char*)&c,1);
|
||||
|
||||
SetTextColor(hdc,oldTextColor);
|
||||
SetBkColor(hdc,oldBkColor);
|
||||
} else {
|
||||
TextOutA(hdc,hexStart+j*3*charWidth,rowY,temp,2);
|
||||
TextOutA(hdc,asciiStart+j*(charWidth+2),rowY,(char*)&c,1);
|
||||
for (int j = 0; j < rowSize; j++) {
|
||||
uint32_t byteAddress = address + j;
|
||||
std::string tag;
|
||||
for (auto info : memRangeInfo) {
|
||||
if (info.start <= byteAddress && info.start + info.size > byteAddress)
|
||||
tag = info.tag;
|
||||
}
|
||||
|
||||
int hexX = hexStart + j * 3 * charWidth;
|
||||
int asciiX = asciiStart + j * (charWidth + 2);
|
||||
|
||||
char c;
|
||||
if (valid) {
|
||||
sprintf(temp, "%02X", memory.bytes[j]);
|
||||
c = (char)memory.bytes[j];
|
||||
if (memory.bytes[j] < 32 || memory.bytes[j] >= 128)
|
||||
c = '.';
|
||||
} else {
|
||||
strcpy(temp, "??");
|
||||
c = '.';
|
||||
}
|
||||
|
||||
COLORREF hexBGCol = standardBG;
|
||||
COLORREF hexTextCol = 0x000000;
|
||||
COLORREF asciiBGCol = standardBG;
|
||||
COLORREF asciiTextCol = 0x000000;
|
||||
int underline = -1;
|
||||
|
||||
if (byteAddress == curAddress && searching == false) {
|
||||
if (asciiSelected) {
|
||||
hexBGCol = 0xC0C0C0;
|
||||
hexTextCol = 0x000000;
|
||||
asciiBGCol = hasFocus ? 0xFF9933 : 0xC0C0C0;
|
||||
asciiTextCol = hasFocus ? 0xFFFFFF : 0x000000;
|
||||
} else {
|
||||
hexBGCol = hasFocus ? 0xFF9933 : 0xC0C0C0;
|
||||
hexTextCol = hasFocus ? 0xFFFFFF : 0x000000;
|
||||
asciiBGCol = 0xC0C0C0;
|
||||
asciiTextCol = 0x000000;
|
||||
underline = selectedNibble;
|
||||
}
|
||||
} else if (!tag.empty()) {
|
||||
hexBGCol = pickTagColor(tag);
|
||||
asciiBGCol = pickTagColor(tag);
|
||||
}
|
||||
|
||||
setTextColors(hexTextCol, hexBGCol);
|
||||
if (underline == 0) {
|
||||
SelectObject(hdc, (HGDIOBJ)underlineFont);
|
||||
TextOutA(hdc, hexX, rowY, &temp[0], 1);
|
||||
SelectObject(hdc, (HGDIOBJ)font);
|
||||
TextOutA(hdc, hexX + charWidth, rowY, &temp[1], 1);
|
||||
} else if (underline == 1) {
|
||||
TextOutA(hdc, hexX, rowY, &temp[0], 1);
|
||||
SelectObject(hdc, (HGDIOBJ)underlineFont);
|
||||
TextOutA(hdc, hexX + charWidth, rowY, &temp[1], 1);
|
||||
SelectObject(hdc, (HGDIOBJ)font);
|
||||
} else {
|
||||
TextOutA(hdc, hexX, rowY, temp, 2);
|
||||
}
|
||||
|
||||
setTextColors(asciiTextCol, asciiBGCol);
|
||||
TextOutA(hdc, asciiX, rowY, &c, 1);
|
||||
}
|
||||
}
|
||||
|
||||
setTextColors(0x000000, standardBG);
|
||||
SelectObject(hdc,oldFont);
|
||||
SelectObject(hdc,oldPen);
|
||||
SelectObject(hdc,oldBrush);
|
||||
|
@ -804,3 +828,7 @@ void CtrlMemView::setHighlightType(MemBlockFlags flags) {
|
|||
redraw();
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t CtrlMemView::pickTagColor(const std::string &tag) {
|
||||
return 0xFFFFFF;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
//
|
||||
//To get a class instance to be able to access it, just use getFrom(HWND wnd).
|
||||
|
||||
#include <cstdint>
|
||||
#include "Core/Debugger/DebugInterface.h"
|
||||
#include "Core/Debugger/MemBlockInfo.h"
|
||||
|
||||
|
@ -69,6 +70,7 @@ class CtrlMemView
|
|||
|
||||
void updateStatusBarText();
|
||||
void search(bool continueSearch);
|
||||
uint32_t pickTagColor(const std::string &tag);
|
||||
public:
|
||||
CtrlMemView(HWND _wnd);
|
||||
~CtrlMemView();
|
||||
|
|
Loading…
Add table
Reference in a new issue