From f6214df664ac4c0d750b59b7f0cca9cf747894d1 Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Mon, 30 Jan 2017 21:54:02 +0100 Subject: ADL: Clear screen with white in v2+ This fixes hires5, region 14, room 29 --- engines/adl/adl.cpp | 5 ----- engines/adl/adl.h | 1 - engines/adl/adl_v2.cpp | 2 +- engines/adl/console.cpp | 3 ++- engines/adl/graphics.cpp | 17 +++++++++++------ engines/adl/graphics.h | 10 ++++++++-- engines/adl/hires1.cpp | 2 +- engines/adl/hires6.cpp | 2 +- 8 files changed, 24 insertions(+), 18 deletions(-) (limited to 'engines') diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp index 3deeca1aed..bc67ec319a 100644 --- a/engines/adl/adl.cpp +++ b/engines/adl/adl.cpp @@ -446,11 +446,6 @@ void AdlEngine::loadDroppedItemOffsets(Common::ReadStream &stream, byte count) { } } -void AdlEngine::clearScreen() const { - _display->setMode(DISPLAY_MODE_MIXED); - _display->clear(0x00); -} - void AdlEngine::drawPic(byte pic, Common::Point pos) const { if (_roomData.pictures.contains(pic)) _graphics->drawPic(*_roomData.pictures[pic]->createReadStream(), pos); diff --git a/engines/adl/adl.h b/engines/adl/adl.h index 3f26636234..3630cd69b9 100644 --- a/engines/adl/adl.h +++ b/engines/adl/adl.h @@ -309,7 +309,6 @@ protected: int o1_setRoomPic(ScriptEnv &e); // Graphics - void clearScreen() const; void drawPic(byte pic, Common::Point pos = Common::Point()) const; // Sound diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp index e78366ff63..9653e2e40b 100644 --- a/engines/adl/adl_v2.cpp +++ b/engines/adl/adl_v2.cpp @@ -255,7 +255,7 @@ void AdlEngine_v2::showRoom() { if (_state.room != _roomOnScreen) { loadRoom(_state.room); - clearScreen(); + _graphics->clearScreen(); if (!_state.isDark) redrawPic = true; diff --git a/engines/adl/console.cpp b/engines/adl/console.cpp index 7305ec8125..ad3277ffaa 100644 --- a/engines/adl/console.cpp +++ b/engines/adl/console.cpp @@ -24,6 +24,7 @@ #include "adl/console.h" #include "adl/display.h" +#include "adl/graphics.h" #include "adl/adl.h" namespace Adl { @@ -173,7 +174,7 @@ bool Console::Cmd_DumpScripts(int argc, const char **argv) { } void Console::prepareGame() { - _engine->clearScreen(); + _engine->_graphics->clearScreen(); _engine->loadRoom(_engine->_state.room); _engine->showRoom(); _engine->_display->updateTextScreen(); diff --git a/engines/adl/graphics.cpp b/engines/adl/graphics.cpp index 47ef5744fa..e1b76000f6 100644 --- a/engines/adl/graphics.cpp +++ b/engines/adl/graphics.cpp @@ -29,6 +29,11 @@ namespace Adl { +void GraphicsMan::clearScreen() const { + _display.setMode(DISPLAY_MODE_MIXED); + _display.clear(getClearColor()); +} + // Draws a four-connected line void GraphicsMan::drawLine(const Common::Point &p1, const Common::Point &p2, byte color) const { int16 deltaX = p2.x - p1.x; @@ -209,11 +214,6 @@ static const byte fillPatterns[NUM_PATTERNS][PATTERN_LEN] = { p.y += _offset.y; \ } while (0) -void Graphics_v2::clear() { - _display.clear(0xff); - _color = 0; -} - void Graphics_v2::drawCorners(Common::SeekableReadStream &pic, bool yFirst) { Common::Point p; @@ -367,6 +367,10 @@ void Graphics_v2::fill(Common::SeekableReadStream &pic) { } void Graphics_v2::drawPic(Common::SeekableReadStream &pic, const Common::Point &pos) { + // NOTE: The original engine only resets the color for overlays. As a result, room + // pictures that draw without setting a color or clearing the screen, will use the + // last color set by the previous picture. We assume this is unintentional and do + // not copy this behavior. _color = 0; _offset = pos; @@ -393,7 +397,8 @@ void Graphics_v2::drawPic(Common::SeekableReadStream &pic, const Common::Point & fill(pic); break; case 0xe5: - clear(); + clearScreen(); + _color = 0x00; break; case 0xf0: _color = 0x00; diff --git a/engines/adl/graphics.h b/engines/adl/graphics.h index af34e80113..f05045a4dc 100644 --- a/engines/adl/graphics.h +++ b/engines/adl/graphics.h @@ -23,9 +23,10 @@ #ifndef ADL_PICTURE_H #define ADL_PICTURE_H +#include "common/rect.h" + namespace Common { class SeekableReadStream; -struct Point; } namespace Adl { @@ -36,12 +37,16 @@ class GraphicsMan { public: virtual ~GraphicsMan() { } virtual void drawPic(Common::SeekableReadStream &pic, const Common::Point &pos) = 0; + void clearScreen() const; protected: GraphicsMan(Display &display) : _display(display) { } void drawLine(const Common::Point &p1, const Common::Point &p2, byte color) const; Display &_display; + +private: + virtual byte getClearColor() const = 0; }; // Used in hires1 @@ -53,6 +58,7 @@ public: private: void drawCornerPixel(Common::Point &p, byte color, byte bits, byte quadrant) const; + byte getClearColor() const { return 0x00; } }; // Used in hires0 and hires2-hires4 @@ -66,13 +72,13 @@ protected: void fillRow(Common::Point p, const byte pattern, const bool stopBit = false); private: - void clear(); void drawCorners(Common::SeekableReadStream &pic, bool yFirst); void drawRelativeLines(Common::SeekableReadStream &pic); void drawAbsoluteLines(Common::SeekableReadStream &pic); virtual void fillRowLeft(Common::Point p, const byte pattern, const bool stopBit); virtual void fillAt(Common::Point p, const byte pattern); void fill(Common::SeekableReadStream &pic); + byte getClearColor() const { return 0xff; } byte _color; Common::Point _offset; diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp index e811b747c3..239792d4f7 100644 --- a/engines/adl/hires1.cpp +++ b/engines/adl/hires1.cpp @@ -429,7 +429,7 @@ void HiRes1Engine::loadRoom(byte roomNr) { void HiRes1Engine::showRoom() { _state.curPicture = getCurRoom().curPicture; - clearScreen(); + _graphics->clearScreen(); loadRoom(_state.room); if (!_state.isDark) { diff --git a/engines/adl/hires6.cpp b/engines/adl/hires6.cpp index c07493f5bd..77b0cb64ee 100644 --- a/engines/adl/hires6.cpp +++ b/engines/adl/hires6.cpp @@ -335,7 +335,7 @@ void HiRes6Engine::showRoom() { if (getVar(26) < 0x80 && getCurRoom().isFirstTime) setVar(26, 0); - clearScreen(); + _graphics->clearScreen(); if (!_state.isDark) redrawPic = true; -- cgit v1.2.3