Merge pull request #184 from mjbudd77/master

Added RAM Search Window to Qt GUI
This commit is contained in:
mjbudd77 2020-10-17 00:23:56 -04:00 committed by GitHub
commit e66a162430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 2141 additions and 12 deletions

View File

@ -38,7 +38,7 @@ Game genie load/enable capability | YES | YES
Movie record/save/play functionality | YES | YES |
Cheat search window | YES | YES |
Active Cheat window | YES | YES |
RAM Search Window | NO | NO |
RAM Search Window | YES | NO |
RAM Watch Window | YES | YES |
Memory Watch Window | NO | NO |
TAS Editor | NO | NO |

View File

@ -445,6 +445,7 @@ set(SRC_DRIVERS_SDL
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ppuViewer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/NameTableViewer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/RamWatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/RamSearch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/input.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/nes_shm.cpp

View File

@ -27,6 +27,26 @@
static GuiCheatsDialog_t *win = NULL;
//----------------------------------------------------------------------------
void openCheatDialog(QWidget *parent)
{
if ( win != NULL )
{
return;
}
win = new GuiCheatsDialog_t(parent);
win->show();
}
//----------------------------------------------------------------------------
void updateCheatDialog(void)
{
if ( win == NULL )
{
return;
}
win->showActiveCheatList( true );
}
//----------------------------------------------------------------------------
GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent)
: QDialog( parent )
{
@ -412,6 +432,7 @@ GuiCheatsDialog_t::~GuiCheatsDialog_t(void)
}
wasPausedByCheats = false;
win = NULL;
printf("Destroy Cheat Window Event\n");
}
//----------------------------------------------------------------------------

View File

@ -32,6 +32,8 @@ class GuiCheatsDialog_t : public QDialog
int activeCheatListCB (char *name, uint32 a, uint8 v, int c, int s, int type, void *data);
void showActiveCheatList(bool redraw);
protected:
void closeEvent(QCloseEvent *event);
@ -75,7 +77,6 @@ class GuiCheatsDialog_t : public QDialog
private:
void showCheatSearchResults(void);
void showActiveCheatList(bool redraw);
public slots:
void closeWindow(void);
@ -97,3 +98,7 @@ class GuiCheatsDialog_t : public QDialog
void actvCheatItemClicked( QTreeWidgetItem *item, int column);
};
void openCheatDialog(QWidget *parent);
void updateCheatDialog(void);

View File

@ -343,6 +343,7 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent)
cpuCycExdVal->setInputMask( ">9000000000000000;" );
cpuCycExdVal->setAlignment(Qt::AlignLeft);
cpuCycExdVal->setMaximumWidth( 18 * fontCharWidth );
cpuCycExdVal->setCursorPosition(0);
connect( cpuCycExdVal, SIGNAL(textEdited(const QString &)), this, SLOT(cpuCycleThresChanged(const QString &)));
instrExdVal->setFont( font );
@ -350,6 +351,7 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent)
instrExdVal->setInputMask( ">9000000000000000;" );
instrExdVal->setAlignment(Qt::AlignLeft);
instrExdVal->setMaximumWidth( 18 * fontCharWidth );
instrExdVal->setCursorPosition(0);
connect( instrExdVal, SIGNAL(textEdited(const QString &)), this, SLOT(instructionsThresChanged(const QString &)));
brkCpuCycExd->setChecked( break_on_cycles );

View File

