Added logic to fillout property labels on NT view Qt GUI.
This commit is contained in:
parent
652cc4f2c9
commit
2d403fac3e
|
@ -232,6 +232,27 @@ void ppuNameTableViewerDialog_t::periodicUpdate(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
void ppuNameTableViewerDialog_t::setPropertyLabels( int TileID, int TileX, int TileY, int NameTable, int PPUAddress, int AttAddress, int Attrib )
|
||||||
|
{
|
||||||
|
char stmp[64];
|
||||||
|
|
||||||
|
sprintf( stmp, "Tile ID: %02X", TileID);
|
||||||
|
|
||||||
|
tileID->setText( tr(stmp) );
|
||||||
|
|
||||||
|
sprintf( stmp, "X/Y : %0d/%0d", TileX, TileY);
|
||||||
|
|
||||||
|
tileXY->setText( tr(stmp) );
|
||||||
|
|
||||||
|
sprintf(stmp,"PPU Address: %04X",PPUAddress);
|
||||||
|
|
||||||
|
ppuAddrLbl->setText( tr(stmp) );
|
||||||
|
|
||||||
|
sprintf(stmp,"Attribute: %1X (%04X)",Attrib,AttAddress);
|
||||||
|
|
||||||
|
attrbLbl->setText( tr(stmp) );
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
void ppuNameTableViewerDialog_t::updateMirrorButtons(void)
|
void ppuNameTableViewerDialog_t::updateMirrorButtons(void)
|
||||||
{
|
{
|
||||||
switch ( ntmirroring )
|
switch ( ntmirroring )
|
||||||
|
@ -324,6 +345,7 @@ void ppuNameTableViewerDialog_t::refreshSliderChanged(int value)
|
||||||
ppuNameTableView_t::ppuNameTableView_t(QWidget *parent)
|
ppuNameTableView_t::ppuNameTableView_t(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
|
this->parent = (ppuNameTableViewerDialog_t*)parent;
|
||||||
this->setFocusPolicy(Qt::StrongFocus);
|
this->setFocusPolicy(Qt::StrongFocus);
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
viewWidth = 256 * 2;
|
viewWidth = 256 * 2;
|
||||||
|
@ -345,16 +367,78 @@ void ppuNameTableView_t::resizeEvent(QResizeEvent *event)
|
||||||
//printf("%ix%i\n", viewWidth, viewHeight );
|
//printf("%ix%i\n", viewWidth, viewHeight );
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
void ppuNameTableView_t::computeNameTableProperties( int x, int y )
|
||||||
|
{
|
||||||
|
int i, xx, yy, w, h, TileID, TileX, TileY, NameTable, PPUAddress, AttAddress, Attrib;
|
||||||
|
ppuNameTable_t *tbl = NULL;
|
||||||
|
|
||||||
|
NameTable = 0;
|
||||||
|
|
||||||
|
if ( vnapage[0] == NULL )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (i=0; i<4; i++)
|
||||||
|
{
|
||||||
|
xx = nameTable[i].x;
|
||||||
|
yy = nameTable[i].y;
|
||||||
|
w = (nameTable[i].w * 256);
|
||||||
|
h = (nameTable[i].h * 240);
|
||||||
|
|
||||||
|
if ( (x >= xx) && (x < (xx+w) ) &&
|
||||||
|
(y >= yy) && (y < (yy+h) ) )
|
||||||
|
{
|
||||||
|
tbl = &nameTable[i];
|
||||||
|
NameTable = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( tbl == NULL )
|
||||||
|
{
|
||||||
|
//printf("Mouse not over a tile\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
xx = tbl->x; yy = tbl->y;
|
||||||
|
w = tbl->w; h = tbl->h;
|
||||||
|
|
||||||
|
if ( (NameTable%2) == 1 )
|
||||||
|
{
|
||||||
|
TileX = ((x - xx) / (w*8)) + 32;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TileX = (x - xx) / (w*8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (NameTable/2) == 1 )
|
||||||
|
{
|
||||||
|
TileY = ((y - yy) / (h*8)) + 30;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TileY = (y - yy) / (h*8);
|
||||||
|
}
|
||||||
|
|
||||||
|
PPUAddress = 0x2000+(NameTable*0x400)+((TileY%30)*32)+(TileX%32);
|
||||||
|
|
||||||
|
TileID = vnapage[(PPUAddress>>10)&0x3][PPUAddress&0x3FF];
|
||||||
|
|
||||||
|
AttAddress = 0x23C0 | (PPUAddress & 0x0C00) | ((PPUAddress >> 4) & 0x38) | ((PPUAddress >> 2) & 0x07);
|
||||||
|
Attrib = vnapage[(AttAddress>>10)&0x3][AttAddress&0x3FF];
|
||||||
|
Attrib = (Attrib >> ((PPUAddress&2) | ((PPUAddress&64)>>4))) & 0x3;
|
||||||
|
|
||||||
|
//printf("NT:%i Tile X/Y : %i/%i \n", NameTable, TileX, TileY );
|
||||||
|
|
||||||
|
if ( parent )
|
||||||
|
{
|
||||||
|
parent->setPropertyLabels( TileID, TileX, TileY, NameTable, PPUAddress, AttAddress, Attrib );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
void ppuNameTableView_t::mouseMoveEvent(QMouseEvent *event)
|
void ppuNameTableView_t::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
//QPoint tile = convPixToTile( event->pos() );
|
computeNameTableProperties( event->pos().x(), event->pos().y() );
|
||||||
|
|
||||||
//if ( (tile.x() < 16) && (tile.y() < 16) )
|
|
||||||
//{
|
|
||||||
// char stmp[64];
|
|
||||||
// sprintf( stmp, "Tile: $%X%X", tile.y(), tile.x() );
|
|
||||||
// tileLabel->setText( tr(stmp) );
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void ppuNameTableView_t::mousePressEvent(QMouseEvent * event)
|
void ppuNameTableView_t::mousePressEvent(QMouseEvent * event)
|
||||||
|
@ -388,8 +472,10 @@ void ppuNameTableView_t::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
nt = &nameTable[n];
|
nt = &nameTable[n];
|
||||||
|
|
||||||
xx = (n%2) * (viewWidth / 2);
|
nt->w = w; nt->h = h;
|
||||||
yy = (n/2) * (viewHeight / 2);
|
|
||||||
|
nt->x = xx = (n%2) * (viewWidth / 2);
|
||||||
|
nt->y = yy = (n/2) * (viewHeight / 2);
|
||||||
|
|
||||||
for (j=0; j<30; j++)
|
for (j=0; j<30; j++)
|
||||||
{
|
{
|
||||||
|
@ -399,6 +485,9 @@ void ppuNameTableView_t::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
ii = (i*8);
|
ii = (i*8);
|
||||||
|
|
||||||
|
nt->tile[j][i].x = xx+(ii*w);
|
||||||
|
nt->tile[j][i].y = yy+(jj*h);
|
||||||
|
|
||||||
for (y=0; y<8; y++)
|
for (y=0; y<8; y++)
|
||||||
{
|
{
|
||||||
for (x=0; x<8; x++)
|
for (x=0; x<8; x++)
|
||||||
|
|
|
@ -35,10 +35,14 @@ struct ppuNameTable_t
|
||||||
{
|
{
|
||||||
struct ppuNameTableTile_t tile[30][32];
|
struct ppuNameTableTile_t tile[30][32];
|
||||||
|
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
int w;
|
int w;
|
||||||
int h;
|
int h;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ppuNameTableViewerDialog_t;
|
||||||
|
|
||||||
class ppuNameTableView_t : public QWidget
|
class ppuNameTableView_t : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -52,7 +56,9 @@ class ppuNameTableView_t : public QWidget
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
void mouseMoveEvent(QMouseEvent *event);
|
void mouseMoveEvent(QMouseEvent *event);
|
||||||
void mousePressEvent(QMouseEvent * event);
|
void mousePressEvent(QMouseEvent * event);
|
||||||
|
void computeNameTableProperties( int x, int y );
|
||||||
|
|
||||||
|
ppuNameTableViewerDialog_t *parent;
|
||||||
int viewWidth;
|
int viewWidth;
|
||||||
int viewHeight;
|
int viewHeight;
|
||||||
};
|
};
|
||||||
|
@ -65,6 +71,7 @@ class ppuNameTableViewerDialog_t : public QDialog
|
||||||
ppuNameTableViewerDialog_t(QWidget *parent = 0);
|
ppuNameTableViewerDialog_t(QWidget *parent = 0);
|
||||||
~ppuNameTableViewerDialog_t(void);
|
~ppuNameTableViewerDialog_t(void);
|
||||||
|
|
||||||
|
void setPropertyLabels( int TileID, int TileX, int TileY, int NameTable, int PPUAddress, int AttAddress, int Attrib );
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *bar);
|
void closeEvent(QCloseEvent *bar);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue