Added logic to display sprite 8x16 on Qt PPU viewer
This commit is contained in:
parent
ccb8b63282
commit
ec6a6e06e7
|
@ -202,7 +202,7 @@ ppuPatternView_t::~ppuPatternView_t(void)
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void ppuPatternView_t::paintEvent(QPaintEvent *event)
|
void ppuPatternView_t::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
int i,j,x,y,w,h,xx,yy;
|
int i,j,x,y,w,h,xx,yy,ii,jj,rr;
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
int viewWidth = event->rect().width();
|
int viewWidth = event->rect().width();
|
||||||
int viewHeight = event->rect().height();
|
int viewHeight = event->rect().height();
|
||||||
|
@ -212,8 +212,53 @@ void ppuPatternView_t::paintEvent(QPaintEvent *event)
|
||||||
w = viewWidth / 128;
|
w = viewWidth / 128;
|
||||||
h = viewHeight / 128;
|
h = viewHeight / 128;
|
||||||
|
|
||||||
|
pattern->w = w;
|
||||||
|
pattern->h = h;
|
||||||
|
|
||||||
xx = 0; yy = 0;
|
xx = 0; yy = 0;
|
||||||
|
|
||||||
|
if ( PPUView_sprite16Mode[ patternIndex ] )
|
||||||
|
{
|
||||||
|
for (i=0; i<16; i++) //Columns
|
||||||
|
{
|
||||||
|
for (j=0; j<16; j++) //Rows
|
||||||
|
{
|
||||||
|
rr = (j%2);
|
||||||
|
jj = j;
|
||||||
|
|
||||||
|
if ( rr )
|
||||||
|
{
|
||||||
|
jj--;
|
||||||
|
}
|
||||||
|
|
||||||
|
ii = (i*2)+rr;
|
||||||
|
|
||||||
|
if ( ii >= 16 )
|
||||||
|
{
|
||||||
|
ii = ii % 16;
|
||||||
|
jj++;
|
||||||
|
}
|
||||||
|
|
||||||
|
xx = (i*8)*w;
|
||||||
|
|
||||||
|
for (x=0; x < 8; x++)
|
||||||
|
{
|
||||||
|
yy = (j*8)*h;
|
||||||
|
|
||||||
|
for (y=0; y < 8; y++)
|
||||||
|
{
|
||||||
|
pattern->tile[jj][ii].x = xx;
|
||||||
|
pattern->tile[jj][ii].y = yy;
|
||||||
|
painter.fillRect( xx, yy, w, h, pattern->tile[jj][ii].pixel[y][x].color );
|
||||||
|
yy += h;
|
||||||
|
}
|
||||||
|
xx += w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for (i=0; i<16; i++) //Columns
|
for (i=0; i<16; i++) //Columns
|
||||||
{
|
{
|
||||||
for (j=0; j<16; j++) //Rows
|
for (j=0; j<16; j++) //Rows
|
||||||
|
@ -226,6 +271,8 @@ void ppuPatternView_t::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
for (y=0; y < 8; y++)
|
for (y=0; y < 8; y++)
|
||||||
{
|
{
|
||||||
|
pattern->tile[j][i].x = xx;
|
||||||
|
pattern->tile[j][i].y = yy;
|
||||||
painter.fillRect( xx, yy, w, h, pattern->tile[j][i].pixel[y][x].color );
|
painter.fillRect( xx, yy, w, h, pattern->tile[j][i].pixel[y][x].color );
|
||||||
yy += h;
|
yy += h;
|
||||||
}
|
}
|
||||||
|
@ -233,6 +280,7 @@ void ppuPatternView_t::paintEvent(QPaintEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
static void DrawPatternTable( ppuPatternTable_t *pattern, uint8_t *table, uint8_t *log, uint8_t pal)
|
static void DrawPatternTable( ppuPatternTable_t *pattern, uint8_t *table, uint8_t *log, uint8_t pal)
|
||||||
|
@ -392,8 +440,6 @@ void ppuPalatteView_t::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
for (x=0; x < PALETTEWIDTH; x++)
|
for (x=0; x < PALETTEWIDTH; x++)
|
||||||
{
|
{
|
||||||
|
|
||||||
//painter.setPen( pattern0.tile[j][i].pixel[y][x].color );
|
|
||||||
painter.fillRect( xx, yy, w, h, ppuv_palette[y][x] );
|
painter.fillRect( xx, yy, w, h, ppuv_palette[y][x] );
|
||||||
xx += w;
|
xx += w;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,14 @@ struct ppuPatternTable_t
|
||||||
{
|
{
|
||||||
QColor color;
|
QColor color;
|
||||||
} pixel[8][8];
|
} pixel[8][8];
|
||||||
|
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
|
||||||
} tile[16][16];
|
} tile[16][16];
|
||||||
|
|
||||||
|
int w;
|
||||||
|
int h;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ppuPatternView_t : public QWidget
|
class ppuPatternView_t : public QWidget
|
||||||
|
|
Loading…
Reference in New Issue