Added a context menu to the Qt nametable viewer.
This commit is contained in:
parent
27e94f0fad
commit
1958daf6cb
|
@ -38,12 +38,15 @@
|
||||||
#include "../../debug.h"
|
#include "../../debug.h"
|
||||||
#include "../../palette.h"
|
#include "../../palette.h"
|
||||||
|
|
||||||
|
#include "Qt/ConsoleWindow.h"
|
||||||
#include "Qt/ConsoleUtilities.h"
|
#include "Qt/ConsoleUtilities.h"
|
||||||
#include "Qt/NameTableViewer.h"
|
#include "Qt/NameTableViewer.h"
|
||||||
|
#include "Qt/HexEditor.h"
|
||||||
#include "Qt/main.h"
|
#include "Qt/main.h"
|
||||||
#include "Qt/dface.h"
|
#include "Qt/dface.h"
|
||||||
#include "Qt/input.h"
|
#include "Qt/input.h"
|
||||||
#include "Qt/config.h"
|
#include "Qt/config.h"
|
||||||
|
#include "Qt/ppuViewer.h"
|
||||||
#include "Qt/fceuWrapper.h"
|
#include "Qt/fceuWrapper.h"
|
||||||
|
|
||||||
static ppuNameTableViewerDialog_t *nameTableViewWindow = NULL;
|
static ppuNameTableViewerDialog_t *nameTableViewWindow = NULL;
|
||||||
|
@ -856,6 +859,10 @@ ppuNameTableView_t::ppuNameTableView_t(QWidget *parent)
|
||||||
selTable = 0;
|
selTable = 0;
|
||||||
scrollArea = NULL;
|
scrollArea = NULL;
|
||||||
hover2Focus = false;
|
hover2Focus = false;
|
||||||
|
ppuAddr = 0x2000;
|
||||||
|
palAddr = 0x3F00;
|
||||||
|
atrbAddr = 0x3F00;
|
||||||
|
tileAddr = 0x0000;
|
||||||
|
|
||||||
tileSelColor.setRgb(255,255,255);
|
tileSelColor.setRgb(255,255,255);
|
||||||
tileGridColor.setRgb(255, 0, 0);
|
tileGridColor.setRgb(255, 0, 0);
|
||||||
|
@ -1009,19 +1016,23 @@ int ppuNameTableView_t::calcTableTileAddr( int NameTable, int TileX, int TileY
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void ppuNameTableView_t::computeNameTableProperties( int NameTable, int TileX, int TileY )
|
void ppuNameTableView_t::computeNameTableProperties( int NameTable, int TileX, int TileY )
|
||||||
{
|
{
|
||||||
int TileID, PPUAddress, AttAddress, Attrib, palAddr;
|
int TileID, PPUAddress, AttAddress, Attrib;
|
||||||
|
|
||||||
if ( vnapage[0] == NULL )
|
if ( vnapage[0] == NULL )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PPUAddress = 0x2000+(NameTable*0x400)+((TileY%30)*32)+(TileX%32);
|
ppuAddr = PPUAddress = 0x2000+(NameTable*0x400)+((TileY%30)*32)+(TileX%32);
|
||||||
|
|
||||||
TileID = vnapage[(PPUAddress>>10)&0x3][PPUAddress&0x3FF];
|
TileID = vnapage[(PPUAddress>>10)&0x3][PPUAddress&0x3FF];
|
||||||
|
|
||||||
AttAddress = 0x23C0 | (PPUAddress & 0x0C00) | ((PPUAddress >> 4) & 0x38) | ((PPUAddress >> 2) & 0x07);
|
tileAddr = TileID << 4;
|
||||||
|
|
||||||
|
atrbAddr = AttAddress = 0x23C0 | (PPUAddress & 0x0C00) | ((PPUAddress >> 4) & 0x38) | ((PPUAddress >> 2) & 0x07);
|
||||||
|
|
||||||
Attrib = vnapage[(AttAddress>>10)&0x3][AttAddress&0x3FF];
|
Attrib = vnapage[(AttAddress>>10)&0x3][AttAddress&0x3FF];
|
||||||
|
|
||||||
//Attrib = (Attrib >> ((PPUAddress&2) | ((PPUAddress&64)>>4))) & 0x3;
|
//Attrib = (Attrib >> ((PPUAddress&2) | ((PPUAddress&64)>>4))) & 0x3;
|
||||||
|
|
||||||
//palAddr = 0x3F00 + ( FCEUPPU_GetAttr( NameTable, TileX, TileY ) * 4 );
|
//palAddr = 0x3F00 + ( FCEUPPU_GetAttr( NameTable, TileX, TileY ) * 4 );
|
||||||
|
@ -1203,6 +1214,71 @@ void ppuNameTableView_t::mousePressEvent(QMouseEvent * event)
|
||||||
redrawtables = true;
|
redrawtables = true;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
void ppuNameTableView_t::contextMenuEvent(QContextMenuEvent *event)
|
||||||
|
{
|
||||||
|
QAction *act;
|
||||||
|
QMenu menu(this);
|
||||||
|
QMenu *subMenu;
|
||||||
|
//QActionGroup *group;
|
||||||
|
char stmp[64];
|
||||||
|
int tIdx, tx, ty;
|
||||||
|
|
||||||
|
convertXY2TableTile( event->pos().x(), event->pos().y(), &tIdx, &tx, &ty );
|
||||||
|
|
||||||
|
selTable = tIdx;
|
||||||
|
selTile.setX( tx );
|
||||||
|
selTile.setY( ty );
|
||||||
|
|
||||||
|
redrawtables = true;
|
||||||
|
|
||||||
|
sprintf( stmp, "Open Tile %X%X in PPU Viewer", selTile.x(), selTile.y() );
|
||||||
|
act = new QAction(tr(stmp), &menu);
|
||||||
|
act->setShortcut( QKeySequence(tr("V")));
|
||||||
|
connect( act, SIGNAL(triggered(void)), this, SLOT(openTilePpuViewer(void)) );
|
||||||
|
menu.addAction( act );
|
||||||
|
|
||||||
|
sprintf( stmp, "Open Tile Addr $%04X in Hex Editor", tileAddr );
|
||||||
|
act = new QAction(tr(stmp), &menu);
|
||||||
|
//act->setShortcut( QKeySequence(tr("H")));
|
||||||
|
connect( act, SIGNAL(triggered(void)), this, SLOT(openTileAddrHexEdit(void)) );
|
||||||
|
menu.addAction( act );
|
||||||
|
|
||||||
|
sprintf( stmp, "Open Attr Addr $%04X in Hex Editor", atrbAddr );
|
||||||
|
act = new QAction(tr(stmp), &menu);
|
||||||
|
//act->setShortcut( QKeySequence(tr("H")));
|
||||||
|
connect( act, SIGNAL(triggered(void)), this, SLOT(openAtrbAddrHexEdit(void)) );
|
||||||
|
menu.addAction( act );
|
||||||
|
|
||||||
|
sprintf( stmp, "Open PPU Addr $%04X in Hex Editor", ppuAddr );
|
||||||
|
act = new QAction(tr(stmp), &menu);
|
||||||
|
//act->setShortcut( QKeySequence(tr("H")));
|
||||||
|
connect( act, SIGNAL(triggered(void)), this, SLOT(openPpuAddrHexEdit(void)) );
|
||||||
|
menu.addAction( act );
|
||||||
|
|
||||||
|
menu.exec(event->globalPos());
|
||||||
|
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
|
void ppuNameTableView_t::openTilePpuViewer(void)
|
||||||
|
{
|
||||||
|
openPPUViewWindow( consoleWindow );
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
|
void ppuNameTableView_t::openTileAddrHexEdit(void)
|
||||||
|
{
|
||||||
|
hexEditorOpenFromDebugger( QHexEdit::MODE_NES_PPU, tileAddr );
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
|
void ppuNameTableView_t::openAtrbAddrHexEdit(void)
|
||||||
|
{
|
||||||
|
hexEditorOpenFromDebugger( QHexEdit::MODE_NES_PPU, atrbAddr );
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
|
void ppuNameTableView_t::openPpuAddrHexEdit(void)
|
||||||
|
{
|
||||||
|
hexEditorOpenFromDebugger( QHexEdit::MODE_NES_PPU, ppuAddr );
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
void ppuNameTableView_t::paintEvent(QPaintEvent *event)
|
void ppuNameTableView_t::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
ppuNameTable_t *nt;
|
ppuNameTable_t *nt;
|
||||||
|
@ -1383,6 +1459,8 @@ inline void DrawChr( ppuNameTableTile_t *tile, const uint8_t *chr, int pal)
|
||||||
uint8 chr0, chr1;
|
uint8 chr0, chr1;
|
||||||
//uint8 *table = &VPage[0][0]; //use the background table
|
//uint8 *table = &VPage[0][0]; //use the background table
|
||||||
//pbitmap += 3*
|
//pbitmap += 3*
|
||||||
|
//
|
||||||
|
tile->pal = pal;
|
||||||
|
|
||||||
for (y = 0; y < 8; y++) { //todo: use index for y?
|
for (y = 0; y < 8; y++) { //todo: use index for y?
|
||||||
chr0 = chr[index];
|
chr0 = chr[index];
|
||||||
|
@ -1471,6 +1549,8 @@ static void DrawNameTable(int scanline, int ntnum, bool invalidateCache)
|
||||||
const uint8* chrp = FCEUPPU_GetCHR(ptable+chr,refreshaddr);
|
const uint8* chrp = FCEUPPU_GetCHR(ptable+chr,refreshaddr);
|
||||||
if (attview) chrp = ATTRIBUTE_VIEW_TILE;
|
if (attview) chrp = ATTRIBUTE_VIEW_TILE;
|
||||||
|
|
||||||
|
nameTable[ntnum].tile[y][x].pTbl = ptable;
|
||||||
|
|
||||||
//a good way to do it:
|
//a good way to do it:
|
||||||
DrawChr( &nameTable[ntnum].tile[y][x], chrp, a);
|
DrawChr( &nameTable[ntnum].tile[y][x], chrp, a);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,15 @@ struct ppuNameTableTile_t
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
int pTbl;
|
||||||
|
int pal;
|
||||||
|
|
||||||
|
ppuNameTableTile_t(void)
|
||||||
|
{
|
||||||
|
x = y = 0;
|
||||||
|
pTbl = 0;
|
||||||
|
pal = 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ppuNameTable_t
|
struct ppuNameTable_t
|
||||||
|
@ -40,6 +49,12 @@ struct ppuNameTable_t
|
||||||
int y;
|
int y;
|
||||||
int w;
|
int w;
|
||||||
int h;
|
int h;
|
||||||
|
|
||||||
|
ppuNameTable_t(void)
|
||||||
|
{
|
||||||
|
x = y = 0;
|
||||||
|
w = h = 8;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ppuNameTableViewerDialog_t;
|
class ppuNameTableViewerDialog_t;
|
||||||
|
@ -71,6 +86,7 @@ class ppuNameTableView_t : public QWidget
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
void mouseMoveEvent(QMouseEvent *event);
|
void mouseMoveEvent(QMouseEvent *event);
|
||||||
void mousePressEvent(QMouseEvent * event);
|
void mousePressEvent(QMouseEvent * event);
|
||||||
|
void contextMenuEvent(QContextMenuEvent *event);
|
||||||
void computeNameTableProperties( int NameTable, int TileX, int TileY );
|
void computeNameTableProperties( int NameTable, int TileX, int TileY );
|
||||||
int convertXY2TableTile( int x, int y, int *tableIdxOut, int *tileXout, int *tileYout );
|
int convertXY2TableTile( int x, int y, int *tableIdxOut, int *tileXout, int *tileYout );
|
||||||
int calcTableTileAddr( int table, int tileX, int tileY );
|
int calcTableTileAddr( int table, int tileX, int tileY );
|
||||||
|
@ -79,6 +95,10 @@ class ppuNameTableView_t : public QWidget
|
||||||
int viewWidth;
|
int viewWidth;
|
||||||
int viewHeight;
|
int viewHeight;
|
||||||
int viewScale;
|
int viewScale;
|
||||||
|
int ppuAddr;
|
||||||
|
int atrbAddr;
|
||||||
|
int tileAddr;
|
||||||
|
int palAddr;
|
||||||
int selTable;
|
int selTable;
|
||||||
QPoint selTile;
|
QPoint selTile;
|
||||||
QPoint selTileLoc;
|
QPoint selTileLoc;
|
||||||
|
@ -87,6 +107,11 @@ class ppuNameTableView_t : public QWidget
|
||||||
|
|
||||||
bool ensureVis;
|
bool ensureVis;
|
||||||
bool hover2Focus;
|
bool hover2Focus;
|
||||||
|
private slots:
|
||||||
|
void openTilePpuViewer(void);
|
||||||
|
void openPpuAddrHexEdit(void);
|
||||||
|
void openTileAddrHexEdit(void);
|
||||||
|
void openAtrbAddrHexEdit(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ppuNameTableTileView_t : public QWidget
|
class ppuNameTableTileView_t : public QWidget
|
||||||
|
|
|
@ -99,7 +99,7 @@ ppuViewerDialog_t::ppuViewerDialog_t(QWidget *parent)
|
||||||
|
|
||||||
ppuViewWindow = this;
|
ppuViewWindow = this;
|
||||||
|
|
||||||
setWindowTitle( tr("PPU Viewer") );
|
setWindowTitle( tr("PPU Viewer") );
|
||||||
|
|
||||||
mainLayout = new QVBoxLayout();
|
mainLayout = new QVBoxLayout();
|
||||||
|
|
||||||
|
@ -191,11 +191,14 @@ ppuViewerDialog_t::ppuViewerDialog_t(QWidget *parent)
|
||||||
|
|
||||||
connect( refreshSlider, SIGNAL(valueChanged(int)), this, SLOT(refreshSliderChanged(int)));
|
connect( refreshSlider, SIGNAL(valueChanged(int)), this, SLOT(refreshSliderChanged(int)));
|
||||||
|
|
||||||
|
cycleCount = 0;
|
||||||
|
PPUViewSkip = 100;
|
||||||
|
|
||||||
FCEUD_UpdatePPUView( -1, 1 );
|
FCEUD_UpdatePPUView( -1, 1 );
|
||||||
|
|
||||||
updateTimer = new QTimer( this );
|
updateTimer = new QTimer( this );
|
||||||
|
|
||||||
connect( updateTimer, &QTimer::timeout, this, &ppuViewerDialog_t::periodicUpdate );
|
connect( updateTimer, &QTimer::timeout, this, &ppuViewerDialog_t::periodicUpdate );
|
||||||
|
|
||||||
updateTimer->start( 33 ); // 30hz
|
updateTimer->start( 33 ); // 30hz
|
||||||
}
|
}
|
||||||
|
@ -226,7 +229,9 @@ void ppuViewerDialog_t::closeWindow(void)
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void ppuViewerDialog_t::periodicUpdate(void)
|
void ppuViewerDialog_t::periodicUpdate(void)
|
||||||
{
|
{
|
||||||
if ( redrawWindow )
|
cycleCount = (cycleCount + 1) % 30;
|
||||||
|
|
||||||
|
if ( redrawWindow || (cycleCount == 0) )
|
||||||
{
|
{
|
||||||
this->update();
|
this->update();
|
||||||
redrawWindow = false;
|
redrawWindow = false;
|
||||||
|
@ -382,7 +387,7 @@ void ppuPatternView_t::mouseMoveEvent(QMouseEvent *event)
|
||||||
sprintf( stmp, "Tile: $%X%X", tile.y(), tile.x() );
|
sprintf( stmp, "Tile: $%X%X", tile.y(), tile.x() );
|
||||||
tileLabel->setText( tr(stmp) );
|
tileLabel->setText( tr(stmp) );
|
||||||
|
|
||||||
selTile = tile;
|
selTile = tile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,7 +500,7 @@ void ppuPatternView_t::exitTileMode(void)
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void ppuPatternView_t::openTileEditor(void)
|
void ppuPatternView_t::openTileEditor(void)
|
||||||
{
|
{
|
||||||
ppuTileEditor_t *tileEditor;
|
ppuTileEditor_t *tileEditor;
|
||||||
|
|
||||||
tileEditor = new ppuTileEditor_t( patternIndex, this );
|
tileEditor = new ppuTileEditor_t( patternIndex, this );
|
||||||
|
|
||||||
|
@ -506,7 +511,7 @@ void ppuPatternView_t::openTileEditor(void)
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void ppuPatternView_t::cycleNextPalette(void)
|
void ppuPatternView_t::cycleNextPalette(void)
|
||||||
{
|
{
|
||||||
pindex[ patternIndex ] = (pindex[ patternIndex ] + 1) % 9;
|
pindex[ patternIndex ] = (pindex[ patternIndex ] + 1) % 9;
|
||||||
|
|
||||||
PPUViewSkip = 100;
|
PPUViewSkip = 100;
|
||||||
|
|
||||||
|
|
|
@ -218,8 +218,8 @@ class ppuTileEditor_t : public QDialog
|
||||||
int palIdx;
|
int palIdx;
|
||||||
int tileAddr;
|
int tileAddr;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void closeWindow(void);
|
void closeWindow(void);
|
||||||
private slots:
|
private slots:
|
||||||
void periodicUpdate(void);
|
void periodicUpdate(void);
|
||||||
void paletteChanged(int index);
|
void paletteChanged(int index);
|
||||||
|
@ -239,7 +239,7 @@ class ppuViewerDialog_t : public QDialog
|
||||||
ppuPatternView_t *patternView[2];
|
ppuPatternView_t *patternView[2];
|
||||||
ppuPalatteView_t *paletteView;
|
ppuPalatteView_t *paletteView;
|
||||||
|
|
||||||
void closeEvent(QCloseEvent *bar);
|
void closeEvent(QCloseEvent *bar);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QGroupBox *patternFrame[2];
|
QGroupBox *patternFrame[2];
|
||||||
|
@ -252,8 +252,10 @@ class ppuViewerDialog_t : public QDialog
|
||||||
QLineEdit *scanLineEdit;
|
QLineEdit *scanLineEdit;
|
||||||
QTimer *updateTimer;
|
QTimer *updateTimer;
|
||||||
|
|
||||||
public slots:
|
int cycleCount;
|
||||||
void closeWindow(void);
|
|
||||||
|
public slots:
|
||||||
|
void closeWindow(void);
|
||||||
private slots:
|
private slots:
|
||||||
void periodicUpdate(void);
|
void periodicUpdate(void);
|
||||||
void sprite8x16Changed0(int state);
|
void sprite8x16Changed0(int state);
|
||||||
|
|
Loading…
Reference in New Issue