aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter van Niftrik2019-07-22 08:54:08 +0200
committerWalter van Niftrik2019-08-11 23:36:27 +0200
commitd5c7e9d2073c54ed284e1aa4e532f36bf68c3818 (patch)
treec57393b386098449f0dbdc414d66919776100be0
parent92a3a3a8a551f32abc9654d3731ae3d297280878 (diff)
downloadscummvm-rg350-d5c7e9d2073c54ed284e1aa4e532f36bf68c3818.tar.gz
scummvm-rg350-d5c7e9d2073c54ed284e1aa4e532f36bf68c3818.tar.bz2
scummvm-rg350-d5c7e9d2073c54ed284e1aa4e532f36bf68c3818.zip
ADL: Refactor Display class
-rw-r--r--engines/adl/adl.cpp8
-rw-r--r--engines/adl/adl_v2.cpp6
-rw-r--r--engines/adl/console.cpp4
-rw-r--r--engines/adl/display.cpp45
-rw-r--r--engines/adl/display.h22
-rw-r--r--engines/adl/display_a2.cpp430
-rw-r--r--engines/adl/display_a2.h20
-rw-r--r--engines/adl/hires1.cpp6
-rw-r--r--engines/adl/hires4.cpp16
-rw-r--r--engines/adl/hires5.cpp4
-rw-r--r--engines/adl/hires6.cpp8
11 files changed, 284 insertions, 285 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index 2379ecdb8f..baf14ea466 100644
--- a/engines/adl/adl.cpp
+++ b/engines/adl/adl.cpp
@@ -286,7 +286,7 @@ byte AdlEngine::inputKey(bool showCursor) const {
if (_inputScript && !_scriptPaused)
return _display->asciiToNative('\r');
- _display->copyTextSurface();
+ _display->renderText();
g_system->delayMillis(16);
}
@@ -730,7 +730,7 @@ void AdlEngine::gameLoop() {
}
Common::Error AdlEngine::run() {
- _display = new Display_A2();
+ _display = Display_A2_create();
_console = new Console(this);
_display->init();
@@ -964,7 +964,7 @@ Common::Error AdlEngine::saveGameState(int slot, const Common::String &desc) {
uint32 playTime = getTotalPlayTime();
outFile->writeUint32BE(playTime);
- _display->saveThumbnail(*outFile);
+ Graphics::saveThumbnail(*outFile);
saveState(*outFile);
outFile->finalize();
@@ -1280,7 +1280,7 @@ int AdlEngine::o_restart(ScriptEnv &e) {
if (input.size() == 0 || input[0] != _display->asciiToNative('N')) {
_isRestarting = true;
_graphics->clearScreen();
- _display->copyGfxSurface();
+ _display->renderGraphics();
_display->printString(_strings.pressReturn);
initState();
_display->printAsciiString(_strings.lineFeeds);
diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp
index 81ff145689..e30502eac9 100644
--- a/engines/adl/adl_v2.cpp
+++ b/engines/adl/adl_v2.cpp
@@ -112,7 +112,7 @@ void AdlEngine_v2::checkTextOverflow(char c) {
void AdlEngine_v2::handleTextOverflow() {
_linesPrinted = 0;
- _display->copyTextSurface();
+ _display->renderText();
if (_inputScript) {
// Set pause flag to activate regular behaviour of delay and inputKey
@@ -185,7 +185,7 @@ void AdlEngine_v2::printString(const Common::String &str) {
checkTextOverflow(returnChar);
_display->printChar(returnChar);
- _display->copyTextSurface();
+ _display->renderText();
}
void AdlEngine_v2::drawItem(Item &item, const Common::Point &pos) {
@@ -263,7 +263,7 @@ void AdlEngine_v2::showRoom() {
if (!_state.isDark)
drawItems();
- _display->copyGfxSurface();
+ _display->renderGraphics();
printString(_roomData.description);
}
diff --git a/engines/adl/console.cpp b/engines/adl/console.cpp
index 876389c33a..45672652e2 100644
--- a/engines/adl/console.cpp
+++ b/engines/adl/console.cpp
@@ -182,8 +182,8 @@ void Console::prepareGame() {
_engine->_graphics->clearScreen();
_engine->loadRoom(_engine->_state.room);
_engine->showRoom();
- _engine->_display->copyTextSurface();
- _engine->_display->copyGfxSurface();
+ _engine->_display->renderText();
+ _engine->_display->renderGraphics();
}
bool Console::Cmd_Region(int argc, const char **argv) {
diff --git a/engines/adl/display.cpp b/engines/adl/display.cpp
index 736b09497b..d7159441da 100644
--- a/engines/adl/display.cpp
+++ b/engines/adl/display.cpp
@@ -25,27 +25,12 @@
#include "common/str.h"
#include "common/system.h"
-#include "graphics/surface.h"
-
#include "adl/display.h"
namespace Adl {
Display::~Display() {
delete[] _textBuf;
- _textSurface->free();
- delete _textSurface;
-
- _gfxSurface->free();
- delete _gfxSurface;
-}
-
-void Display::createSurfaces(uint gfxWidth, uint gfxHeight, uint splitHeight) {
- _gfxSurface = new Graphics::Surface;
- _gfxSurface->create(gfxWidth, gfxHeight, Graphics::PixelFormat::createFormatCLUT8());
- _textSurface = new Graphics::Surface;
- _textSurface->create(gfxWidth, gfxHeight, Graphics::PixelFormat::createFormatCLUT8());
- _splitHeight = splitHeight;
}
void Display::createTextBuffer(uint textWidth, uint textHeight) {
@@ -60,31 +45,9 @@ void Display::setMode(Display::Mode mode) {
_mode = mode;
if (_mode == Display::kModeText || _mode == Display::kModeMixed)
- copyTextSurface();
+ renderText();
if (_mode == Display::kModeGraphics || _mode == Display::kModeMixed)
- copyGfxSurface();
-}
-
-void Display::copyTextSurface() {
- updateTextSurface();
-
- if (_mode == Display::kModeText)
- g_system->copyRectToScreen(_textSurface->getPixels(), _textSurface->pitch, 0, 0, _textSurface->w, _textSurface->h);
- else if (_mode == Display::kModeMixed)
- g_system->copyRectToScreen(_textSurface->getBasePtr(0, _textSurface->h - _splitHeight), _textSurface->pitch, 0, _textSurface->h - _splitHeight, _textSurface->w, _splitHeight);
-
- g_system->updateScreen();
-}
-
-void Display::copyGfxSurface() {
- updateGfxSurface();
-
- if (_mode == kModeGraphics)
- g_system->copyRectToScreen(_gfxSurface->getPixels(), _gfxSurface->pitch, 0, 0, _gfxSurface->w, _gfxSurface->h);
- else if (_mode == kModeMixed)
- g_system->copyRectToScreen(_gfxSurface->getPixels(), _gfxSurface->pitch, 0, 0, _gfxSurface->w, _gfxSurface->h - _splitHeight);
-
- g_system->updateScreen();
+ renderGraphics();
}
void Display::home() {
@@ -116,7 +79,7 @@ void Display::printString(const Common::String &str) {
for (c = str.begin(); c != str.end(); ++c)
printChar(*c);
- copyTextSurface();
+ renderText();
}
void Display::printAsciiString(const Common::String &str) {
@@ -124,7 +87,7 @@ void Display::printAsciiString(const Common::String &str) {
for (c = str.begin(); c != str.end(); ++c)
printChar(asciiToNative(*c));
- copyTextSurface();
+ renderText();
}
void Display::setCharAtCursor(byte c) {
diff --git a/engines/adl/display.h b/engines/adl/display.h
index a92993e2ec..0c43d65749 100644
--- a/engines/adl/display.h
+++ b/engines/adl/display.h
@@ -26,15 +26,10 @@
#include "common/types.h"
namespace Common {
-class WriteStream;
class String;
struct Point;
}
-namespace Graphics {
-struct Surface;
-}
-
namespace Adl {
class Display {
@@ -48,10 +43,9 @@ public:
virtual ~Display();
virtual void init() = 0;
- virtual bool saveThumbnail(Common::WriteStream &out) = 0;
void setMode(Mode mode);
- void copyTextSurface();
- void copyGfxSurface();
+ virtual void renderText() = 0;
+ virtual void renderGraphics() = 0;
virtual char asciiToNative(char c) const = 0;
virtual void printChar(char c) = 0;
@@ -68,23 +62,13 @@ public:
void scrollUp();
protected:
- Display() : _textBuf(nullptr), _textSurface(nullptr), _gfxSurface(nullptr), _cursorPos(0),
- _mode(kModeText), _splitHeight(0), _textWidth(0), _textHeight(0) { }
+ Display() : _textBuf(nullptr), _cursorPos(0), _mode(kModeText), _textWidth(0), _textHeight(0) { }
- void createSurfaces(uint gfxWidth, uint gfxHeight, uint splitHeight);
void createTextBuffer(uint textWidth, uint textHeight);
byte *_textBuf;
- Graphics::Surface *_textSurface;
- Graphics::Surface *_gfxSurface;
uint _cursorPos;
-
-private:
- virtual void updateTextSurface() = 0;
- virtual void updateGfxSurface() = 0;
-
Mode _mode;
- uint _splitHeight;
uint _textWidth;
uint _textHeight;
};
diff --git a/engines/adl/display_a2.cpp b/engines/adl/display_a2.cpp
index 3a62e33ca6..e738e77154 100644
--- a/engines/adl/display_a2.cpp
+++ b/engines/adl/display_a2.cpp
@@ -101,183 +101,6 @@ static const byte font[64][5] = {
{ 0x00, 0x82, 0x44, 0x28, 0x10 }, { 0x04, 0x02, 0xb2, 0x0a, 0x04 } // >?
};
-Display_A2::Display_A2() : _showCursor(false) {
- initGraphics(Display_A2::kGfxWidth * 2, Display_A2::kGfxHeight * 2);
-}
-
-Display_A2::~Display_A2() {
- delete[] _frameBuf;
-
- if (_font) {
- _font->free();
- delete _font;
- }
-}
-
-void Display_A2::init() {
- _monochrome = !ConfMan.getBool("color");
- _scanlines = ConfMan.getBool("scanlines");
-
- if (_monochrome)
- g_system->getPaletteManager()->setPalette(monoPalette, 0, MONO_PALETTE_ENTRIES);
- else
- g_system->getPaletteManager()->setPalette(colorPalette, 0, COLOR_PALETTE_ENTRIES);
-
- showScanlines(_scanlines);
-
- // We need 2x scaling to properly render the half-pixel shift
- // of the second palette
- createSurfaces(Display_A2::kGfxWidth * 2, Display_A2::kGfxHeight * 2, 64);
- createTextBuffer(Display_A2::kTextWidth, Display_A2::kTextHeight);
-
- _frameBuf = new byte[Display_A2::kGfxSize];
- memset(_frameBuf, 0, Display_A2::kGfxSize);
-
- createFont();
-
- _startMillis = g_system->getMillis();
-}
-
-bool Display_A2::saveThumbnail(Common::WriteStream &out) {
- if (_scanlines) {
- showScanlines(false);
- g_system->updateScreen();
- }
-
- bool retval = Graphics::saveThumbnail(out);
-
- if (_scanlines) {
- showScanlines(true);
- g_system->updateScreen();
- }
-
- return retval;
-}
-
-void Display_A2::loadFrameBuffer(Common::ReadStream &stream, byte *dst) {
- for (uint j = 0; j < 8; ++j) {
- for (uint i = 0; i < 8; ++i) {
- stream.read(dst, Display_A2::kGfxPitch);
- dst += Display_A2::kGfxPitch * 64;
- stream.read(dst, Display_A2::kGfxPitch);
- dst += Display_A2::kGfxPitch * 64;
- stream.read(dst, Display_A2::kGfxPitch);
- stream.readUint32LE();
- stream.readUint32LE();
- dst -= Display_A2::kGfxPitch * 120;
- }
- dst -= Display_A2::kGfxPitch * 63;
- }
-
- if (stream.eos() || stream.err())
- error("Failed to read frame buffer");
-}
-
-void Display_A2::loadFrameBuffer(Common::ReadStream &stream) {
- loadFrameBuffer(stream, _frameBuf);
-}
-
-void Display_A2::putPixel(const Common::Point &p, byte color) {
- byte offset = p.x / 7;
- byte mask = 0x80 | (1 << (p.x % 7));
-
- // Since white and black are in both palettes, we leave
- // the palette bit alone
- if ((color & 0x7f) == 0x7f || (color & 0x7f) == 0)
- mask &= 0x7f;
-
- // Adjust colors starting with bits '01' or '10' for
- // odd offsets
- if (offset & 1) {
- byte c = color << 1;
- if (c >= 0x40 && c < 0xc0)
- color ^= 0x7f;
- }
-
- writeFrameBuffer(p, color, mask);
-}
-
-void Display_A2::setPixelByte(const Common::Point &p, byte color) {
- assert(p.x >= 0 && p.x < Display_A2::kGfxWidth && p.y >= 0 && p.y < Display_A2::kGfxHeight);
-
- _frameBuf[p.y * Display_A2::kGfxPitch + p.x / 7] = color;
-}
-
-void Display_A2::setPixelBit(const Common::Point &p, byte color) {
- writeFrameBuffer(p, color, 1 << (p.x % 7));
-}
-
-void Display_A2::setPixelPalette(const Common::Point &p, byte color) {
- writeFrameBuffer(p, color, 0x80);
-}
-
-byte Display_A2::getPixelByte(const Common::Point &p) const {
- assert(p.x >= 0 && p.x < Display_A2::kGfxWidth && p.y >= 0 && p.y < Display_A2::kGfxHeight);
-
- return _frameBuf[p.y * Display_A2::kGfxPitch + p.x / 7];
-}
-
-bool Display_A2::getPixelBit(const Common::Point &p) const {
- assert(p.x >= 0 && p.x < Display_A2::kGfxWidth && p.y >= 0 && p.y < Display_A2::kGfxHeight);
-
- byte *b = _frameBuf + p.y * Display_A2::kGfxPitch + p.x / 7;
- return *b & (1 << (p.x % 7));
-}
-
-void Display_A2::clear(byte color) {
- byte val = 0;
-
- byte c = color << 1;
- if (c >= 0x40 && c < 0xc0)
- val = 0x7f;
-
- for (uint i = 0; i < Display_A2::kGfxSize; ++i) {
- _frameBuf[i] = color;
- color ^= val;
- }
-}
-
-// FIXME: This does not currently update the surfaces
-void Display_A2::printChar(char c) {
- if (c == Display_A2::asciiToNative('\r'))
- _cursorPos = (_cursorPos / Display_A2::kTextWidth + 1) * Display_A2::kTextWidth;
- else if (c == Display_A2::asciiToNative('\a')) {
- copyTextSurface();
- static_cast<AdlEngine *>(g_engine)->bell();
- } else if ((byte)c < 0x80 || (byte)c >= 0xa0) {
- setCharAtCursor(c);
- ++_cursorPos;
- }
-
- if (_cursorPos == Display_A2::kTextWidth * Display_A2::kTextHeight)
- scrollUp();
-}
-
-void Display_A2::showCursor(bool enable) {
- _showCursor = enable;
-}
-
-void Display_A2::writeFrameBuffer(const Common::Point &p, byte color, byte mask) {
- assert(p.x >= 0 && p.x < Display_A2::kGfxWidth && p.y >= 0 && p.y < Display_A2::kGfxHeight);
-
- byte *b = _frameBuf + p.y * Display_A2::kGfxPitch + p.x / 7;
- color ^= *b;
- color &= mask;
- *b ^= color;
-}
-
-void Display_A2::showScanlines(bool enable) {
- byte pal[COLOR_PALETTE_ENTRIES * 3];
-
- g_system->getPaletteManager()->grabPalette(pal, 0, COLOR_PALETTE_ENTRIES);
-
- if (enable) {
- for (uint i = 0; i < ARRAYSIZE(pal); ++i)
- pal[i] = pal[i] * (100 - SCANLINE_OPACITY) / 100;
- }
-
- g_system->getPaletteManager()->setPalette(pal, COLOR_PALETTE_ENTRIES, COLOR_PALETTE_ENTRIES);
-}
static byte processColorBits(uint16 &bits, bool &odd, bool secondPal) {
byte color = 0;
@@ -395,7 +218,82 @@ static void copyEvenSurfaceRows(Graphics::Surface &surf) {
}
}
-void Display_A2::updateGfxSurface() {
+class Display_A2_Monitor : public Display_A2 {
+public:
+ Display_A2_Monitor();
+ ~Display_A2_Monitor();
+
+ enum {
+ kSplitHeight = 64
+ };
+
+ void init() override;
+ void renderText() override;
+ void renderGraphics() override;
+
+private:
+ void updateTextSurface();
+ void updateGfxSurface();
+ void drawChar(byte c, int x, int y);
+ void createFont();
+ void showScanlines(bool enable);
+ void createSurfaces(uint gfxWidth, uint gfxHeight);
+
+ Graphics::Surface *_textSurface;
+ Graphics::Surface *_gfxSurface;
+ Graphics::Surface *_font;
+ bool _scanlines;
+ bool _monochrome;
+};
+
+Display_A2_Monitor::Display_A2_Monitor() :
+ _textSurface(nullptr),
+ _gfxSurface(nullptr),
+ _font(nullptr),
+ _scanlines(false),
+ _monochrome(false) { }
+
+Display_A2_Monitor::~Display_A2_Monitor() {
+ if (_font) {
+ _font->free();
+ delete _font;
+ }
+
+ _textSurface->free();
+ delete _textSurface;
+
+ _gfxSurface->free();
+ delete _gfxSurface;
+}
+
+void Display_A2_Monitor::createSurfaces(uint gfxWidth, uint gfxHeight) {
+ _gfxSurface = new Graphics::Surface;
+ _gfxSurface->create(gfxWidth, gfxHeight, Graphics::PixelFormat::createFormatCLUT8());
+ _textSurface = new Graphics::Surface;
+ _textSurface->create(gfxWidth, gfxHeight, Graphics::PixelFormat::createFormatCLUT8());
+}
+
+void Display_A2_Monitor::init() {
+ Display_A2::init();
+
+ // We need 2x scaling to properly render the half-pixel shift
+ // of the second palette
+ createSurfaces(Display_A2::kGfxWidth * 2, Display_A2::kGfxHeight * 2);
+
+ _monochrome = !ConfMan.getBool("color");
+ _scanlines = ConfMan.getBool("scanlines");
+
+ if (_monochrome)
+ g_system->getPaletteManager()->setPalette(monoPalette, 0, MONO_PALETTE_ENTRIES);
+ else
+ g_system->getPaletteManager()->setPalette(colorPalette, 0, COLOR_PALETTE_ENTRIES);
+
+ createFont();
+
+ showScanlines(_scanlines);
+}
+
+void Display_A2_Monitor::updateGfxSurface() {
byte *src = _frameBuf;
byte *dst = (byte *)_gfxSurface->getPixels();
@@ -411,7 +309,7 @@ void Display_A2::updateGfxSurface() {
copyEvenSurfaceRows(*_gfxSurface);
}
-void Display_A2::updateTextSurface() {
+void Display_A2_Monitor::updateTextSurface() {
for (uint row = 0; row < 24; ++row)
for (uint col = 0; col < Display_A2::kTextWidth; ++col) {
uint charPos = row * Display_A2::kTextWidth + col;
@@ -424,11 +322,7 @@ void Display_A2::updateTextSurface() {
r.translate(((c & 0x3f) % 16) * 7 * 2, (c & 0x3f) / 16 * 8 * 2);
if (!(c & 0x80)) {
- // Blink text. We subtract _startMillis to make this compatible
- // with the event recorder, which returns offsetted values on
- // playback.
- const uint32 millisPassed = g_system->getMillis() - _startMillis;
- if (!(c & 0x40) || ((millisPassed / 270) & 1))
+ if (!(c & 0x40) || ((g_system->getMillis() / 270) & 1))
r.translate(0, 4 * 8 * 2);
}
@@ -436,7 +330,29 @@ void Display_A2::updateTextSurface() {
}
}
-void Display_A2::drawChar(byte c, int x, int y) {
+void Display_A2_Monitor::renderText() {
+ updateTextSurface();
+
+ if (_mode == Display::kModeText)
+ g_system->copyRectToScreen(_textSurface->getPixels(), _textSurface->pitch, 0, 0, _textSurface->w, _textSurface->h);
+ else if (_mode == Display::kModeMixed)
+ g_system->copyRectToScreen(_textSurface->getBasePtr(0, _textSurface->h - kSplitHeight), _textSurface->pitch, 0, _textSurface->h - kSplitHeight, _textSurface->w, kSplitHeight);
+
+ g_system->updateScreen();
+}
+
+void Display_A2_Monitor::renderGraphics() {
+ updateGfxSurface();
+
+ if (_mode == kModeGraphics)
+ g_system->copyRectToScreen(_gfxSurface->getPixels(), _gfxSurface->pitch, 0, 0, _gfxSurface->w, _gfxSurface->h);
+ else if (_mode == kModeMixed)
+ g_system->copyRectToScreen(_gfxSurface->getPixels(), _gfxSurface->pitch, 0, 0, _gfxSurface->w, _gfxSurface->h - kSplitHeight);
+
+ g_system->updateScreen();
+}
+
+void Display_A2_Monitor::drawChar(byte c, int x, int y) {
byte *buf = (byte *)_font->getPixels() + y * _font->pitch + x;
for (uint row = 0; row < 8; ++row) {
@@ -451,7 +367,7 @@ void Display_A2::drawChar(byte c, int x, int y) {
}
}
-void Display_A2::createFont() {
+void Display_A2_Monitor::createFont() {
_font = new Graphics::Surface;
_font->create(16 * 7 * 2, 4 * 8 * 2 * 2, Graphics::PixelFormat::createFormatCLUT8());
@@ -474,4 +390,146 @@ void Display_A2::createFont() {
copyEvenSurfaceRows(*_font);
}
+void Display_A2_Monitor::showScanlines(bool enable) {
+ byte pal[COLOR_PALETTE_ENTRIES * 3];
+
+ g_system->getPaletteManager()->grabPalette(pal, 0, COLOR_PALETTE_ENTRIES);
+
+ if (enable) {
+ for (uint i = 0; i < ARRAYSIZE(pal); ++i)
+ pal[i] = pal[i] * (100 - SCANLINE_OPACITY) / 100;
+ }
+
+ g_system->getPaletteManager()->setPalette(pal, COLOR_PALETTE_ENTRIES, COLOR_PALETTE_ENTRIES);
+}
+
+Display_A2::Display_A2() : _frameBuf(nullptr), _showCursor(false) {
+ initGraphics(Display_A2::kGfxWidth * 2, Display_A2::kGfxHeight * 2);
+}
+
+Display_A2::~Display_A2() {
+ delete[] _frameBuf;
+}
+
+void Display_A2::init() {
+ createTextBuffer(Display_A2::kTextWidth, Display_A2::kTextHeight);
+
+ _frameBuf = new byte[Display_A2::kGfxSize];
+ memset(_frameBuf, 0, Display_A2::kGfxSize);
+}
+
+void Display_A2::loadFrameBuffer(Common::ReadStream &stream, byte *dst) {
+ for (uint j = 0; j < 8; ++j) {
+ for (uint i = 0; i < 8; ++i) {
+ stream.read(dst, Display_A2::kGfxPitch);
+ dst += Display_A2::kGfxPitch * 64;
+ stream.read(dst, Display_A2::kGfxPitch);
+ dst += Display_A2::kGfxPitch * 64;
+ stream.read(dst, Display_A2::kGfxPitch);
+ stream.readUint32LE();
+ stream.readUint32LE();
+ dst -= Display_A2::kGfxPitch * 120;
+ }
+ dst -= Display_A2::kGfxPitch * 63;
+ }
+
+ if (stream.eos() || stream.err())
+ error("Failed to read frame buffer");
+}
+
+void Display_A2::loadFrameBuffer(Common::ReadStream &stream) {
+ loadFrameBuffer(stream, _frameBuf);
+}
+
+void Display_A2::putPixel(const Common::Point &p, byte color) {
+ byte offset = p.x / 7;
+ byte mask = 0x80 | (1 << (p.x % 7));
+
+ // Since white and black are in both palettes, we leave
+ // the palette bit alone
+ if ((color & 0x7f) == 0x7f || (color & 0x7f) == 0)
+ mask &= 0x7f;
+
+ // Adjust colors starting with bits '01' or '10' for
+ // odd offsets
+ if (offset & 1) {
+ byte c = color << 1;
+ if (c >= 0x40 && c < 0xc0)
+ color ^= 0x7f;
+ }
+
+ writeFrameBuffer(p, color, mask);
+}
+
+void Display_A2::setPixelByte(const Common::Point &p, byte color) {
+ assert(p.x >= 0 && p.x < Display_A2::kGfxWidth && p.y >= 0 && p.y < Display_A2::kGfxHeight);
+
+ _frameBuf[p.y * Display_A2::kGfxPitch + p.x / 7] = color;
+}
+
+void Display_A2::setPixelBit(const Common::Point &p, byte color) {
+ writeFrameBuffer(p, color, 1 << (p.x % 7));
+}
+
+void Display_A2::setPixelPalette(const Common::Point &p, byte color) {
+ writeFrameBuffer(p, color, 0x80);
+}
+
+byte Display_A2::getPixelByte(const Common::Point &p) const {
+ assert(p.x >= 0 && p.x < Display_A2::kGfxWidth && p.y >= 0 && p.y < Display_A2::kGfxHeight);
+
+ return _frameBuf[p.y * Display_A2::kGfxPitch + p.x / 7];
+}
+
+bool Display_A2::getPixelBit(const Common::Point &p) const {
+ assert(p.x >= 0 && p.x < Display_A2::kGfxWidth && p.y >= 0 && p.y < Display_A2::kGfxHeight);
+
+ byte *b = _frameBuf + p.y * Display_A2::kGfxPitch + p.x / 7;
+ return *b & (1 << (p.x % 7));
+}
+
+void Display_A2::clear(byte color) {
+ byte val = 0;
+
+ byte c = color << 1;
+ if (c >= 0x40 && c < 0xc0)
+ val = 0x7f;
+
+ for (uint i = 0; i < Display_A2::kGfxSize; ++i) {
+ _frameBuf[i] = color;
+ color ^= val;
+ }
+}
+
+// FIXME: This does not currently update the surfaces
+void Display_A2::printChar(char c) {
+ if (c == Display_A2::asciiToNative('\r'))
+ _cursorPos = (_cursorPos / Display_A2::kTextWidth + 1) * Display_A2::kTextWidth;
+ else if (c == Display_A2::asciiToNative('\a')) {
+ renderText();
+ static_cast<AdlEngine *>(g_engine)->bell();
+ } else if ((byte)c < 0x80 || (byte)c >= 0xa0) {
+ setCharAtCursor(c);
+ ++_cursorPos;
+ }
+
+ if (_cursorPos == Display_A2::kTextWidth * Display_A2::kTextHeight)
+ scrollUp();
+}
+
+void Display_A2::showCursor(bool enable) {
+ _showCursor = enable;
+}
+
+void Display_A2::writeFrameBuffer(const Common::Point &p, byte color, byte mask) {
+ assert(p.x >= 0 && p.x < Display_A2::kGfxWidth && p.y >= 0 && p.y < Display_A2::kGfxHeight);
+
+ byte *b = _frameBuf + p.y * Display_A2::kGfxPitch + p.x / 7;
+ color ^= *b;
+ color &= mask;
+ *b ^= color;
+}
+
+Display_A2 *Display_A2_create() { return new Display_A2_Monitor(); }
+
} // End of namespace Adl
diff --git a/engines/adl/display_a2.h b/engines/adl/display_a2.h
index 52c7970d26..4e84facd58 100644
--- a/engines/adl/display_a2.h
+++ b/engines/adl/display_a2.h
@@ -42,7 +42,6 @@ public:
};
void init() override;
- bool saveThumbnail(Common::WriteStream &out) override;
// Graphics
uint getGfxWidth() const { return kGfxWidth; }
@@ -63,23 +62,18 @@ public:
void printChar(char c) override;
void showCursor(bool enable) override;
+protected:
+ byte *_frameBuf;
+ bool _showCursor;
+
private:
void writeFrameBuffer(const Common::Point &p, byte color, byte mask);
- void updateTextSurface() override;
- void updateGfxSurface() override;
-
- void showScanlines(bool enable);
- void drawChar(byte c, int x, int y);
- void createFont();
- byte *_frameBuf;
- bool _scanlines;
- bool _monochrome;
- Graphics::Surface *_font;
- bool _showCursor;
- uint32 _startMillis;
+ virtual void showScanlines(bool enable) { };
};
+Display_A2 *Display_A2_create();
+
} // End of namespace Adl
#endif
diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp
index 169a0ea7d9..9c448b8fd7 100644
--- a/engines/adl/hires1.cpp
+++ b/engines/adl/hires1.cpp
@@ -156,7 +156,7 @@ void HiRes1Engine::runIntro() {
stream->seek(IDI_HR1_OFS_LOGO_0);
_display->setMode(Display::kModeGraphics);
static_cast<Display_A2 *>(_display)->loadFrameBuffer(*stream);
- _display->copyGfxSurface();
+ _display->renderGraphics();
if (getGameVersion() == GAME_VER_HR1_PD) {
// Only the PD version shows a title screen during the load
@@ -239,7 +239,7 @@ void HiRes1Engine::runIntro() {
stream.reset(_files->createReadStream(IDS_HR1_EXE_1));
stream->seek(0x1800);
static_cast<Display_A2 *>(_display)->loadFrameBuffer(*stream);
- _display->copyGfxSurface();
+ _display->renderGraphics();
_display->setMode(Display::kModeMixed);
@@ -479,7 +479,7 @@ void HiRes1Engine::showRoom() {
drawItems();
}
- _display->copyGfxSurface();
+ _display->renderGraphics();
_messageDelay = false;
printString(_roomData.description);
_messageDelay = true;
diff --git a/engines/adl/hires4.cpp b/engines/adl/hires4.cpp
index 5171685175..a4499533c3 100644
--- a/engines/adl/hires4.cpp
+++ b/engines/adl/hires4.cpp
@@ -134,7 +134,7 @@ void HiRes4Engine::putSpace(uint x, uint y) const {
_display->moveCursorTo(Common::Point(x, y));
_display->printChar(' ');
- _display->copyTextSurface();
+ _display->renderText();
delay(2);
}
@@ -167,7 +167,7 @@ void HiRes4Engine::drawText(const Common::String &str, Common::SeekableReadStrea
drawChar(c, shapeTable, pos);
drawChar(98, shapeTable, pos);
- _display->copyGfxSurface();
+ _display->renderGraphics();
delay(15);
}
}
@@ -223,7 +223,7 @@ void HiRes4Engine::runIntroAdvise(Common::SeekableReadStream &menu) {
_display->printAsciiString(left);
_display->moveCursorTo(Common::Point(19, y));
_display->printAsciiString(right);
- _display->copyTextSurface();
+ _display->renderText();
delay(35);
} while (x != backupText[i].size() / 2);
@@ -245,7 +245,7 @@ void HiRes4Engine::runIntroAdvise(Common::SeekableReadStream &menu) {
_display->moveCursorTo(Common::Point(32, 18));
_display->printChar(_display->asciiToNative(cursor[cursorIdx]));
- _display->copyTextSurface();
+ _display->renderText();
g_system->delayMillis(25);
cursorIdx = (cursorIdx + 1) % cursor.size();
}
@@ -269,7 +269,7 @@ void HiRes4Engine::runIntroLogo(Common::SeekableReadStream &ms2) {
if (x % 7 == 6)
display->setPixelPalette(Common::Point(x, y), p);
}
- display->copyGfxSurface();
+ display->renderGraphics();
if (shouldQuit()) {
delete[] logo;
@@ -288,7 +288,7 @@ void HiRes4Engine::runIntroLogo(Common::SeekableReadStream &ms2) {
for (p.x = 0; p.x < (int)width; p.x += 7)
display->setPixelByte(Common::Point(p.x, p.y - 1), display->getPixelByte(p));
- display->copyGfxSurface();
+ display->renderGraphics();
Tones tone;
tone.push_back(Tone(kClock / 2.0 / ((i * 4 + 1) * 10.0 + 10.0), 12.5));
@@ -314,13 +314,13 @@ void HiRes4Engine::runIntroTitle(Common::SeekableReadStream &menu, Common::Seeka
// Draw "TM" with lines
_graphics->drawLine(Common::Point(200, 170), Common::Point(200, 174), 0x7f);
_graphics->drawLine(Common::Point(198, 170), Common::Point(202, 170), 0x7f);
- _display->copyGfxSurface();
+ _display->renderGraphics();
delay(7);
_graphics->drawLine(Common::Point(204, 170), Common::Point(204, 174), 0x7f);
_graphics->drawLine(Common::Point(204, 170), Common::Point(207, 173), 0x7f);
_graphics->drawLine(Common::Point(207, 173), Common::Point(209, 170), 0x7f);
_graphics->drawLine(Common::Point(209, 170), Common::Point(209, 174), 0x7f);
- _display->copyGfxSurface();
+ _display->renderGraphics();
delay(7);
titleString = readStringAt(menu, 0x46c);
diff --git a/engines/adl/hires5.cpp b/engines/adl/hires5.cpp
index b98dfc57c3..b9b51c60fc 100644
--- a/engines/adl/hires5.cpp
+++ b/engines/adl/hires5.cpp
@@ -97,7 +97,7 @@ void HiRes5Engine::drawLight(uint index, byte color) const {
for (int xDelta = 0; xDelta < 7; ++xDelta)
display->putPixel(Common::Point(xCoord[index] + xDelta, yCoord + yDelta), color);
- display->copyGfxSurface();
+ display->renderGraphics();
}
void HiRes5Engine::animateLights() const {
@@ -248,7 +248,7 @@ void HiRes5Engine::runIntro() {
display->setMode(Display::kModeGraphics);
display->loadFrameBuffer(*stream);
- display->copyGfxSurface();
+ display->renderGraphics();
inputKey();
diff --git a/engines/adl/hires6.cpp b/engines/adl/hires6.cpp
index da5b4655c2..53db92dd26 100644
--- a/engines/adl/hires6.cpp
+++ b/engines/adl/hires6.cpp
@@ -200,11 +200,11 @@ void HiRes6Engine::runIntro() {
display->setMode(Display::kModeGraphics);
display->loadFrameBuffer(*stream);
- display->copyGfxSurface();
+ display->renderGraphics();
delay(256 * 8609 / 1000);
display->loadFrameBuffer(*stream);
- display->copyGfxSurface();
+ display->renderGraphics();
delay(256 * 8609 / 1000);
display->loadFrameBuffer(*stream);
@@ -220,7 +220,7 @@ void HiRes6Engine::runIntro() {
delete files;
- display->copyGfxSurface();
+ display->renderGraphics();
display->home();
display->setMode(Display::kModeMixed);
display->moveCursorTo(Common::Point(0, 21));
@@ -328,7 +328,7 @@ void HiRes6Engine::showRoom() {
if (!_state.isDark)
drawItems();
- _display->copyGfxSurface();
+ _display->renderGraphics();
setVar(2, 0xff);
printString(_roomData.description);
}