Skip to content

Commit

Permalink
SHERLOCK: RT: Implement maskArea
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jul 23, 2015
1 parent 71296d6 commit 5117482
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 26 deletions.
5 changes: 0 additions & 5 deletions engines/sherlock/surface.cpp
Expand Up @@ -299,9 +299,4 @@ void Surface::writeFancyString(const Common::String &str, const Common::Point &p
writeString(str, Common::Point(pt.x + 1, pt.y + 1), overrideColor2);
}

void Surface::maskArea(const ImageFrame &src, const Common::Point &pt) {
// TODO
error("TODO: maskArea");
}

} // End of namespace Sherlock
2 changes: 0 additions & 2 deletions engines/sherlock/surface.h
Expand Up @@ -142,8 +142,6 @@ class Surface: public Fonts {

void fill(uint16 color);

void maskArea(const ImageFrame &src, const Common::Point &pt);

/**
* Clear the surface
*/
Expand Down
6 changes: 3 additions & 3 deletions engines/sherlock/tattoo/tattoo.cpp
Expand Up @@ -89,11 +89,11 @@ void TattooEngine::startScene() {
case 53:
case 68:
// Load overlay mask(s) for the scene
ui._mask = new ImageFile(Common::String::format("res%02d.msk", _scene->_goToScene));
ui._mask = _res->load(Common::String::format("res%02d.msk", _scene->_goToScene));
if (_scene->_goToScene == 8)
ui._mask1 = new ImageFile("res08a.msk");
ui._mask1 = _res->load("res08a.msk");
else if (_scene->_goToScene == 18 || _scene->_goToScene == 68)
ui._mask1 = new ImageFile("res08a.msk");
ui._mask1 = _res->load("res08a.msk");
break;

case OVERHEAD_MAP:
Expand Down
57 changes: 42 additions & 15 deletions engines/sherlock/tattoo/tattoo_user_interface.cpp
Expand Up @@ -750,50 +750,77 @@ void TattooUserInterface::doBgAnimEraseBackground() {

void TattooUserInterface::drawMaskArea(bool mode) {
Scene &scene = *_vm->_scene;
Screen &screen = *_vm->_screen;
int xp = mode ? _maskOffset.x : 0;

if (_mask != nullptr) {
switch (scene._currentScene) {
case 7:
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110));
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110));
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 110));
maskArea(*_mask, Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110));
maskArea(*_mask, Common::Point(_maskOffset.x, 110));
maskArea(*_mask, Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 110));
break;

case 8:
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 180));
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 180));
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 180));
maskArea(*_mask, Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 180));
maskArea(*_mask, Common::Point(_maskOffset.x, 180));
maskArea(*_mask, Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 180));
if (!_vm->readFlags(880))
screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(940, 300));
maskArea(*_mask1, Common::Point(940, 300));
break;

case 18:
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(xp, 203));
maskArea(*_mask, Common::Point(xp, 203));
if (!_vm->readFlags(189))
screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124 + xp, 239));
maskArea(*_mask1, Common::Point(124 + xp, 239));
break;

case 53:
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110));
maskArea(*_mask, Common::Point(_maskOffset.x, 110));
if (mode)
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110));
maskArea(*_mask, Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110));
break;

case 68:
screen._backBuffer1.maskArea((*_mask)[0], Common::Point(xp, 203));
screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124 + xp, 239));
maskArea(*_mask, Common::Point(xp, 203));
maskArea(*_mask1, Common::Point(124 + xp, 239));
break;
}
}
}

void TattooUserInterface::maskArea(Common::SeekableReadStream &mask, const Common::Point &pt) {
Screen &screen = *_vm->_screen;
Surface &bb1 = screen._backBuffer1;
mask.seek(0);
int xSize = mask.readUint16LE();
int ySize = mask.readUint16LE();
int pixel, len, xp, yp;

for (yp = 0; yp < ySize; ++yp) {
byte *ptr = bb1.getBasePtr(pt.x, pt.y + yp);

for (xp = 0; xp < xSize;) {
// The mask data consists of pairs of pixel/lengths, where all non-zero pixels means that the
// given pixel on the back buffer is darkened (the mask pixel value isn't otherwise used)
pixel = mask.readByte();
len = mask.readByte();

for (; len > 0; --len, ++xp, ++ptr) {
if (pixel && (pt.x + xp) >= screen._currentScroll.x && (pt.x + xp) < (screen._currentScroll.x + SHERLOCK_SCREEN_WIDTH)) {
*ptr = _lookupTable1[*ptr];
}
}
}

assert(xp == xSize);
}
}

void TattooUserInterface::makeBGArea(const Common::Rect &r) {
Screen &screen = *_vm->_screen;

for (int yp = r.top; yp < r.bottom; ++yp) {
byte *ptr = screen._backBuffer1.getBasePtr(r.left, yp);
byte *ptr = screen._backBuffer1.getBasePtr(r.left + screen._currentScroll.x, yp);

for (int xp = r.left; xp < r.right; ++xp, ++ptr)
*ptr = _lookupTable[*ptr];
Expand Down
9 changes: 8 additions & 1 deletion engines/sherlock/tattoo/tattoo_user_interface.h
Expand Up @@ -103,7 +103,7 @@ class TattooUserInterface : public UserInterface {
Common::KeyState _keyState;
Common::Point _lookPos;
ScrollHighlight _scrollHighlight;
ImageFile *_mask, *_mask1;
Common::SeekableReadStream *_mask, *_mask1;
Common::Point _maskOffset;
int _maskCounter;
ImageFile *_interfaceImages;
Expand Down Expand Up @@ -180,6 +180,13 @@ class TattooUserInterface : public UserInterface {

void drawMaskArea(bool mode);

/**
* Takes the data passed in the image and apply it to the surface at the given position.
* The src mask data is encoded with a different color for each item. To highlight one,
the runs that do not match the highlight number will be darkened
*/
void maskArea(Common::SeekableReadStream &mask, const Common::Point &pt);

/**
* Translate a given area of the back buffer to greyscale shading
*/
Expand Down

0 comments on commit 5117482

Please sign in to comment.