Updated Qt PPU debugger display.

This commit is contained in:
mjbudd77 2021-08-01 20:16:42 -04:00
parent f45ba2f8af
commit 77b2f1be33
3 changed files with 176 additions and 100 deletions

View File

@ -101,7 +101,6 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent)
{ {
QMenuBar *menuBar; QMenuBar *menuBar;
QSettings settings; QSettings settings;
QFont cpuFont;
std::string fontString; std::string fontString;
g_config->getOption("SDL.DebuggerCpuStatusFont", &fontString); g_config->getOption("SDL.DebuggerCpuStatusFont", &fontString);
@ -1080,106 +1079,126 @@ void ConsoleDebugger::buildCpuListDisplay(void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ConsoleDebugger::buildPpuListDisplay(void) void ConsoleDebugger::buildPpuListDisplay(void)
{ {
QVBoxLayout *vbox, *vbox1; QFontMetrics fm(cpuFont);
QHBoxLayout /**hbox,*/ *hbox1; QVBoxLayout *vbox1;
QGridLayout *grid, *grid1; //QHBoxLayout *hbox;
QGroupBox *ctlFrame; QGridLayout *grid;
QLabel *bgAddrLbl, *sprAddrLbl; QLabel *ppuCtrlLbl, *ppuMaskLbl, *ppuStatLbl, *ppuAddrLbl,
QFont lblFont; *oamAddrLbl, *ppuLineLbl, *ppuPixLbl;
int fontCharWidth;
fontCharWidth = fm.averageCharWidth();
ppuStatContainerWidget = new QWidget(this); ppuStatContainerWidget = new QWidget(this);
ppuStatContainerWidget->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ); ppuStatContainerWidget->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum );
vbox = new QVBoxLayout(); vbox1 = new QVBoxLayout();
hbox1 = new QHBoxLayout();
ppuFrame = new QFrame(); ppuFrame = new QFrame();
ppuLbl = new QLabel( tr("PPU:") );
spriteLbl = new QLabel( tr("Sprite:") );
scanLineLbl = new QLabel( tr("Scanline:") );
pixLbl = new QLabel( tr("Pixel:") );
ppuFrame->setObjectName( tr("debuggerStatusPPU") );
hbox1->addLayout( vbox );
vbox->addWidget( ppuLbl );
vbox->addWidget( spriteLbl );
vbox->addWidget( scanLineLbl );
vbox->addWidget( pixLbl );
bgAddrLbl = new QLabel( tr("BG Addr") );
sprAddrLbl = new QLabel( tr("Spr Addr") );
ctlFrame = new QGroupBox( tr("Control / Mask") );
grid1 = new QGridLayout();
grid = new QGridLayout(); grid = new QGridLayout();
hbox1->addWidget( ctlFrame ); ppuDataGrid = grid;
ctlFrame->setLayout( grid1 ); ppuFrame->setObjectName( tr("debuggerStatusPPU") );
//ppuBgAddr = new QLineEdit(); ppuCtrlLbl = new QLabel( tr("PPUCTRL:") );
ppuBgAddr = new ppuCtrlRegDpy(); ppuMaskLbl = new QLabel( tr("PPUMASK:") );
ppuSprAddr = new QLineEdit(); ppuStatLbl = new QLabel( tr("PPUSTAT:") );
ppuAddrLbl = new QLabel( tr("PPUADDR:") );
oamAddrLbl = new QLabel( tr("OAMADDR:") );
ppuLineLbl = new QLabel( tr("Scanline:") );
ppuPixLbl = new QLabel( tr("Pixel:") );
grid->addWidget( bgAddrLbl, 0, 0 ); ppuCtrlLbl->setToolTip( tr("PPU Control Register, Address $2000") );
grid->addWidget( sprAddrLbl, 1, 0 ); ppuMaskLbl->setToolTip( tr("PPU Mask Register, Address $2001") );
grid->addWidget( ppuBgAddr, 0, 1 ); ppuStatLbl->setToolTip( tr("PPU Status Register, Address $2002") );
grid->addWidget( ppuSprAddr, 1, 1 ); oamAddrLbl->setToolTip( tr("OAM Address Register, Address $2003") );
ppuAddrLbl->setToolTip( tr("PPU Address Register, Address $2006") );
ppuLineLbl->setToolTip( tr("PPU Current Scanline being processed") );
ppuPixLbl->setToolTip( tr("PPU Current Pixel being processed") );
grid1->addLayout( grid, 0, 0, 3, 1 ); ppuCtrlReg = new ppuCtrlRegDpy();
ppuMaskReg = new ppuCtrlRegDpy();
ppuStatReg = new ppuCtrlRegDpy();
ppuAddrDsp = new QLineEdit();
oamAddrDsp = new QLineEdit();
ppuScanLineDsp = new QLineEdit();
ppuPixelDsp = new QLineEdit();
ppuScrollX = new QLineEdit();
ppuScrollY = new QLineEdit();
bgEnabled_cbox = new QCheckBox( tr("BG Enabled") ); ppuAddrDsp->setReadOnly(true);
sprites_cbox = new QCheckBox( tr("Sprites Enabled") ); oamAddrDsp->setReadOnly(true);
drawLeftBg_cbox = new QCheckBox( tr("Draw Left BG (8px)") ); ppuScanLineDsp->setReadOnly(true);
drawLeftFg_cbox = new QCheckBox( tr("Draw Left Sprites (8px)") ); ppuPixelDsp->setReadOnly(true);
vwrite_cbox = new QCheckBox( tr("Vertical Write") ); ppuScrollX->setReadOnly(true);
nmiBlank_cbox = new QCheckBox( tr("NMI on vBlank") ); ppuScrollY->setReadOnly(true);
sprite8x16_cbox = new QCheckBox( tr("8x16 Sprites") );
grayscale_cbox = new QCheckBox( tr("Grayscale") );
iRed_cbox = new QCheckBox( tr("Intensify Red") );
iGrn_cbox = new QCheckBox( tr("Intensify Green") );
iBlu_cbox = new QCheckBox( tr("Intensify Blue") );
grid1->addWidget( bgEnabled_cbox , 3, 0 ); ppuCtrlReg->setFont( cpuFont );
grid1->addWidget( sprites_cbox , 4, 0 ); ppuMaskReg->setFont( cpuFont );
grid1->addWidget( drawLeftBg_cbox, 5, 0 ); ppuStatReg->setFont( cpuFont );
grid1->addWidget( drawLeftFg_cbox, 6, 0 ); ppuAddrDsp->setFont( cpuFont );
oamAddrDsp->setFont( cpuFont );
ppuScanLineDsp->setFont( cpuFont );
ppuPixelDsp->setFont( cpuFont );
ppuScrollX->setFont( cpuFont );
ppuScrollY->setFont( cpuFont );
grid1->addWidget( vwrite_cbox , 0, 1 ); ppuCtrlReg->setMinimumWidth( 4 * fontCharWidth );
grid1->addWidget( nmiBlank_cbox , 1, 1 ); ppuMaskReg->setMinimumWidth( 4 * fontCharWidth );
grid1->addWidget( sprite8x16_cbox, 2, 1 ); ppuStatReg->setMinimumWidth( 4 * fontCharWidth );
grid1->addWidget( grayscale_cbox , 3, 1 ); ppuAddrDsp->setMinimumWidth( 7 * fontCharWidth );
grid1->addWidget( iRed_cbox , 4, 1 ); oamAddrDsp->setMinimumWidth( 4 * fontCharWidth );
grid1->addWidget( iGrn_cbox , 5, 1 ); ppuScanLineDsp->setMinimumWidth( 4 * fontCharWidth );
grid1->addWidget( iBlu_cbox , 6, 1 ); ppuPixelDsp->setMinimumWidth( 4 * fontCharWidth );
ppuScrollX->setMinimumWidth( 4 * fontCharWidth );
ppuScrollY->setMinimumWidth( 4 * fontCharWidth );
ppuStatContainerWidget->setLayout( hbox1 ); ppuCtrlReg->setMaximumWidth( 4 * fontCharWidth );
ppuMaskReg->setMaximumWidth( 4 * fontCharWidth );
ppuStatReg->setMaximumWidth( 4 * fontCharWidth );
ppuAddrDsp->setMaximumWidth( 7 * fontCharWidth );
oamAddrDsp->setMaximumWidth( 4 * fontCharWidth );
ppuScanLineDsp->setMaximumWidth( 4 * fontCharWidth );
ppuPixelDsp->setMaximumWidth( 4 * fontCharWidth );
ppuScrollX->setMaximumWidth( 8 * fontCharWidth );
ppuScrollY->setMaximumWidth( 8 * fontCharWidth );
grid->setColumnMinimumWidth(1, 8 * fontCharWidth);
grid->setColumnMinimumWidth(3, 8 * fontCharWidth);
grid->addWidget( ppuCtrlLbl, 0, 0 );
grid->addWidget( ppuCtrlReg, 0, 1 );
grid->addWidget( ppuMaskLbl, 0, 2 );
grid->addWidget( ppuMaskReg, 0, 3 );
grid->addWidget( ppuStatLbl, 0, 4 );
grid->addWidget( ppuStatReg, 0, 5 );
grid->addWidget( oamAddrLbl, 1, 0 );
grid->addWidget( oamAddrDsp, 1, 1 );
grid->addWidget( ppuAddrLbl, 1, 2 );
grid->addWidget( ppuAddrDsp, 1, 3 );
grid->addWidget( ppuLineLbl, 2, 0 );
grid->addWidget( ppuScanLineDsp, 2, 1 );
grid->addWidget( ppuPixLbl, 2, 2 );
grid->addWidget( ppuPixelDsp, 2, 3 );
grid->addWidget( new QLabel( tr("X Scroll:") ), 3, 0 );
grid->addWidget( ppuScrollX, 3, 1 );
grid->addWidget( new QLabel( tr("Y Scroll:") ), 3, 2 );
grid->addWidget( ppuScrollY, 3, 3 );
ppuStatContainerWidget->setLayout( grid );
vbox1 = new QVBoxLayout(); vbox1 = new QVBoxLayout();
vbox1->addWidget( ppuStatContainerWidget, 1 ); vbox1->addWidget( ppuStatContainerWidget, 1 );
vbox1->addStretch( 10 ); vbox1->addStretch( 10 );
ppuFrame->setLayout( vbox1 ); ppuFrame->setLayout( vbox1 );
lblFont = bgAddrLbl->font();
printf("Point Size: %i \n", lblFont.pointSize() );
lblFont.setPointSize(9);
bgAddrLbl->setFont( lblFont );
sprAddrLbl->setFont( lblFont );
bgEnabled_cbox->setFont( lblFont );
sprites_cbox->setFont( lblFont );
drawLeftBg_cbox->setFont( lblFont );
drawLeftFg_cbox->setFont( lblFont );
vwrite_cbox->setFont( lblFont );
nmiBlank_cbox->setFont( lblFont );
sprite8x16_cbox->setFont( lblFont );
grayscale_cbox->setFont( lblFont );
iRed_cbox->setFont( lblFont );
iGrn_cbox->setFont( lblFont );
iBlu_cbox->setFont( lblFont );
//printf("Grid vspc:%i \n", grid1->verticalSpacing() );
grid1->setVerticalSpacing( grid1->verticalSpacing() / 2 );
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ConsoleDebugger::buildBpListDisplay(void) void ConsoleDebugger::buildBpListDisplay(void)
@ -1528,6 +1547,48 @@ void ConsoleDebugger::setCpuStatusFont( const QFont &font )
cpuInstrsVal->setMinimumWidth( 24 * fontCharWidth ); cpuInstrsVal->setMinimumWidth( 24 * fontCharWidth );
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ConsoleDebugger::setPpuStatusFont( const QFont &font )
{
QFontMetrics fm(font);
int fontCharWidth;
fontCharWidth = fm.averageCharWidth();
ppuCtrlReg->setFont( font );
ppuMaskReg->setFont( font );
ppuStatReg->setFont( font );
ppuAddrDsp->setFont( font );
oamAddrDsp->setFont( font );
ppuScanLineDsp->setFont( font );
ppuPixelDsp->setFont( font );
ppuScrollX->setFont( font );
ppuScrollY->setFont( font );
ppuCtrlReg->setMinimumWidth( 4 * fontCharWidth );
ppuMaskReg->setMinimumWidth( 4 * fontCharWidth );
ppuStatReg->setMinimumWidth( 4 * fontCharWidth );
ppuAddrDsp->setMinimumWidth( 7 * fontCharWidth );
oamAddrDsp->setMinimumWidth( 4 * fontCharWidth );
ppuScanLineDsp->setMinimumWidth( 4 * fontCharWidth );
ppuPixelDsp->setMinimumWidth( 4 * fontCharWidth );
ppuScrollX->setMinimumWidth( 4 * fontCharWidth );
ppuScrollY->setMinimumWidth( 4 * fontCharWidth );
ppuCtrlReg->setMaximumWidth( 4 * fontCharWidth );
ppuMaskReg->setMaximumWidth( 4 * fontCharWidth );
ppuStatReg->setMaximumWidth( 4 * fontCharWidth );
ppuAddrDsp->setMaximumWidth( 7 * fontCharWidth );
oamAddrDsp->setMaximumWidth( 4 * fontCharWidth );
ppuScanLineDsp->setMaximumWidth( 4 * fontCharWidth );
ppuPixelDsp->setMaximumWidth( 4 * fontCharWidth );
ppuScrollX->setMaximumWidth( 8 * fontCharWidth );
ppuScrollY->setMaximumWidth( 8 * fontCharWidth );
ppuDataGrid->setColumnMinimumWidth(1, 8 * fontCharWidth);
ppuDataGrid->setColumnMinimumWidth(3, 8 * fontCharWidth);
}
//----------------------------------------------------------------------------
void ConsoleDebugger::bpItemClicked( QTreeWidgetItem *item, int column) void ConsoleDebugger::bpItemClicked( QTreeWidgetItem *item, int column)
{ {
int row = bpTree->indexOfTopLevelItem(item); int row = bpTree->indexOfTopLevelItem(item);
@ -2456,7 +2517,9 @@ void ConsoleDebugger::changeCpuFontCB(void)
if ( ok ) if ( ok )
{ {
cpuFont = selFont;
setCpuStatusFont( selFont ); setCpuStatusFont( selFont );
setPpuStatusFont( selFont );
//printf("Font Changed to: '%s'\n", font.toString().toStdString().c_str() ); //printf("Font Changed to: '%s'\n", font.toString().toStdString().c_str() );
@ -3762,11 +3825,20 @@ void ConsoleDebugger::updateRegisterView(void)
cpuInstrsVal->setText( tr(stmp) ); cpuInstrsVal->setText( tr(stmp) );
// PPU Labels // PPU Labels
sprintf(stmp, "PPU: 0x%04X", (int)FCEUPPU_PeekAddress()); sprintf(stmp, "$%02X", PPU[0] );
ppuLbl->setText( tr(stmp) ); ppuCtrlReg->setText( tr(stmp) );
sprintf(stmp, "Sprite: 0x%02X", PPU[3] ); sprintf(stmp, "$%02X", PPU[1] );
spriteLbl->setText( tr(stmp) ); ppuMaskReg->setText( tr(stmp) );
sprintf(stmp, "$%02X", PPU[2] );
ppuStatReg->setText( tr(stmp) );
sprintf(stmp, "$%04X", (int)FCEUPPU_PeekAddress());
ppuAddrDsp->setText( tr(stmp) );
sprintf(stmp, "$%02X", PPU[3] );
oamAddrDsp->setText( tr(stmp) );
extern int linestartts; extern int linestartts;
#define GETLASTPIXEL (PAL?((timestamp*48-linestartts)/15) : ((timestamp*48-linestartts)/16) ) #define GETLASTPIXEL (PAL?((timestamp*48-linestartts)/15) : ((timestamp*48-linestartts)/16) )
@ -3806,12 +3878,18 @@ void ConsoleDebugger::updateRegisterView(void)
sprintf(str2,"%d",newppu_get_dot()); sprintf(str2,"%d",newppu_get_dot());
} }
sprintf( stmp, "Scanline: %s", str ); sprintf( stmp, "%s", str );
scanLineLbl->setText( tr(stmp) ); ppuScanLineDsp->setText( tr(stmp) );
sprintf( stmp, "Pixel: %s", str2 ); sprintf( stmp, "%s", str2 );
pixLbl->setText( tr(stmp) ); ppuPixelDsp->setText( tr(stmp) );
int ppuScrollPosX, ppuScrollPosY;
ppu_getScroll( ppuScrollPosX, ppuScrollPosY);
sprintf( stmp, "%i", ppuScrollPosX );
ppuScrollX->setText( tr(stmp) );
sprintf( stmp, "%i", ppuScrollPosY );
ppuScrollY->setText( tr(stmp) );
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ConsoleDebugger::updateWindowData(void) void ConsoleDebugger::updateWindowData(void)

View File

@ -432,6 +432,7 @@ class ConsoleDebugger : public QDialog
QLabel *asmLineSelLbl; QLabel *asmLineSelLbl;
void setCpuStatusFont( const QFont &font ); void setCpuStatusFont( const QFont &font );
void setPpuStatusFont( const QFont &font );
protected: protected:
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
//void keyPressEvent(QKeyEvent *event) override; //void keyPressEvent(QKeyEvent *event) override;
@ -476,17 +477,16 @@ class ConsoleDebugger : public QDialog
QCheckBox *Z_chkbox; QCheckBox *Z_chkbox;
QCheckBox *C_chkbox; QCheckBox *C_chkbox;
QCheckBox *bgEnabled_cbox; ppuCtrlRegDpy *ppuCtrlReg;
QCheckBox *sprites_cbox; ppuCtrlRegDpy *ppuMaskReg;
QCheckBox *drawLeftBg_cbox; ppuCtrlRegDpy *ppuStatReg;
QCheckBox *drawLeftFg_cbox; QLineEdit *ppuAddrDsp;
QCheckBox *vwrite_cbox; QLineEdit *oamAddrDsp;
QCheckBox *nmiBlank_cbox; QLineEdit *ppuScanLineDsp;
QCheckBox *sprite8x16_cbox; QLineEdit *ppuPixelDsp;
QCheckBox *grayscale_cbox; QLineEdit *ppuScrollX;
QCheckBox *iRed_cbox; QLineEdit *ppuScrollY;
QCheckBox *iGrn_cbox; QGridLayout *ppuDataGrid;
QCheckBox *iBlu_cbox;
QAction *brkOnCycleExcAct; QAction *brkOnCycleExcAct;
QAction *brkOnInstrExcAct; QAction *brkOnInstrExcAct;
@ -497,14 +497,11 @@ class ConsoleDebugger : public QDialog
QWidget *bmTreeContainerWidget; QWidget *bmTreeContainerWidget;
QWidget *ppuStatContainerWidget; QWidget *ppuStatContainerWidget;
QLabel *emuStatLbl; QLabel *emuStatLbl;
QLabel *ppuLbl;
QLabel *spriteLbl;
QLabel *scanLineLbl;
QLabel *pixLbl;
QLabel *cpuCyclesLbl1; QLabel *cpuCyclesLbl1;
QLabel *cpuInstrsLbl1; QLabel *cpuInstrsLbl1;
QTimer *periodicTimer; QTimer *periodicTimer;
QFont font; QFont font;
QFont cpuFont;
QVBoxLayout *mainLayoutv; QVBoxLayout *mainLayoutv;
QSplitter *mainLayouth; QSplitter *mainLayouth;

View File

@ -369,6 +369,7 @@ void consoleWin_t::winScreenChanged(QScreen *scr)
{ {
return; return;
} }
//printf("Screen Refresh Rate: %f\n", scr->refreshRate() );
//printf("Screen Changed: %p\n", scr ); //printf("Screen Changed: %p\n", scr );
if ( viewport_GL != NULL ) if ( viewport_GL != NULL )