@ -36,6 +36,7 @@
#include "Qt/ppuViewer.h"
#include "Qt/NameTableViewer.h"
#include "Qt/RamWatch.h"
#include "Qt/RamSearch.h"
#include "Qt/keyscan.h"
#include "Qt/nes_shm.h"
@ -484,6 +485,14 @@ void consoleWin_t::createMainMenu(void)
toolsMenu->addAction(cheatsAct);
// Tools -> RAM Search
ramSearchAct = new QAction(tr("RAM Search..."), this);
//ramSearchAct->setShortcut( QKeySequence(tr("Shift+F7")));
ramSearchAct->setStatusTip(tr("Open RAM Search Window"));
connect(ramSearchAct, SIGNAL(triggered()), this, SLOT(openRamSearch(void)) );
toolsMenu->addAction(ramSearchAct);
// Tools -> RAM Watch
ramWatchAct = new QAction(tr("RAM Watch..."), this);
//ramWatchAct->setShortcut( QKeySequence(tr("Shift+F7")));
@ -1017,13 +1026,9 @@ void consoleWin_t::openGuiConfWin(void)
void consoleWin_t::openCheats(void)
{
GuiCheatsDialog_t *cheatWin;
//printf("Open GUI Cheat Window\n");
cheatWin = new GuiCheatsDialog_t(this);
cheatWin->show();
openCheatDialog(this);
}
void consoleWin_t::openRamWatch(void)
@ -1037,6 +1042,12 @@ void consoleWin_t::openRamWatch(void)
ramWatchWin->show();
}
void consoleWin_t::openRamSearch(void)
{
//printf("Open GUI RAM Search Window\n");
openRamSearchWindow(this);
}
void consoleWin_t::openDebugWindow(void)
{
ConsoleDebugger *debugWin;

View File

@ -90,6 +90,7 @@ class consoleWin_t : public QMainWindow
QAction *fdsLoadBiosAct;
QAction *cheatsAct;
QAction *ramWatchAct;
QAction *ramSearchAct;
QAction *debuggerAct;
QAction *codeDataLogAct;
QAction *traceLogAct;
@ -169,6 +170,7 @@ class consoleWin_t : public QMainWindow
void openNTViewer(void);
void openCheats(void);
void openRamWatch(void);
void openRamSearch(void);
void openMovie(void);
void stopMovie(void);
void recordMovie(void);

View File

@ -563,7 +563,7 @@ HexEditorDialog_t::HexEditorDialog_t(QWidget *parent)
// File -> Save ROM
saveROM = new QAction(tr("Save ROM"), this);
//saveROM->setShortcuts(QKeySequence::Open);
//saveROM->setShortcut(QKeySequence::Open);
saveROM->setStatusTip(tr("Save ROM File"));
connect(saveROM, SIGNAL(triggered()), this, SLOT(saveRomFile(void)) );
@ -571,12 +571,20 @@ HexEditorDialog_t::HexEditorDialog_t(QWidget *parent)
// File -> Save ROM As
saveROM = new QAction(tr("Save ROM As"), this);
//saveROM->setShortcuts(QKeySequence::Open);
//saveROM->setShortcut(QKeySequence::Open);
saveROM->setStatusTip(tr("Save ROM File As"));
connect(saveROM, SIGNAL(triggered()), this, SLOT(saveRomFileAs(void)) );
fileMenu->addAction(saveROM);
// File -> Goto Address
gotoAddrAct = new QAction(tr("Goto Addresss"), this);
gotoAddrAct->setShortcut(QKeySequence(tr("Ctrl+A")));
gotoAddrAct->setStatusTip(tr("Goto Address"));
connect(gotoAddrAct, SIGNAL(triggered()), this, SLOT(openGotoAddrDialog(void)) );
fileMenu->addAction(gotoAddrAct);
fileMenu->addSeparator();
// File -> Close
@ -1132,6 +1140,11 @@ void HexEditorDialog_t::updatePeriodic(void)
}
}
//----------------------------------------------------------------------------
void HexEditorDialog_t::openGotoAddrDialog(void)
{
editor->openGotoAddrDialog();
}
//----------------------------------------------------------------------------
QHexEdit::QHexEdit(QWidget *parent)
: QWidget( parent )
{
@ -1361,6 +1374,33 @@ void QHexEdit::resizeEvent(QResizeEvent *event)
}
//----------------------------------------------------------------------------
void QHexEdit::openGotoAddrDialog(void)
{
int ret;
char stmp[128];
QInputDialog dialog(this);
sprintf( stmp, "Specify Address [ 0x0 -> 0x%X ]", mb.size()-1 );
dialog.setWindowTitle( tr("Goto Address") );
dialog.setLabelText( tr(stmp) );
dialog.setOkButtonText( tr("Go") );
//dialog.setTextValue( tr("0") );
dialog.show();
ret = dialog.exec();
if ( QDialog::Accepted == ret )
{
int addr;
std::string s = dialog.textValue().toStdString();
addr = strtol( s.c_str(), NULL, 16 );
parent->gotoAddress(addr);
}
}
//----------------------------------------------------------------------------
void QHexEdit::resetCursor(void)
{
cursorBlink = true;
@ -1599,6 +1639,13 @@ void QHexEdit::keyPressEvent(QKeyEvent *event)
vbar->setValue( lineOffset );
resetCursor();
}
else if (Qt::ControlModifier == event->modifiers())
{
if ( event->key() == Qt::Key_A )
{
openGotoAddrDialog();
}
}
else if (event->key() == Qt::Key_Tab && (cursorPosX < 32) )
{ // switch from hex to ascii edit
cursorPosX = 32 + (cursorPosX / 2);

View File

@ -113,6 +113,7 @@ class QHexEdit : public QWidget
void setForeGroundColor( QColor fg );
void setBackGroundColor( QColor bg );
void memModeUpdate(void);
void openGotoAddrDialog(void);
int checkMemActivity(void);
int getAddr(void){ return cursorAddr; };
@ -221,6 +222,7 @@ class HexEditorDialog_t : public QDialog
QAction *viewPPU;
QAction *viewOAM;
QAction *viewROM;
QAction *gotoAddrAct;
private:
@ -242,6 +244,7 @@ class HexEditorDialog_t : public QDialog
void pickForeGroundColor(void);
void pickBackGroundColor(void);
void removeAllBookmarks(void);
void openGotoAddrDialog(void);
};
int hexEditorNumWindows(void);

