Skip to content

Commit

Permalink
ADL: Clear screen with white in v2+
Browse files Browse the repository at this point in the history
This fixes hires5, region 14, room 29
  • Loading branch information
waltervn committed Jan 30, 2017
1 parent c8cd4d2 commit f6214df
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 18 deletions.
5 changes: 0 additions & 5 deletions engines/adl/adl.cpp
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion engines/adl/adl.h
Expand Up @@ -309,7 +309,6 @@ friend class Console;
int o1_setRoomPic(ScriptEnv &e);

// Graphics
void clearScreen() const;
void drawPic(byte pic, Common::Point pos = Common::Point()) const;

// Sound
Expand Down
2 changes: 1 addition & 1 deletion engines/adl/adl_v2.cpp
Expand Up @@ -255,7 +255,7 @@ void AdlEngine_v2::showRoom() {

if (_state.room != _roomOnScreen) {
loadRoom(_state.room);
clearScreen();
_graphics->clearScreen();

if (!_state.isDark)
redrawPic = true;
Expand Down
3 changes: 2 additions & 1 deletion engines/adl/console.cpp
Expand Up @@ -24,6 +24,7 @@

#include "adl/console.h"
#include "adl/display.h"
#include "adl/graphics.h"
#include "adl/adl.h"

namespace Adl {
Expand Down Expand Up @@ -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();
Expand Down
17 changes: 11 additions & 6 deletions engines/adl/graphics.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down
10 changes: 8 additions & 2 deletions engines/adl/graphics.h
Expand Up @@ -23,9 +23,10 @@
#ifndef ADL_PICTURE_H
#define ADL_PICTURE_H

#include "common/rect.h"

namespace Common {
class SeekableReadStream;
struct Point;
}

namespace Adl {
Expand All @@ -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
Expand All @@ -53,6 +58,7 @@ class Graphics_v1 : public GraphicsMan {

private:
void drawCornerPixel(Common::Point &p, byte color, byte bits, byte quadrant) const;
byte getClearColor() const { return 0x00; }
};

// Used in hires0 and hires2-hires4
Expand All @@ -66,13 +72,13 @@ class Graphics_v2 : public GraphicsMan {
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;
Expand Down
2 changes: 1 addition & 1 deletion engines/adl/hires1.cpp
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion engines/adl/hires6.cpp
Expand Up @@ -335,7 +335,7 @@ void HiRes6Engine::showRoom() {
if (getVar(26) < 0x80 && getCurRoom().isFirstTime)
setVar(26, 0);

clearScreen();
_graphics->clearScreen();

if (!_state.isDark)
redrawPic = true;
Expand Down

0 comments on commit f6214df

Please sign in to comment.