Add support for Double Low & Hi Resolution.
For Double Low Res, I am not sure the colors are correct. Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
3231f86f87
commit
8dd454af4d
3 changed files with 96 additions and 32 deletions
|
@ -19,12 +19,12 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
QPixmap buildHiResMono()
|
||||
QPixmap buildHiResMono80()
|
||||
{
|
||||
const QColor black(Qt::black);
|
||||
const QColor white(Qt::white);
|
||||
|
||||
QPixmap hires(14, 128 * 2); // 128 values 2 lines each
|
||||
QPixmap hires(7, 128 * 2); // 128 values 2 lines each
|
||||
|
||||
QPainter painter(&hires);
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace
|
|||
for (int j = 0; j < 7; ++j)
|
||||
{
|
||||
const QColor & color = (i & (1 << j)) ? white : black;
|
||||
painter.fillRect(j * 2, i * 2, 2, 2, color);
|
||||
painter.fillRect(j, i * 2, 1, 2, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ namespace
|
|||
|
||||
#define SETFRAMECOLOR(c, r, g, b) colors[c].setRgb(r, g, b);
|
||||
|
||||
QPixmap buildLoResColor()
|
||||
QPixmap buildLoResColor80()
|
||||
{
|
||||
std::vector<QColor> colors(16);
|
||||
|
||||
|
@ -86,7 +86,7 @@ namespace
|
|||
SETFRAMECOLOR(WHITE, 0xFF,0xFF,0xFF); // FF
|
||||
|
||||
|
||||
QPixmap lores(14, 256 * 16); // 256 values 16 lines each
|
||||
QPixmap lores(7, 256 * 16); // 256 values 16 lines each
|
||||
|
||||
QPainter painter(&lores);
|
||||
|
||||
|
@ -95,8 +95,8 @@ namespace
|
|||
const int top = i & 0b1111;
|
||||
const int bottom = (i >> 4) & 0b1111;
|
||||
|
||||
painter.fillRect(0, i * 16, 14, 8, colors[top]);
|
||||
painter.fillRect(0, i * 16 + 8, 14, 8, colors[bottom]);
|
||||
painter.fillRect(0, i * 16, 7, 8, colors[top]);
|
||||
painter.fillRect(0, i * 16 + 8, 7, 8, colors[bottom]);
|
||||
}
|
||||
|
||||
return lores;
|
||||
|
@ -115,9 +115,15 @@ GraphicsCache::GraphicsCache()
|
|||
myCharset80 = myCharset40.scaled(myCharset40.width() / 2, myCharset40.height());
|
||||
// it was already half scan
|
||||
|
||||
myHiResMono = buildHiResMono();
|
||||
halfScanLines(myHiResMono, black);
|
||||
myHiResMono80 = buildHiResMono80();
|
||||
halfScanLines(myHiResMono80, black);
|
||||
|
||||
myLoResColor = buildLoResColor();
|
||||
halfScanLines(myLoResColor, black);
|
||||
myHiResMono40 = myHiResMono80.scaled(myHiResMono80.width() * 2, myHiResMono80.height());
|
||||
// it was already half scan
|
||||
|
||||
myLoResColor80 = buildLoResColor80();
|
||||
halfScanLines(myLoResColor80, black);
|
||||
|
||||
myLoResColor40 = myLoResColor80.scaled(myLoResColor80.width() * 2, myLoResColor80.height());
|
||||
// it was already half scan
|
||||
}
|
||||
|
|
|
@ -19,22 +19,35 @@ public:
|
|||
return myCharset80;
|
||||
}
|
||||
|
||||
const QPixmap & hires() const
|
||||
const QPixmap & hires40() const
|
||||
{
|
||||
return myHiResMono;
|
||||
return myHiResMono40;
|
||||
}
|
||||
|
||||
const QPixmap & lores() const
|
||||
const QPixmap & hires80() const
|
||||
{
|
||||
return myLoResColor;
|
||||
return myHiResMono80;
|
||||
}
|
||||
|
||||
const QPixmap & lores40() const
|
||||
{
|
||||
return myLoResColor40;
|
||||
}
|
||||
|
||||
const QPixmap & lores80() const
|
||||
{
|
||||
return myLoResColor80;
|
||||
}
|
||||
|
||||
private:
|
||||
QPixmap myCharset40;
|
||||
QPixmap myCharset80;
|
||||
|
||||
QPixmap myHiResMono;
|
||||
QPixmap myLoResColor;
|
||||
QPixmap myHiResMono40;
|
||||
QPixmap myHiResMono80;
|
||||
|
||||
QPixmap myLoResColor40;
|
||||
QPixmap myLoResColor80;
|
||||
};
|
||||
|
||||
#endif // GRAPHICSCACHE_H
|
||||
|
|
|
@ -37,7 +37,9 @@ bool Video::Update40ColCell (QPainter & painter, int x, int y, int xpixel, int y
|
|||
Q_UNUSED(x)
|
||||
Q_UNUSED(y)
|
||||
|
||||
const BYTE ch = *(g_pTextBank0+offset);
|
||||
const QPixmap & text40Col = myGraphicsCache->text40Col();
|
||||
|
||||
const BYTE ch = *(g_pTextBank0 + offset);
|
||||
|
||||
const int base = g_nAltCharSetOffset ? 16 : 0;
|
||||
|
||||
|
@ -46,7 +48,6 @@ bool Video::Update40ColCell (QPainter & painter, int x, int y, int xpixel, int y
|
|||
|
||||
const int sx = 16 * column;
|
||||
const int sy = 16 * (base + row);
|
||||
const QPixmap & text40Col = myGraphicsCache->text40Col();
|
||||
|
||||
painter.drawPixmap(xpixel, ypixel, text40Col, sx, sy, 14, 16);
|
||||
|
||||
|
@ -59,10 +60,11 @@ bool Video::Update80ColCell(QPainter & painter, int x, int y, int xpixel, int yp
|
|||
Q_UNUSED(y)
|
||||
|
||||
const QPixmap & text80Col = myGraphicsCache->text80Col();
|
||||
|
||||
const int base = g_nAltCharSetOffset ? 16 : 0;
|
||||
|
||||
{
|
||||
const BYTE ch1 = *(g_pTextBank1+offset);
|
||||
const BYTE ch1 = *(g_pTextBank1 + offset);
|
||||
|
||||
const int row = ch1 / 16;
|
||||
const int column = ch1 % 16;
|
||||
|
@ -73,7 +75,7 @@ bool Video::Update80ColCell(QPainter & painter, int x, int y, int xpixel, int yp
|
|||
}
|
||||
|
||||
{
|
||||
const BYTE ch2 = *(g_pTextBank0+offset);
|
||||
const BYTE ch2 = *(g_pTextBank0 + offset);
|
||||
|
||||
const int row = ch2 / 16;
|
||||
const int column = ch2 % 16;
|
||||
|
@ -91,11 +93,12 @@ bool Video::UpdateLoResCell(QPainter & painter, int x, int y, int xpixel, int yp
|
|||
Q_UNUSED(x)
|
||||
Q_UNUSED(y)
|
||||
|
||||
const BYTE ch = *(g_pTextBank0+offset);
|
||||
const QPixmap & lores = myGraphicsCache->lores40();
|
||||
|
||||
const BYTE ch = *(g_pTextBank0 + offset);
|
||||
|
||||
const int sx = 0;
|
||||
const int sy = ch * 16;
|
||||
const QPixmap & lores = myGraphicsCache->lores();
|
||||
|
||||
painter.drawPixmap(xpixel, ypixel, lores, sx, sy, 14, 16);
|
||||
|
||||
|
@ -104,12 +107,28 @@ bool Video::UpdateLoResCell(QPainter & painter, int x, int y, int xpixel, int yp
|
|||
|
||||
bool Video::UpdateDLoResCell(QPainter & painter, int x, int y, int xpixel, int ypixel, int offset)
|
||||
{
|
||||
Q_UNUSED(painter)
|
||||
Q_UNUSED(x)
|
||||
Q_UNUSED(y)
|
||||
Q_UNUSED(xpixel)
|
||||
Q_UNUSED(ypixel)
|
||||
Q_UNUSED(offset)
|
||||
|
||||
const QPixmap & lores = myGraphicsCache->lores80();
|
||||
|
||||
{
|
||||
const BYTE ch = *(g_pTextBank1 + offset);
|
||||
|
||||
const int sx = 0;
|
||||
const int sy = ch * 16;
|
||||
|
||||
painter.drawPixmap(xpixel, ypixel, lores, sx, sy, 7, 16);
|
||||
}
|
||||
|
||||
{
|
||||
const BYTE ch = *(g_pTextBank0 + offset);
|
||||
|
||||
const int sx = 0;
|
||||
const int sy = ch * 16;
|
||||
|
||||
painter.drawPixmap(xpixel + 7, ypixel, lores, sx, sy, 7, 16);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -120,7 +139,7 @@ bool Video::UpdateHiResCell(QPainter & painter, int x, int y, int xpixel, int yp
|
|||
Q_UNUSED(y)
|
||||
|
||||
const BYTE * base = g_pHiresBank0 + offset;
|
||||
const QPixmap & hires = myGraphicsCache->hires();
|
||||
const QPixmap & hires = myGraphicsCache->hires40();
|
||||
|
||||
for (size_t i = 0; i < 8; ++i)
|
||||
{
|
||||
|
@ -137,12 +156,38 @@ bool Video::UpdateHiResCell(QPainter & painter, int x, int y, int xpixel, int yp
|
|||
|
||||
bool Video::UpdateDHiResCell(QPainter & painter, int x, int y, int xpixel, int ypixel, int offset)
|
||||
{
|
||||
Q_UNUSED(painter)
|
||||
Q_UNUSED(x)
|
||||
Q_UNUSED(y)
|
||||
Q_UNUSED(xpixel)
|
||||
Q_UNUSED(ypixel)
|
||||
Q_UNUSED(offset)
|
||||
|
||||
const QPixmap & dhires = myGraphicsCache->hires80();
|
||||
|
||||
{
|
||||
const BYTE * base = g_pHiresBank1 + offset;
|
||||
|
||||
for (size_t i = 0; i < 8; ++i)
|
||||
{
|
||||
const int line = 0x0400 * i;
|
||||
const BYTE value = *(base + line);
|
||||
|
||||
const int row = value & 0x7f;
|
||||
|
||||
painter.drawPixmap(xpixel, ypixel + i * 2, dhires, 0, row * 2, 7, 2);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const BYTE * base = g_pHiresBank0 + offset;
|
||||
|
||||
for (size_t i = 0; i < 8; ++i)
|
||||
{
|
||||
const int line = 0x0400 * i;
|
||||
const BYTE value = *(base + line);
|
||||
|
||||
const int row = value & 0x7f;
|
||||
|
||||
painter.drawPixmap(xpixel + 7, ypixel + i * 2, dhires, 0, row * 2, 7, 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue