Successful test of all Qt RAM watch features. Minor cppcheck warning cleanup.
This commit is contained in:
parent
778d9c733d
commit
1f11c67c84
|
@ -44,7 +44,9 @@ static class NTCache
|
|||
public:
|
||||
NTCache(void)
|
||||
: curr_vnapage(0)
|
||||
{}
|
||||
{
|
||||
memset( cache, 0, sizeof(cache) );
|
||||
}
|
||||
|
||||
uint8_t* curr_vnapage;
|
||||
uint8_t cache[0x400];
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <QGroupBox>
|
||||
#include <QLineEdit>
|
||||
#include <QRadioButton>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "../../types.h"
|
||||
#include "../../fceu.h"
|
||||
|
@ -27,7 +28,9 @@
|
|||
#include "Qt/keyscan.h"
|
||||
#include "Qt/fceuWrapper.h"
|
||||
#include "Qt/RamWatch.h"
|
||||
#include "Qt/ConsoleUtilities.h"
|
||||
|
||||
ramWatchList_t ramWatchList;
|
||||
//----------------------------------------------------------------------------
|
||||
RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
|
||||
: QDialog( parent )
|
||||
|
@ -74,7 +77,7 @@ RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
|
|||
menuAct = new QAction(tr("New List"), this);
|
||||
menuAct->setShortcut( QKeySequence(tr("Ctrl+N")) );
|
||||
menuAct->setStatusTip(tr("New List"));
|
||||
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
|
||||
connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
|
||||
|
||||
fileMenu->addAction(menuAct);
|
||||
|
||||
|
@ -82,7 +85,7 @@ RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
|
|||
menuAct = new QAction(tr("Open"), this);
|
||||
menuAct->setShortcut( QKeySequence(tr("Ctrl+O")) );
|
||||
menuAct->setStatusTip(tr("Open Watch File"));
|
||||
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
|
||||
connect(menuAct, SIGNAL(triggered()), this, SLOT(openListCB(void)) );
|
||||
|
||||
fileMenu->addAction(menuAct);
|
||||
|
||||
|
@ -90,7 +93,7 @@ RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
|
|||
menuAct = new QAction(tr("Save"), this);
|
||||
menuAct->setShortcut( QKeySequence(tr("Ctrl+S")) );
|
||||
menuAct->setStatusTip(tr("Save Watch File"));
|
||||
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
|
||||
connect(menuAct, SIGNAL(triggered()), this, SLOT(saveListCB(void)) );
|
||||
|
||||
fileMenu->addAction(menuAct);
|
||||
|
||||
|
@ -98,7 +101,7 @@ RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
|
|||
menuAct = new QAction(tr("Save As"), this);
|
||||
menuAct->setShortcut( QKeySequence(tr("Ctrl+Shift+S")) );
|
||||
menuAct->setStatusTip(tr("Save As Watch File"));
|
||||
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
|
||||
connect(menuAct, SIGNAL(triggered()), this, SLOT(saveListAs(void)) );
|
||||
|
||||
fileMenu->addAction(menuAct);
|
||||
|
||||
|
@ -106,7 +109,7 @@ RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
|
|||
menuAct = new QAction(tr("Append"), this);
|
||||
//menuAct->setShortcut( QKeySequence(tr("Ctrl+A")) );
|
||||
menuAct->setStatusTip(tr("Append to Watch File"));
|
||||
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
|
||||
connect(menuAct, SIGNAL(triggered()), this, SLOT(appendListCB(void)) );
|
||||
|
||||
fileMenu->addAction(menuAct);
|
||||
|
||||
|
@ -151,7 +154,7 @@ RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
|
|||
menuAct = new QAction(tr("Duplicate Watch"), this);
|
||||
menuAct->setShortcut( QKeySequence(tr("A")) );
|
||||
menuAct->setStatusTip(tr("Duplicate Watch"));
|
||||
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
|
||||
connect(menuAct, SIGNAL(triggered()), this, SLOT(dupWatchClicked(void)) );
|
||||
|
||||
watchMenu->addAction(menuAct);
|
||||
|
||||
|
@ -217,28 +220,37 @@ RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
|
|||
up_btn = new QPushButton( tr("Up") );
|
||||
vbox->addWidget( up_btn );
|
||||
connect( up_btn, SIGNAL(clicked(void)), this, SLOT(moveWatchUpClicked(void)));
|
||||
up_btn->setEnabled(false);
|
||||
|
||||
down_btn = new QPushButton( tr("Down") );
|
||||
vbox->addWidget( down_btn );
|
||||
connect( down_btn, SIGNAL(clicked(void)), this, SLOT(moveWatchDownClicked(void)));
|
||||
down_btn->setEnabled(false);
|
||||
|
||||
edit_btn = new QPushButton( tr("Edit") );
|
||||
vbox->addWidget( edit_btn );
|
||||
connect( edit_btn, SIGNAL(clicked(void)), this, SLOT(editWatchClicked(void)));
|
||||
edit_btn->setEnabled(false);
|
||||
|
||||
del_btn = new QPushButton( tr("Remove") );
|
||||
vbox->addWidget( del_btn );
|
||||
connect( del_btn, SIGNAL(clicked(void)), this, SLOT(removeWatchClicked(void)));
|
||||
del_btn->setEnabled(false);
|
||||
|
||||
new_btn = new QPushButton( tr("New") );
|
||||
vbox->addWidget( new_btn );
|
||||
connect( new_btn, SIGNAL(clicked(void)), this, SLOT(newWatchClicked(void)));
|
||||
new_btn->setEnabled(true);
|
||||
|
||||
dup_btn = new QPushButton( tr("Duplicate") );
|
||||
vbox->addWidget( dup_btn );
|
||||
connect( dup_btn, SIGNAL(clicked(void)), this, SLOT(dupWatchClicked(void)));
|
||||
dup_btn->setEnabled(false);
|
||||
|
||||
sep_btn = new QPushButton( tr("Separator") );
|
||||
vbox->addWidget( sep_btn );
|
||||
sep_btn->setEnabled(true);
|
||||
connect( sep_btn, SIGNAL(clicked(void)), this, SLOT(sepWatchClicked(void)));
|
||||
|
||||
mainLayout->addWidget( tree );
|
||||
mainLayout->addLayout( vbox1 );
|
||||
|
@ -246,6 +258,8 @@ RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
|
|||
|
||||
cht_btn = new QPushButton( tr("Add Cheat") );
|
||||
vbox1->addWidget( cht_btn );
|
||||
cht_btn->setEnabled(false);
|
||||
connect( cht_btn, SIGNAL(clicked(void)), this, SLOT(addCheatClicked(void)));
|
||||
|
||||
setLayout( mainLayout );
|
||||
|
||||
|
@ -279,6 +293,26 @@ void RamWatchDialog_t::closeWindow(void)
|
|||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::periodicUpdate(void)
|
||||
{
|
||||
bool buttonEnable;
|
||||
QTreeWidgetItem *item;
|
||||
|
||||
item = tree->currentItem();
|
||||
|
||||
if ( item == NULL )
|
||||
{
|
||||
buttonEnable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonEnable = true;
|
||||
}
|
||||
up_btn->setEnabled(buttonEnable);
|
||||
down_btn->setEnabled(buttonEnable);
|
||||
edit_btn->setEnabled(buttonEnable);
|
||||
del_btn->setEnabled(buttonEnable);
|
||||
dup_btn->setEnabled(buttonEnable);
|
||||
cht_btn->setEnabled(buttonEnable);
|
||||
|
||||
|
||||
updateRamWatchDisplay();
|
||||
|
||||
|
@ -304,10 +338,24 @@ void RamWatchDialog_t::updateRamWatchDisplay(void)
|
|||
|
||||
tree->addTopLevelItem( item );
|
||||
}
|
||||
if ( rw->isSep || (rw->addr < 0) )
|
||||
{
|
||||
strcpy (addrStr, "--------");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (addrStr, "$%04X", rw->addr);
|
||||
}
|
||||
|
||||
rw->updateMem ();
|
||||
|
||||
if ( rw->isSep || (rw->addr < 0) )
|
||||
{
|
||||
strcpy( valStr1, "--------");
|
||||
strcpy( valStr2, "--------");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rw->size == 4)
|
||||
{
|
||||
if (rw->type)
|
||||
|
@ -344,6 +392,7 @@ void RamWatchDialog_t::updateRamWatchDisplay(void)
|
|||
}
|
||||
sprintf (valStr2, "0x%02X", rw->val.u8);
|
||||
}
|
||||
}
|
||||
|
||||
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemNeverHasChildren );
|
||||
|
||||
|
@ -367,10 +416,230 @@ void RamWatchDialog_t::watchClicked( QTreeWidgetItem *item, int column)
|
|||
{
|
||||
// int row = tree->indexOfTopLevelItem(item);
|
||||
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::newListCB(void)
|
||||
{
|
||||
ramWatchList.clear();
|
||||
tree->clear();
|
||||
tree->viewport()->update();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::openListCB(void)
|
||||
{
|
||||
int ret, useNativeFileDialogVal;
|
||||
QString filename;
|
||||
const char *romFile = NULL;
|
||||
QFileDialog dialog(this, tr("Open Watch File") );
|
||||
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
dialog.setNameFilter(tr("Watch files (*.wch *.WCH) ;; All files (*)"));
|
||||
|
||||
dialog.setViewMode(QFileDialog::List);
|
||||
dialog.setFilter( QDir::AllEntries | QDir::Hidden );
|
||||
dialog.setLabelText( QFileDialog::Accept, tr("Open") );
|
||||
|
||||
//g_config->getOption ("SDL.LastOpenFile", &last );
|
||||
|
||||
romFile = getRomFile();
|
||||
|
||||
if ( romFile != NULL )
|
||||
{
|
||||
char dir[512], base[256];
|
||||
|
||||
parseFilepath( romFile, dir, base );
|
||||
|
||||
strcat( base, ".wch");
|
||||
|
||||
dialog.setDirectory( tr(dir) );
|
||||
|
||||
dialog.selectFile( tr(base) );
|
||||
}
|
||||
|
||||
// Check config option to use native file dialog or not
|
||||
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||
|
||||
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
||||
|
||||
dialog.show();
|
||||
ret = dialog.exec();
|
||||
|
||||
if ( ret )
|
||||
{
|
||||
QStringList fileList;
|
||||
fileList = dialog.selectedFiles();
|
||||
|
||||
if ( fileList.size() > 0 )
|
||||
{
|
||||
filename = fileList[0];
|
||||
}
|
||||
}
|
||||
|
||||
if ( filename.isNull() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
//qDebug() << "selected file path : " << filename.toUtf8();
|
||||
|
||||
loadWatchFile ( filename.toStdString().c_str() );
|
||||
|
||||
return;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::appendListCB(void)
|
||||
{
|
||||
int ret, useNativeFileDialogVal;
|
||||
QString filename;
|
||||
const char *romFile = NULL;
|
||||
QFileDialog dialog(this, tr("Append Watch List To File") );
|
||||
|
||||
if ( ramWatchList.size() == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
|
||||
dialog.setNameFilter(tr("Watch Files (*.wch *.WCH) ;; All files (*)"));
|
||||
|
||||
dialog.setViewMode(QFileDialog::List);
|
||||
dialog.setFilter( QDir::AllEntries | QDir::Hidden );
|
||||
dialog.setLabelText( QFileDialog::Accept, tr("Save") );
|
||||
dialog.setDefaultSuffix( tr(".wch") );
|
||||
|
||||
romFile = getRomFile();
|
||||
|
||||
if ( romFile != NULL )
|
||||
{
|
||||
char dir[512], base[256];
|
||||
|
||||
parseFilepath( romFile, dir, base );
|
||||
|
||||
strcat( base, ".wch");
|
||||
|
||||
dialog.setDirectory( tr(dir) );
|
||||
|
||||
dialog.selectFile( tr(base) );
|
||||
}
|
||||
|
||||
// Check config option to use native file dialog or not
|
||||
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||
|
||||
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
||||
|
||||
dialog.show();
|
||||
ret = dialog.exec();
|
||||
|
||||
if ( ret )
|
||||
{
|
||||
QStringList fileList;
|
||||
fileList = dialog.selectedFiles();
|
||||
|
||||
if ( fileList.size() > 0 )
|
||||
{
|
||||
filename = fileList[0];
|
||||
}
|
||||
}
|
||||
|
||||
if ( filename.isNull() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
//qDebug() << "selected file path : " << filename.toUtf8();
|
||||
|
||||
saveWatchFile( filename.toStdString().c_str(), 1 );
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::saveListCB(void)
|
||||
{
|
||||
if ( ramWatchList.size() == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( saveFileName.size() > 0 )
|
||||
{
|
||||
char file[512];
|
||||
|
||||
strcpy( file, saveFileName.c_str() );
|
||||
|
||||
saveWatchFile( file );
|
||||
}
|
||||
else
|
||||
{
|
||||
saveListAs();
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::saveListAs(void)
|
||||
{
|
||||
int ret, useNativeFileDialogVal;
|
||||
QString filename;
|
||||
const char *romFile = NULL;
|
||||
QFileDialog dialog(this, tr("Save Watch List To File") );
|
||||
|
||||
if ( ramWatchList.size() == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
|
||||
dialog.setNameFilter(tr("Watch Files (*.wch *.WCH) ;; All files (*)"));
|
||||
|
||||
dialog.setViewMode(QFileDialog::List);
|
||||
dialog.setFilter( QDir::AllEntries | QDir::Hidden );
|
||||
dialog.setLabelText( QFileDialog::Accept, tr("Save") );
|
||||
dialog.setDefaultSuffix( tr(".wch") );
|
||||
|
||||
romFile = getRomFile();
|
||||
|
||||
if ( romFile != NULL )
|
||||
{
|
||||
char dir[512], base[256];
|
||||
|
||||
parseFilepath( romFile, dir, base );
|
||||
|
||||
strcat( base, ".wch");
|
||||
|
||||
dialog.setDirectory( tr(dir) );
|
||||
|
||||
dialog.selectFile( tr(base) );
|
||||
}
|
||||
|
||||
// Check config option to use native file dialog or not
|
||||
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||
|
||||
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
||||
|
||||
dialog.show();
|
||||
ret = dialog.exec();
|
||||
|
||||
if ( ret )
|
||||
{
|
||||
QStringList fileList;
|
||||
fileList = dialog.selectedFiles();
|
||||
|
||||
if ( fileList.size() > 0 )
|
||||
{
|
||||
filename = fileList[0];
|
||||
}
|
||||
}
|
||||
|
||||
if ( filename.isNull() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
//qDebug() << "selected file path : " << filename.toUtf8();
|
||||
|
||||
saveWatchFile( filename.toStdString().c_str() );
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void ramWatch_t::updateMem (void)
|
||||
{
|
||||
if ( addr < 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (size == 1)
|
||||
{
|
||||
val.u8 = GetMem (addr);
|
||||
|
@ -385,9 +654,9 @@ void ramWatch_t::updateMem (void)
|
|||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::openWatchEditWindow(int idx)
|
||||
void RamWatchDialog_t::openWatchEditWindow( ramWatch_t *rw, int mode)
|
||||
{
|
||||
int ret;
|
||||
int ret, isSep = 0;
|
||||
QDialog dialog(this);
|
||||
QVBoxLayout *mainLayout, *vbox;
|
||||
QHBoxLayout *hbox;
|
||||
|
@ -397,12 +666,6 @@ void RamWatchDialog_t::openWatchEditWindow(int idx)
|
|||
QRadioButton *signedTypeBtn, *unsignedTypeBtn;
|
||||
QRadioButton *dataSize1Btn, *dataSize2Btn, *dataSize4Btn;
|
||||
QPushButton *cancelButton, *okButton;
|
||||
ramWatch_t *rw = NULL;
|
||||
|
||||
if ( idx >= 0 )
|
||||
{
|
||||
rw = ramWatchList.getIndex(idx);
|
||||
}
|
||||
|
||||
if ( rw == NULL )
|
||||
{
|
||||
|
@ -422,7 +685,7 @@ void RamWatchDialog_t::openWatchEditWindow(int idx)
|
|||
addrEntry = new QLineEdit();
|
||||
|
||||
addrEntry->setMaxLength(4);
|
||||
addrEntry->setInputMask( ">HHHH;0" );
|
||||
addrEntry->setInputMask( ">HHHH;" );
|
||||
addrEntry->setCursorPosition(0);
|
||||
|
||||
mainLayout->addLayout( hbox );
|
||||
|
@ -480,8 +743,17 @@ void RamWatchDialog_t::openWatchEditWindow(int idx)
|
|||
{
|
||||
char stmp[64];
|
||||
|
||||
isSep = rw->isSep;
|
||||
|
||||
if ( (rw->addr >= 0) && !rw->isSep )
|
||||
{
|
||||
sprintf( stmp, "%04X", rw->addr );
|
||||
addrEntry->setText( tr(stmp) );
|
||||
}
|
||||
else
|
||||
{
|
||||
addrEntry->setEnabled(false);
|
||||
}
|
||||
notesEntry->setText( tr(rw->name.c_str()) );
|
||||
signedTypeBtn->setChecked( !rw->type );
|
||||
unsignedTypeBtn->setChecked( rw->type );
|
||||
|
@ -519,10 +791,10 @@ void RamWatchDialog_t::openWatchEditWindow(int idx)
|
|||
size = 1;
|
||||
}
|
||||
|
||||
if ( rw == NULL )
|
||||
if ( (rw == NULL) || mode )
|
||||
{
|
||||
ramWatchList.add_entry( notesEntry->text().toStdString().c_str(),
|
||||
addr, unsignedTypeBtn->isChecked(), size );
|
||||
addr, unsignedTypeBtn->isChecked(), size, isSep);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -530,17 +802,14 @@ void RamWatchDialog_t::openWatchEditWindow(int idx)
|
|||
rw->type = unsignedTypeBtn->isChecked();
|
||||
rw->addr = addr;
|
||||
rw->size = size;
|
||||
rw->isSep = isSep;
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::newWatchClicked(void)
|
||||
{
|
||||
openWatchEditWindow();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::editWatchClicked(void)
|
||||
void RamWatchDialog_t::addCheatClicked(void)
|
||||
{
|
||||
ramWatch_t *rw = NULL;
|
||||
QTreeWidgetItem *item;
|
||||
|
||||
item = tree->currentItem();
|
||||
|
@ -552,7 +821,72 @@ void RamWatchDialog_t::editWatchClicked(void)
|
|||
}
|
||||
int row = tree->indexOfTopLevelItem(item);
|
||||
|
||||
openWatchEditWindow(row);
|
||||
if ( row >= 0 )
|
||||
{
|
||||
rw = ramWatchList.getIndex(row);
|
||||
}
|
||||
|
||||
if ( rw != NULL )
|
||||
{
|
||||
FCEUI_AddCheat( rw->name.c_str(), rw->addr, GetMem(rw->addr), -1, 1 );
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::newWatchClicked(void)
|
||||
{
|
||||
openWatchEditWindow();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::sepWatchClicked(void)
|
||||
{
|
||||
ramWatch_t rw;
|
||||
|
||||
rw.addr = -1;
|
||||
rw.isSep = 1;
|
||||
|
||||
openWatchEditWindow( &rw, 1 );
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::editWatchClicked(void)
|
||||
{
|
||||
ramWatch_t *rw = NULL;
|
||||
QTreeWidgetItem *item;
|
||||
|
||||
item = tree->currentItem();
|
||||
|
||||
if ( item == NULL )
|
||||
{
|
||||
printf( "No Item Selected\n");
|
||||
return;
|
||||
}
|
||||
int row = tree->indexOfTopLevelItem(item);
|
||||
|
||||
if ( row >= 0 )
|
||||
{
|
||||
rw = ramWatchList.getIndex(row);
|
||||
}
|
||||
openWatchEditWindow(rw, 0);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::dupWatchClicked(void)
|
||||
{
|
||||
ramWatch_t *rw = NULL;
|
||||
QTreeWidgetItem *item;
|
||||
|
||||
item = tree->currentItem();
|
||||
|
||||
if ( item == NULL )
|
||||
{
|
||||
printf( "No Item Selected\n");
|
||||
return;
|
||||
}
|
||||
int row = tree->indexOfTopLevelItem(item);
|
||||
|
||||
if ( row >= 0 )
|
||||
{
|
||||
rw = ramWatchList.getIndex(row);
|
||||
}
|
||||
openWatchEditWindow(rw, 1);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::removeWatchClicked(void)
|
||||
|
@ -576,7 +910,14 @@ void RamWatchDialog_t::removeWatchClicked(void)
|
|||
|
||||
if ( row > 0 )
|
||||
{
|
||||
item = tree->topLevelItem( row-1 );
|
||||
if ( row >= tree->topLevelItemCount() )
|
||||
{
|
||||
item = tree->topLevelItem( tree->topLevelItemCount()-1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
item = tree->topLevelItem( row );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -605,6 +946,7 @@ void RamWatchDialog_t::moveWatchUpClicked(void)
|
|||
|
||||
if ( row > 0 )
|
||||
{
|
||||
ramWatchList.moveIndexUp(row);
|
||||
item = tree->topLevelItem( row-1 );
|
||||
|
||||
if ( item )
|
||||
|
@ -630,6 +972,8 @@ void RamWatchDialog_t::moveWatchDownClicked(void)
|
|||
|
||||
if ( row < (tree->topLevelItemCount()-1) )
|
||||
{
|
||||
ramWatchList.moveIndexDown(row);
|
||||
|
||||
item = tree->topLevelItem( row+1 );
|
||||
|
||||
if ( item )
|
||||
|
@ -640,21 +984,24 @@ void RamWatchDialog_t::moveWatchDownClicked(void)
|
|||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void RamWatchDialog_t::saveWatchFile (const char *filename)
|
||||
void RamWatchDialog_t::saveWatchFile (const char *filename, int append )
|
||||
{
|
||||
int i;
|
||||
FILE *fp;
|
||||
const char *c;
|
||||
const char *c, *mode;
|
||||
std::list < ramWatch_t * >::iterator it;
|
||||
ramWatch_t *rw;
|
||||
|
||||
fp = fopen (filename, "w");
|
||||
mode = (append) ? "a" : "w";
|
||||
|
||||
fp = fopen (filename, mode);
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf ("Error: Failed to open file: %s\n", filename);
|
||||
return;
|
||||
}
|
||||
saveFileName.assign( filename );
|
||||
|
||||
for (it = ramWatchList.ls.begin (); it != ramWatchList.ls.end (); it++)
|
||||
{
|
||||
|
@ -662,8 +1009,15 @@ void RamWatchDialog_t::saveWatchFile (const char *filename)
|
|||
|
||||
c = rw->name.c_str ();
|
||||
|
||||
if ( rw->isSep )
|
||||
{
|
||||
fprintf (fp, "0x%04x %c%c ", rw->addr, 'S', 'S' );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (fp, "0x%04x %c%i ", rw->addr, rw->type ? 'U' : 'S',
|
||||
rw->size);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
fprintf (fp, "\"");
|
||||
|
@ -688,7 +1042,7 @@ void RamWatchDialog_t::saveWatchFile (const char *filename)
|
|||
void RamWatchDialog_t::loadWatchFile (const char *filename)
|
||||
{
|
||||
FILE *fp;
|
||||
int i, j, a, t, s, literal;
|
||||
int i, j, a, t, s, isSep, literal;
|
||||
char line[512], stmp[512];
|
||||
ramWatch_t *rw;
|
||||
|
||||
|
@ -699,12 +1053,14 @@ void RamWatchDialog_t::loadWatchFile (const char *filename)
|
|||
printf ("Error: Failed to open file: %s\n", filename);
|
||||
return;
|
||||
}
|
||||
saveFileName.assign( filename );
|
||||
|
||||
while (fgets (line, sizeof (line) - 1, fp) != NULL)
|
||||
{
|
||||
a = -1;
|
||||
t = -1;
|
||||
s = -1;
|
||||
isSep = 0;
|
||||
// Check for Comments
|
||||
i = 0;
|
||||
while (line[i] != 0)
|
||||
|
@ -775,12 +1131,19 @@ void RamWatchDialog_t::loadWatchFile (const char *filename)
|
|||
printf ("Error: Invalid RAM Watch Byte Type: %c", t);
|
||||
continue;
|
||||
}
|
||||
if (!isdigit (s))
|
||||
if (!isdigit (s) && (s != 'S'))
|
||||
{
|
||||
printf ("Error: Invalid RAM Watch Byte Size: %c", s);
|
||||
continue;
|
||||
}
|
||||
if (s == 'S')
|
||||
{
|
||||
isSep = 1; s = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = s - '0';
|
||||
}
|
||||
|
||||
if ((s != 1) && (s != 2) && (s != 4))
|
||||
{
|
||||
|
@ -826,13 +1189,12 @@ void RamWatchDialog_t::loadWatchFile (const char *filename)
|
|||
rw->addr = a;
|
||||
rw->type = (t == 'U') ? 1 : 0;
|
||||
rw->size = s;
|
||||
rw->isSep = isSep;
|
||||
rw->name.assign (stmp);
|
||||
|
||||
ramWatchList.ls.push_back (rw);
|
||||
}
|
||||
|
||||
fclose (fp);
|
||||
|
||||
//showAllRamWatchResults (1);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -25,6 +25,7 @@ struct ramWatch_t
|
|||
int addr;
|
||||
int type;
|
||||
int size;
|
||||
int isSep;
|
||||
|
||||
union
|
||||
{
|
||||
|
@ -41,6 +42,7 @@ struct ramWatch_t
|
|||
addr = 0;
|
||||
type = 0;
|
||||
size = 0;
|
||||
isSep = 0;
|
||||
val.u32 = 0;
|
||||
};
|
||||
|
||||
|
@ -76,7 +78,21 @@ struct ramWatchList_t
|
|||
return ls.size ();
|
||||
};
|
||||
|
||||
void add_entry (const char *name, int addr, int type, int size)
|
||||
void clear(void)
|
||||
{
|
||||
ramWatch_t *rw;
|
||||
|
||||
while (!ls.empty ())
|
||||
{
|
||||
rw = ls.front ();
|
||||
|
||||
delete rw;
|
||||
|
||||
ls.pop_front ();
|
||||
}
|
||||
}
|
||||
|
||||
void add_entry (const char *name, int addr, int type, int size, int isSep = 0)
|
||||
{
|
||||
ramWatch_t *rw = new ramWatch_t;
|
||||
|
||||
|
@ -84,6 +100,7 @@ struct ramWatchList_t
|
|||
rw->addr = addr;
|
||||
rw->type = type;
|
||||
rw->size = size;
|
||||
rw->isSep = isSep;
|
||||
ls.push_back (rw);
|
||||
}
|
||||
|
||||
|
@ -133,6 +150,51 @@ struct ramWatchList_t
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int moveIndexUp(size_t idx)
|
||||
{
|
||||
size_t i = 0;
|
||||
std::list < ramWatch_t * >::iterator it, lp;
|
||||
|
||||
lp = ls.begin();
|
||||
|
||||
for (it = ls.begin (); it != ls.end (); it++)
|
||||
{
|
||||
if (i == idx)
|
||||
{
|
||||
ls.insert( lp, *it );
|
||||
ls.erase (it);
|
||||
return 0;
|
||||
}
|
||||
lp = it;
|
||||
|
||||
i++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int moveIndexDown(size_t idx)
|
||||
{
|
||||
size_t i = 0;
|
||||
std::list < ramWatch_t * >::iterator it, next;
|
||||
|
||||
for (it = ls.begin (); it != ls.end (); it++)
|
||||
{
|
||||
if (i == idx)
|
||||
{
|
||||
next = it; next++;
|
||||
|
||||
if ( next != ls.end() )
|
||||
{
|
||||
ls.insert( it, *next );
|
||||
ls.erase (next);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
class RamWatchDialog_t : public QDialog
|
||||
|
@ -146,7 +208,7 @@ class RamWatchDialog_t : public QDialog
|
|||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void loadWatchFile (const char *filename);
|
||||
void saveWatchFile (const char *filename);
|
||||
void saveWatchFile (const char *filename, int append = 0);
|
||||
|
||||
QFont font;
|
||||
QTreeWidget *tree;
|
||||
|
@ -160,19 +222,29 @@ class RamWatchDialog_t : public QDialog
|
|||
QPushButton *cht_btn;
|
||||
QTimer *updateTimer;
|
||||
|
||||
ramWatchList_t ramWatchList;
|
||||
std::string saveFileName;
|
||||
|
||||
//ramWatchList_t ramWatchList;
|
||||
|
||||
int fontCharWidth;
|
||||
|
||||
private:
|
||||
void updateRamWatchDisplay(void);
|
||||
void openWatchEditWindow( int idx = -1);
|
||||
void openWatchEditWindow( ramWatch_t *rw = NULL, int mode = 0);
|
||||
|
||||
public slots:
|
||||
void closeWindow(void);
|
||||
private slots:
|
||||
void newListCB(void);
|
||||
void openListCB(void);
|
||||
void saveListCB(void);
|
||||
void saveListAs(void);
|
||||
void appendListCB(void);
|
||||
void periodicUpdate(void);
|
||||
void addCheatClicked(void);
|
||||
void newWatchClicked(void);
|
||||
void sepWatchClicked(void);
|
||||
void dupWatchClicked(void);
|
||||
void editWatchClicked(void);
|
||||
void removeWatchClicked(void);
|
||||
void moveWatchUpClicked(void);
|
||||
|
@ -180,3 +252,5 @@ class RamWatchDialog_t : public QDialog
|
|||
void watchClicked( QTreeWidgetItem *item, int column);
|
||||
|
||||
};
|
||||
|
||||
extern ramWatchList_t ramWatchList;
|
||||
|
|
|
@ -659,6 +659,9 @@ int traceRecord_t::convToText( char *txt )
|
|||
char stmp[128];
|
||||
char str_axystate[32], str_procstatus[32];
|
||||
|
||||
str_axystate[0] = 0;
|
||||
str_procstatus[0] = 0;
|
||||
|
||||
txt[0] = 0;
|
||||
if ( opSize == 0 )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue