project64/Source/Project64/UserInterface/Debugger/DMALog.cpp

102 lines
2.0 KiB
C++
Raw Normal View History

2017-08-18 05:08:22 +00:00
#include "stdafx.h"
#include "DMALog.h"
void CDMALog::AddEntry(uint32_t romAddr, uint32_t ramAddr, uint32_t length)
{
2019-12-25 00:41:20 +00:00
DMALOGENTRY entry = { romAddr, ramAddr, length };
m_Log.push_back(entry);
2017-08-18 05:08:22 +00:00
}
void CDMALog::ClearEntries()
{
2019-12-25 00:41:20 +00:00
m_Log.clear();
2017-08-18 05:08:22 +00:00
}
size_t CDMALog::GetNumEntries()
{
2019-12-25 00:41:20 +00:00
return m_Log.size();
2017-08-18 05:08:22 +00:00
}
DMALOGENTRY* CDMALog::GetEntryByIndex(uint32_t index)
{
2019-12-25 00:41:20 +00:00
if (index < m_Log.size())
{
return &m_Log[index];
}
2021-04-12 11:35:39 +00:00
return nullptr;
2017-08-18 05:08:22 +00:00
}
DMALOGENTRY* CDMALog::GetEntryByRamAddress(uint32_t ramAddr)
{
2019-12-25 00:41:20 +00:00
uint32_t nEntries = GetNumEntries();
if (nEntries == 0)
{
2021-04-12 11:35:39 +00:00
return nullptr;
2019-12-25 00:41:20 +00:00
}
for (uint32_t i = nEntries - 1; i-- > 0;)
{
uint32_t min = m_Log[i].ramAddr;
uint32_t max = min + m_Log[i].length - 1;
if (ramAddr >= min && ramAddr <= max)
{
return &m_Log[i];
}
}
2021-04-12 11:35:39 +00:00
return nullptr;
2017-08-18 05:08:22 +00:00
}
DMALOGENTRY* CDMALog::GetEntryByRamAddress(uint32_t ramAddr, uint32_t* lpRomAddr, uint32_t* lpOffset)
{
2019-12-25 00:41:20 +00:00
DMALOGENTRY* lpEntry = GetEntryByRamAddress(ramAddr);
2017-08-18 05:08:22 +00:00
2021-04-12 11:35:39 +00:00
if (lpEntry == nullptr)
2019-12-25 00:41:20 +00:00
{
2021-04-12 11:35:39 +00:00
return nullptr;
2019-12-25 00:41:20 +00:00
}
2017-08-18 05:08:22 +00:00
2019-12-25 00:41:20 +00:00
*lpOffset = ramAddr - lpEntry->ramAddr;
*lpRomAddr = lpEntry->romAddr + *lpOffset;
2017-08-18 05:08:22 +00:00
2019-12-25 00:41:20 +00:00
return lpEntry;
2017-08-18 05:08:22 +00:00
}
DMALOGENTRY* CDMALog::GetEntryByRomAddress(uint32_t romAddr)
{
2019-12-25 00:41:20 +00:00
uint32_t nEntries = GetNumEntries();
if (nEntries == 0)
{
2021-04-12 11:35:39 +00:00
return nullptr;
2019-12-25 00:41:20 +00:00
}
for (uint32_t i = nEntries - 1; i-- > 0; )
{
uint32_t min = m_Log[i].romAddr;
uint32_t max = min + m_Log[i].length - 1;
if (romAddr >= min && romAddr <= max)
{
return &m_Log[i];
}
}
2021-04-12 11:35:39 +00:00
return nullptr;
2017-08-18 05:08:22 +00:00
}
DMALOGENTRY* CDMALog::GetEntryByRomAddress(uint32_t romAddr, uint32_t* lpRamAddr, uint32_t* lpOffset)
{
2019-12-25 00:41:20 +00:00
DMALOGENTRY* lpEntry = GetEntryByRomAddress(romAddr);
2017-08-18 05:08:22 +00:00
2021-04-12 11:35:39 +00:00
if (lpEntry == nullptr)
2019-12-25 00:41:20 +00:00
{
2021-04-12 11:35:39 +00:00
return nullptr;
2019-12-25 00:41:20 +00:00
}
2017-08-18 05:08:22 +00:00
2019-12-25 00:41:20 +00:00
*lpOffset = romAddr - lpEntry->romAddr;
*lpRamAddr = lpEntry->ramAddr + *lpOffset;
2017-08-18 05:08:22 +00:00
2019-12-25 00:41:20 +00:00
return lpEntry;
2021-03-18 03:37:19 +00:00
}