Minor performance improvements to Qt Ram Search window.

This commit is contained in:
mjbudd77 2021-02-17 21:22:25 -05:00
parent 14b07ab5f2
commit 67752c1ea2
2 changed files with 215 additions and 193 deletions

View File

@ -95,6 +95,7 @@ struct memoryLocation_t
}
};
static struct memoryLocation_t memLoc[0x10000];
static uint8_t lclMemBuf[0x10000];
static std::list <struct memoryLocation_t*> actvSrchList;
static std::list <struct memoryLocation_t*> deactvSrchList;
@ -481,9 +482,12 @@ void RamSearchDialog_t::periodicUpdate(void)
{
int selAddr = -1;
fceuWrapperLock();
if ( currFrameCounter != frameCounterLastPass )
{
fceuWrapperLock();
copyRamToLocalBuffer();
fceuWrapperUnLock();
//if ( currFrameCounter != (frameCounterLastPass+1) )
//{
// printf("Warning: Ram Search Missed Frame: %i \n", currFrameCounter );
@ -496,8 +500,9 @@ void RamSearchDialog_t::periodicUpdate(void)
}
frameCounterLastPass = currFrameCounter;
}
fceuWrapperUnLock();
if ( (cycleCounter % 10) == 0)
{
undoButton->setEnabled( deactvFrameStack.size() > 0 );
selAddr = ramView->getSelAddr();
@ -517,8 +522,6 @@ void RamSearchDialog_t::periodicUpdate(void)
hexEditButton->setEnabled(false);
}
if ( (cycleCounter % 10) == 0)
{
ramView->update();
}
cycleCounter++;
@ -1020,7 +1023,7 @@ static unsigned int ReadValueAtHardwareAddress(int address, unsigned int size)
if ( address < maxAddr )
{
value <<= 8;
value |= GetMem(address);
value |= lclMemBuf[address];
address++;
}
}
@ -1053,8 +1056,22 @@ void RamSearchDialog_t::runSearch(void)
undoButton->setEnabled( deactvFrameStack.size() > 0 );
}
//----------------------------------------------------------------------------
void RamSearchDialog_t::copyRamToLocalBuffer(void)
{
for (unsigned int addr=0; addr<0x10000; addr++)
{
lclMemBuf[addr] = GetMem(addr);
}
}
//----------------------------------------------------------------------------
void RamSearchDialog_t::resetSearch(void)
{
memset( lclMemBuf, 0, sizeof(lclMemBuf));
fceuWrapperLock();
copyRamToLocalBuffer();
fceuWrapperUnLock();
actvSrchList.clear();
deactvSrchList.clear();
deactvFrameStack.clear();
@ -1063,7 +1080,7 @@ void RamSearchDialog_t::resetSearch(void)
{
memLoc[addr].hist.clear();
memLoc[addr].addr = addr;
memLoc[addr].val.v8.u = GetMem(addr);
memLoc[addr].val.v8.u = lclMemBuf[addr];
memLoc[addr].val.v16.u = ReadValueAtHardwareAddress(addr, 2);
memLoc[addr].val.v32.u = ReadValueAtHardwareAddress(addr, 4);
memLoc[addr].elimMask = 0;
@ -1227,9 +1244,13 @@ void RamSearchDialog_t::addCheatClicked(void)
}
strcpy( desc, "Quick Cheat Add");
fceuWrapperLock();
FCEUI_AddCheat( desc, addr, GetMem(addr), -1, 1 );
updateCheatDialog();
fceuWrapperUnLock();
}
//----------------------------------------------------------------------------
void RamSearchDialog_t::addRamWatchClicked(void)
@ -1459,7 +1480,7 @@ void RamSearchDialog_t::updateRamValues(void)
{
loc = *it;
val.v8.u = GetMem(loc->addr);
val.v8.u = lclMemBuf[loc->addr];
val.v16.u = ReadValueAtHardwareAddress(loc->addr, 2);
val.v32.u = ReadValueAtHardwareAddress(loc->addr, 4);

View File

@ -131,6 +131,7 @@ class RamSearchDialog_t : public QDialog
void SearchSpecificValue(void);
void SearchSpecificAddress(void);
void SearchNumberChanges(void);
void copyRamToLocalBuffer(void);
public slots:
void closeWindow(void);