mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 21:39:52 +00:00
Fix some bugs and style for #12994
This commit is contained in:
parent
021e783b4a
commit
4e7944a353
@ -634,17 +634,16 @@ void CtrlMemView::scrollCursor(int bytes)
|
||||
|
||||
std::vector<u32> CtrlMemView::searchString(std::string searchQuery)
|
||||
{
|
||||
|
||||
std::vector<u32> searchResAddrs;
|
||||
std::vector<u8> searchData;
|
||||
|
||||
auto memLock = Memory::Lock();
|
||||
if (!PSP_IsInited())
|
||||
return searchResAddrs;
|
||||
|
||||
|
||||
size_t queryLength = searchQuery.length();
|
||||
u32 segmentStart = PSP_GetKernelMemoryBase(); //RAM start
|
||||
u32 const segmentEnd = PSP_GetUserMemoryEnd() - queryLength; //RAM end
|
||||
const u32 segmentEnd = PSP_GetUserMemoryEnd() - (u32)queryLength; //RAM end
|
||||
u8* ptr;
|
||||
|
||||
redraw();
|
||||
@ -660,7 +659,7 @@ std::vector<u32> CtrlMemView::searchString(std::string searchQuery)
|
||||
}
|
||||
};
|
||||
redraw();
|
||||
|
||||
|
||||
return searchResAddrs;
|
||||
};
|
||||
|
||||
@ -670,11 +669,11 @@ void CtrlMemView::search(bool continueSearch)
|
||||
if (!PSP_IsInited())
|
||||
return;
|
||||
|
||||
u32 searchAddress;
|
||||
u32 segmentStart;
|
||||
u32 segmentEnd;
|
||||
u8* dataPointer;
|
||||
if (continueSearch == false || searchQuery[0] == 0)
|
||||
u32 searchAddress = 0;
|
||||
u32 segmentStart = 0;
|
||||
u32 segmentEnd = 0;
|
||||
u8* dataPointer = 0;
|
||||
if (continueSearch == false || searchQuery.empty())
|
||||
{
|
||||
if (InputBox_GetString(GetModuleHandle(NULL),wnd,L"Search for", "",searchQuery) == false)
|
||||
{
|
||||
@ -706,7 +705,7 @@ void CtrlMemView::search(bool continueSearch)
|
||||
}
|
||||
|
||||
u8 value = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (int i = 0; i < 2 && index < searchQuery.size(); i++)
|
||||
{
|
||||
char c = tolower(searchQuery[index++]);
|
||||
if (c >= 'a' && c <= 'f')
|
||||
@ -726,19 +725,16 @@ void CtrlMemView::search(bool continueSearch)
|
||||
}
|
||||
|
||||
std::vector<std::pair<u32,u32>> memoryAreas;
|
||||
memoryAreas.push_back(std::pair<u32,u32>(0x04000000,0x04200000));
|
||||
memoryAreas.push_back(std::pair<u32,u32>(0x08000000,0x0A000000));
|
||||
memoryAreas.push_back(std::pair<u32,u32>(0x04000000, 0x04200000));
|
||||
memoryAreas.push_back(std::pair<u32,u32>(0x08000000, 0x0A000000));
|
||||
|
||||
searching = true;
|
||||
redraw(); // so the cursor is disabled
|
||||
|
||||
|
||||
|
||||
for (size_t i = 0; i < memoryAreas.size(); i++)
|
||||
{
|
||||
for (size_t i = 0; i < memoryAreas.size(); i++) {
|
||||
segmentStart = memoryAreas[i].first;
|
||||
segmentEnd = memoryAreas[i].second;
|
||||
|
||||
|
||||
dataPointer = Memory::GetPointer(segmentStart);
|
||||
if (dataPointer == NULL) continue; // better safe than sorry, I guess
|
||||
|
||||
@ -746,19 +742,15 @@ void CtrlMemView::search(bool continueSearch)
|
||||
if (searchAddress >= segmentEnd) continue;
|
||||
|
||||
int index = searchAddress-segmentStart;
|
||||
int endIndex = segmentEnd-segmentStart-(int)searchData.size();
|
||||
int endIndex = segmentEnd-segmentStart - (int)searchData.size();
|
||||
|
||||
while (index < endIndex)
|
||||
{
|
||||
while (index < endIndex) {
|
||||
// cancel search
|
||||
if ((index % 256) == 0 && KeyDownAsync(VK_ESCAPE))
|
||||
{
|
||||
if ((index % 256) == 0 && KeyDownAsync(VK_ESCAPE)) {
|
||||
searching = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (memcmp(&dataPointer[index],searchData.data(),searchData.size()) == 0)
|
||||
{
|
||||
if (memcmp(&dataPointer[index], searchData.data(), searchData.size()) == 0) {
|
||||
matchAddress = index+segmentStart;
|
||||
searching = false;
|
||||
gotoAddr(matchAddress);
|
||||
@ -783,14 +775,12 @@ void CtrlMemView::drawOffsetScale(HDC hdc)
|
||||
currentX = addressStart + ((8 + 1)*charWidth); // the start offset, the size of the hex addresses and one space
|
||||
|
||||
char temp[64];
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
sprintf(temp, "%02X", i);
|
||||
TextOutA(hdc, currentX, offsetPositionY, temp, 2);
|
||||
currentX += 3 * charWidth; // hex and space
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CtrlMemView::toggleOffsetScale(CommonToggles toggle)
|
||||
|
@ -102,13 +102,12 @@ void CMemoryDlg::Update(void)
|
||||
}
|
||||
|
||||
void CMemoryDlg::searchBoxRedraw(std::vector<u32> results) {
|
||||
int index;
|
||||
wchar_t temp[256];
|
||||
wchar_t temp[256]{};
|
||||
SendMessage(srcListHdl, WM_SETREDRAW, FALSE, 0);
|
||||
ListBox_ResetContent(srcListHdl);
|
||||
for (int i = 0; i < results.size(); i++) {
|
||||
wsprintf(temp, L"0x%08X", results[i]);
|
||||
index = (int)ListBox_AddString(srcListHdl,temp);
|
||||
int index = (int)ListBox_AddString(srcListHdl, temp);
|
||||
ListBox_SetItemData(srcListHdl, index, results[i]);
|
||||
}
|
||||
SendMessage(srcListHdl, WM_SETREDRAW, TRUE, 0);
|
||||
@ -139,13 +138,13 @@ BOOL CMemoryDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(message){
|
||||
case WM_COMMAND:{
|
||||
HWND lb = GetDlgItem(m_hDlg, LOWORD(wParam));
|
||||
HWND lb = GetDlgItem(m_hDlg, LOWORD(wParam));
|
||||
switch (LOWORD(wParam)){
|
||||
case IDC_REGIONS:
|
||||
switch (HIWORD(wParam)) {
|
||||
switch (HIWORD(wParam)) {
|
||||
case LBN_DBLCLK:{
|
||||
int n = ComboBox_GetCurSel(lb);
|
||||
if (n!=-1){
|
||||
if (n != -1) {
|
||||
unsigned int addr = (unsigned int)ComboBox_GetItemData(lb,n);
|
||||
memView->gotoAddr(addr);
|
||||
}
|
||||
@ -157,7 +156,7 @@ BOOL CMemoryDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
switch (HIWORD(wParam)) {
|
||||
case LBN_DBLCLK:{
|
||||
int n = ListBox_GetCurSel(lb);
|
||||
if (n!=-1) {
|
||||
if (n != -1) {
|
||||
unsigned int addr = (unsigned int)ListBox_GetItemData(lb,n);
|
||||
memView->gotoAddr(addr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user