MemoryWindow: base address search added

This commit is contained in:
Sepalani 2017-08-12 18:21:22 +01:00
parent f2a9ad0089
commit c71ce9a8eb

View file

@ -345,7 +345,7 @@ void CMemoryWindow::Search(SearchType search_type)
{ {
u8* ram_ptr = nullptr; u8* ram_ptr = nullptr;
std::size_t ram_size = 0; std::size_t ram_size = 0;
// NOTE: We're assuming the base address is zero. u32 base_address = 0;
switch (m_memory_view->GetMemoryType()) switch (m_memory_view->GetMemoryType())
{ {
case 0: case 0:
@ -354,6 +354,7 @@ void CMemoryWindow::Search(SearchType search_type)
{ {
ram_ptr = Memory::m_pRAM; ram_ptr = Memory::m_pRAM;
ram_size = Memory::REALRAM_SIZE; ram_size = Memory::REALRAM_SIZE;
base_address = 0x80000000;
} }
break; break;
case 1: case 1:
@ -363,6 +364,7 @@ void CMemoryWindow::Search(SearchType search_type)
{ {
ram_ptr = aram; ram_ptr = aram;
ram_size = DSP::ARAM_SIZE; ram_size = DSP::ARAM_SIZE;
base_address = 0x0c005000;
} }
} }
break; break;
@ -419,7 +421,7 @@ void CMemoryWindow::Search(SearchType search_type)
} }
// Search starting from specified address if there is one. // Search starting from specified address if there is one.
u32 addr = 0; // Base address u32 addr = 0; // Physical address
{ {
wxString addr_val = m_address_search_ctrl->GetValue(); wxString addr_val = m_address_search_ctrl->GetValue();
addr_val.Trim(true).Trim(false); addr_val.Trim(true).Trim(false);
@ -429,6 +431,9 @@ void CMemoryWindow::Search(SearchType search_type)
if (addr_val.ToULong(&addr_ul, 16)) if (addr_val.ToULong(&addr_ul, 16))
{ {
addr = static_cast<u32>(addr_ul); addr = static_cast<u32>(addr_ul);
// Get physical address
if (addr >= base_address)
addr -= base_address;
// Don't find the result we're already looking at // Don't find the result we're already looking at
if (m_continue_search && addr == m_last_search_address && if (m_continue_search && addr == m_last_search_address &&
search_type == SearchType::FindNext) search_type == SearchType::FindNext)
@ -466,7 +471,7 @@ void CMemoryWindow::Search(SearchType search_type)
m_search_result_msg->SetLabel(_("Match Found")); m_search_result_msg->SetLabel(_("Match Found"));
u32 offset = static_cast<u32>(ptr - ram_ptr); u32 offset = static_cast<u32>(ptr - ram_ptr);
// NOTE: SetValue() generates a synthetic wxEVT_TEXT // NOTE: SetValue() generates a synthetic wxEVT_TEXT
m_address_search_ctrl->SetValue(wxString::Format("%08x", offset)); m_address_search_ctrl->SetValue(wxString::Format("%08x", base_address + offset));
m_last_search_address = offset; m_last_search_address = offset;
m_continue_search = true; m_continue_search = true;
return; return;