1837
src/drivers/Qt/RamSearch.cpp Normal file

File diff suppressed because it is too large Load Diff

170
src/drivers/Qt/RamSearch.h Normal file
View File

@ -0,0 +1,170 @@
// RamSearch.h
//
#pragma once
#include <list>
#include <QWidget>
#include <QDialog>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QComboBox>
#include <QCheckBox>
#include <QPushButton>
#include <QRadioButton>
#include <QLabel>
#include <QFrame>
#include <QGroupBox>
#include <QScrollBar>
#include "Qt/main.h"
class QRamSearchView : public QWidget
{
Q_OBJECT
public:
QRamSearchView(QWidget *parent = 0);
~QRamSearchView(void);
void setScrollBars( QScrollBar *hbar, QScrollBar *vbar );
int getSelAddr(void){ return selAddr; }
protected:
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent *event);
//void keyReleaseEvent(QKeyEvent *event);
void mousePressEvent(QMouseEvent * event);
void resizeEvent(QResizeEvent *event);
int convPixToLine( QPoint p );
void calcFontData(void);
QFont font;
QScrollBar *vbar;
QScrollBar *hbar;
int lineOffset;
int maxLineOffset;
int pxCharWidth;
int pxCharHeight;
int pxLineSpacing;
int pxLineLead;
int pxCursorHeight;
int pxLineXScroll;
int pxLineWidth;
int pxColWidth[4];
int viewLines;
int viewWidth;
int viewHeight;
int selAddr;
int selLine;
};
class RamSearchDialog_t : public QDialog
{
Q_OBJECT
public:
RamSearchDialog_t(QWidget *parent = 0);
~RamSearchDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
QRamSearchView *ramView;
QScrollBar *vbar;
QScrollBar *hbar;
QTimer *updateTimer;
QPushButton *searchButton;
QPushButton *resetButton;
QPushButton *clearChangeButton;
QPushButton *undoButton;
QPushButton *elimButton;
QPushButton *watchButton;
QPushButton *addCheatButton;
QPushButton *hexEditButton;
QRadioButton *lt_btn;
QRadioButton *gt_btn;
QRadioButton *le_btn;
QRadioButton *ge_btn;
QRadioButton *eq_btn;
QRadioButton *ne_btn;
QRadioButton *df_btn;
QRadioButton *md_btn;
QRadioButton *pv_btn;
QRadioButton *sv_btn;
QRadioButton *sa_btn;
QRadioButton *nc_btn;
QRadioButton *ds1_btn;
QRadioButton *ds2_btn;
QRadioButton *ds4_btn;
QRadioButton *signed_btn;
QRadioButton *unsigned_btn;
QRadioButton *hex_btn;
QLineEdit *diffByEdit;
QLineEdit *moduloEdit;
QLineEdit *specValEdit;
QLineEdit *specAddrEdit;
QLineEdit *numChangeEdit;
QCheckBox *searchROMCbox;
QCheckBox *misalignedCbox;
QCheckBox *autoSearchCbox;
int fontCharWidth;
int frameCounterLastPass;
unsigned int cycleCounter;
private:
void updateRamValues(void);
void calcRamList(void);
void SearchRelative(void);
void SearchSpecificValue(void);
void SearchSpecificAddress(void);
void SearchNumberChanges(void);
public slots:
void closeWindow(void);
private slots:
void runSearch(void);
void resetSearch(void);
void undoSearch(void);
void clearChangeCounts(void);
void eliminateSelAddr(void);
void hexEditSelAddr(void);
void addCheatClicked(void);
void addRamWatchClicked(void);
void periodicUpdate(void);
void hbarChanged(int val);
void vbarChanged(int val);
void searchROMChanged(int state);
void misalignedChanged(int state);
void ds1Clicked(void);
void ds2Clicked(void);
void ds4Clicked(void);
void signedTypeClicked(void);
void unsignedTypeClicked(void);
void hexTypeClicked(void);
void opLtClicked(void);
void opGtClicked(void);
void opLeClicked(void);
void opGeClicked(void);
void opEqClicked(void);
void opNeClicked(void);
void opDfClicked(void);
void opMdClicked(void);
void pvBtnClicked(void);
void svBtnClicked(void);
void saBtnClicked(void);
void ncBtnClicked(void);
};
void openRamSearchWindow(QWidget *parent);

