Bug fix for Qt GUI frame advance logic. Updated RamSearch to run after ever completed frame.

This commit is contained in:
Matthew Budd 2020-10-12 15:51:24 -04:00
parent 25152af42a
commit 1368d0550e
4 changed files with 47 additions and 9 deletions

View File

@ -22,6 +22,7 @@
#include "../../fceu.h" #include "../../fceu.h"
#include "../../cheat.h" #include "../../cheat.h"
#include "../../debug.h" #include "../../debug.h"
#include "../../movie.h"
#include "Qt/main.h" #include "Qt/main.h"
#include "Qt/dface.h" #include "Qt/dface.h"
@ -74,7 +75,9 @@ struct memoryLocation_t
}; };
static struct memoryLocation_t memLoc[0x10000]; static struct memoryLocation_t memLoc[0x10000];
static std::list <struct memoryLocation_t*> actvSrchList; static std::list <struct memoryLocation_t*> actvSrchList;
static std::list <struct memoryLocation_t*> deactvSrchList;
static std::vector <int> deactvFrameStack;
static int dpySize = 'b'; static int dpySize = 'b';
static int dpyType = 's'; static int dpyType = 's';
@ -148,7 +151,7 @@ RamSearchDialog_t::RamSearchDialog_t(QWidget *parent)
undoButton = new QPushButton( tr("Undo") ); undoButton = new QPushButton( tr("Undo") );
vbox->addWidget( undoButton ); vbox->addWidget( undoButton );
//connect( undoButton, SIGNAL(clicked(void)), this, SLOT(removeWatchClicked(void))); //connect( undoButton, SIGNAL(clicked(void)), this, SLOT(removeWatchClicked(void)));
//undoButton->setEnabled(false); undoButton->setEnabled(false);
searchROMCbox = new QCheckBox( tr("Search ROM") ); searchROMCbox = new QCheckBox( tr("Search ROM") );
vbox->addWidget( searchROMCbox ); vbox->addWidget( searchROMCbox );
@ -297,22 +300,26 @@ RamSearchDialog_t::RamSearchDialog_t(QWidget *parent)
setLayout( mainLayout ); setLayout( mainLayout );
cycleCounter = 0;
resetSearch(); resetSearch();
updateTimer = new QTimer( this ); updateTimer = new QTimer( this );
connect( updateTimer, &QTimer::timeout, this, &RamSearchDialog_t::periodicUpdate ); connect( updateTimer, &QTimer::timeout, this, &RamSearchDialog_t::periodicUpdate );
updateTimer->start( 100 ); // 10hz updateTimer->start( 8 ); // ~120hz
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
RamSearchDialog_t::~RamSearchDialog_t(void) RamSearchDialog_t::~RamSearchDialog_t(void)
{ {
updateTimer->stop(); updateTimer->stop();
printf("Destroy RAM Watch Config Window\n"); printf("Destroy RAM Search Window\n");
ramSearchWin = NULL; ramSearchWin = NULL;
actvSrchList.clear(); actvSrchList.clear();
deactvSrchList.clear();
deactvFrameStack.clear();
for (unsigned int addr=0; addr<0x08000; addr++) for (unsigned int addr=0; addr<0x08000; addr++)
{ {
@ -322,7 +329,7 @@ RamSearchDialog_t::~RamSearchDialog_t(void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void RamSearchDialog_t::closeEvent(QCloseEvent *event) void RamSearchDialog_t::closeEvent(QCloseEvent *event)
{ {
printf("RAM Watch Close Window Event\n"); printf("RAM Search Close Window Event\n");
done(0); done(0);
deleteLater(); deleteLater();
event->accept(); event->accept();
@ -337,9 +344,18 @@ void RamSearchDialog_t::closeWindow(void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void RamSearchDialog_t::periodicUpdate(void) void RamSearchDialog_t::periodicUpdate(void)
{ {
updateRamValues(); if ( currFrameCounter != frameCounterLastPass )
{
updateRamValues();
frameCounterLastPass = currFrameCounter;
}
ramView->update(); if ( (cycleCounter % 10) == 0)
{
ramView->update();
}
cycleCounter++;
} }
//---------------------------------------------------- //----------------------------------------------------
void RamSearchDialog_t::hbarChanged(int val) void RamSearchDialog_t::hbarChanged(int val)
@ -364,6 +380,15 @@ void RamSearchDialog_t::misalignedChanged(int state)
calcRamList(); calcRamList();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static bool memoryAddrCompare( memoryLocation_t *loc1, memoryLocation_t *loc2 )
{
return loc1->addr < loc2->addr;
}
static void sortActvMemList(void)
{
actvSrchList.sort( memoryAddrCompare );
}
//----------------------------------------------------------------------------
static unsigned int ReadValueAtHardwareAddress(int address, unsigned int size) static unsigned int ReadValueAtHardwareAddress(int address, unsigned int size)
{ {
unsigned int value = 0; unsigned int value = 0;
@ -389,6 +414,8 @@ void RamSearchDialog_t::runSearch(void)
void RamSearchDialog_t::resetSearch(void) void RamSearchDialog_t::resetSearch(void)
{ {
actvSrchList.clear(); actvSrchList.clear();
deactvSrchList.clear();
deactvFrameStack.clear();
for (unsigned int addr=0; addr<0x10000; addr++) for (unsigned int addr=0; addr<0x10000; addr++)
{ {
@ -601,6 +628,8 @@ void QRamSearchView::calcFontData(void)
pxLineWidth = pxColWidth[0] + pxColWidth[1] + pxColWidth[2] + pxColWidth[3]; pxLineWidth = pxColWidth[0] + pxColWidth[1] + pxColWidth[2] + pxColWidth[3];
viewLines = (viewHeight / pxLineSpacing) + 1; viewLines = (viewHeight / pxLineSpacing) + 1;
setMinimumWidth( pxLineWidth );
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void QRamSearchView::setScrollBars( QScrollBar *hbar, QScrollBar *vbar ) void QRamSearchView::setScrollBars( QScrollBar *hbar, QScrollBar *vbar )

View File

@ -114,6 +114,9 @@ class RamSearchDialog_t : public QDialog
QCheckBox *autoSearchCbox; QCheckBox *autoSearchCbox;
int fontCharWidth; int fontCharWidth;
int frameCounterLastPass;
unsigned int cycleCounter;
private: private:
void updateRamValues(void); void updateRamValues(void);

View File

@ -64,6 +64,7 @@ static int periodic_saves = 0;
static int mutexLocks = 0; static int mutexLocks = 0;
static int mutexPending = 0; static int mutexPending = 0;
static bool emulatorHasMutux = 0; static bool emulatorHasMutux = 0;
static unsigned int emulatorCycleCount = 0;
extern double g_fpsScale; extern double g_fpsScale;
@ -945,6 +946,8 @@ static void DoFun(int frameskip, int periodic_saves)
// opause=FCEUI_EmulationPaused(); // opause=FCEUI_EmulationPaused();
// SilenceSound(opause); // SilenceSound(opause);
//} //}
emulatorCycleCount++;
} }
void fceuWrapperLock(void) void fceuWrapperLock(void)
@ -1019,7 +1022,7 @@ int fceuWrapperUpdate( void )
} }
emulatorHasMutux = 1; emulatorHasMutux = 1;
if ( GameInfo && !FCEUI_EmulationPaused() ) if ( GameInfo /*&& !FCEUI_EmulationPaused()*/ )
{ {
DoFun(frameskip, periodic_saves); DoFun(frameskip, periodic_saves);

View File

@ -139,6 +139,7 @@ static uint8 keyonce[SDL_NUM_SCANCODES];
int getKeyState( int k ) int getKeyState( int k )
{ {
k = SDL_GetScancodeFromKey(k);
if ( (k >= 0) && (k < SDL_NUM_SCANCODES) ) if ( (k >= 0) && (k < SDL_NUM_SCANCODES) )
{ {
return g_keyState[k]; return g_keyState[k];
@ -661,12 +662,13 @@ static void KeyboardCommands (void)
} }
static bool frameAdvancing = false; static bool frameAdvancing = false;
if ( _keyonly(Hotkeys[HK_FRAME_ADVANCE])) if ( getKeyState(Hotkeys[HK_FRAME_ADVANCE]))
{ {
if (frameAdvancing == false) if (frameAdvancing == false)
{ {
FCEUI_FrameAdvance (); FCEUI_FrameAdvance ();
frameAdvancing = true; frameAdvancing = true;
//printf("Frame Advance Start\n");
} }
} }
else else
@ -675,6 +677,7 @@ static void KeyboardCommands (void)
{ {
FCEUI_FrameAdvanceEnd (); FCEUI_FrameAdvanceEnd ();
frameAdvancing = false; frameAdvancing = false;
//printf("Frame Advance End\n");
} }
} }