From c1244623e084ab230aba3ad8cefb238f98575805 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 May 2015 22:06:39 -0400 Subject: SHERLOCK: More rename of synchronize methods to load --- engines/sherlock/scene.cpp | 38 ++++++++++++++++++++++++++++---------- engines/sherlock/scene.h | 10 +++++----- 2 files changed, 33 insertions(+), 15 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp index f473004d9a..093c305a97 100644 --- a/engines/sherlock/scene.cpp +++ b/engines/sherlock/scene.cpp @@ -27,7 +27,10 @@ namespace Sherlock { -void BgFileHeader::synchronize(Common::SeekableReadStream &s) { +/** + * Load the data for the object + */ +void BgFileHeader::load(Common::SeekableReadStream &s) { _numStructs = s.readUint16LE(); _numImages = s.readUint16LE(); _numcAnimations = s.readUint16LE(); @@ -38,7 +41,10 @@ void BgFileHeader::synchronize(Common::SeekableReadStream &s) { /*----------------------------------------------------------------*/ -void BgfileheaderInfo::synchronize(Common::SeekableReadStream &s) { +/** + * Load the data for the object + */ +void BgfileheaderInfo::load(Common::SeekableReadStream &s) { _filesize = s.readUint32LE(); _maxFrames = s.readByte(); @@ -49,7 +55,10 @@ void BgfileheaderInfo::synchronize(Common::SeekableReadStream &s) { /*----------------------------------------------------------------*/ -void Exit::synchronize(Common::SeekableReadStream &s) { +/** + * Load the data for the object + */ +void Exit::load(Common::SeekableReadStream &s) { int xp = s.readSint16LE(); int yp = s.readSint16LE(); int xSize = s.readSint16LE(); @@ -65,14 +74,20 @@ void Exit::synchronize(Common::SeekableReadStream &s) { /*----------------------------------------------------------------*/ -void SceneEntry::synchronize(Common::SeekableReadStream &s) { +/** + * Load the data for the object + */ +void SceneEntry::load(Common::SeekableReadStream &s) { _startPosition.x = s.readSint16LE(); _startPosition.y = s.readSint16LE(); _startDir = s.readByte(); _allow = s.readByte(); } -void SceneSound::synchronize(Common::SeekableReadStream &s) { +/** + * Load the data for the object + */ +void SceneSound::load(Common::SeekableReadStream &s) { char buffer[9]; s.read(buffer, 8); buffer[8] = '\0'; @@ -83,6 +98,9 @@ void SceneSound::synchronize(Common::SeekableReadStream &s) { /*----------------------------------------------------------------*/ +/** + * Retuurn the index of the passed object in the array + */ int ObjectArray::indexOf(const Object &obj) const { for (uint idx = 0; idx < size(); ++idx) { if (&(*this)[idx] == &obj) @@ -244,7 +262,7 @@ bool Scene::loadScene(const Common::String &filename) { // Go to header and read it in rrmStream->seek(rrmStream->readUint32LE()); BgFileHeader bgHeader; - bgHeader.synchronize(*rrmStream); + bgHeader.load(*rrmStream); _invGraphicItems = bgHeader._numImages + 1; // Read in the shapes header info @@ -252,7 +270,7 @@ bool Scene::loadScene(const Common::String &filename) { bgInfo.resize(bgHeader._numStructs); for (uint idx = 0; idx < bgInfo.size(); ++idx) - bgInfo[idx].synchronize(*rrmStream); + bgInfo[idx].load(*rrmStream); // Read information Common::SeekableReadStream *infoStream = !_lzwMode ? rrmStream : @@ -366,17 +384,17 @@ bool Scene::loadScene(const Common::String &filename) { _exits.resize(numExits); for (int idx = 0; idx < numExits; ++idx) - _exits[idx].synchronize(*rrmStream); + _exits[idx].load(*rrmStream); // Read in the entrance - _entrance.synchronize(*rrmStream); + _entrance.load(*rrmStream); // Initialize sound list int numSounds = rrmStream->readByte(); _sounds.resize(numSounds); for (int idx = 0; idx < numSounds; ++idx) - _sounds[idx].synchronize(*rrmStream); + _sounds[idx].load(*rrmStream); for (int idx = 0; idx < numSounds; ++idx) sound.loadSound(_sounds[idx]._name, _sounds[idx]._priority); diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h index 96714c4a3a..665f5d28e4 100644 --- a/engines/sherlock/scene.h +++ b/engines/sherlock/scene.h @@ -46,7 +46,7 @@ struct BgFileHeader { int _seqSize; int _fill; - void synchronize(Common::SeekableReadStream &s); + void load(Common::SeekableReadStream &s); }; struct BgfileheaderInfo { @@ -54,7 +54,7 @@ struct BgfileheaderInfo { int _maxFrames; // How many unique frames in object Common::String _filename; // Filename of object - void synchronize(Common::SeekableReadStream &s); + void load(Common::SeekableReadStream &s); }; struct Exit { @@ -65,7 +65,7 @@ struct Exit { Common::Point _people; int _peopleDir; - void synchronize(Common::SeekableReadStream &s); + void load(Common::SeekableReadStream &s); }; struct SceneEntry { @@ -73,14 +73,14 @@ struct SceneEntry { int _startDir; int _allow; - void synchronize(Common::SeekableReadStream &s); + void load(Common::SeekableReadStream &s); }; struct SceneSound { Common::String _name; int _priority; - void synchronize(Common::SeekableReadStream &s); + void load(Common::SeekableReadStream &s); }; class ObjectArray: public Common::Array { -- cgit v1.2.3 From 187b5838533b0a182b8b44c4bfd513eeaae6aaa0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 13 May 2015 08:24:48 +0200 Subject: SHERLOCK: Handle multiple sound containers --- engines/sherlock/sound.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp index 09e55ec82b..7b8d6c69c6 100644 --- a/engines/sherlock/sound.cpp +++ b/engines/sherlock/sound.cpp @@ -45,6 +45,8 @@ Sound::Sound(SherlockEngine *vm, Audio::Mixer *mixer): _vm(vm), _mixer(mixer) { _speechOn = true; _vm->_res->addToCache("MUSIC.LIB"); + _vm->_res->addToCache("TITLE.SND"); + _vm->_res->addToCache("EPILOGUE.SND"); _vm->_res->addToCache("SND.SND"); } @@ -92,7 +94,18 @@ bool Sound::playSound(const Common::String &name, WaitType waitType, int priorit Common::String filename = name; if (!filename.contains('.')) filename += ".SND"; - Common::SeekableReadStream *stream = _vm->_res->load(filename, "TITLE.SND"); + + Common::SeekableReadStream *stream = nullptr; + + if (_vm->_res->exists(filename)) + stream = _vm->_res->load(filename, "TITLE.SND"); + else if (_vm->_res->exists(filename)) + stream = _vm->_res->load(filename, "EPILOGUE.SND"); + else if (_vm->_res->exists(filename)) + stream = _vm->_res->load(filename, "SND.SND"); + + if (!stream) + error("Unable to find sound file %s", filename.c_str()); stream->skip(2); int size = stream->readUint32BE(); -- cgit v1.2.3 From c6c056133c7720fc83de0513acbf4b0cc96bc50e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 13 May 2015 22:54:03 +0200 Subject: SHERLOCK: Remove useless checks in playSound --- engines/sherlock/sound.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp index 7b8d6c69c6..59098c32cc 100644 --- a/engines/sherlock/sound.cpp +++ b/engines/sherlock/sound.cpp @@ -95,17 +95,10 @@ bool Sound::playSound(const Common::String &name, WaitType waitType, int priorit if (!filename.contains('.')) filename += ".SND"; - Common::SeekableReadStream *stream = nullptr; - - if (_vm->_res->exists(filename)) - stream = _vm->_res->load(filename, "TITLE.SND"); - else if (_vm->_res->exists(filename)) - stream = _vm->_res->load(filename, "EPILOGUE.SND"); - else if (_vm->_res->exists(filename)) - stream = _vm->_res->load(filename, "SND.SND"); + Common::SeekableReadStream *stream = _vm->_res->load(filename); if (!stream) - error("Unable to find sound file %s", filename.c_str()); + error("Unable to find sound file '%s'", filename.c_str()); stream->skip(2); int size = stream->readUint32BE(); @@ -128,6 +121,15 @@ bool Sound::playSound(const Common::String &name, WaitType waitType, int priorit free(data); +#if 0 + // Debug : used to dump files + Common::DumpFile outFile; + outFile.open(filename); + outFile.write(decoded, (size - 2) * 2); + outFile.flush(); + outFile.close(); +#endif + Audio::AudioStream *audioStream = Audio::makeRawStream(decoded, (size - 2) * 2, rate, Audio::FLAG_UNSIGNED, DisposeAfterUse::YES); _mixer->playStream(Audio::Mixer::kPlainSoundType, &_effectsHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume); _soundPlaying = true; @@ -151,14 +153,6 @@ bool Sound::playSound(const Common::String &name, WaitType waitType, int priorit _soundPlaying = false; _mixer->stopHandle(_effectsHandle); -#if 0 - // Debug : used to dump files - Common::DumpFile outFile; - outFile.open(filename); - outFile.write(decoded, (size - 2) * 2); - outFile.flush(); - outFile.close(); -#endif return retval; } -- cgit v1.2.3 From 6f263e5774f7f4f8877932bb136621ac9606d11e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 13 May 2015 22:54:57 +0200 Subject: SHERLOCK: Fix a glitch in decompressLZ, when file size is unknown --- engines/sherlock/decompress.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/decompress.cpp b/engines/sherlock/decompress.cpp index dfa573209f..b781285471 100644 --- a/engines/sherlock/decompress.cpp +++ b/engines/sherlock/decompress.cpp @@ -32,7 +32,7 @@ namespace Sherlock { */ Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream &source, int32 outSize) { if (outSize == -1) { - source.seek(5); + source.seek(4); outSize = source.readSint32LE(); } -- cgit v1.2.3 From fab0e75c292887254493f0efc6a5a40c851aba53 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 13 May 2015 22:57:15 +0200 Subject: SHERLOCK: Rework a bit Cache::load to use MKTAG, add support for compressed sub-files in Resources::load --- engines/sherlock/resources.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/resources.cpp b/engines/sherlock/resources.cpp index f50f780195..e990013cb3 100644 --- a/engines/sherlock/resources.cpp +++ b/engines/sherlock/resources.cpp @@ -66,18 +66,15 @@ void Cache::load(const Common::String &name, Common::SeekableReadStream &stream) if (_resources.contains(name)) return; - // Check whether the file is compressed - const char LZW_HEADER[5] = { "LZV\x1a" }; - char header[5]; - stream.read(header, 5); - bool isCompressed = !strncmp(header, LZW_HEADER, 5); + int32 signature = stream.readUint32BE(); stream.seek(0); // Allocate a new cache entry _resources[name] = CacheEntry(); CacheEntry &cacheEntry = _resources[name]; - if (isCompressed) { + // Check whether the file is compressed + if (signature == MKTAG('L', 'Z', 'V', 26)) { // It's compressed, so decompress the file and store it's data in the cache entry Common::SeekableReadStream *decompressed = decompressLZ(stream); cacheEntry.resize(decompressed->size()); @@ -168,8 +165,19 @@ Common::SeekableReadStream *Resources::load(const Common::String &filename) { stream->seek(entry._offset); Common::SeekableReadStream *resStream = stream->readStream(entry._size); - delete stream; - return resStream; + // Check whether the file is compressed + if (resStream->readUint32BE() == MKTAG('L', 'Z', 'V', 26)) { + resStream->seek(0); + // It's compressed, so decompress the sub-file and return it + Common::SeekableReadStream *decompressed = decompressLZ(*resStream); + delete stream; + delete resStream; + return decompressed; + } else { + resStream->seek(0); + delete stream; + return resStream; + } } } -- cgit v1.2.3 From 4cffb1c65fe9a1d8665d3303be8cb6f3acc1494d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 May 2015 18:08:06 -0400 Subject: SHERLOCK: Simplify rect check in addDirtyRect --- engines/sherlock/screen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index fb155bf502..4cc3ba92e7 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -161,7 +161,7 @@ void Screen::fadeIn(const byte palette[PALETTE_SIZE], int speed) { */ void Screen::addDirtyRect(const Common::Rect &r) { _dirtyRects.push_back(r); - assert(r.isValidRect() && r.width() > 0 && r.height() > 0); + assert(r.width() > 0 && r.height() > 0); } /** -- cgit v1.2.3 From 2a7019bd3d47c9e40b5e78ee83cc7bfb1c08bd1a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 May 2015 18:33:23 -0400 Subject: SHERLOCK: Remove redundant _scriptCurrentIndex field --- engines/sherlock/talk.cpp | 40 ++++--------------------------------- engines/sherlock/talk.h | 1 - engines/sherlock/user_interface.cpp | 3 --- 3 files changed, 4 insertions(+), 40 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp index 61f0004fd6..d656431823 100644 --- a/engines/sherlock/talk.cpp +++ b/engines/sherlock/talk.cpp @@ -104,7 +104,6 @@ Talk::Talk(SherlockEngine *vm): _vm(vm) { _moreTalkDown = _moreTalkUp = false; _scriptMoreFlag = 0; _scriptSaveIndex = -1; - _scriptCurrentIndex = -1; } /** @@ -1082,10 +1081,6 @@ void Talk::doScript(const Common::String &script) { // Handle control code switch (c) { case SWITCH_SPEAKER: - // Save the current point in the script, since it might be intterupted by - // doing bg anims in the next call, so we need to know where to return to - _scriptCurrentIndex = str - scriptStart; - if (!(_speaker & 128)) people.clearTalking(); if (_talkToAbort) @@ -1103,10 +1098,7 @@ void Talk::doScript(const Common::String &script) { break; case RUN_CANIMATION: - // Save the current point in the script, since it might be intterupted by - // doing bg anims in the next call, so we need to know where to return to ++str; - _scriptCurrentIndex = (str + 1) - scriptStart; scene.startCAnim((str[0] - 1) & 127, (str[0] & 128) ? -1 : 1); if (_talkToAbort) return; @@ -1143,10 +1135,6 @@ void Talk::doScript(const Common::String &script) { break; case REMOVE_PORTRAIT: - // Save the current point in the script, since it might be intterupted by - // doing bg anims in the next call, so we need to know where to return to - _scriptCurrentIndex = str - scriptStart; - if (_speaker >= 0 && _speaker < 128) people.clearTalking(); pullSequence(); @@ -1203,10 +1191,7 @@ void Talk::doScript(const Common::String &script) { } case WALK_TO_COORDS: - // Save the current point in the script, since it might be interrupted by - // doing bg anims in the next call, so we need to know where to return to ++str; - _scriptCurrentIndex = str - scriptStart; people.walkToCoords(Common::Point(((str[0] - 1) * 256 + str[1] - 1) * 100, str[2] * 100), str[3] - 1); @@ -1217,10 +1202,7 @@ void Talk::doScript(const Common::String &script) { break; case PAUSE_WITHOUT_CONTROL: - // Save the current point in the script, since it might be intterupted by - // doing bg anims in the next call, so we need to know where to return to ++str; - _scriptCurrentIndex = str - scriptStart; for (int idx = 0; idx < (str[0] - 1); ++idx) { scene.doBgAnim(); @@ -1234,10 +1216,6 @@ void Talk::doScript(const Common::String &script) { break; case BANISH_WINDOW: - // Save the current point in the script, since it might be intterupted by - // doing bg anims in the next call, so we need to know where to return to - _scriptCurrentIndex = str - scriptStart; - if (!(_speaker & 128)) people.clearTalking(); pullSequence(); @@ -1403,19 +1381,19 @@ void Talk::doScript(const Common::String &script) { break; } - case CALL_TALK_FILE: + case CALL_TALK_FILE: { ++str; for (int idx = 0; idx < 8 && str[idx] != '~'; ++idx) tempString += str[idx]; str += 8; - _scriptCurrentIndex = str - scriptStart; + int scriptCurrentIndex = str - scriptStart; // Save the current script position and new talk file if (_scriptStack.size() < 9) { ScriptStackEntry rec1; rec1._name = _scriptName; - rec1._currentIndex = _scriptCurrentIndex; + rec1._currentIndex = scriptCurrentIndex; rec1._select = _scriptSelect; _scriptStack.push(rec1); @@ -1433,12 +1411,10 @@ void Talk::doScript(const Common::String &script) { endStr = true; wait = 0; break; + } case MOVE_MOUSE: - // Save the current point in the script, since it might be intterupted by - // doing bg anims in the next call, so we need to know where to return to ++str; - _scriptCurrentIndex = str - scriptStart; events.moveMouse(Common::Point((str[0] - 1) * 256 + str[1] - 1, str[2])); if (_talkToAbort) return; @@ -1464,10 +1440,6 @@ void Talk::doScript(const Common::String &script) { ++str; CAnim &animation = scene._cAnim[str[0] - 1]; - // Save the current point in the script, since it might be interrupted by - // doing bg anims in the next call, so we need to know where to return to - _scriptCurrentIndex = (str + 1) - scriptStart; - people.walkToCoords(animation._goto, animation._gotoDir); if (_talkToAbort) return; @@ -1614,10 +1586,6 @@ void Talk::doScript(const Common::String &script) { } if (wait) { - // Save the current point in the script, since it might be intterupted by - // doing bg anims in the next call, so we need to know where to return to - _scriptCurrentIndex = str - scriptStart; - // Handling pausing if (!pauseFlag && charCount < 160) charCount = 160; diff --git a/engines/sherlock/talk.h b/engines/sherlock/talk.h index d81586228f..b1a735827c 100644 --- a/engines/sherlock/talk.h +++ b/engines/sherlock/talk.h @@ -140,7 +140,6 @@ private: int _talkStealth; int _talkToFlag; int _scriptSaveIndex; - int _scriptCurrentIndex; private: void stripVoiceCommands(); void setTalkMap(); diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 41505b89fc..e4230cae83 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1694,9 +1694,6 @@ void UserInterface::doTalkControl() { sound._speechOn = false; } - // Set the _scriptCurrentIndex so if the statement is irrupted, the entire - // reply will be shown when it's restarted - talk._scriptCurrentIndex = 0; talk.waitForMore(talk._statements[_selector]._statement.size()); if (talk._talkToAbort) return; -- cgit v1.2.3 From afa49212e8dab03a48ec50c900a942c2843bce07 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 May 2015 19:00:52 -0400 Subject: SHERLOCK: Remove space/Enter handling for keyboard cursor We don't implement the keyboard cursor movement anyway, and it was stopping Space and Enter from working when showing dialogs --- engines/sherlock/user_interface.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index e4230cae83..aa6bf2ba81 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -167,11 +167,6 @@ void UserInterface::handleInput() { _vm->quitGame(); events.pollEvents(); return; - } else if (keyState.keycode == Common::KEYCODE_SPACE || - keyState.keycode == Common::KEYCODE_RETURN) { - events._pressed = false; - events._oldButtons = 0; - _keycode = Common::KEYCODE_INVALID; } } -- cgit v1.2.3 From 24b93a14be56725d65983082592029ee6d24f3c1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 May 2015 20:05:19 -0400 Subject: SHERLOCK: Renamed graphics.cpp to surface.cpp --- engines/sherlock/graphics.cpp | 197 -------------------------------------- engines/sherlock/graphics.h | 60 ------------ engines/sherlock/map.h | 2 +- engines/sherlock/module.mk | 2 +- engines/sherlock/saveload.cpp | 2 +- engines/sherlock/screen.h | 3 +- engines/sherlock/sherlock.cpp | 2 +- engines/sherlock/surface.cpp | 197 ++++++++++++++++++++++++++++++++++++++ engines/sherlock/surface.h | 60 ++++++++++++ engines/sherlock/user_interface.h | 2 +- 10 files changed, 263 insertions(+), 264 deletions(-) delete mode 100644 engines/sherlock/graphics.cpp delete mode 100644 engines/sherlock/graphics.h create mode 100644 engines/sherlock/surface.cpp create mode 100644 engines/sherlock/surface.h (limited to 'engines/sherlock') diff --git a/engines/sherlock/graphics.cpp b/engines/sherlock/graphics.cpp deleted file mode 100644 index 234928156a..0000000000 --- a/engines/sherlock/graphics.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "sherlock/graphics.h" -#include "sherlock/sherlock.h" -#include "common/system.h" -#include "graphics/palette.h" - -namespace Sherlock { - -Surface::Surface(uint16 width, uint16 height): _freePixels(true) { - create(width, height); -} - -Surface::Surface() : _freePixels(false) { -} - -Surface::~Surface() { - if (_freePixels) - free(); -} - -/** - * Sets up an internal surface with the specified dimensions that will be automatically freed - * when the surface object is destroyed - */ -void Surface::create(uint16 width, uint16 height) { - if (_freePixels) - free(); - - Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8()); - _freePixels = true; -} - -/** - * Copy a surface into this one - */ -void Surface::blitFrom(const Graphics::Surface &src) { - blitFrom(src, Common::Point(0, 0)); -} - -/** - * Draws a surface at a given position within this surface - */ -void Surface::blitFrom(const Graphics::Surface &src, const Common::Point &pt) { - Common::Rect drawRect(0, 0, src.w, src.h); - Common::Point destPt = pt; - - if (destPt.x < 0) { - drawRect.left += -destPt.x; - destPt.x = 0; - } - if (destPt.y < 0) { - drawRect.top += -destPt.y; - destPt.y = 0; - } - int right = destPt.x + src.w; - if (right > this->w) { - drawRect.right -= (right - this->w); - } - int bottom = destPt.y + src.h; - if (bottom > this->h) { - drawRect.bottom -= (bottom - this->h); - } - - if (drawRect.isValidRect()) - blitFrom(src, destPt, drawRect); -} - -/** - * Draws a sub-section of a surface at a given position within this surface - */ -void Surface::blitFrom(const Graphics::Surface &src, const Common::Point &pt, - const Common::Rect &srcBounds) { - Common::Rect destRect(pt.x, pt.y, pt.x + srcBounds.width(), - pt.y + srcBounds.height()); - Common::Rect srcRect = srcBounds; - - if (clip(srcRect, destRect)) { - // Surface is at least partially or completely on-screen - addDirtyRect(destRect); - copyRectToSurface(src, destRect.left, destRect.top, srcRect); - } -} - -/** -* Draws an image frame at a given position within this surface with transparency -*/ -void Surface::transBlitFrom(const ImageFrame &src, const Common::Point &pt, - bool flipped, int overrideColor) { - transBlitFrom(src._frame, pt + src._offset, flipped, overrideColor); -} - -/** -* Draws a surface at a given position within this surface with transparency -*/ -void Surface::transBlitFrom(const Graphics::Surface &src, const Common::Point &pt, - bool flipped, int overrideColor) { - Common::Rect drawRect(0, 0, src.w, src.h); - Common::Rect destRect(pt.x, pt.y, pt.x + src.w, pt.y + src.h); - - // Clip the display area to on-screen - if (!clip(drawRect, destRect)) - // It's completely off-screen - return; - - if (flipped) - drawRect = Common::Rect(src.w - drawRect.right, src.h - drawRect.bottom, - src.w - drawRect.left, src.h - drawRect.top); - - Common::Point destPt(destRect.left, destRect.top); - addDirtyRect(Common::Rect(destPt.x, destPt.y, destPt.x + drawRect.width(), - destPt.y + drawRect.height())); - - // Draw loop - const int TRANSPARENCY = 0xFF; - for (int yp = 0; yp < drawRect.height(); ++yp) { - const byte *srcP = (const byte *)src.getBasePtr( - flipped ? drawRect.right - 1 : drawRect.left, drawRect.top + yp); - byte *destP = (byte *)getBasePtr(destPt.x, destPt.y + yp); - - for (int xp = 0; xp < drawRect.width(); ++xp, ++destP) { - if (*srcP != TRANSPARENCY) - *destP = overrideColor ? overrideColor : *srcP; - - srcP = flipped ? srcP - 1 : srcP + 1; - } - } -} - -/** - * Fill a given area of the surface with a given color - */ -void Surface::fillRect(int x1, int y1, int x2, int y2, byte color) { - fillRect(Common::Rect(x1, y1, x2, y2), color); -} - -/** - * Fill a given area of the surface with a given color - */ -void Surface::fillRect(const Common::Rect &r, byte color) { - Graphics::Surface::fillRect(r, color); - addDirtyRect(r); -} - -/** - * Clips the given source bounds so the passed destBounds will be entirely on-screen - */ -bool Surface::clip(Common::Rect &srcBounds, Common::Rect &destBounds) { - if (destBounds.left >= this->w || destBounds.top >= this->h || - destBounds.right <= 0 || destBounds.bottom <= 0) - return false; - - // Clip the bounds if necessary to fit on-screen - if (destBounds.right > this->w) { - srcBounds.right -= destBounds.right - this->w; - destBounds.right = this->w; - } - - if (destBounds.bottom > this->h) { - srcBounds.bottom -= destBounds.bottom - this->h; - destBounds.bottom = this->h; - } - - if (destBounds.top < 0) { - srcBounds.top += -destBounds.top; - destBounds.top = 0; - } - - if (destBounds.left < 0) { - srcBounds.left += -destBounds.left; - destBounds.left = 0; - } - - return true; -} - -} // End of namespace Sherlock diff --git a/engines/sherlock/graphics.h b/engines/sherlock/graphics.h deleted file mode 100644 index d4a1584968..0000000000 --- a/engines/sherlock/graphics.h +++ /dev/null @@ -1,60 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef SHERLOCK_GRAPHICS_H -#define SHERLOCK_GRAPHICS_H - -#include "common/rect.h" -#include "graphics/surface.h" -#include "sherlock/resources.h" - -namespace Sherlock { - -class Surface : public Graphics::Surface { -private: - bool _freePixels; - - bool clip(Common::Rect &srcBounds, Common::Rect &destBounds); -protected: - virtual void addDirtyRect(const Common::Rect &r) {} -public: - Surface(uint16 width, uint16 height); - Surface(); - virtual ~Surface(); - - void create(uint16 width, uint16 height); - void blitFrom(const Graphics::Surface &src); - void blitFrom(const Graphics::Surface &src, const Common::Point &pt); - void blitFrom(const Graphics::Surface &src, const Common::Point &pt, - const Common::Rect &srcBounds); - void transBlitFrom(const ImageFrame &src, const Common::Point &pt, - bool flipped = false, int overrideColor = 0); - void transBlitFrom(const Graphics::Surface &src, const Common::Point &pt, - bool flipped = false, int overrideColor = 0); - - void fillRect(int x1, int y1, int x2, int y2, byte color); - void fillRect(const Common::Rect &r, byte color); -}; - -} // End of namespace Sherlock - -#endif diff --git a/engines/sherlock/map.h b/engines/sherlock/map.h index 4432ec8553..4a418138b2 100644 --- a/engines/sherlock/map.h +++ b/engines/sherlock/map.h @@ -29,7 +29,7 @@ #include "common/serializer.h" #include "common/str.h" #include "common/str-array.h" -#include "sherlock/graphics.h" +#include "sherlock/surface.h" #include "sherlock/objects.h" namespace Sherlock { diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk index babd0c49a0..630c4faf32 100644 --- a/engines/sherlock/module.mk +++ b/engines/sherlock/module.mk @@ -9,7 +9,6 @@ MODULE_OBJS = \ debugger.o \ detection.o \ events.o \ - graphics.o \ inventory.o \ journal.o \ map.o \ @@ -22,6 +21,7 @@ MODULE_OBJS = \ settings.o \ sherlock.o \ sound.o \ + surface.o \ talk.o \ user_interface.o diff --git a/engines/sherlock/saveload.cpp b/engines/sherlock/saveload.cpp index a78b89b00c..b9ac3e79d6 100644 --- a/engines/sherlock/saveload.cpp +++ b/engines/sherlock/saveload.cpp @@ -21,7 +21,7 @@ */ #include "sherlock/saveload.h" -#include "sherlock/graphics.h" +#include "sherlock/surface.h" #include "sherlock/sherlock.h" #include "common/system.h" #include "graphics/scaler.h" diff --git a/engines/sherlock/screen.h b/engines/sherlock/screen.h index 501506f8ec..1f3c23748f 100644 --- a/engines/sherlock/screen.h +++ b/engines/sherlock/screen.h @@ -26,8 +26,7 @@ #include "common/list.h" #include "common/rect.h" #include "common/serializer.h" -#include "graphics/surface.h" -#include "sherlock/graphics.h" +#include "sherlock/surface.h" #include "sherlock/resources.h" namespace Sherlock { diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index 2a5d9ec627..a9a17a99f8 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -21,7 +21,7 @@ */ #include "sherlock/sherlock.h" -#include "sherlock/graphics.h" +#include "sherlock/surface.h" #include "common/scummsys.h" #include "common/config-manager.h" #include "common/debug-channels.h" diff --git a/engines/sherlock/surface.cpp b/engines/sherlock/surface.cpp new file mode 100644 index 0000000000..3e82f1dc5b --- /dev/null +++ b/engines/sherlock/surface.cpp @@ -0,0 +1,197 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "sherlock/surface.h" +#include "sherlock/sherlock.h" +#include "common/system.h" +#include "graphics/palette.h" + +namespace Sherlock { + +Surface::Surface(uint16 width, uint16 height): _freePixels(true) { + create(width, height); +} + +Surface::Surface() : _freePixels(false) { +} + +Surface::~Surface() { + if (_freePixels) + free(); +} + +/** + * Sets up an internal surface with the specified dimensions that will be automatically freed + * when the surface object is destroyed + */ +void Surface::create(uint16 width, uint16 height) { + if (_freePixels) + free(); + + Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8()); + _freePixels = true; +} + +/** + * Copy a surface into this one + */ +void Surface::blitFrom(const Graphics::Surface &src) { + blitFrom(src, Common::Point(0, 0)); +} + +/** + * Draws a surface at a given position within this surface + */ +void Surface::blitFrom(const Graphics::Surface &src, const Common::Point &pt) { + Common::Rect drawRect(0, 0, src.w, src.h); + Common::Point destPt = pt; + + if (destPt.x < 0) { + drawRect.left += -destPt.x; + destPt.x = 0; + } + if (destPt.y < 0) { + drawRect.top += -destPt.y; + destPt.y = 0; + } + int right = destPt.x + src.w; + if (right > this->w) { + drawRect.right -= (right - this->w); + } + int bottom = destPt.y + src.h; + if (bottom > this->h) { + drawRect.bottom -= (bottom - this->h); + } + + if (drawRect.isValidRect()) + blitFrom(src, destPt, drawRect); +} + +/** + * Draws a sub-section of a surface at a given position within this surface + */ +void Surface::blitFrom(const Graphics::Surface &src, const Common::Point &pt, + const Common::Rect &srcBounds) { + Common::Rect destRect(pt.x, pt.y, pt.x + srcBounds.width(), + pt.y + srcBounds.height()); + Common::Rect srcRect = srcBounds; + + if (clip(srcRect, destRect)) { + // Surface is at least partially or completely on-screen + addDirtyRect(destRect); + copyRectToSurface(src, destRect.left, destRect.top, srcRect); + } +} + +/** +* Draws an image frame at a given position within this surface with transparency +*/ +void Surface::transBlitFrom(const ImageFrame &src, const Common::Point &pt, + bool flipped, int overrideColor) { + transBlitFrom(src._frame, pt + src._offset, flipped, overrideColor); +} + +/** +* Draws a surface at a given position within this surface with transparency +*/ +void Surface::transBlitFrom(const Graphics::Surface &src, const Common::Point &pt, + bool flipped, int overrideColor) { + Common::Rect drawRect(0, 0, src.w, src.h); + Common::Rect destRect(pt.x, pt.y, pt.x + src.w, pt.y + src.h); + + // Clip the display area to on-screen + if (!clip(drawRect, destRect)) + // It's completely off-screen + return; + + if (flipped) + drawRect = Common::Rect(src.w - drawRect.right, src.h - drawRect.bottom, + src.w - drawRect.left, src.h - drawRect.top); + + Common::Point destPt(destRect.left, destRect.top); + addDirtyRect(Common::Rect(destPt.x, destPt.y, destPt.x + drawRect.width(), + destPt.y + drawRect.height())); + + // Draw loop + const int TRANSPARENCY = 0xFF; + for (int yp = 0; yp < drawRect.height(); ++yp) { + const byte *srcP = (const byte *)src.getBasePtr( + flipped ? drawRect.right - 1 : drawRect.left, drawRect.top + yp); + byte *destP = (byte *)getBasePtr(destPt.x, destPt.y + yp); + + for (int xp = 0; xp < drawRect.width(); ++xp, ++destP) { + if (*srcP != TRANSPARENCY) + *destP = overrideColor ? overrideColor : *srcP; + + srcP = flipped ? srcP - 1 : srcP + 1; + } + } +} + +/** + * Fill a given area of the surface with a given color + */ +void Surface::fillRect(int x1, int y1, int x2, int y2, byte color) { + fillRect(Common::Rect(x1, y1, x2, y2), color); +} + +/** + * Fill a given area of the surface with a given color + */ +void Surface::fillRect(const Common::Rect &r, byte color) { + Graphics::Surface::fillRect(r, color); + addDirtyRect(r); +} + +/** + * Clips the given source bounds so the passed destBounds will be entirely on-screen + */ +bool Surface::clip(Common::Rect &srcBounds, Common::Rect &destBounds) { + if (destBounds.left >= this->w || destBounds.top >= this->h || + destBounds.right <= 0 || destBounds.bottom <= 0) + return false; + + // Clip the bounds if necessary to fit on-screen + if (destBounds.right > this->w) { + srcBounds.right -= destBounds.right - this->w; + destBounds.right = this->w; + } + + if (destBounds.bottom > this->h) { + srcBounds.bottom -= destBounds.bottom - this->h; + destBounds.bottom = this->h; + } + + if (destBounds.top < 0) { + srcBounds.top += -destBounds.top; + destBounds.top = 0; + } + + if (destBounds.left < 0) { + srcBounds.left += -destBounds.left; + destBounds.left = 0; + } + + return true; +} + +} // End of namespace Sherlock diff --git a/engines/sherlock/surface.h b/engines/sherlock/surface.h new file mode 100644 index 0000000000..d4a1584968 --- /dev/null +++ b/engines/sherlock/surface.h @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef SHERLOCK_GRAPHICS_H +#define SHERLOCK_GRAPHICS_H + +#include "common/rect.h" +#include "graphics/surface.h" +#include "sherlock/resources.h" + +namespace Sherlock { + +class Surface : public Graphics::Surface { +private: + bool _freePixels; + + bool clip(Common::Rect &srcBounds, Common::Rect &destBounds); +protected: + virtual void addDirtyRect(const Common::Rect &r) {} +public: + Surface(uint16 width, uint16 height); + Surface(); + virtual ~Surface(); + + void create(uint16 width, uint16 height); + void blitFrom(const Graphics::Surface &src); + void blitFrom(const Graphics::Surface &src, const Common::Point &pt); + void blitFrom(const Graphics::Surface &src, const Common::Point &pt, + const Common::Rect &srcBounds); + void transBlitFrom(const ImageFrame &src, const Common::Point &pt, + bool flipped = false, int overrideColor = 0); + void transBlitFrom(const Graphics::Surface &src, const Common::Point &pt, + bool flipped = false, int overrideColor = 0); + + void fillRect(int x1, int y1, int x2, int y2, byte color); + void fillRect(const Common::Rect &r, byte color); +}; + +} // End of namespace Sherlock + +#endif diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h index 79382a19fe..2ff60715e3 100644 --- a/engines/sherlock/user_interface.h +++ b/engines/sherlock/user_interface.h @@ -25,7 +25,7 @@ #include "common/scummsys.h" #include "common/events.h" -#include "sherlock/graphics.h" +#include "sherlock/surface.h" #include "sherlock/objects.h" #include "sherlock/resources.h" -- cgit v1.2.3 From 91d69c7dc151fabdc17b240e525181485c99b807 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 May 2015 21:24:42 -0400 Subject: SHERLOCK: Simplify blitFrom methods --- engines/sherlock/surface.cpp | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/surface.cpp b/engines/sherlock/surface.cpp index 3e82f1dc5b..2dfbdef77f 100644 --- a/engines/sherlock/surface.cpp +++ b/engines/sherlock/surface.cpp @@ -62,28 +62,7 @@ void Surface::blitFrom(const Graphics::Surface &src) { * Draws a surface at a given position within this surface */ void Surface::blitFrom(const Graphics::Surface &src, const Common::Point &pt) { - Common::Rect drawRect(0, 0, src.w, src.h); - Common::Point destPt = pt; - - if (destPt.x < 0) { - drawRect.left += -destPt.x; - destPt.x = 0; - } - if (destPt.y < 0) { - drawRect.top += -destPt.y; - destPt.y = 0; - } - int right = destPt.x + src.w; - if (right > this->w) { - drawRect.right -= (right - this->w); - } - int bottom = destPt.y + src.h; - if (bottom > this->h) { - drawRect.bottom -= (bottom - this->h); - } - - if (drawRect.isValidRect()) - blitFrom(src, destPt, drawRect); + blitFrom(src, pt, Common::Rect(0, 0, src.w, src.h)); } /** @@ -91,11 +70,10 @@ void Surface::blitFrom(const Graphics::Surface &src, const Common::Point &pt) { */ void Surface::blitFrom(const Graphics::Surface &src, const Common::Point &pt, const Common::Rect &srcBounds) { - Common::Rect destRect(pt.x, pt.y, pt.x + srcBounds.width(), - pt.y + srcBounds.height()); Common::Rect srcRect = srcBounds; + Common::Rect destRect(pt.x, pt.y, pt.x + srcRect.width(), pt.y + srcRect.height()); - if (clip(srcRect, destRect)) { + if (srcRect.isValidRect() && clip(srcRect, destRect)) { // Surface is at least partially or completely on-screen addDirtyRect(destRect); copyRectToSurface(src, destRect.left, destRect.top, srcRect); -- cgit v1.2.3 From f987cda9f06e66962fb84b68fe060970c21d071f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 May 2015 21:39:08 -0400 Subject: SHERLOCK: Properly clear screen after fading to black --- engines/sherlock/screen.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/sherlock') diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index 4cc3ba92e7..38bbb93800 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -141,6 +141,7 @@ void Screen::fadeToBlack(int speed) { } setPalette(tempPalette); + fillRect(Common::Rect(0, 0, this->w, this->h), 0); } /** -- cgit v1.2.3 From d3f1a76cc8336983d8bb36538fb8e6c520051935 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 14 May 2015 19:53:03 -0400 Subject: SHERLOCK: Default Files button to show GMM, with engine option to disable --- engines/sherlock/detection.cpp | 21 ++++++++++++++++++++- engines/sherlock/detection_tables.h | 2 +- engines/sherlock/sherlock.cpp | 4 ++++ engines/sherlock/sherlock.h | 1 + engines/sherlock/user_interface.cpp | 17 ++++++++++++----- 5 files changed, 38 insertions(+), 7 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/detection.cpp b/engines/sherlock/detection.cpp index 78ab33bfd0..34fd919770 100644 --- a/engines/sherlock/detection.cpp +++ b/engines/sherlock/detection.cpp @@ -25,6 +25,7 @@ #include "sherlock/scalpel/scalpel.h" #include "sherlock/tattoo/tattoo.h" #include "common/system.h" +#include "common/translation.h" #include "engines/advancedDetector.h" namespace Sherlock { @@ -57,11 +58,29 @@ static const PlainGameDescriptor sherlockGames[] = { {0, 0} }; + +#define GAMEOPTION_ORIGINAL_SAVES GUIO_GAMEOPTIONS1 + +static const ADExtraGuiOptionsMap optionsList[] = { + { + GAMEOPTION_ORIGINAL_SAVES, + { + _s("Use original savegame dialog"), + _s("Files button in-game shows original savegame dialog rather than ScummVM menu"), + "OriginalSaves", + false + } + }, + + AD_EXTRA_GUI_OPTIONS_TERMINATOR +}; + #include "sherlock/detection_tables.h" class SherlockMetaEngine : public AdvancedMetaEngine { public: - SherlockMetaEngine() : AdvancedMetaEngine(Sherlock::gameDescriptions, sizeof(Sherlock::SherlockGameDescription), sherlockGames) {} + SherlockMetaEngine() : AdvancedMetaEngine(Sherlock::gameDescriptions, sizeof(Sherlock::SherlockGameDescription), + sherlockGames, optionsList) {} virtual const char *getName() const { return "Sherlock Engine"; diff --git a/engines/sherlock/detection_tables.h b/engines/sherlock/detection_tables.h index 975b7323ec..8300a0ffcf 100644 --- a/engines/sherlock/detection_tables.h +++ b/engines/sherlock/detection_tables.h @@ -33,7 +33,7 @@ static const SherlockGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, ADGF_UNSTABLE | ADGF_NO_FLAGS, - GUIO1(GUIO_NOSPEECH) + GUIO2(GUIO_NOSPEECH, GAMEOPTION_ORIGINAL_SAVES) }, GType_SerratedScalpel, }, diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index a9a17a99f8..41c41473d7 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -48,6 +48,7 @@ SherlockEngine::SherlockEngine(OSystem *syst, const SherlockGameDescription *gam _useEpilogue2 = false; _loadGameSlot = -1; _canLoadSave = false; + _showOriginalSavesDialog = false; } SherlockEngine::~SherlockEngine() { @@ -104,6 +105,9 @@ Common::Error SherlockEngine::run() { // Initialize the engine initialize(); + // Flag for whether to show original saves dialog rather than the ScummVM GMM + _showOriginalSavesDialog = ConfMan.hasKey("OriginalSaves") && ConfMan.getBool("OriginalSaves"); + // If requested, load a savegame instead of showing the intro if (ConfMan.hasKey("save_slot")) { int saveSlot = ConfMan.getInt("save_slot"); diff --git a/engines/sherlock/sherlock.h b/engines/sherlock/sherlock.h index 501fdcb292..33e4a45b40 100644 --- a/engines/sherlock/sherlock.h +++ b/engines/sherlock/sherlock.h @@ -108,6 +108,7 @@ public: bool _useEpilogue2; int _loadGameSlot; bool _canLoadSave; + bool _showOriginalSavesDialog; public: SherlockEngine(OSystem *syst, const SherlockGameDescription *gameDesc); virtual ~SherlockEngine(); diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index aa6bf2ba81..85838f8a93 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1420,17 +1420,24 @@ void UserInterface::doMainControl() { break; case 'F': pushButton(10); - _menuMode = FILES_MODE; // Create a thumbnail of the current screen before the files dialog is shown, in case // the user saves the game saves.createThumbnail(); - // Display the dialog - saves.drawInterface(); - _selector = _oldSelector = -1; - _windowOpen = true; + + if (_vm->_showOriginalSavesDialog) { + // Show the original dialog + _menuMode = FILES_MODE; + saves.drawInterface(); + _windowOpen = true; + } else { + // Show the ScummVM GMM instead + _vm->_canLoadSave = true; + _vm->openMainMenuDialog(); + _vm->_canLoadSave = false; + } break; case 'S': pushButton(11); -- cgit v1.2.3 From 8d2ec6f9fa45fc17d517db36fa688b12eb809681 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 15 May 2015 09:55:35 +0200 Subject: SHERLOCK: Remove a couple of unused variables in inventory --- engines/sherlock/inventory.cpp | 5 ----- engines/sherlock/inventory.h | 2 -- 2 files changed, 7 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/inventory.cpp b/engines/sherlock/inventory.cpp index d8c0104e6c..1997807d15 100644 --- a/engines/sherlock/inventory.cpp +++ b/engines/sherlock/inventory.cpp @@ -49,8 +49,6 @@ Inventory::Inventory(SherlockEngine *vm) : Common::Array(), _vm(v _invGraphicsLoaded = false; _invIndex = 0; _holdings = 0; - _oldFlag = 0; - _invFlag = 0; _invMode = INVMODE_EXIT; } @@ -215,7 +213,6 @@ void Inventory::drawInventory(int flag) { UserInterface &ui = *_vm->_ui; int tempFlag = flag; - _oldFlag = 7; loadInv(); if (flag == 128) { @@ -257,10 +254,8 @@ void Inventory::drawInventory(int flag) { if (flag) { ui._oldKey = INVENTORY_COMMANDS[flag]; - _oldFlag = flag; } else { ui._oldKey = -1; - _invFlag = 6; } invCommands(0); diff --git a/engines/sherlock/inventory.h b/engines/sherlock/inventory.h index f4cea7729a..eb5aebdd7c 100644 --- a/engines/sherlock/inventory.h +++ b/engines/sherlock/inventory.h @@ -75,8 +75,6 @@ public: int _holdings; // Used to hold number of visible items in active inventory. // Since Inventory array also contains some special hidden items void freeGraphics(); - int _oldFlag; - int _invFlag; public: Inventory(SherlockEngine *vm); ~Inventory(); -- cgit v1.2.3 From 07e9262ee7f38b31743d940fa8238dbbaeede864 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 May 2015 19:36:39 -0400 Subject: SHERLOCK: Change save extra option to use more standard originalsaveload --- engines/sherlock/detection.cpp | 2 +- engines/sherlock/sherlock.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/detection.cpp b/engines/sherlock/detection.cpp index 34fd919770..2804ec1d31 100644 --- a/engines/sherlock/detection.cpp +++ b/engines/sherlock/detection.cpp @@ -67,7 +67,7 @@ static const ADExtraGuiOptionsMap optionsList[] = { { _s("Use original savegame dialog"), _s("Files button in-game shows original savegame dialog rather than ScummVM menu"), - "OriginalSaves", + "originalsaveload", false } }, diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index 41c41473d7..a84eedbd04 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -106,7 +106,7 @@ Common::Error SherlockEngine::run() { initialize(); // Flag for whether to show original saves dialog rather than the ScummVM GMM - _showOriginalSavesDialog = ConfMan.hasKey("OriginalSaves") && ConfMan.getBool("OriginalSaves"); + _showOriginalSavesDialog = ConfMan.hasKey("originalsaveload") && ConfMan.getBool("originalsaveload"); // If requested, load a savegame instead of showing the intro if (ConfMan.hasKey("save_slot")) { -- cgit v1.2.3 From a77c6dd43f797c33c7537df6e0cd1a79586087b5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 May 2015 19:40:28 -0400 Subject: SHERLOCK: Fix mismatched alloc/free in decompressed resource buffers --- engines/sherlock/decompress.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/decompress.cpp b/engines/sherlock/decompress.cpp index b781285471..2157d47eb8 100644 --- a/engines/sherlock/decompress.cpp +++ b/engines/sherlock/decompress.cpp @@ -40,7 +40,7 @@ Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream &source, int uint16 lzWindowPos; uint16 cmd; - byte *outBuffer = new byte[outSize]; + byte *outBuffer = (byte *)malloc(outSize); byte *outBufferEnd = outBuffer + outSize; Common::MemoryReadStream *outS = new Common::MemoryReadStream(outBuffer, outSize, DisposeAfterUse::YES); -- cgit v1.2.3 From 07907819c18d075c39158d2d35f5949e13497127 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 May 2015 19:42:18 -0400 Subject: SHERLOCK: Fix saving mute flags in saveConfig --- engines/sherlock/sherlock.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index a84eedbd04..d6fe0c69aa 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -231,9 +231,9 @@ void SherlockEngine::loadConfig() { * Saves game configuration information */ void SherlockEngine::saveConfig() { - ConfMan.setBool("mute", _sound->_digitized); - ConfMan.setBool("music_mute", _sound->_music); - ConfMan.setBool("speech_mute", _sound->_voices); + ConfMan.setBool("mute", !_sound->_digitized); + ConfMan.setBool("music_mute", !_sound->_music); + ConfMan.setBool("speech_mute", !_sound->_voices); ConfMan.setInt("font", _screen->fontNumber()); ConfMan.setBool("fade_style", _screen->_fadeStyle); -- cgit v1.2.3 From d9a7d87b1908da6f249a1b16110ae3fd3cc9ed07 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 May 2015 19:46:29 -0400 Subject: SHERLOCK: Fix positioning of Quit Yes/No buttons --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 85838f8a93..1521421c15 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -919,7 +919,7 @@ void UserInterface::doEnvControl() { screen.print(Common::Point(0, CONTROLS_Y + 20), INV_FOREGROUND, "Are you sure you wish to Quit ?"); screen.vgaBar(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y + 10), BORDER_COLOR); - screen.makeButton(Common::Rect(112, CONTROLS_Y, 150, CONTROLS_Y + 10), 136 - screen.stringWidth("Yes") / 2, "Yes"); + screen.makeButton(Common::Rect(112, CONTROLS_Y, 160, CONTROLS_Y + 10), 136 - screen.stringWidth("Yes") / 2, "Yes"); screen.makeButton(Common::Rect(161, CONTROLS_Y, 209, CONTROLS_Y + 10), 184 - screen.stringWidth("No") / 2, "No"); screen.slamArea(112, CONTROLS_Y, 97, 10); -- cgit v1.2.3 From 62ce7a9c839f82121c14ce8357d107bc1ba70244 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 May 2015 20:02:40 -0400 Subject: SHERLOCK: Use ConfMan.registerDefault to simply reading options --- engines/sherlock/sherlock.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index d6fe0c69aa..95da79d988 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -106,7 +106,7 @@ Common::Error SherlockEngine::run() { initialize(); // Flag for whether to show original saves dialog rather than the ScummVM GMM - _showOriginalSavesDialog = ConfMan.hasKey("originalsaveload") && ConfMan.getBool("originalsaveload"); + _showOriginalSavesDialog = ConfMan.getBool("originalsaveload"); // If requested, load a savegame instead of showing the intro if (ConfMan.hasKey("save_slot")) { @@ -214,17 +214,18 @@ void SherlockEngine::loadConfig() { // Load sound settings syncSoundSettings(); - // Load other settings - if (ConfMan.hasKey("font")) - _screen->setFont(ConfMan.getInt("font")); - if (ConfMan.hasKey("fade_style")) - _screen->_fadeStyle = ConfMan.getBool("fade_style"); - if (ConfMan.hasKey("help_style")) - _ui->_helpStyle = ConfMan.getBool("help_style"); - if (ConfMan.hasKey("window_style")) - _ui->_windowStyle = ConfMan.getInt("window_style"); - if (ConfMan.hasKey("portraits_on")) - _people->_portraitsOn = ConfMan.getBool("portraits_on"); + ConfMan.registerDefault("font", 1); + ConfMan.registerDefault("fade_style", false); + ConfMan.registerDefault("help_style", false); + ConfMan.registerDefault("window_style", 1); + ConfMan.registerDefault("portraits_on", true); + ConfMan.registerDefault("originalsaveload", false); + + _screen->setFont(ConfMan.getInt("font")); + _screen->_fadeStyle = ConfMan.getBool("fade_style"); + _ui->_helpStyle = ConfMan.getBool("help_style"); + _ui->_windowStyle = ConfMan.getInt("window_style"); + _people->_portraitsOn = ConfMan.getBool("portraits_on"); } /** -- cgit v1.2.3 From 95ce29ac7470435dbec167df526cf4ff38fc8805 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 May 2015 20:44:12 -0400 Subject: SHERLOCK: Fix random pixel transitions, and make it the default fade style --- engines/sherlock/screen.cpp | 2 +- engines/sherlock/sherlock.cpp | 3 +++ engines/sherlock/surface.cpp | 7 +++++++ engines/sherlock/surface.h | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index 38bbb93800..cbf18f146f 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -217,7 +217,7 @@ void Screen::randomTransition() { if (offset < (SHERLOCK_SCREEN_WIDTH * SHERLOCK_SCREEN_HEIGHT)) *((byte *)getPixels() + offset) = *((const byte *)_backBuffer->getPixels() + offset); - if (idx != 0 && (idx % 100) == 0) { + if (idx != 0 && (idx % 300) == 0) { // Ensure there's a full screen dirty rect for the next frame update if (_dirtyRects.empty()) addDirtyRect(Common::Rect(0, 0, this->w, this->h)); diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index 95da79d988..81d461b161 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -129,6 +129,9 @@ Common::Error SherlockEngine::run() { if (shouldQuit()) break; + // Clear the screen + _screen->clear(); + // Reset UI flags _ui->reset(); diff --git a/engines/sherlock/surface.cpp b/engines/sherlock/surface.cpp index 2dfbdef77f..36e625794c 100644 --- a/engines/sherlock/surface.cpp +++ b/engines/sherlock/surface.cpp @@ -172,4 +172,11 @@ bool Surface::clip(Common::Rect &srcBounds, Common::Rect &destBounds) { return true; } +/** + * Clear the screen + */ +void Surface::clear() { + fillRect(Common::Rect(0, 0, this->w, this->h), 0); +} + } // End of namespace Sherlock diff --git a/engines/sherlock/surface.h b/engines/sherlock/surface.h index d4a1584968..b2a759aa8d 100644 --- a/engines/sherlock/surface.h +++ b/engines/sherlock/surface.h @@ -53,6 +53,8 @@ public: void fillRect(int x1, int y1, int x2, int y2, byte color); void fillRect(const Common::Rect &r, byte color); + + void clear(); }; } // End of namespace Sherlock -- cgit v1.2.3 From 8c7f5bf92fc3eadddf2e2dd69548ad9433e7fdb3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 May 2015 07:18:36 -0400 Subject: SHERLOCK: Fix default fade style option --- engines/sherlock/sherlock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index 81d461b161..64fabc78df 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -218,7 +218,7 @@ void SherlockEngine::loadConfig() { syncSoundSettings(); ConfMan.registerDefault("font", 1); - ConfMan.registerDefault("fade_style", false); + ConfMan.registerDefault("fade_style", true); ConfMan.registerDefault("help_style", false); ConfMan.registerDefault("window_style", 1); ConfMan.registerDefault("portraits_on", true); -- cgit v1.2.3 From 052e04c00574720192c2975c6549fd33c6a23390 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 May 2015 08:56:50 -0400 Subject: SHERLOCK: Merged decompression code into Resources class --- engines/sherlock/decompress.cpp | 80 ----------------------------------------- engines/sherlock/decompress.h | 36 ------------------- engines/sherlock/module.mk | 1 - engines/sherlock/resources.cpp | 66 +++++++++++++++++++++++++++++++--- engines/sherlock/resources.h | 9 +++-- engines/sherlock/scene.cpp | 15 ++++---- engines/sherlock/sherlock.cpp | 2 +- 7 files changed, 77 insertions(+), 132 deletions(-) delete mode 100644 engines/sherlock/decompress.cpp delete mode 100644 engines/sherlock/decompress.h (limited to 'engines/sherlock') diff --git a/engines/sherlock/decompress.cpp b/engines/sherlock/decompress.cpp deleted file mode 100644 index 2157d47eb8..0000000000 --- a/engines/sherlock/decompress.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "sherlock/decompress.h" - -namespace Sherlock { - -/** - * Decompresses an LZW compressed resource. If no outSize is specified, it will - * decompress the entire resource. If, however, an explicit size is specified, - * then it means we're already within a resource, and only want to decompress - * part of it. - */ -Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream &source, int32 outSize) { - if (outSize == -1) { - source.seek(4); - outSize = source.readSint32LE(); - } - - byte lzWindow[4096]; - uint16 lzWindowPos; - uint16 cmd; - - byte *outBuffer = (byte *)malloc(outSize); - byte *outBufferEnd = outBuffer + outSize; - Common::MemoryReadStream *outS = new Common::MemoryReadStream(outBuffer, outSize, DisposeAfterUse::YES); - - memset(lzWindow, 0xFF, 0xFEE); - lzWindowPos = 0xFEE; - cmd = 0; - - do { - cmd >>= 1; - if (!(cmd & 0x100)) - cmd = source.readByte() | 0xFF00; - - if (cmd & 1) { - byte literal = source.readByte(); - *outBuffer++ = literal; - lzWindow[lzWindowPos] = literal; - lzWindowPos = (lzWindowPos + 1) & 0x0FFF; - } else { - int copyPos, copyLen; - copyPos = source.readByte(); - copyLen = source.readByte(); - copyPos = copyPos | ((copyLen & 0xF0) << 4); - copyLen = (copyLen & 0x0F) + 3; - while (copyLen--) { - byte literal = lzWindow[copyPos]; - copyPos = (copyPos + 1) & 0x0FFF; - *outBuffer++ = literal; - lzWindow[lzWindowPos] = literal; - lzWindowPos = (lzWindowPos + 1) & 0x0FFF; - } - } - } while (outBuffer < outBufferEnd); - - return outS; -} - -} // namespace Sherlock diff --git a/engines/sherlock/decompress.h b/engines/sherlock/decompress.h deleted file mode 100644 index 694f56aa65..0000000000 --- a/engines/sherlock/decompress.h +++ /dev/null @@ -1,36 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef SHERLOCK_DECOMPRESS_H -#define SHERLOCK_DECOMPRESS_H - -#include "common/memstream.h" - -namespace Sherlock { - -#include "common/stream.h" - -Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream &source, int32 outSize = -1); - -} // namespace Sherlock - -#endif diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk index 630c4faf32..2ded999ed1 100644 --- a/engines/sherlock/module.mk +++ b/engines/sherlock/module.mk @@ -5,7 +5,6 @@ MODULE_OBJS = \ scalpel/scalpel.o \ tattoo/tattoo.o \ animation.o \ - decompress.o \ debugger.o \ detection.o \ events.o \ diff --git a/engines/sherlock/resources.cpp b/engines/sherlock/resources.cpp index e990013cb3..b5f4f5f6dd 100644 --- a/engines/sherlock/resources.cpp +++ b/engines/sherlock/resources.cpp @@ -21,14 +21,14 @@ */ #include "sherlock/resources.h" -#include "sherlock/decompress.h" #include "sherlock/screen.h" #include "sherlock/sherlock.h" #include "common/debug.h" +#include "common/memstream.h" namespace Sherlock { -Cache::Cache() { +Cache::Cache(SherlockEngine *vm): _vm(vm) { } /** @@ -76,7 +76,7 @@ void Cache::load(const Common::String &name, Common::SeekableReadStream &stream) // Check whether the file is compressed if (signature == MKTAG('L', 'Z', 'V', 26)) { // It's compressed, so decompress the file and store it's data in the cache entry - Common::SeekableReadStream *decompressed = decompressLZ(stream); + Common::SeekableReadStream *decompressed = _vm->_res->decompressLZ(stream); cacheEntry.resize(decompressed->size()); decompressed->read(&cacheEntry[0], decompressed->size()); @@ -99,7 +99,7 @@ Common::SeekableReadStream *Cache::get(const Common::String &filename) const { /*----------------------------------------------------------------*/ -Resources::Resources() { +Resources::Resources(SherlockEngine *vm): _vm(vm), _cache(vm) { _resourceIndex = -1; addToCache("vgs.lib"); @@ -404,4 +404,62 @@ void ImageFile::decompressFrame(ImageFrame &frame, const byte *src) { } } +/** + * Decompress an LZW compressed resource + */ +Common::SeekableReadStream *Resources::decompressLZ(Common::SeekableReadStream &source) { + if (_vm->getGameID() == GType_SerratedScalpel) { + uint32 id = source.readUint32BE(); + assert(id == MKTAG('L', 'Z', 'V', 0x1A)); + } + + uint32 size = source.readUint32LE(); + return decompressLZ(source, size); +} + +/** + * Decompresses an LZW block of data with a specified output size + */ +Common::SeekableReadStream *Resources::decompressLZ(Common::SeekableReadStream &source, uint32 outSize) { + byte lzWindow[4096]; + uint16 lzWindowPos; + uint16 cmd; + + byte *outBuffer = (byte *)malloc(outSize); + byte *outBufferEnd = outBuffer + outSize; + Common::MemoryReadStream *outS = new Common::MemoryReadStream(outBuffer, outSize, DisposeAfterUse::YES); + + memset(lzWindow, 0xFF, 0xFEE); + lzWindowPos = 0xFEE; + cmd = 0; + + do { + cmd >>= 1; + if (!(cmd & 0x100)) + cmd = source.readByte() | 0xFF00; + + if (cmd & 1) { + byte literal = source.readByte(); + *outBuffer++ = literal; + lzWindow[lzWindowPos] = literal; + lzWindowPos = (lzWindowPos + 1) & 0x0FFF; + } else { + int copyPos, copyLen; + copyPos = source.readByte(); + copyLen = source.readByte(); + copyPos = copyPos | ((copyLen & 0xF0) << 4); + copyLen = (copyLen & 0x0F) + 3; + while (copyLen--) { + byte literal = lzWindow[copyPos]; + copyPos = (copyPos + 1) & 0x0FFF; + *outBuffer++ = literal; + lzWindow[lzWindowPos] = literal; + lzWindowPos = (lzWindowPos + 1) & 0x0FFF; + } + } + } while (outBuffer < outBufferEnd); + + return outS; +} + } // End of namespace Sherlock diff --git a/engines/sherlock/resources.h b/engines/sherlock/resources.h index e1f97f1def..d5e83a1745 100644 --- a/engines/sherlock/resources.h +++ b/engines/sherlock/resources.h @@ -52,9 +52,10 @@ class SherlockEngine; class Cache { private: + SherlockEngine *_vm; CacheHash _resources; public: - Cache(); + Cache(SherlockEngine *_vm); bool isCached(const Common::String &filename) const; @@ -66,13 +67,14 @@ public: class Resources { private: + SherlockEngine *_vm; Cache _cache; LibraryIndexes _indexes; int _resourceIndex; void loadLibraryIndex(const Common::String &libFilename, Common::SeekableReadStream *stream); public: - Resources(); + Resources(SherlockEngine *vm); void addToCache(const Common::String &filename); void addToCache(const Common::String &filename, const Common::String &libFilename); @@ -86,6 +88,9 @@ public: bool exists(const Common::String &filename) const; int resourceIndex() const; + + static Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream &source, uint32 outSize); + Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream &source); }; struct ImageFrame { diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp index 093c305a97..9fbf25ce98 100644 --- a/engines/sherlock/scene.cpp +++ b/engines/sherlock/scene.cpp @@ -23,7 +23,6 @@ #include "sherlock/scene.h" #include "sherlock/sherlock.h" #include "sherlock/scalpel/scalpel.h" -#include "sherlock/decompress.h" namespace Sherlock { @@ -274,7 +273,7 @@ bool Scene::loadScene(const Common::String &filename) { // Read information Common::SeekableReadStream *infoStream = !_lzwMode ? rrmStream : - decompressLZ(*rrmStream, bgHeader._numImages * 569 + + Resources::decompressLZ(*rrmStream, bgHeader._numImages * 569 + bgHeader._descSize + bgHeader._seqSize); _bgShapes.resize(bgHeader._numStructs); @@ -302,7 +301,7 @@ bool Scene::loadScene(const Common::String &filename) { // Read in the image data Common::SeekableReadStream *imageStream = _lzwMode ? - decompressLZ(*rrmStream, bgInfo[idx]._filesize) : + Resources::decompressLZ(*rrmStream, bgInfo[idx]._filesize) : rrmStream->readStream(bgInfo[idx]._filesize); _images[idx + 1]._images = new ImageFile(*imageStream); @@ -331,7 +330,7 @@ bool Scene::loadScene(const Common::String &filename) { _cAnim.clear(); if (bgHeader._numcAnimations) { Common::SeekableReadStream *canimStream = _lzwMode ? - decompressLZ(*rrmStream, 65 * bgHeader._numcAnimations) : + Resources::decompressLZ(*rrmStream, 65 * bgHeader._numcAnimations) : rrmStream->readStream(65 * bgHeader._numcAnimations); _cAnim.resize(bgHeader._numcAnimations); @@ -344,7 +343,7 @@ bool Scene::loadScene(const Common::String &filename) { // Read in the room bounding areas int size = rrmStream->readUint16LE(); Common::SeekableReadStream *boundsStream = !_lzwMode ? rrmStream : - decompressLZ(*rrmStream, size); + Resources::decompressLZ(*rrmStream, size); _zones.resize(size / 10); for (uint idx = 0; idx < _zones.size(); ++idx) { @@ -371,7 +370,7 @@ bool Scene::loadScene(const Common::String &filename) { // Read in the walk data size = rrmStream->readUint16LE(); Common::SeekableReadStream *walkStream = !_lzwMode ? rrmStream : - decompressLZ(*rrmStream, size); + Resources::decompressLZ(*rrmStream, size); _walkData.resize(size); walkStream->read(&_walkData[0], size); @@ -408,7 +407,7 @@ bool Scene::loadScene(const Common::String &filename) { // Read in the background Common::SeekableReadStream *bgStream = !_lzwMode ? rrmStream : - decompressLZ(*rrmStream, SHERLOCK_SCREEN_WIDTH * SHERLOCK_SCENE_HEIGHT); + Resources::decompressLZ(*rrmStream, SHERLOCK_SCREEN_WIDTH * SHERLOCK_SCENE_HEIGHT); bgStream->read(screen._backBuffer1.getPixels(), SHERLOCK_SCREEN_WIDTH * SHERLOCK_SCENE_HEIGHT); @@ -982,7 +981,7 @@ int Scene::startCAnim(int cAnimNum, int playRate) { // Load the canimation into the cache Common::SeekableReadStream *imgStream = !_lzwMode ? rrmStream->readStream(cAnim._size) : - decompressLZ(*rrmStream, cAnim._size); + Resources::decompressLZ(*rrmStream, cAnim._size); res.addToCache(fname, *imgStream); delete imgStream; diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index 64fabc78df..09a8ef18ef 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -79,7 +79,7 @@ void SherlockEngine::initialize() { ImageFile::setVm(this); Object::setVm(this); Sprite::setVm(this); - _res = new Resources(); + _res = new Resources(this); _animation = new Animation(this); _debugger = new Debugger(this); _events = new Events(this); -- cgit v1.2.3 From 96e929f5233b23917169c7d0121e9c1e264455c1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 May 2015 09:03:53 -0400 Subject: SHERLOCK: Clear screen before transitioning to the map --- engines/sherlock/map.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/sherlock') diff --git a/engines/sherlock/map.cpp b/engines/sherlock/map.cpp index e178dece0c..7fca4ea5f3 100644 --- a/engines/sherlock/map.cpp +++ b/engines/sherlock/map.cpp @@ -140,6 +140,10 @@ int Map::show() { int oldFont = screen.fontNumber(); screen.setFont(0); + // Initial screen clear + screen._backBuffer1.clear(); + screen.clear(); + // Load the entire map ImageFile bigMap("bigmap.vgs"); screen.setPalette(bigMap._palette); -- cgit v1.2.3