View File

@ -1,4 +1,4 @@
// HotKeyConf.cpp
// RamWatch.cpp
//
#include <stdio.h>
#include <stdlib.h>
@ -28,9 +28,22 @@
#include "Qt/keyscan.h"
#include "Qt/fceuWrapper.h"
#include "Qt/RamWatch.h"
#include "Qt/CheatsConf.h"
#include "Qt/ConsoleUtilities.h"
ramWatchList_t ramWatchList;
static RamWatchDialog_t *ramWatchMainWin = NULL;
//----------------------------------------------------------------------------
void openRamWatchWindow( QWidget *parent, int force )
{
if ( !force )
{
if ( ramWatchMainWin != NULL ) return;
}
ramWatchMainWin = new RamWatchDialog_t(parent);
ramWatchMainWin->show();
}
//----------------------------------------------------------------------------
RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
: QDialog( parent )
@ -263,6 +276,8 @@ RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
setLayout( mainLayout );
ramWatchMainWin = this;
updateTimer = new QTimer( this );
connect( updateTimer, &QTimer::timeout, this, &RamWatchDialog_t::periodicUpdate );
@ -273,6 +288,11 @@ RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
RamWatchDialog_t::~RamWatchDialog_t(void)
{
updateTimer->stop();
if ( ramWatchMainWin == this )
{
ramWatchMainWin = NULL;
}
printf("Destroy RAM Watch Config Window\n");
}
//----------------------------------------------------------------------------
@ -898,6 +918,8 @@ void RamWatchDialog_t::addCheatClicked(void)
if ( rw != NULL )
{
FCEUI_AddCheat( rw->name.c_str(), rw->addr, GetMem(rw->addr), -1, 1 );
updateCheatDialog();
}
}
//----------------------------------------------------------------------------

View File

@ -254,3 +254,5 @@ class RamWatchDialog_t : public QDialog
};
extern ramWatchList_t ramWatchList;
void openRamWatchWindow( QWidget *parent, int force = 0 );

View File

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

View File

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