Added breakpoint editor address validity checking to Qt GUI.
This commit is contained in:
parent
46054d190c
commit
da7c7761a2
|
@ -19,10 +19,15 @@ unsigned int debuggerPageSize = 14;
|
|||
int vblankScanLines = 0; //Used to calculate scanlines 240-261 (vblank)
|
||||
int vblankPixel = 0; //Used to calculate the pixels in vblank
|
||||
|
||||
int offsetStringToInt(unsigned int type, const char* offsetBuffer)
|
||||
int offsetStringToInt(unsigned int type, const char* offsetBuffer, bool *conversionOk)
|
||||
{
|
||||
int offset = -1;
|
||||
|
||||
if (conversionOk)
|
||||
{
|
||||
*conversionOk = false;
|
||||
}
|
||||
|
||||
if (sscanf(offsetBuffer,"%7X",(unsigned int *)&offset) == EOF)
|
||||
{
|
||||
return -1;
|
||||
|
@ -30,14 +35,26 @@ int offsetStringToInt(unsigned int type, const char* offsetBuffer)
|
|||
|
||||
if (type & BT_P)
|
||||
{
|
||||
if (conversionOk)
|
||||
{
|
||||
*conversionOk = (offset >= 0) && (offset < 0x4000);
|
||||
}
|
||||
return offset & 0x3FFF;
|
||||
}
|
||||
else if (type & BT_S)
|
||||
{
|
||||
if (conversionOk)
|
||||
{
|
||||
*conversionOk = (offset >= 0) && (offset < 0x100);
|
||||
}
|
||||
return offset & 0x00FF;
|
||||
}
|
||||
else if (type & BT_R)
|
||||
{
|
||||
if (conversionOk)
|
||||
{
|
||||
*conversionOk = (offset >= 0);
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
else // BT_C
|
||||
|
@ -46,6 +63,10 @@ int offsetStringToInt(unsigned int type, const char* offsetBuffer)
|
|||
|
||||
if (sym)
|
||||
{
|
||||
if (conversionOk)
|
||||
{
|
||||
*conversionOk = true;
|
||||
}
|
||||
return sym->offset() & 0xFFFF;
|
||||
}
|
||||
|
||||
|
@ -56,21 +77,26 @@ int offsetStringToInt(unsigned int type, const char* offsetBuffer)
|
|||
type = GameInfo->type;
|
||||
}
|
||||
if (type == GIT_NSF) { //NSF Breakpoint keywords
|
||||
if (strcmp(offsetBuffer,"LOAD") == 0) return (NSFHeader.LoadAddressLow | (NSFHeader.LoadAddressHigh<<8));
|
||||
if (strcmp(offsetBuffer,"INIT") == 0) return (NSFHeader.InitAddressLow | (NSFHeader.InitAddressHigh<<8));
|
||||
if (strcmp(offsetBuffer,"PLAY") == 0) return (NSFHeader.PlayAddressLow | (NSFHeader.PlayAddressHigh<<8));
|
||||
if (strcmp(offsetBuffer,"LOAD") == 0) offset = (NSFHeader.LoadAddressLow | (NSFHeader.LoadAddressHigh<<8));
|
||||
else if (strcmp(offsetBuffer,"INIT") == 0) offset = (NSFHeader.InitAddressLow | (NSFHeader.InitAddressHigh<<8));
|
||||
else if (strcmp(offsetBuffer,"PLAY") == 0) offset = (NSFHeader.PlayAddressLow | (NSFHeader.PlayAddressHigh<<8));
|
||||
}
|
||||
else if (type == GIT_FDS) { //FDS Breakpoint keywords
|
||||
if (strcmp(offsetBuffer,"NMI1") == 0) return (GetMem(0xDFF6) | (GetMem(0xDFF7)<<8));
|
||||
if (strcmp(offsetBuffer,"NMI2") == 0) return (GetMem(0xDFF8) | (GetMem(0xDFF9)<<8));
|
||||
if (strcmp(offsetBuffer,"NMI3") == 0) return (GetMem(0xDFFA) | (GetMem(0xDFFB)<<8));
|
||||
if (strcmp(offsetBuffer,"RST") == 0) return (GetMem(0xDFFC) | (GetMem(0xDFFD)<<8));
|
||||
if ((strcmp(offsetBuffer,"IRQ") == 0) || (strcmp(offsetBuffer,"BRK") == 0)) return (GetMem(0xDFFE) | (GetMem(0xDFFF)<<8));
|
||||
if (strcmp(offsetBuffer,"NMI1") == 0) offset = (GetMem(0xDFF6) | (GetMem(0xDFF7)<<8));
|
||||
else if (strcmp(offsetBuffer,"NMI2") == 0) offset = (GetMem(0xDFF8) | (GetMem(0xDFF9)<<8));
|
||||
else if (strcmp(offsetBuffer,"NMI3") == 0) offset = (GetMem(0xDFFA) | (GetMem(0xDFFB)<<8));
|
||||
else if (strcmp(offsetBuffer,"RST") == 0) offset = (GetMem(0xDFFC) | (GetMem(0xDFFD)<<8));
|
||||
else if ((strcmp(offsetBuffer,"IRQ") == 0) || (strcmp(offsetBuffer,"BRK") == 0)) offset = (GetMem(0xDFFE) | (GetMem(0xDFFF)<<8));
|
||||
}
|
||||
else { //NES Breakpoint keywords
|
||||
if ((strcmp(offsetBuffer,"NMI") == 0) || (strcmp(offsetBuffer,"VBL") == 0)) return (GetMem(0xFFFA) | (GetMem(0xFFFB)<<8));
|
||||
if (strcmp(offsetBuffer,"RST") == 0) return (GetMem(0xFFFC) | (GetMem(0xFFFD)<<8));
|
||||
if ((strcmp(offsetBuffer,"IRQ") == 0) || (strcmp(offsetBuffer,"BRK") == 0)) return (GetMem(0xFFFE) | (GetMem(0xFFFF)<<8));
|
||||
if ((strcmp(offsetBuffer,"NMI") == 0) || (strcmp(offsetBuffer,"VBL") == 0)) offset = (GetMem(0xFFFA) | (GetMem(0xFFFB)<<8));
|
||||
else if (strcmp(offsetBuffer,"RST") == 0) offset = (GetMem(0xFFFC) | (GetMem(0xFFFD)<<8));
|
||||
else if ((strcmp(offsetBuffer,"IRQ") == 0) || (strcmp(offsetBuffer,"BRK") == 0)) offset = (GetMem(0xFFFE) | (GetMem(0xFFFF)<<8));
|
||||
}
|
||||
|
||||
if (conversionOk)
|
||||
{
|
||||
*conversionOk = (offset >= 0) && (offset < 0x10000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ DebuggerState &FCEUI_Debugger();
|
|||
//#define WRITE_BREAKPOINT 16
|
||||
//#define EXECUTE_BREAKPOINT 32
|
||||
|
||||
int offsetStringToInt(unsigned int type, const char* offsetBuffer);
|
||||
int offsetStringToInt(unsigned int type, const char* offsetBuffer, bool *conversionOk = nullptr);
|
||||
unsigned int NewBreak(const char* name, int start, int end, unsigned int type, const char* condition, unsigned int num, bool enable);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1872,6 +1872,9 @@ DebuggerBreakpointEditor::DebuggerBreakpointEditor(int editIndex, watchpointinfo
|
|||
hbox->addWidget( lbl );
|
||||
hbox->addWidget( addr2 );
|
||||
|
||||
connect( addr1, SIGNAL(textChanged(const QString &)), this, SLOT(addressTextChanged(const QString &)));
|
||||
connect( addr2, SIGNAL(textChanged(const QString &)), this, SLOT(addressTextChanged(const QString &)));
|
||||
|
||||
forbidChkBox = new QCheckBox( tr("Forbid") );
|
||||
hbox->addWidget( forbidChkBox );
|
||||
|
||||
|
@ -1904,6 +1907,11 @@ DebuggerBreakpointEditor::DebuggerBreakpointEditor(int editIndex, watchpointinfo
|
|||
rom_radio = new QRadioButton( tr("ROM") );
|
||||
cpu_radio->setChecked(true);
|
||||
|
||||
connect( cpu_radio, SIGNAL(toggled(bool)), this, SLOT(typeChanged(bool)));
|
||||
connect( ppu_radio, SIGNAL(toggled(bool)), this, SLOT(typeChanged(bool)));
|
||||
connect( oam_radio, SIGNAL(toggled(bool)), this, SLOT(typeChanged(bool)));
|
||||
connect( rom_radio, SIGNAL(toggled(bool)), this, SLOT(typeChanged(bool)));
|
||||
|
||||
gbox->setLayout( hbox );
|
||||
hbox->addWidget( cpu_radio );
|
||||
hbox->addWidget( ppu_radio );
|
||||
|
@ -2069,7 +2077,73 @@ void DebuggerBreakpointEditor::closeWindow(int ret)
|
|||
//----------------------------------------------------------------------------
|
||||
void DebuggerBreakpointEditor::checkDataValid(void)
|
||||
{
|
||||
bool allEntriesValid = condValid;
|
||||
int type = 0;
|
||||
bool startAddrValid = false;
|
||||
bool endAddrValid = false;
|
||||
bool allEntriesValid = false;
|
||||
int addrLowerBound = 0;
|
||||
int addrUpperBound = 0;
|
||||
int start_addr = 0, end_addr = 0;
|
||||
|
||||
if ( cpu_radio->isChecked() )
|
||||
{
|
||||
type |= BT_C;
|
||||
addrLowerBound = 0;
|
||||
addrUpperBound = 0x10000;
|
||||
}
|
||||
else if ( ppu_radio->isChecked() )
|
||||
{
|
||||
type |= BT_P;
|
||||
addrLowerBound = 0;
|
||||
addrUpperBound = 0x4000;
|
||||
}
|
||||
else if ( oam_radio->isChecked() )
|
||||
{
|
||||
type |= BT_S;
|
||||
addrLowerBound = 0;
|
||||
addrUpperBound = 0x100;
|
||||
}
|
||||
else if ( rom_radio->isChecked() )
|
||||
{
|
||||
type |= BT_R;
|
||||
addrLowerBound = 0;
|
||||
addrUpperBound = 0x10000;
|
||||
|
||||
if (GameInfo != nullptr)
|
||||
{
|
||||
addrUpperBound = 16+PRGsize[0]+CHRsize[0];
|
||||
}
|
||||
}
|
||||
|
||||
if ( addr1->text().size() > 0 )
|
||||
{
|
||||
bool convOk = false;
|
||||
|
||||
start_addr = offsetStringToInt( type, addr1->text().toStdString().c_str(), &convOk );
|
||||
|
||||
//printf("StartAddr:0x%04X Upper:0x%04X\n", start_addr, addrUpperBound);
|
||||
startAddrValid = convOk && (start_addr >= addrLowerBound) && (start_addr < addrUpperBound);
|
||||
}
|
||||
else
|
||||
{
|
||||
startAddrValid = false;
|
||||
}
|
||||
|
||||
if ( addr2->text().size() > 0 )
|
||||
{
|
||||
bool convOk = false;
|
||||
|
||||
end_addr = offsetStringToInt( type, addr2->text().toStdString().c_str(), &convOk );
|
||||
|
||||
endAddrValid = convOk && (end_addr >= addrLowerBound) &&
|
||||
(end_addr < addrUpperBound) && (start_addr < end_addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
endAddrValid = true;
|
||||
}
|
||||
|
||||
allEntriesValid = startAddrValid && endAddrValid && condValid;
|
||||
|
||||
okButton->setEnabled( allEntriesValid );
|
||||
|
||||
|
@ -2077,6 +2151,14 @@ void DebuggerBreakpointEditor::checkDataValid(void)
|
|||
{
|
||||
msgLbl->clear();
|
||||
}
|
||||
else if (!startAddrValid)
|
||||
{
|
||||
msgLbl->setText(tr("Start Address Invalid"));
|
||||
}
|
||||
else if (!endAddrValid)
|
||||
{
|
||||
msgLbl->setText(tr("End Address Invalid"));
|
||||
}
|
||||
else if (!condValid)
|
||||
{
|
||||
msgLbl->setText(tr("Condition Invalid"));
|
||||
|
@ -2087,6 +2169,19 @@ void DebuggerBreakpointEditor::checkDataValid(void)
|
|||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void DebuggerBreakpointEditor::typeChanged(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
checkDataValid();
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void DebuggerBreakpointEditor::addressTextChanged(const QString &txt)
|
||||
{
|
||||
checkDataValid();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void DebuggerBreakpointEditor::conditionTextChanged(const QString &txt)
|
||||
{
|
||||
if ( txt.size() > 0 )
|
||||
|
|
|
@ -460,6 +460,8 @@ class DebuggerBreakpointEditor : public QDialog
|
|||
|
||||
private slots:
|
||||
void closeWindow(int ret);
|
||||
void typeChanged(bool checked);
|
||||
void addressTextChanged( const QString &text );
|
||||
void conditionTextChanged( const QString &text );
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue